diff options
Diffstat (limited to 'fs/ext4/resize.c')
-rw-r--r-- | fs/ext4/resize.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index e5fb38451a73..ebbc663d0798 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | int ext4_resize_begin(struct super_block *sb) | 20 | int ext4_resize_begin(struct super_block *sb) |
21 | { | 21 | { |
22 | struct ext4_sb_info *sbi = EXT4_SB(sb); | ||
22 | int ret = 0; | 23 | int ret = 0; |
23 | 24 | ||
24 | if (!capable(CAP_SYS_RESOURCE)) | 25 | if (!capable(CAP_SYS_RESOURCE)) |
@@ -29,7 +30,7 @@ int ext4_resize_begin(struct super_block *sb) | |||
29 | * because the user tools have no way of handling this. Probably a | 30 | * because the user tools have no way of handling this. Probably a |
30 | * bad time to do it anyways. | 31 | * bad time to do it anyways. |
31 | */ | 32 | */ |
32 | if (EXT4_SB(sb)->s_sbh->b_blocknr != | 33 | if (EXT4_B2C(sbi, sbi->s_sbh->b_blocknr) != |
33 | le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) { | 34 | le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) { |
34 | ext4_warning(sb, "won't resize using backup superblock at %llu", | 35 | ext4_warning(sb, "won't resize using backup superblock at %llu", |
35 | (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr); | 36 | (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr); |
@@ -1986,6 +1987,26 @@ retry: | |||
1986 | } | 1987 | } |
1987 | } | 1988 | } |
1988 | 1989 | ||
1990 | /* | ||
1991 | * Make sure the last group has enough space so that it's | ||
1992 | * guaranteed to have enough space for all metadata blocks | ||
1993 | * that it might need to hold. (We might not need to store | ||
1994 | * the inode table blocks in the last block group, but there | ||
1995 | * will be cases where this might be needed.) | ||
1996 | */ | ||
1997 | if ((ext4_group_first_block_no(sb, n_group) + | ||
1998 | ext4_group_overhead_blocks(sb, n_group) + 2 + | ||
1999 | sbi->s_itb_per_group + sbi->s_cluster_ratio) >= n_blocks_count) { | ||
2000 | n_blocks_count = ext4_group_first_block_no(sb, n_group); | ||
2001 | n_group--; | ||
2002 | n_blocks_count_retry = 0; | ||
2003 | if (resize_inode) { | ||
2004 | iput(resize_inode); | ||
2005 | resize_inode = NULL; | ||
2006 | } | ||
2007 | goto retry; | ||
2008 | } | ||
2009 | |||
1989 | /* extend the last group */ | 2010 | /* extend the last group */ |
1990 | if (n_group == o_group) | 2011 | if (n_group == o_group) |
1991 | add = n_blocks_count - o_blocks_count; | 2012 | add = n_blocks_count - o_blocks_count; |