iomap: make buffered writes work with RWF_DONTCACHE
authorJens Axboe <axboe@kernel.dk>
Tue, 5 Nov 2024 21:56:16 +0000 (14:56 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 20 Dec 2024 15:30:54 +0000 (08:30 -0700)
Add iomap buffered write support for RWF_DONTCACHE. If RWF_DONTCACHE is
set for a write, mark the folios being written as uncached. Then
writeback completion will drop the pages. The write_iter handler simply
kicks off writeback for the pages, and writeback completion will take
care of the rest.

This still needs the user of the iomap buffered write helpers to call
folio_end_dropbehind_write() upon successful issue of the writes.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/iomap/buffered-io.c
include/linux/iomap.h

index 955f19e27e47c5d3d44e8c2408adf62a909fc411..25d793fa58e99ac058f14e0d9743054fcd7afd46 100644 (file)
@@ -603,6 +603,8 @@ struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len)
 
        if (iter->flags & IOMAP_NOWAIT)
                fgp |= FGP_NOWAIT;
+       if (iter->flags & IOMAP_DONTCACHE)
+               fgp |= FGP_DONTCACHE;
        fgp |= fgf_set_order(len);
 
        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,
 
        if (iocb->ki_flags & IOCB_NOWAIT)
                iter.flags |= IOMAP_NOWAIT;
+       if (iocb->ki_flags & IOCB_DONTCACHE)
+               iter.flags |= IOMAP_DONTCACHE;
 
        while ((ret = iomap_iter(&iter, ops)) > 0)
                iter.processed = iomap_write_iter(&iter, i);
index 5675af6b740c27bc2baeaca311e3db495a6474df..0dd9d967040e08c2f8aee586416029e483f73cb7 100644 (file)
@@ -183,6 +183,7 @@ struct iomap_folio_ops {
 #define IOMAP_DAX              0
 #endif /* CONFIG_FS_DAX */
 #define IOMAP_ATOMIC           (1 << 9)
+#define IOMAP_DONTCACHE                (1 << 10)
 
 struct iomap_ops {
        /*