[PATCH v6 2/2] f2fs: enable buffered RWF_DONTCACHE

From: Wenjie Qi

Date: Fri Nov 27 2026 - 03:50:14 EST


Pass FGP_DONTCACHE to f2fs_filemap_get_folio() for
IOCB_DONTCACHE writes and advertise FOP_DONTCACHE.

The address-space write_begin callback is also used by internal
callers that pass a NULL kiocb, including page_symlink(). Check iocb before
inspecting its flags.

Keep the F2FS-specific lookup because write_begin_get_folio() adds
FGP_STABLE, which can deadlock here.

Reported-by: syzbot+cid5582b8164122eda@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://ci.syzbot.org/series/cbb9ded8-1388-4a7b-bfa7-44082b04025b
Signed-off-by: Wenjie Qi <qiwenjie@xxxxxxxxxx>
---
Changes since v5:

- Rebase onto dev, using the existing fgp variable and preserving its
folio-order handling.

fs/f2fs/data.c | 3 +++
fs/f2fs/file.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 37d74afc8b26..f3559c27d44c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -5622,6 +5622,9 @@ static int f2fs_write_begin(const struct kiocb *iocb,
unsigned int blen;
int err = 0;

+ if (iocb && iocb->ki_flags & IOCB_DONTCACHE)
+ fgp |= FGP_DONTCACHE;
+
trace_f2fs_write_begin(inode, pos, len);

if (!f2fs_is_checkpoint_ready(sbi)) {
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index c80dbbe76f8f..571a848c6af5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -6274,6 +6274,6 @@ const struct file_operations f2fs_file_operations = {
.splice_read = f2fs_file_splice_read,
.splice_write = iter_file_splice_write,
.fadvise = f2fs_file_fadvise,
- .fop_flags = FOP_BUFFER_RASYNC,
+ .fop_flags = FOP_BUFFER_RASYNC | FOP_DONTCACHE,
.setlease = generic_setlease,
};
--
2.43.0