mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiale Yao <yaojiale02@163.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>,
	Eric Biggers <ebiggers@google.com>,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH v2] f2fs: drain in-flight DIO before buffered fallback
Date: Mon, 26 Oct 2026 09:35:36 +0800	[thread overview]
Message-ID: <20261026013536.385261-1-yaojiale02@163.com> (raw)

A partial direct write can fall back to buffered I/O for the unwritten
remainder. Other asynchronous direct writes may still be active after their
submitters release the inode lock. Their completion can invalidate pages
dirtied by the fallback before it flushes them, causing page-cache
invalidation failures and recording an I/O error.

Wait for all in-flight direct I/O before the fallback dirties page cache.
This only serializes the internal direct-to-buffered fallback and does not
change ordinary buffered write handling.

Fixes: a1e09b03e6f5 ("f2fs: use iomap for direct I/O")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
 fs/f2fs/file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 0c759cc99054..e54456e3a226 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -5596,6 +5596,7 @@ static ssize_t f2fs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from,
 		 * The direct write was partial, so we need to fall back to a
 		 * buffered write for the remainder.
 		 */
+		inode_dio_wait(inode);
 
 		ret2 = f2fs_buffered_write_iter(iocb, from);
 		if (iov_iter_count(from))
-- 
2.34.1


                 reply	other threads:[~2026-10-26  1:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261026013536.385261-1-yaojiale02@163.com \
    --to=yaojiale02@163.com \
    --cc=chao@kernel.org \
    --cc=ebiggers@google.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --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®