X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fext4_balloc.c;h=89455544f657e1c642aead88a912639358ba4d95;hb=fb46550c54e6efbcd5ceb7f86d88e89ca9f1cee3;hp=2980e2686c030c5fbbdedfd4fb5c8cae7e37ae20;hpb=a45154a49b743eba4669442e6993c50583329d99;p=lwext4.git diff --git a/src/ext4_balloc.c b/src/ext4_balloc.c index 2980e26..8945554 100644 --- a/src/ext4_balloc.c +++ b/src/ext4_balloc.c @@ -38,14 +38,20 @@ * @brief Physical block allocator. */ -#include "ext4_config.h" -#include "ext4_balloc.h" -#include "ext4_super.h" -#include "ext4_crc32.h" -#include "ext4_block_group.h" -#include "ext4_fs.h" -#include "ext4_bitmap.h" -#include "ext4_inode.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include /**@brief Compute number of block group from block address. * @param sb superblock pointer. @@ -219,13 +225,17 @@ int ext4_balloc_free_block(struct ext4_inode_ref *inode_ref, ext4_fsblk_t baddr) } ext4_bcache_invalidate_lba(fs->bdev->bc, baddr, 1); /* Release block group reference */ - return ext4_fs_put_block_group_ref(&bg_ref); + rc = ext4_fs_put_block_group_ref(&bg_ref); + + return rc; } int ext4_balloc_free_blocks(struct ext4_inode_ref *inode_ref, ext4_fsblk_t first, uint32_t count) { int rc = EOK; + uint32_t blk_cnt = count; + ext4_fsblk_t start_block = first; struct ext4_fs *fs = inode_ref->fs; struct ext4_sblock *sb = &fs->sb; @@ -325,16 +335,17 @@ int ext4_balloc_free_blocks(struct ext4_inode_ref *inode_ref, } uint32_t i; - for (i = 0;i < count;i++) { - rc = ext4_trans_try_revoke_block(fs->bdev, first + i); + for (i = 0;i < blk_cnt;i++) { + rc = ext4_trans_try_revoke_block(fs->bdev, start_block + i); if (rc != EOK) return rc; } - ext4_bcache_invalidate_lba(fs->bdev->bc, first, count); + ext4_bcache_invalidate_lba(fs->bdev->bc, start_block, blk_cnt); /*All blocks should be released*/ ext4_assert(count == 0); + return rc; }