* [PATCH] ext4: Avoid excessive credit estimate in ext4_tmpfile()
@ 2024-03-07 11:53 Jan Kara
2024-03-08 11:26 ` Luis Henriques
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jan Kara @ 2024-03-07 11:53 UTC (permalink / raw
To: Ted Tso; +Cc: linux-ext4, Jan Kara
A user with minimum journal size (1024 blocks these days) complained
about the following error triggered by generic/697 test in
ext4_tmpfile():
run fstests generic/697 at 2024-02-28 05:34:46
JBD2: vfstest wants too many credits credits:260 rsv_credits:0 max:256
EXT4-fs error (device loop0) in __ext4_new_inode:1083: error 28
Indeed the credit estimate in ext4_tmpfile() is huge.
EXT4_MAXQUOTAS_INIT_BLOCKS() is 219, then 10 credits from ext4_tmpfile()
itself and then ext4_xattr_credits_for_new_inode() adds more credits
needed for security attributes and ACLs. Now the
EXT4_MAXQUOTAS_INIT_BLOCKS() is in fact unnecessary because we've
already initialized quotas with dquot_init() shortly before and so
EXT4_MAXQUOTAS_TRANS_BLOCKS() is enough (which boils down to 3 credits).
Fixes: af51a2ac36d1 ("ext4: ->tmpfile() support")
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/namei.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 05b647e6bc19..58fee3c6febc 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2898,7 +2898,7 @@ static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
inode = ext4_new_inode_start_handle(idmap, dir, mode,
NULL, 0, NULL,
EXT4_HT_DIR,
- EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
+ EXT4_MAXQUOTAS_TRANS_BLOCKS(dir->i_sb) +
4 + EXT4_XATTR_TRANS_BLOCKS);
handle = ext4_journal_current_handle();
err = PTR_ERR(inode);
--
2.35.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Avoid excessive credit estimate in ext4_tmpfile()
2024-03-07 11:53 [PATCH] ext4: Avoid excessive credit estimate in ext4_tmpfile() Jan Kara
@ 2024-03-08 11:26 ` Luis Henriques
2024-03-08 13:11 ` Disha Goel
2024-05-02 20:00 ` Theodore Ts'o
2 siblings, 0 replies; 4+ messages in thread
From: Luis Henriques @ 2024-03-08 11:26 UTC (permalink / raw
To: Jan Kara; +Cc: Ted Tso, linux-ext4
Jan Kara <jack@suse.cz> writes:
> A user with minimum journal size (1024 blocks these days) complained
> about the following error triggered by generic/697 test in
> ext4_tmpfile():
>
> run fstests generic/697 at 2024-02-28 05:34:46
> JBD2: vfstest wants too many credits credits:260 rsv_credits:0 max:256
> EXT4-fs error (device loop0) in __ext4_new_inode:1083: error 28
>
> Indeed the credit estimate in ext4_tmpfile() is huge.
> EXT4_MAXQUOTAS_INIT_BLOCKS() is 219, then 10 credits from ext4_tmpfile()
> itself and then ext4_xattr_credits_for_new_inode() adds more credits
> needed for security attributes and ACLs. Now the
> EXT4_MAXQUOTAS_INIT_BLOCKS() is in fact unnecessary because we've
> already initialized quotas with dquot_init() shortly before and so
> EXT4_MAXQUOTAS_TRANS_BLOCKS() is enough (which boils down to 3 credits).
>
> Fixes: af51a2ac36d1 ("ext4: ->tmpfile() support")
> Signed-off-by: Jan Kara <jack@suse.cz>
FWIW, I've run generic/697 with a 1GiB device, with a block size of 65536.
Without this patch the test fails. Feel free to add my
Tested-by: Luis Henriques <lhenriques@suse.de>
Cheers,
--
Luís
> ---
> fs/ext4/namei.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 05b647e6bc19..58fee3c6febc 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2898,7 +2898,7 @@ static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> inode = ext4_new_inode_start_handle(idmap, dir, mode,
> NULL, 0, NULL,
> EXT4_HT_DIR,
> - EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
> + EXT4_MAXQUOTAS_TRANS_BLOCKS(dir->i_sb) +
> 4 + EXT4_XATTR_TRANS_BLOCKS);
> handle = ext4_journal_current_handle();
> err = PTR_ERR(inode);
> --
>
> 2.35.3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Avoid excessive credit estimate in ext4_tmpfile()
2024-03-07 11:53 [PATCH] ext4: Avoid excessive credit estimate in ext4_tmpfile() Jan Kara
2024-03-08 11:26 ` Luis Henriques
@ 2024-03-08 13:11 ` Disha Goel
2024-05-02 20:00 ` Theodore Ts'o
2 siblings, 0 replies; 4+ messages in thread
From: Disha Goel @ 2024-03-08 13:11 UTC (permalink / raw
To: Jan Kara, Ted Tso; +Cc: linux-ext4
On 07/03/24 5:23 pm, Jan Kara wrote:
> A user with minimum journal size (1024 blocks these days) complained
> about the following error triggered by generic/697 test in
> ext4_tmpfile():
>
> run fstests generic/697 at 2024-02-28 05:34:46
> JBD2: vfstest wants too many credits credits:260 rsv_credits:0 max:256
> EXT4-fs error (device loop0) in __ext4_new_inode:1083: error 28
>
> Indeed the credit estimate in ext4_tmpfile() is huge.
> EXT4_MAXQUOTAS_INIT_BLOCKS() is 219, then 10 credits from ext4_tmpfile()
> itself and then ext4_xattr_credits_for_new_inode() adds more credits
> needed for security attributes and ACLs. Now the
> EXT4_MAXQUOTAS_INIT_BLOCKS() is in fact unnecessary because we've
> already initialized quotas with dquot_init() shortly before and so
> EXT4_MAXQUOTAS_TRANS_BLOCKS() is enough (which boils down to 3 credits).
>
> Fixes: af51a2ac36d1 ("ext4: ->tmpfile() support")
> Signed-off-by: Jan Kara <jack@suse.cz>
Thanks for the fix patch. I have tested the patch on a power machine with smaller
disk and journal size, generic/697 test passed (for both bs<ps and bs=ps) and no
longer seeing the error.
Feel free to add:
Tested-by: Disha Goel<disgoel@linux.ibm.com>
> ---
> fs/ext4/namei.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 05b647e6bc19..58fee3c6febc 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2898,7 +2898,7 @@ static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> inode = ext4_new_inode_start_handle(idmap, dir, mode,
> NULL, 0, NULL,
> EXT4_HT_DIR,
> - EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
> + EXT4_MAXQUOTAS_TRANS_BLOCKS(dir->i_sb) +
> 4 + EXT4_XATTR_TRANS_BLOCKS);
> handle = ext4_journal_current_handle();
> err = PTR_ERR(inode);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Avoid excessive credit estimate in ext4_tmpfile()
2024-03-07 11:53 [PATCH] ext4: Avoid excessive credit estimate in ext4_tmpfile() Jan Kara
2024-03-08 11:26 ` Luis Henriques
2024-03-08 13:11 ` Disha Goel
@ 2024-05-02 20:00 ` Theodore Ts'o
2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2024-05-02 20:00 UTC (permalink / raw
To: Jan Kara; +Cc: Theodore Ts'o, linux-ext4
On Thu, 07 Mar 2024 12:53:20 +0100, Jan Kara wrote:
> A user with minimum journal size (1024 blocks these days) complained
> about the following error triggered by generic/697 test in
> ext4_tmpfile():
>
> run fstests generic/697 at 2024-02-28 05:34:46
> JBD2: vfstest wants too many credits credits:260 rsv_credits:0 max:256
> EXT4-fs error (device loop0) in __ext4_new_inode:1083: error 28
>
> [...]
Applied, thanks!
[1/1] ext4: Avoid excessive credit estimate in ext4_tmpfile()
commit: 35a1f12f0ca857fee1d7a04ef52cbd5f1f84de13
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-02 20:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-07 11:53 [PATCH] ext4: Avoid excessive credit estimate in ext4_tmpfile() Jan Kara
2024-03-08 11:26 ` Luis Henriques
2024-03-08 13:11 ` Disha Goel
2024-05-02 20:00 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).