From: Jiale Yao <yaojiale02@163.com>
To: Damien Le Moal <dlemoal@kernel.org>,
Naohiro Aota <naohiro.aota@wdc.com>,
Johannes Thumshirn <jth@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 5/5] zonefs: drain in-flight DIO before buffered writes
Date: Sun, 25 Oct 2026 20:41:14 +0800 [thread overview]
Message-ID: <20261025124115.3178287-6-yaojiale02@163.com> (raw)
In-Reply-To: <20261025124115.3178287-1-yaojiale02@163.com>
Conventional zone files allow both direct and buffered writes. An
asynchronous direct write can remain active after its submitting thread
releases the inode lock. A buffered write can then dirty page cache before
direct I/O completion performs post-write invalidation, causing the
invalidation to fail and record -EIO in the mapping error sequence.
After taking the exclusive inode lock, wait for active DIO before running
buffered write checks. Return -EAGAIN when an IOCB_NOWAIT request would
otherwise block.
Fixes: 4008e2a0b01a ("zonefs: Reorganize code")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
fs/zonefs/file.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c
index 5b34849be7a2..8635a795c24c 100644
--- a/fs/zonefs/file.c
+++ b/fs/zonefs/file.c
@@ -576,6 +576,14 @@ static ssize_t zonefs_file_buffered_write(struct kiocb *iocb,
inode_lock(inode);
}
+ if (atomic_read(&inode->i_dio_count)) {
+ if (iocb->ki_flags & IOCB_NOWAIT) {
+ ret = -EAGAIN;
+ goto inode_unlock;
+ }
+ inode_dio_wait(inode);
+ }
+
ret = zonefs_write_checks(iocb, from);
if (ret <= 0)
goto inode_unlock;
--
2.34.1
prev parent reply other threads:[~2026-10-25 12:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 12:41 [PATCH 0/5] fs: " Jiale Yao
2026-10-25 12:41 ` [PATCH 1/5] filemap: " Jiale Yao
2026-10-26 13:31 ` Jan Kara
2026-10-27 14:52 ` Christoph Hellwig
2026-10-25 12:41 ` [PATCH 2/5] f2fs: " Jiale Yao
2026-10-25 12:41 ` [PATCH 3/5] xfs: " Jiale Yao
2026-10-26 0:52 ` Dave Chinner
2026-10-25 12:41 ` [PATCH 4/5] xfs: drain in-flight DIO before zoned " Jiale Yao
2026-10-25 12:41 ` Jiale Yao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261025124115.3178287-6-yaojiale02@163.com \
--to=yaojiale02@163.com \
--cc=dlemoal@kernel.org \
--cc=jth@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®