Add an optional iomap_attach_folio callback to struct iomap_write_ops. Filesystems may use this hook to tag folios during write-begin without changing iomap core behavior. Signed-off-by: Kundan Kumar Signed-off-by: Anuj Gupta --- fs/iomap/buffered-io.c | 3 +++ include/linux/iomap.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 8b847a1e27f1..701f2e9cd010 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -699,6 +699,9 @@ static int __iomap_write_begin(const struct iomap_iter *iter, size_t from = offset_in_folio(folio, pos), to = from + len; size_t poff, plen; + if (write_ops && write_ops->tag_folio) + write_ops->tag_folio(&iter->iomap, folio, pos, len); + /* * If the write or zeroing completely overlaps the current folio, then * entire folio will be dirtied so there is no need for diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 73dceabc21c8..14ef88f8ee84 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -176,6 +176,9 @@ struct iomap_write_ops { */ int (*read_folio_range)(const struct iomap_iter *iter, struct folio *folio, loff_t pos, size_t len); + + void (*tag_folio)(const struct iomap *iomap, + struct folio *folio, loff_t pos, size_t len); }; /* -- 2.25.1