[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231213-btrfs_map_block-cleanup-v2-9-cf5cfb9e2400@wdc.com>
Date: Wed, 13 Dec 2023 06:43:04 -0800
From: Johannes Thumshirn <johannes.thumshirn@....com>
To: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>
Cc: linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
Johannes Thumshirn <johannes.thumshirn@....com>
Subject: [PATCH v2 09/13] btrfs: factor out block mapping for single
profiles
Now that we have a container for the I/O geometry that has all the needed
information for the block mappings of SINGLE profiles, factor out a helper
calculating this information.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@....com>
---
fs/btrfs/volumes.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 55614a9eb8a5..e23c7d2842a6 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6487,6 +6487,14 @@ static void map_blocks_raid56_read(struct btrfs_chunk_map *map,
io_geom->mirror_num = 1;
}
+static void map_blocks_single(struct btrfs_chunk_map *map,
+ struct btrfs_io_geometry *io_geom)
+{
+ io_geom->stripe_index = io_geom->stripe_nr % map->num_stripes;
+ io_geom->stripe_nr /= map->num_stripes;
+ io_geom->mirror_num = io_geom->stripe_index + 1;
+}
+
/*
* Map one logical range to one or more physical ranges.
*
@@ -6591,9 +6599,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
* device we have to walk to find the data, and stripe_index is
* the number of our device in the stripe array
*/
- io_geom.stripe_index = io_geom.stripe_nr % map->num_stripes;
- io_geom.stripe_nr /= map->num_stripes;
- io_geom.mirror_num = io_geom.stripe_index + 1;
+ map_blocks_single(map, &io_geom);
}
if (io_geom.stripe_index >= map->num_stripes) {
btrfs_crit(fs_info,
--
2.43.0
Powered by blists - more mailing lists