aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2008-08-02 21:21:02 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-08-02 21:21:02 -0400
commite29d1cde63be0b5f1739416b5574a83c34bf8eeb (patch)
tree86f2951e96888a1bd9cdb39ad4b2cb4e88893d95 /fs
parent8a266467b8c4841ca994d0fe59f39e584650e3df (diff)
ext4: sync up block and inode bitmap reading functions
ext4_read_block_bitmap and read_inode_bitmap do essentially the same thing, and yet they are structured quite differently. I came across this difference while looking at doing bg locking during bg initialization. This patch: * removes unnecessary casts in the error messages * renames read_inode_bitmap to ext4_read_inode_bitmap * and more substantially, restructures the inode bitmap reading function to be more like the block bitmap counterpart. The change to the inode bitmap reader simplifies the locking to be applied in the next patch. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/balloc.c8
-rw-r--r--fs/ext4/ialloc.c51
2 files changed, 33 insertions, 26 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 495ab21b9832..386cb79ac4b6 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -314,8 +314,8 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
314 if (unlikely(!bh)) { 314 if (unlikely(!bh)) {
315 ext4_error(sb, __func__, 315 ext4_error(sb, __func__,
316 "Cannot read block bitmap - " 316 "Cannot read block bitmap - "
317 "block_group = %d, block_bitmap = %llu", 317 "block_group = %lu, block_bitmap = %llu",
318 (int)block_group, (unsigned long long)bitmap_blk); 318 block_group, bitmap_blk);
319 return NULL; 319 return NULL;
320 } 320 }
321 if (bh_uptodate_or_lock(bh)) 321 if (bh_uptodate_or_lock(bh))
@@ -331,8 +331,8 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
331 put_bh(bh); 331 put_bh(bh);
332 ext4_error(sb, __func__, 332 ext4_error(sb, __func__,
333 "Cannot read block bitmap - " 333 "Cannot read block bitmap - "
334 "block_group = %d, block_bitmap = %llu", 334 "block_group = %lu, block_bitmap = %llu",
335 (int)block_group, (unsigned long long)bitmap_blk); 335 block_group, bitmap_blk);
336 return NULL; 336 return NULL;
337 } 337 }
338 ext4_valid_block_bitmap(sb, desc, block_group, bh); 338 ext4_valid_block_bitmap(sb, desc, block_group, bh);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index a92eb305344f..09cdcd5914d0 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -97,34 +97,41 @@ unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
97 * Return buffer_head of bitmap on success or NULL. 97 * Return buffer_head of bitmap on success or NULL.
98 */ 98 */
99static struct buffer_head * 99static struct buffer_head *
100read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) 100ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
101{ 101{
102 struct ext4_group_desc *desc; 102 struct ext4_group_desc *desc;
103 struct buffer_head *bh = NULL; 103 struct buffer_head *bh = NULL;
104 ext4_fsblk_t bitmap_blk;
104 105
105 desc = ext4_get_group_desc(sb, block_group, NULL); 106 desc = ext4_get_group_desc(sb, block_group, NULL);
106 if (!desc) 107 if (!desc)
107 goto error_out; 108 return NULL;
109 bitmap_blk = ext4_inode_bitmap(sb, desc);
110 bh = sb_getblk(sb, bitmap_blk);
111 if (unlikely(!bh)) {
112 ext4_error(sb, __func__,
113 "Cannot read inode bitmap - "
114 "block_group = %lu, inode_bitmap = %llu",
115 block_group, bitmap_blk);
116 return NULL;
117 }
118 if (bh_uptodate_or_lock(bh))
119 return bh;
120
108 if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) { 121 if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
109 bh = sb_getblk(sb, ext4_inode_bitmap(sb, desc)); 122 ext4_init_inode_bitmap(sb, bh, block_group, desc);
110 if (!buffer_uptodate(bh)) { 123 set_buffer_uptodate(bh);
111 lock_buffer(bh); 124 unlock_buffer(bh);
112 if (!buffer_uptodate(bh)) { 125 return bh;
113 ext4_init_inode_bitmap(sb, bh, block_group,
114 desc);
115 set_buffer_uptodate(bh);
116 }
117 unlock_buffer(bh);
118 }
119 } else {
120 bh = sb_bread(sb, ext4_inode_bitmap(sb, desc));
121 } 126 }
122 if (!bh) 127 if (bh_submit_read(bh) < 0) {
123 ext4_error(sb, "read_inode_bitmap", 128 put_bh(bh);
129 ext4_error(sb, __func__,
124 "Cannot read inode bitmap - " 130 "Cannot read inode bitmap - "
125 "block_group = %lu, inode_bitmap = %llu", 131 "block_group = %lu, inode_bitmap = %llu",
126 block_group, ext4_inode_bitmap(sb, desc)); 132 block_group, bitmap_blk);
127error_out: 133 return NULL;
134 }
128 return bh; 135 return bh;
129} 136}
130 137
@@ -200,7 +207,7 @@ void ext4_free_inode (handle_t *handle, struct inode * inode)
200 } 207 }
201 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); 208 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
202 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb); 209 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
203 bitmap_bh = read_inode_bitmap(sb, block_group); 210 bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
204 if (!bitmap_bh) 211 if (!bitmap_bh)
205 goto error_return; 212 goto error_return;
206 213
@@ -623,7 +630,7 @@ got_group:
623 goto fail; 630 goto fail;
624 631
625 brelse(bitmap_bh); 632 brelse(bitmap_bh);
626 bitmap_bh = read_inode_bitmap(sb, group); 633 bitmap_bh = ext4_read_inode_bitmap(sb, group);
627 if (!bitmap_bh) 634 if (!bitmap_bh)
628 goto fail; 635 goto fail;
629 636
@@ -891,7 +898,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
891 898
892 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); 899 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
893 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb); 900 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
894 bitmap_bh = read_inode_bitmap(sb, block_group); 901 bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
895 if (!bitmap_bh) { 902 if (!bitmap_bh) {
896 ext4_warning(sb, __func__, 903 ext4_warning(sb, __func__,
897 "inode bitmap error for orphan %lu", ino); 904 "inode bitmap error for orphan %lu", ino);
@@ -969,7 +976,7 @@ unsigned long ext4_count_free_inodes (struct super_block * sb)
969 continue; 976 continue;
970 desc_count += le16_to_cpu(gdp->bg_free_inodes_count); 977 desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
971 brelse(bitmap_bh); 978 brelse(bitmap_bh);
972 bitmap_bh = read_inode_bitmap(sb, i); 979 bitmap_bh = ext4_read_inode_bitmap(sb, i);
973 if (!bitmap_bh) 980 if (!bitmap_bh)
974 continue; 981 continue;
975 982