xfs: Call kiocb_modified() for buffered write
PATCH 1/1 xfs: Call kiocb_modified() for buffered write
kiocb_modified() should be used for sync/async buffered write because it will return -EAGAIN when IOCB_NOWAIT is set. Unfortunately, kiocb_modified() is used by the common xfs_file_write_checks() which is called by all types of write(i.e. buffered/direct/dax write). This issue makes generic/471 with xfs always get the following error:
--------------------------------------------------------
QA output created by 471
pwrite: Resource temporarily unavailable
wrote 8388608/8388608 bytes at offset 0
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
pwrite: Resource temporarily unavailable
...
--------------------------------------------------------
--- fs/xfs/xfs_file.c | 3 +++ 1 file changed, 3 insertions(+)
fs/xfs/xfs_file.c +3 -0
@@ -417,6 +417,9 @@ xfs_file_write_checks(spin_unlock (&ip->i_flags_lock); out: +if (IS_DAX (inode) || (iocb->ki_flags &IOCB_DIRECT )) +return file_modified (file); +return kiocb_modified (iocb); }
Signature · 1 line
2.21.0
Quoted 5 lines · Xiao Yang
kiocb_modified()should be used for sync/async buffered write because it will return-EAGAINwhenIOCB_NOWAITis set. Unfortunately,kiocb_modified()is used by the commonxfs_file_write_checks()which is called by all types of write(i.e. buffered/direct/dax write). This issue makes generic/471 with xfs always get the following error:
Quoted 9 lines
--------------------------------------------------------
QA output created by 471
pwrite: Resource temporarily unavailable
wrote 8388608/8388608 bytes at offset 0
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
pwrite: Resource temporarily unavailable
...
--------------------------------------------------------
There have been earlier discussions about this. Snippet from the earlier discussion:
"generic/471 complains because it expects any write done with RWF_NOWAIT to succeed as long as the blocks for the write are already instantiated. This isn't necessarily a correct assumption, as there are other conditions that can cause an RWF_NOWAIT write to fail with -EAGAIN even if the range is already there."
So the test itself probably needs fixing.
Quoted 20 lines
Fixes 1aa91d9c9933 ("xfs: Add async buffered write support")Signed-off-by Xiao Yang <[email protected]>--- fs/xfs/xfs_file.c | 3 +++ 1 file changed, 3 insertions(+)fs/xfs/xfs_file.c +3
-0@@ -417,6 +417,9 @@ xfs_file_write_checks(spin_unlock (&ip->i_flags_lock); out: +if (IS_DAX (inode) || (iocb->ki_flags &IOCB_DIRECT )) +return file_modified (file); +return kiocb_modified (iocb); }
On 2022/11/17 3:00, Stefan Roesch write:
Quoted 16 lines · Xiao Yang
Quoted 5 lines
kiocb_modified()should be used for sync/async buffered write because it will return-EAGAINwhenIOCB_NOWAITis set. Unfortunately,kiocb_modified()is used by the commonxfs_file_write_checks()which is called by all types of write(i.e. buffered/direct/dax write). This issue makes generic/471 with xfs always get the following error:Quoted 9 lines
--------------------------------------------------------
QA output created by 471
pwrite: Resource temporarily unavailable
wrote 8388608/8388608 bytes at offset 0
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
pwrite: Resource temporarily unavailable
...
--------------------------------------------------------
Quoted 8 lines
There have been earlier discussions about this. Snippet from the earlier discussion:
"generic/471 complains because it expects any write done with
RWF_NOWAITto succeed as long as the blocks for the write are already instantiated. This isn't necessarily a correct assumption, as there are other conditions that can cause anRWF_NOWAITwrite to fail with-EAGAINeven if the range is already there."
Hi Stefan,
Thanks for your reply.
Could you give me the URL about the earlier discussions?
kiocb_modified() makes all types of write always get -EAGAIN when RWF_NOWAIT is set. I don't think this patch[1] is correct because it changed the original logic. The original logic only makes buffered write get -EOPNOTSUPP when RWF_NOWAIT is set.
---------------------------------------------
static int file_modified_flags(struct file *file, int flags)
{
...
if (flags & IOCB_NOWAIT)
return -EAGAIN;
...
}
int kiocb_modified(struct kiocb *iocb)
{
return file_modified_flags(iocb->ki_filp, iocb->ki_flags);
}---------------------------------------------
PS: kiocb_modified() is used by the common xfs_file_write_checks() which is called by all types of write(i.e. buffered/direct/dax write).
Quoted 2 lines
So the test itself probably needs fixing.
In my opinion, both kernel and the test probably need to be fixed.
[1] 1aa91d9c9933 ("xfs: Add async buffered write support")
Best Regards,
Xiao Yang
Hi
Kindly ping. ^_^
Best Regards,
Xiao Yang
-----Original Message-----
From: Yang, Xiao/杨 晓 <[email protected]>
Sent: 2022年11月17日 10:28
To: Stefan Roesch <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Ruan, Shiyang/阮 世阳 <[email protected]>
Subject: Re: [PATCH] xfs: Call kiocb_modified() for buffered write
On 2022/11/17 3:00, Stefan Roesch write:
Quoted 15 lines · Xiao Yang
Quoted 4 lines
kiocb_modified()should be used for sync/async buffered write because it will return-EAGAINwhenIOCB_NOWAITis set. Unfortunately,kiocb_modified()is used by the commonxfs_file_write_checks()which is called by all types of write(i.e. buffered/direct/dax write).Quoted 9 lines
This issue makes generic/471 with xfs always get the following error:
--------------------------------------------------------
QA output created by 471
pwrite: Resource temporarily unavailable wrote 8388608/8388608 bytes at offset 0 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
pwrite: Resource temporarily unavailable ...
--------------------------------------------------------
Quoted 8 lines
There have been earlier discussions about this. Snippet from the earlier discussion:
"generic/471 complains because it expects any write done with
RWF_NOWAITto succeed as long as the blocks for the write are already instantiated. This isn't necessarily a correct assumption, as there are other conditions that can cause anRWF_NOWAITwrite to fail with-EAGAINeven if the range is already there."
Hi Stefan,
Thanks for your reply.
Could you give me the URL about the earlier discussions?
kiocb_modified() makes all types of write always get -EAGAIN when RWF_NOWAIT is set. I don't think this patch[1] is correct because it changed the original logic. The original logic only makes buffered write get -EOPNOTSUPP when RWF_NOWAIT is set.
---------------------------------------------
static int file_modified_flags(struct file *file, int flags) { ...
if (flags & IOCB_NOWAIT)
return -EAGAIN;
...
}
int kiocb_modified(struct kiocb *iocb)
{
return file_modified_flags(iocb->ki_filp, iocb->ki_flags); }---------------------------------------------
PS: kiocb_modified() is used by the common xfs_file_write_checks() which is called by all types of write(i.e. buffered/direct/dax write).
Quoted 2 lines
So the test itself probably needs fixing.
In my opinion, both kernel and the test probably need to be fixed.
[1] 1aa91d9c9933 ("xfs: Add async buffered write support")
Best Regards,
Xiao Yang
This has been discussed in https://lore.kernel.org/linux-xfs/[email protected]/
Here is Jens comment:
From: Jens Axboe <[email protected]>
To: "Darrick J. Wong" <[email protected]>, fstests <[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], Stefan Roesch <[email protected]>
Subject: Re: generic/471 regression with async buffered writes?
Date: Thu, 18 Aug 2022 11:00:38 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <Yv5quvRMZXlDXED/@magnolia>
Quoted 24 lines · Darrick J. Wong
Hi everyone,
I noticed the following fstest failure on XFS on 6.0-rc1 that wasn't there in 5.19:
471.out.bad renamed from 471.out +3
-5@@ -2,12 +2,10 @@ pwrite: Resource temporarily unavailable wrote 8388608/8388608 bytes at offset 0 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -RWF_NOWAIT time is within limits. +pwrite: Resource temporarily unavailable +(standard_in) 1: syntax error +RWF_NOWAIT took seconds 00000000: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................ * -00200000: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb ................ -* -00300000: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................ -* read 8388608/8388608 bytes at offset 0 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
Quoted 2 lines
Is this related to the async buffered write changes, or should I keep looking? AFAICT nobody else has mentioned problems with 471...
The test is just broken. It made some odd assumptions on what RWF_NOWAIT means with buffered writes. There's been a discussion on it previously, I'll see if I can find the links. IIRC, the tldr is that the test doesn't really tie RWF_NOWAIT to whether we'll block or not.
Signature · 1 line
Jens Axboe
Quoted 71 lines · On 1/12/23 8:55 PM, [email protected] wrote:
!-------------------------------------------------------------------|
This Message Is From an External Sender|-------------------------------------------------------------------!
Hi
Kindly ping. ^_^
Best Regards,
Xiao Yang-----Original Message-----
From: Yang, Xiao/杨 晓 <[email protected]>
Sent: 2022年11月17日 10:28
To: Stefan Roesch <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Ruan, Shiyang/阮 世阳 <[email protected]>
Subject: Re: [PATCH] xfs: Callkiocb_modified()for buffered writeOn 2022/11/17 3:00, Stefan Roesch write:
Quoted 15 lines · Xiao Yang
Quoted 4 lines
kiocb_modified()should be used for sync/async buffered write because it will return-EAGAINwhenIOCB_NOWAITis set. Unfortunately,kiocb_modified()is used by the commonxfs_file_write_checks()which is called by all types of write(i.e. buffered/direct/dax write).Quoted 9 lines
This issue makes generic/471 with xfs always get the following error:
--------------------------------------------------------
QA output created by 471
pwrite: Resource temporarily unavailable wrote 8388608/8388608 bytes at offset 0 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
pwrite: Resource temporarily unavailable ...
--------------------------------------------------------Quoted 8 lines
There have been earlier discussions about this. Snippet from the earlier discussion:
"generic/471 complains because it expects any write done with
RWF_NOWAITto succeed as long as the blocks for the write are already instantiated. This isn't necessarily a correct assumption, as there are other conditions that can cause anRWF_NOWAITwrite to fail with-EAGAINeven if the range is already there."Hi Stefan,
Thanks for your reply.
Could you give me the URL about the earlier discussions?
kiocb_modified()makes all types of write always get-EAGAINwhenRWF_NOWAITis set. I don't think this patch[1] is correct because it changed the original logic. The original logic only makes buffered write get-EOPNOTSUPPwhenRWF_NOWAITis set.
---------------------------------------------
static intfile_modified_flags(struct file *file, int flags){ ...
if (flags &IOCB_NOWAIT)
return-EAGAIN;
...
}
intkiocb_modified(struct kiocb *iocb){ return file_modified_flags(iocb->ki_filp, iocb->ki_flags); }---------------------------------------------
PS:kiocb_modified()is used by the commonxfs_file_write_checks()which is called by all types of write(i.e. buffered/direct/dax write).Quoted 2 lines
So the test itself probably needs fixing.
In my opinion, both kernel and the test probably need to be fixed.
[1]
1aa91d9c9933("xfs: Add async buffered write support")Best Regards,
Xiao Yang