From: Seongjae Jeong <jsjlee1020@gmail.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: hans.holmberg@wdc.com, yonggil.song@samsung.com,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org,
Seongjae Jeong <jsjlee1020@gmail.com>
Subject: [PATCH] f2fs: fix O_DIRECT cleanup range for append writes
Date: Fri, 14 Aug 2026 10:52:34 +0000 [thread overview]
Message-ID: <20260814105234.31620-1-jsjlee1020@gmail.com> (raw)
When an O_DIRECT write falls back to buffered I/O,
f2fs_flush_buffered_write() uses orig_pos to flush and invalidate
the page cache.
For O_APPEND writes, f2fs_write_checks() updates iocb->ki_pos to
the end of the file after orig_pos has been saved. As a result,
the cleanup range can differ from the actual buffered write range.
Save the write position after f2fs_write_checks() and use it for
the forced buffered I/O cleanup.
Fixes: 92318f20d703 ("f2fs: preserve direct write semantics when buffering is forced")
Signed-off-by: Seongjae Jeong <jsjlee1020@gmail.com>
---
fs/f2fs/file.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index b99d9cdf9ba7..bf61545603e5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -5313,6 +5313,7 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
const loff_t pos = iocb->ki_pos;
const ssize_t count = iov_iter_count(from);
ssize_t ret;
+ loff_t bufio_start_pos;
if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) {
ret = -EIO;
@@ -5343,6 +5344,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (ret <= 0)
goto out_unlock;
+ bufio_start_pos = iocb->ki_pos;
+
/* Determine whether we will do a direct write or a buffered write. */
dio = f2fs_should_use_dio(inode, iocb, from);
@@ -5396,8 +5399,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
*/
if (ret > 0 && !dio && (iocb->ki_flags & IOCB_DIRECT))
f2fs_flush_buffered_write(iocb->ki_filp->f_mapping,
- orig_pos,
- orig_pos + ret - 1);
+ bufio_start_pos,
+ bufio_start_pos + ret - 1);
return ret;
}
--
2.53.0
next reply other threads:[~2026-08-14 10:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 10:52 Seongjae Jeong [this message]
2026-08-17 3:38 ` Chao Yu
2026-08-18 12:23 ` 정성재
2026-08-19 1:47 ` Chao Yu
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=20260814105234.31620-1-jsjlee1020@gmail.com \
--to=jsjlee1020@gmail.com \
--cc=chao@kernel.org \
--cc=hans.holmberg@wdc.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yonggil.song@samsung.com \
/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®