1 sync up block & inode bitmap reading functions
3 From: Eric Sandeen <sandeen@redhat.com>
5 ext4_read_block_bitmap and read_inode_bitmap do essentially
6 the same thing, and yet they are structured quite differently.
7 I came across this difference while looking at doing bg locking
8 during bg initialization.
12 * removes unnecessary casts in the error messages
13 * renames read_inode_bitmap to ext4_read_inode_bitmap
14 * and more substantially, restructures the inode bitmap
15 reading function to be more like the block bitmap counterpart.
17 The change to the inode bitmap reader simplifies the locking
18 to be applied in the next patch.
20 Signed-off-by: Eric Sandeen <sandeen@redhat.com>
21 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
23 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
24 index 63e5658..b18d590 100644
25 --- a/fs/ext4/balloc.c
26 +++ b/fs/ext4/balloc.c
27 @@ -314,8 +314,8 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
29 ext4_error(sb, __func__,
30 "Cannot read block bitmap - "
31 - "block_group = %d, block_bitmap = %llu",
32 - (int)block_group, (unsigned long long)bitmap_blk);
33 + "block_group = %lu, block_bitmap = %llu",
34 + block_group, bitmap_blk);
37 if (bh_uptodate_or_lock(bh))
38 @@ -331,8 +331,8 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
40 ext4_error(sb, __func__,
41 "Cannot read block bitmap - "
42 - "block_group = %d, block_bitmap = %llu",
43 - (int)block_group, (unsigned long long)bitmap_blk);
44 + "block_group = %lu, block_bitmap = %llu",
45 + block_group, bitmap_blk);
48 ext4_valid_block_bitmap(sb, desc, block_group, bh);
49 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
50 index a92eb30..09cdcd5 100644
51 --- a/fs/ext4/ialloc.c
52 +++ b/fs/ext4/ialloc.c
53 @@ -97,34 +97,41 @@ unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
54 * Return buffer_head of bitmap on success or NULL.
56 static struct buffer_head *
57 -read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
58 +ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
60 struct ext4_group_desc *desc;
61 struct buffer_head *bh = NULL;
62 + ext4_fsblk_t bitmap_blk;
64 desc = ext4_get_group_desc(sb, block_group, NULL);
68 + bitmap_blk = ext4_inode_bitmap(sb, desc);
69 + bh = sb_getblk(sb, bitmap_blk);
70 + if (unlikely(!bh)) {
71 + ext4_error(sb, __func__,
72 + "Cannot read inode bitmap - "
73 + "block_group = %lu, inode_bitmap = %llu",
74 + block_group, bitmap_blk);
77 + if (bh_uptodate_or_lock(bh))
80 if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
81 - bh = sb_getblk(sb, ext4_inode_bitmap(sb, desc));
82 - if (!buffer_uptodate(bh)) {
84 - if (!buffer_uptodate(bh)) {
85 - ext4_init_inode_bitmap(sb, bh, block_group,
87 - set_buffer_uptodate(bh);
92 - bh = sb_bread(sb, ext4_inode_bitmap(sb, desc));
93 + ext4_init_inode_bitmap(sb, bh, block_group, desc);
94 + set_buffer_uptodate(bh);
99 - ext4_error(sb, "read_inode_bitmap",
100 + if (bh_submit_read(bh) < 0) {
102 + ext4_error(sb, __func__,
103 "Cannot read inode bitmap - "
104 "block_group = %lu, inode_bitmap = %llu",
105 - block_group, ext4_inode_bitmap(sb, desc));
107 + block_group, bitmap_blk);
113 @@ -200,7 +207,7 @@ void ext4_free_inode (handle_t *handle, struct inode * inode)
115 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
116 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
117 - bitmap_bh = read_inode_bitmap(sb, block_group);
118 + bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
122 @@ -623,7 +630,7 @@ got_group:
126 - bitmap_bh = read_inode_bitmap(sb, group);
127 + bitmap_bh = ext4_read_inode_bitmap(sb, group);
131 @@ -891,7 +898,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
133 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
134 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
135 - bitmap_bh = read_inode_bitmap(sb, block_group);
136 + bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
138 ext4_warning(sb, __func__,
139 "inode bitmap error for orphan %lu", ino);
140 @@ -969,7 +976,7 @@ unsigned long ext4_count_free_inodes (struct super_block * sb)
142 desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
144 - bitmap_bh = read_inode_bitmap(sb, i);
145 + bitmap_bh = ext4_read_inode_bitmap(sb, i);