diff options
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 1cd6994fc446..8eae94771c45 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -969,7 +969,6 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb, | |||
969 | 969 | ||
970 | block++; | 970 | block++; |
971 | pnum = block / blocks_per_page; | 971 | pnum = block / blocks_per_page; |
972 | poff = block % blocks_per_page; | ||
973 | page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); | 972 | page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); |
974 | if (!page) | 973 | if (!page) |
975 | return -EIO; | 974 | return -EIO; |
@@ -2077,8 +2076,9 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) | |||
2077 | struct super_block *sb = seq->private; | 2076 | struct super_block *sb = seq->private; |
2078 | ext4_group_t group = (ext4_group_t) ((unsigned long) v); | 2077 | ext4_group_t group = (ext4_group_t) ((unsigned long) v); |
2079 | int i; | 2078 | int i; |
2080 | int err; | 2079 | int err, buddy_loaded = 0; |
2081 | struct ext4_buddy e4b; | 2080 | struct ext4_buddy e4b; |
2081 | struct ext4_group_info *grinfo; | ||
2082 | struct sg { | 2082 | struct sg { |
2083 | struct ext4_group_info info; | 2083 | struct ext4_group_info info; |
2084 | ext4_grpblk_t counters[16]; | 2084 | ext4_grpblk_t counters[16]; |
@@ -2095,15 +2095,21 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) | |||
2095 | 2095 | ||
2096 | i = (sb->s_blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) + | 2096 | i = (sb->s_blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) + |
2097 | sizeof(struct ext4_group_info); | 2097 | sizeof(struct ext4_group_info); |
2098 | err = ext4_mb_load_buddy(sb, group, &e4b); | 2098 | grinfo = ext4_get_group_info(sb, group); |
2099 | if (err) { | 2099 | /* Load the group info in memory only if not already loaded. */ |
2100 | seq_printf(seq, "#%-5u: I/O error\n", group); | 2100 | if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) { |
2101 | return 0; | 2101 | err = ext4_mb_load_buddy(sb, group, &e4b); |
2102 | if (err) { | ||
2103 | seq_printf(seq, "#%-5u: I/O error\n", group); | ||
2104 | return 0; | ||
2105 | } | ||
2106 | buddy_loaded = 1; | ||
2102 | } | 2107 | } |
2103 | ext4_lock_group(sb, group); | 2108 | |
2104 | memcpy(&sg, ext4_get_group_info(sb, group), i); | 2109 | memcpy(&sg, ext4_get_group_info(sb, group), i); |
2105 | ext4_unlock_group(sb, group); | 2110 | |
2106 | ext4_mb_unload_buddy(&e4b); | 2111 | if (buddy_loaded) |
2112 | ext4_mb_unload_buddy(&e4b); | ||
2107 | 2113 | ||
2108 | seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free, | 2114 | seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free, |
2109 | sg.info.bb_fragments, sg.info.bb_first_free); | 2115 | sg.info.bb_fragments, sg.info.bb_first_free); |
@@ -2825,7 +2831,6 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
2825 | err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh); | 2831 | err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh); |
2826 | 2832 | ||
2827 | out_err: | 2833 | out_err: |
2828 | ext4_mark_super_dirty(sb); | ||
2829 | brelse(bitmap_bh); | 2834 | brelse(bitmap_bh); |
2830 | return err; | 2835 | return err; |
2831 | } | 2836 | } |
@@ -4694,7 +4699,6 @@ do_more: | |||
4694 | put_bh(bitmap_bh); | 4699 | put_bh(bitmap_bh); |
4695 | goto do_more; | 4700 | goto do_more; |
4696 | } | 4701 | } |
4697 | ext4_mark_super_dirty(sb); | ||
4698 | error_return: | 4702 | error_return: |
4699 | brelse(bitmap_bh); | 4703 | brelse(bitmap_bh); |
4700 | ext4_std_error(sb, err); | 4704 | ext4_std_error(sb, err); |