diff options
author | Johannes Thumshirn <johannes.thumshirn@wdc.com> | 2021-05-18 18:40:29 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-06-21 16:19:05 +0300 |
commit | e7ff9e6b8e7d89199119468ae61b29a56f81ad28 (patch) | |
tree | 391a711a8b389f79518e2803a17721da185b02b4 /fs/btrfs/zoned.c | |
parent | 50535db8fbf67d44522de5b79ddf66fb6d0c14a8 (diff) | |
download | linux-e7ff9e6b8e7d89199119468ae61b29a56f81ad28.tar.xz |
btrfs: zoned: factor out zoned device lookup
To be able to construct a zone append bio we need to look up the
btrfs_device. The code doing the chunk map lookup to get the device is
present in btrfs_submit_compressed_write and submit_extent_page.
Factor out the lookup calls into a helper and use it in the submission
paths.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/zoned.c')
-rw-r--r-- | fs/btrfs/zoned.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index c7243d392ca8..549912120cfe 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1533,3 +1533,24 @@ int btrfs_sync_zone_write_pointer(struct btrfs_device *tgt_dev, u64 logical, length = wp - physical_pos; return btrfs_zoned_issue_zeroout(tgt_dev, physical_pos, length); } + +struct btrfs_device *btrfs_zoned_get_device(struct btrfs_fs_info *fs_info, + u64 logical, u64 length) +{ + struct btrfs_device *device; + struct extent_map *em; + struct map_lookup *map; + + em = btrfs_get_chunk_map(fs_info, logical, length); + if (IS_ERR(em)) + return ERR_CAST(em); + + map = em->map_lookup; + /* We only support single profile for now */ + ASSERT(map->num_stripes == 1); + device = map->stripes[0].dev; + + free_extent_map(em); + + return device; +} |