From 761346811e80b515480aaa6c068fb51cf99839b5 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 3 May 2015 00:04:19 -0400 Subject: [PATCH] add patch fix-growing-of-tiny-filesystems --- fix-growing-of-tiny-filesystems | 44 +++++++++++++++++++++++++++++++++++++++++ series | 1 + timestamps | 7 ++++--- 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 fix-growing-of-tiny-filesystems diff --git a/fix-growing-of-tiny-filesystems b/fix-growing-of-tiny-filesystems new file mode 100644 index 00000000..5fe0149f --- /dev/null +++ b/fix-growing-of-tiny-filesystems @@ -0,0 +1,44 @@ +ext4: fix growing of tiny filesystems + +From: Jan Kara + +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 +Signed-off-by: Theodore Ts'o +Reviewed-by: Eric Sandeen +--- + fs/ext4/resize.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c +index 8a8ec62..cf0c472 100644 +--- a/fs/ext4/resize.c ++++ b/fs/ext4/resize.c +@@ -1432,12 +1432,15 @@ static int ext4_flex_group_add(struct super_block *sb, + goto exit; + /* + * We will always be modifying at least the superblock and GDT +- * block. If we are adding a group past the last current GDT block, ++ * blocks. If we are adding a group past the last current GDT block, + * we will also modify the inode and the dindirect block. If we + * are adding a group with superblock/GDT backups we will also + * modify each of the reserved GDT dindirect blocks. + */ +- credit = flex_gd->count * 4 + reserved_gdb; ++ credit = 3; /* sb, resize inode, resize inode dindirect */ ++ /* GDT blocks */ ++ credit += 1 + DIV_ROUND_UP(flex_gd->count, EXT4_DESC_PER_BLOCK(sb)); ++ credit += reserved_gdb; /* Reserved GDT dindirect blocks */ + handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, credit); + if (IS_ERR(handle)) { + err = PTR_ERR(handle); diff --git a/series b/series index b6eb0dc1..1c2ea0d4 100644 --- a/series +++ b/series @@ -6,6 +6,7 @@ do-not-select-from-ext4_fs_encryption remove-duplicated-encryption-mode-definitions fix-data-corruption-caused-by-unwriten-and-delayed-extents move-check-under-lock-scope-to-close-a-race +fix-growing-of-tiny-filesystems # for 4.1 optimize-ext4-encryption diff --git a/timestamps b/timestamps index 1379e7dd..253dc64c 100755 --- a/timestamps +++ b/timestamps @@ -31,7 +31,8 @@ touch -d @1430576939 stop-allocating-pages touch -d @1430576959 do-not-select-from-ext4_fs_encryption touch -d @1430576962 remove-duplicated-encryption-mode-definitions touch -d @1430617015 fix-data-corruption-caused-by-unwriten-and-delayed-extents -touch -d @1430622147 timestamps -touch -d @1430623212 series touch -d @1430623275 move-check-under-lock-scope-to-close-a-race -touch -d @1430623275 status +touch -d @1430625135 series +touch -d @1430625512 fix-growing-of-tiny-filesystems +touch -d @1430625512 status +touch -d @1430625844 timestamps -- 2.11.4.GIT