Skip to content

Commit 13368df

Browse files
committed
Merge patch series "iomap: make buffered writes work with RWF_DONTCACHE"
Support buffered writes with RWF_DONTCACHE. * patches from https://lore.kernel.org/r/20250204184047.356762-2-axboe@kernel.dk: xfs: flag as supporting FOP_DONTCACHE iomap: make buffered writes work with RWF_DONTCACHE Link: https://lore.kernel.org/r/20250204184047.356762-2-axboe@kernel.dk Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents 2014c95 + 974c5e6 commit 13368df

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

Documentation/filesystems/iomap/design.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ operations:
352352
``IOMAP_NOWAIT`` is often set on behalf of ``IOCB_NOWAIT`` or
353353
``RWF_NOWAIT``.
354354

355+
* ``IOMAP_DONTCACHE`` is set when the caller wishes to perform a
356+
buffered file I/O and would like the kernel to drop the pagecache
357+
after the I/O completes, if it isn't already being used by another
358+
thread.
359+
355360
If it is necessary to read existing file contents from a `different
356361
<https://lore.kernel.org/all/20191008071527.29304-9-hch@lst.de/>`_
357362
device or address range on a device, the filesystem should return that

Documentation/filesystems/iomap/operations.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ These ``struct kiocb`` flags are significant for buffered I/O with iomap:
131131

132132
* ``IOCB_NOWAIT``: Turns on ``IOMAP_NOWAIT``.
133133

134+
* ``IOCB_DONTCACHE``: Turns on ``IOMAP_DONTCACHE``.
135+
134136
Internal per-Folio State
135137
------------------------
136138

fs/iomap/buffered-io.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len)
603603

604604
if (iter->flags & IOMAP_NOWAIT)
605605
fgp |= FGP_NOWAIT;
606+
if (iter->flags & IOMAP_DONTCACHE)
607+
fgp |= FGP_DONTCACHE;
606608
fgp |= fgf_set_order(len);
607609

608610
return __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT,
@@ -1034,6 +1036,8 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,
10341036

10351037
if (iocb->ki_flags & IOCB_NOWAIT)
10361038
iter.flags |= IOMAP_NOWAIT;
1039+
if (iocb->ki_flags & IOCB_DONTCACHE)
1040+
iter.flags |= IOMAP_DONTCACHE;
10371041

10381042
while ((ret = iomap_iter(&iter, ops)) > 0)
10391043
iter.processed = iomap_write_iter(&iter, i);

fs/xfs/xfs_file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,8 @@ const struct file_operations xfs_file_operations = {
16261626
.fadvise = xfs_file_fadvise,
16271627
.remap_file_range = xfs_file_remap_range,
16281628
.fop_flags = FOP_MMAP_SYNC | FOP_BUFFER_RASYNC |
1629-
FOP_BUFFER_WASYNC | FOP_DIO_PARALLEL_WRITE,
1629+
FOP_BUFFER_WASYNC | FOP_DIO_PARALLEL_WRITE |
1630+
FOP_DONTCACHE,
16301631
};
16311632

16321633
const struct file_operations xfs_dir_file_operations = {

include/linux/iomap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ struct iomap_folio_ops {
183183
#define IOMAP_DAX 0
184184
#endif /* CONFIG_FS_DAX */
185185
#define IOMAP_ATOMIC (1 << 9)
186+
#define IOMAP_DONTCACHE (1 << 10)
186187

187188
struct iomap_ops {
188189
/*

0 commit comments

Comments
 (0)