public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: ensure revoke credits when set xattr
@ 2019-12-21 11:34 Murphy Zhou
  2019-12-22  2:06 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Murphy Zhou @ 2019-12-21 11:34 UTC (permalink / raw)
  To: linux-ext4; +Cc: Jan Kara

It is possible that we need to release and forget blocks
during set xattr block, especially with 128 inode size,
so we need enough revoke credits to do that. Or we'll
hit WARNING since commit:
	[83448bd] ext4: Reserve revoke credits for freed blocks

This can be triggered easily in a kinda corner case:
--------------

namegen()
{
	echo "fstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | md5sum  | cut -c -10`"
}

md0="/`namegen`"
d0=`namegen`
d1=`namegen`
d2=`namegen`

fallocate -l 200m test.img
mkfs.ext4 -F -b 4096 -I 128 test.img
mkdir -p $md0
mount -o loop test.img $md0 || exit
pushd $md0

mkdir ${d0}
setfacl -d -m 'u::rwx' ${d0}
mkdir ${d0}/${d1} # hit warning
echo $?
mkdir ${d0}/${d2}
rm -rf ${d0}

popd
umount -d $md0
rm -rf $md0 test.img
--------------

Which is derived from the pjd test suite[1].

Patch tested by xfstests auto group.

[1] https://sourceforge.net/p/ntfs-3g/pjd-fstest/ci/master/tree/

Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
---
 fs/ext4/xattr.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 8966a54..5c32c54 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -2319,6 +2319,12 @@ static struct buffer_head *ext4_xattr_get_block(struct inode *inode)
 			error = -ENOSPC;
 			goto cleanup;
 		}
+		error = ext4_journal_ensure_credits(handle, credits,
+				ext4_trans_default_revoke_credits(inode->i_sb));
+		if (error < 0) {
+			EXT4_ERROR_INODE(inode, "ensure credits (error %d)", error);
+			goto cleanup;
+		}
 	}
 
 	error = ext4_reserve_inode_write(handle, inode, &is.iloc);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-23  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-21 11:34 [PATCH] ext4: ensure revoke credits when set xattr Murphy Zhou
2019-12-22  2:06 ` Theodore Y. Ts'o
2019-12-23  7:53   ` Murphy Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox