aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/zoned.c
diff options
context:
space:
mode:
authorNaohiro Aota <naohiro.aota@wdc.com>2021-08-19 21:19:16 +0900
committerDavid Sterba <dsterba@suse.com>2021-10-26 19:07:59 +0200
commitdafc340dbd10a21c133f3b152cee6214fcfbf84a (patch)
tree99c9c5944e8ba8146f01d0c5c2275bc7c67e5e6f /fs/btrfs/zoned.c
parentbtrfs: zoned: load active zone information from devices (diff)
downloadlinux-dev-dafc340dbd10a21c133f3b152cee6214fcfbf84a.tar.xz
linux-dev-dafc340dbd10a21c133f3b152cee6214fcfbf84a.zip
btrfs: zoned: introduce physical_map to btrfs_block_group
We will use a block group's physical location to track active zones and finish fully written zones in the following commits. Since the zone activation is done in the extent allocation context which already holding the tree locks, we can't query the chunk tree for the physical locations. So, copy the location info into a block group and use it for activation. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/zoned.c')
-rw-r--r--fs/btrfs/zoned.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 2ccdc6e1f793..4c89ac02843e 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1158,10 +1158,18 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
map = em->map_lookup;
+ cache->physical_map = kmalloc(map_lookup_size(map->num_stripes), GFP_NOFS);
+ if (!cache->physical_map) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ memcpy(cache->physical_map, map, map_lookup_size(map->num_stripes));
+
alloc_offsets = kcalloc(map->num_stripes, sizeof(*alloc_offsets), GFP_NOFS);
if (!alloc_offsets) {
- free_extent_map(em);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto out;
}
caps = kcalloc(map->num_stripes, sizeof(*caps), GFP_NOFS);
@@ -1344,6 +1352,10 @@ out:
if (!ret)
cache->meta_write_pointer = cache->alloc_offset + cache->start;
+ if (ret) {
+ kfree(cache->physical_map);
+ cache->physical_map = NULL;
+ }
kfree(caps);
kfree(alloc_offsets);
free_extent_map(em);