summaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-09-19 00:55:56 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-09-19 00:55:56 -0400
commit59e31c156a24d483bbd2ea07d4dc96043a55b6bc (patch)
treeadb76b9f52a862c4a844be737c7f16c4a8dbaa81 /fs/ext4
parentc9b92530a723ac5ef8e352885a1862b18f31b2f5 (diff)
downloadlinux-59e31c156a24d483bbd2ea07d4dc96043a55b6bc.tar.gz
linux-59e31c156a24d483bbd2ea07d4dc96043a55b6bc.tar.bz2
linux-59e31c156a24d483bbd2ea07d4dc96043a55b6bc.zip
ext4: fix online resizing when the # of block groups is constant
Commit 1c6bd7173d66b3 introduced a regression where an online resize operation which did not change the number of block groups would fail, i.e: mke2fs -t /dev/vdc 60000 mount /dev/vdc resize2fs /dev/vdc 60001 This was due to a bug in the logic regarding when to try converting the filesystem to use meta_bg. Also fix up a number of other minor issues with the online resizing code: (a) Fix a sparse warning; (b) only check to make sure the device is large enough once, instead of multiple times through the resize loop. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/resize.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 3c9367b9bebd..ee985ca05100 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1772,23 +1772,18 @@ static int ext4_convert_meta_bg(struct super_block *sb, struct inode *inode)
handle_t *handle;
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_super_block *es = sbi->s_es;
- struct ext4_inode_info *ei = 0;
+ struct ext4_inode_info *ei = EXT4_I(inode);
ext4_fsblk_t nr;
int i, ret, err = 0;
int credits = 1;
ext4_msg(sb, KERN_INFO, "Converting file system to meta_bg");
- if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_RESIZE_INODE)) {
+ if (inode) {
if (es->s_reserved_gdt_blocks) {
ext4_error(sb, "Unexpected non-zero "
"s_reserved_gdt_blocks");
return -EPERM;
}
- if (!inode) {
- ext4_error(sb, "Unexpected NULL resize_inode");
- return -EPERM;
- }
- ei = EXT4_I(inode);
/* Do a quick sanity check of the resize inode */
if (inode->i_blocks != 1 << (inode->i_blkbits - 9))
@@ -1873,12 +1868,19 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
int err = 0, flexbg_size = 1 << sbi->s_log_groups_per_flex;
int meta_bg;
+ /* See if the device is actually as big as what was requested */
+ bh = sb_bread(sb, n_blocks_count - 1);
+ if (!bh) {
+ ext4_warning(sb, "can't read last block, resize aborted");
+ return -ENOSPC;
+ }
+ brelse(bh);
+
retry:
o_blocks_count = ext4_blocks_count(es);
- if (test_opt(sb, DEBUG))
- ext4_msg(sb, KERN_DEBUG, "resizing filesystem from %llu "
- "to %llu blocks", o_blocks_count, n_blocks_count);
+ ext4_msg(sb, KERN_INFO, "resizing filesystem from %llu "
+ "to %llu blocks", o_blocks_count, n_blocks_count);
if (n_blocks_count < o_blocks_count) {
/* On-line shrinking not supported */
@@ -1922,7 +1924,7 @@ retry:
}
}
- if ((!resize_inode && !meta_bg) || n_group == o_group) {
+ if ((!resize_inode && !meta_bg) || n_blocks_count == o_blocks_count) {
err = ext4_convert_meta_bg(sb, resize_inode);
if (err)
goto out;
@@ -1937,14 +1939,6 @@ retry:
}
}
- /* See if the device is actually as big as what was requested */
- bh = sb_bread(sb, n_blocks_count - 1);
- if (!bh) {
- ext4_warning(sb, "can't read last block, resize aborted");
- return -ENOSPC;
- }
- brelse(bh);
-
/* extend the last group */
if (n_group == o_group)
add = n_blocks_count - o_blocks_count;
@@ -2005,8 +1999,6 @@ out:
free_flex_gd(flex_gd);
if (resize_inode != NULL)
iput(resize_inode);
- if (test_opt(sb, DEBUG))
- ext4_msg(sb, KERN_DEBUG, "resized filesystem to %llu",
- n_blocks_count);
+ ext4_msg(sb, KERN_INFO, "resized filesystem to %llu", n_blocks_count);
return err;
}