[PATCH 10/12] btrfs: define btrfs_iomap_folio_ops

From: Goldwyn Rodrigues
Date: Fri Oct 04 2024 - 16:23:41 EST


From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>

The put_folio() sets folio->private to EXTENT_PAGE_PRIVATE if not
already set using set_page_extent_mapped().

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
---
fs/btrfs/extent_io.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 43418b6d4824..ee0d37388441 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -901,6 +901,18 @@ void clear_folio_extent_mapped(struct folio *folio)
folio_detach_private(folio);
}

+static void btrfs_put_folio(struct inode *inode, loff_t pos,
+ unsigned copied, struct folio *folio)
+{
+ set_folio_extent_mapped(folio);
+ folio_unlock(folio);
+ folio_put(folio);
+}
+
+static const struct iomap_folio_ops btrfs_iomap_folio_ops = {
+ .put_folio = btrfs_put_folio,
+};
+
static void btrfs_em_to_iomap(struct inode *inode,
struct extent_map *em, struct iomap *iomap,
loff_t sector_pos, bool write)
@@ -928,6 +940,7 @@ static void btrfs_em_to_iomap(struct inode *inode,
iomap->offset = em->start;
iomap->bdev = fs_info->fs_devices->latest_dev->bdev;
iomap->length = em->len;
+ iomap->folio_ops = &btrfs_iomap_folio_ops;
}

static struct extent_map *__get_extent_map(struct inode *inode,
--
2.46.1