aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/ialloc.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-09-09 18:42:51 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-09-09 18:42:51 -0400
commitfd034a84e1ea5c8c8d159cd2089c32e792c269b0 (patch)
tree5992d541a005137a57a44921fd1be6311ee841d2 /fs/ext4/ialloc.c
parent49f7f9af4bb4d7972f3a35a74877937fec9f622d (diff)
ext4: split out ext4_free_blocks_after_init()
The function ext4_free_blocks_after_init() used to be a #define of ext4_init_block_bitmap(). This actually made it difficult to understand how the function worked, and made it hard make changes to support clusters. So as an initial cleanup, I've separated out the functionality of initializing block bitmap from calculating the number of free blocks in the new block group. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r--fs/ext4/ialloc.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 9c63f273b550..b7a8130d0af4 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -816,7 +816,6 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode,
816 int ret2, err = 0; 816 int ret2, err = 0;
817 struct inode *ret; 817 struct inode *ret;
818 ext4_group_t i; 818 ext4_group_t i;
819 int free = 0;
820 static int once = 1; 819 static int once = 1;
821 ext4_group_t flex_group; 820 ext4_group_t flex_group;
822 821
@@ -950,26 +949,21 @@ got:
950 goto fail; 949 goto fail;
951 } 950 }
952 951
953 free = 0; 952 BUFFER_TRACE(block_bitmap_bh, "dirty block bitmap");
954 ext4_lock_group(sb, group); 953 err = ext4_handle_dirty_metadata(handle, NULL, block_bitmap_bh);
954 brelse(block_bitmap_bh);
955
955 /* recheck and clear flag under lock if we still need to */ 956 /* recheck and clear flag under lock if we still need to */
957 ext4_lock_group(sb, group);
956 if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { 958 if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
957 free = ext4_free_blocks_after_init(sb, group, gdp);
958 gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT); 959 gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
959 ext4_free_blks_set(sb, gdp, free); 960 ext4_free_blks_set(sb, gdp,
961 ext4_free_blocks_after_init(sb, group, gdp));
960 gdp->bg_checksum = ext4_group_desc_csum(sbi, group, 962 gdp->bg_checksum = ext4_group_desc_csum(sbi, group,
961 gdp); 963 gdp);
962 } 964 }
963 ext4_unlock_group(sb, group); 965 ext4_unlock_group(sb, group);
964 966
965 /* Don't need to dirty bitmap block if we didn't change it */
966 if (free) {
967 BUFFER_TRACE(block_bitmap_bh, "dirty block bitmap");
968 err = ext4_handle_dirty_metadata(handle,
969 NULL, block_bitmap_bh);
970 }
971
972 brelse(block_bitmap_bh);
973 if (err) 967 if (err)
974 goto fail; 968 goto fail;
975 } 969 }