This is a note to let you know that I've just added the patch titled ext4: avoid unaccounted block allocation when expanding inode to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ext4-avoid-unaccounted-block-allocation-when-expanding-inode.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 8994d11395f8165b3deca1971946f549f0822630 Mon Sep 17 00:00:00 2001 From: Jan Kara <jack@xxxxxxx> Date: Wed, 7 Dec 2022 12:59:28 +0100 Subject: ext4: avoid unaccounted block allocation when expanding inode From: Jan Kara <jack@xxxxxxx> commit 8994d11395f8165b3deca1971946f549f0822630 upstream. When expanding inode space in ext4_expand_extra_isize_ea() we may need to allocate external xattr block. If quota is not initialized for the inode, the block allocation will not be accounted into quota usage. Make sure the quota is initialized before we try to expand inode space. Reported-by: Pengfei Xu <pengfei.xu@xxxxxxxxx> Link: https://lore.kernel.org/all/Y5BT+k6xWqthZc1P@xxxxxxxxxxxxxxxx Signed-off-by: Jan Kara <jack@xxxxxxx> Cc: stable@xxxxxxxxxx Link: https://lore.kernel.org/r/20221207115937.26601-2-jack@xxxxxxx Signed-off-by: Theodore Ts'o <tytso@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/ext4/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6059,6 +6059,14 @@ static int __ext4_expand_extra_isize(str return 0; } + /* + * We may need to allocate external xattr block so we need quotas + * initialized. Here we can be called with various locks held so we + * cannot affort to initialize quotas ourselves. So just bail. + */ + if (dquot_initialize_needed(inode)) + return -EAGAIN; + /* try to expand with EAs present */ error = ext4_expand_extra_isize_ea(inode, new_extra_isize, raw_inode, handle); Patches currently in stable-queue which might be from jack@xxxxxxx are queue-5.4/udf-avoid-double-brelse-in-udf_rename.patch queue-5.4/ext4-avoid-unaccounted-block-allocation-when-expanding-inode.patch queue-5.4/udf-do-not-bother-looking-for-prealloc-extents-if-i_lenextents-matches-i_size.patch queue-5.4/ext4-fix-bug_on-in-__es_tree_search-caused-by-bad-boot-loader-inode.patch queue-5.4/ext4-fix-inode-leak-in-ext4_xattr_inode_create-on-an-error-path.patch queue-5.4/ext4-add-helper-to-check-quota-inums.patch queue-5.4/udf-fix-extending-file-within-last-block.patch queue-5.4/ext4-fix-corruption-when-online-resizing-a-1k-bigalloc-fs.patch queue-5.4/ext4-allocate-extended-attribute-value-in-vmalloc-area.patch queue-5.4/ext4-init-quota-for-old.inode-in-ext4_rename.patch queue-5.4/ext4-add-ext4_iget_bad-flag-to-prevent-unexpected-bad-inode.patch queue-5.4/udf-fix-preallocation-discarding-at-indirect-extent-boundary.patch queue-5.4/ext4-avoid-bug_on-when-creating-xattrs.patch queue-5.4/udf-discard-preallocation-before-extending-file-with-a-hole.patch queue-5.4/ext4-initialize-quota-before-expanding-inode-in-setproject-ioctl.patch