[RFC PATCH 2/2] f2fs: enable buffered RWF_DONTCACHE
From: Wenjie Qi
Date: Thu Aug 06 2026 - 11:09:58 EST
Expose FOP_DONTCACHE and propagate IOCB_DONTCACHE
to write_begin folio allocation so buffered
RWF_DONTCACHE can reach the F2FS write path.
The write-side completion and bio-isolation
semantics are prepared by the previous patch in
this RFC series.
Signed-off-by: Wenjie Qi <qiwenjie@xxxxxxxxxx>
---
fs/f2fs/data.c | 9 ++++++---
fs/f2fs/file.c | 2 +-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8a1e407..40c8f7a 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3982,6 +3982,7 @@ static int f2fs_write_begin(const struct kiocb *iocb,
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct folio *folio;
pgoff_t index = pos >> PAGE_SHIFT;
+ fgf_t fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT;
bool need_balance = false;
block_t blkaddr = NULL_ADDR;
int err = 0;
@@ -4031,9 +4032,11 @@ repeat:
* Do not use FGP_STABLE to avoid deadlock.
* Will wait that below with our IO control.
*/
- folio = f2fs_filemap_get_folio(mapping, index,
- FGP_LOCK | FGP_WRITE | FGP_CREAT,
- mapping_gfp_mask(mapping));
+ if (iocb && (iocb->ki_flags & IOCB_DONTCACHE))
+ fgp_flags |= FGP_DONTCACHE;
+
+ folio = f2fs_filemap_get_folio(mapping, index, fgp_flags,
+ mapping_gfp_mask(mapping));
if (IS_ERR(folio)) {
err = PTR_ERR(folio);
goto fail;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index b99d9cd..b3d1684 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -5578,6 +5578,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