diff options
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r-- | fs/ext4/ialloc.c | 51 |
1 files changed, 29 insertions, 22 deletions
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 | */ |
99 | static struct buffer_head * | 99 | static struct buffer_head * |
100 | read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) | 100 | ext4_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); |
127 | error_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 | ||