[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <23762f818bfb84bd38b4ad0e803588dc140cd14a.1728071257.git.rgoldwyn@suse.com>
Date: Fri, 4 Oct 2024 16:04:34 -0400
From: Goldwyn Rodrigues <rgoldwyn@...e.de>
To: linux-kernel@...r.kernel.org
Cc: linux-fsdevel@...r.kernel.org,
Goldwyn Rodrigues <rgoldwyn@...e.com>
Subject: [PATCH 07/12] btrfs: btrfs_em_to_iomap() to convert em to iomap
From: Goldwyn Rodrigues <rgoldwyn@...e.com>
btrfs_em_to_iomap() converts and extent map into passed argument struct
iomap. It makes sure the information is in multiple of sectorsize block.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@...e.com>
---
fs/btrfs/extent_io.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index cb0a39370d30..7f40c2b8bfb8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -14,6 +14,7 @@
#include <linux/pagevec.h>
#include <linux/prefetch.h>
#include <linux/fsverity.h>
+#include <linux/iomap.h>
#include "extent_io.h"
#include "extent-io-tree.h"
#include "extent_map.h"
@@ -900,6 +901,35 @@ void clear_folio_extent_mapped(struct folio *folio)
folio_detach_private(folio);
}
+static void btrfs_em_to_iomap(struct inode *inode,
+ struct extent_map *em, struct iomap *iomap,
+ loff_t sector_pos, bool write)
+{
+ struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+
+ if (!btrfs_is_data_reloc_root(BTRFS_I(inode)->root) &&
+ em->flags & EXTENT_FLAG_PINNED) {
+ iomap->type = IOMAP_UNWRITTEN;
+ iomap->addr = extent_map_block_start(em);
+ } else if (em->disk_bytenr == EXTENT_MAP_INLINE) {
+ iomap->addr = IOMAP_NULL_ADDR;
+ iomap->type = IOMAP_INLINE;
+ } else if (em->disk_bytenr == EXTENT_MAP_HOLE ||
+ (!write && (em->flags & EXTENT_FLAG_PREALLOC))) {
+ iomap->addr = IOMAP_NULL_ADDR;
+ iomap->type = IOMAP_HOLE;
+ } else if (extent_map_is_compressed(em)) {
+ iomap->type = IOMAP_ENCODED;
+ iomap->addr = em->disk_bytenr;
+ } else {
+ iomap->addr = extent_map_block_start(em);
+ iomap->type = IOMAP_MAPPED;
+ }
+ iomap->offset = em->start;
+ iomap->bdev = fs_info->fs_devices->latest_dev->bdev;
+ iomap->length = em->len;
+}
+
static struct extent_map *__get_extent_map(struct inode *inode,
struct folio *folio, u64 start,
u64 len, struct extent_map **em_cached)
--
2.46.1
Powered by blists - more mailing lists