Skip to content

Commit 2c869b2

Browse files
jankaratytso
authored andcommitted
ext4: fix growing of tiny filesystems
The estimate of necessary transaction credits in ext4_flex_group_add() is too pessimistic. It reserves credit for sb, resize inode, and resize inode dindirect block for each group added in a flex group although they are always the same block and thus it is enough to account them only once. Also the number of modified GDT block is overestimated since we fit EXT4_DESC_PER_BLOCK(sb) descriptors in one block. Make the estimation more precise. That reduces number of requested credits enough that we can grow 20 MB filesystem (which has 1 MB journal, 79 reserved GDT blocks, and flex group size 16 by default). Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
1 parent 280227a commit 2c869b2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/ext4/resize.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,12 +1432,15 @@ static int ext4_flex_group_add(struct super_block *sb,
14321432
goto exit;
14331433
/*
14341434
* We will always be modifying at least the superblock and GDT
1435-
* block. If we are adding a group past the last current GDT block,
1435+
* blocks. If we are adding a group past the last current GDT block,
14361436
* we will also modify the inode and the dindirect block. If we
14371437
* are adding a group with superblock/GDT backups we will also
14381438
* modify each of the reserved GDT dindirect blocks.
14391439
*/
1440-
credit = flex_gd->count * 4 + reserved_gdb;
1440+
credit = 3; /* sb, resize inode, resize inode dindirect */
1441+
/* GDT blocks */
1442+
credit += 1 + DIV_ROUND_UP(flex_gd->count, EXT4_DESC_PER_BLOCK(sb));
1443+
credit += reserved_gdb; /* Reserved GDT dindirect blocks */
14411444
handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, credit);
14421445
if (IS_ERR(handle)) {
14431446
err = PTR_ERR(handle);

0 commit comments

Comments
 (0)