diff options
author | Naohiro Aota <naohiro.aota@wdc.com> | 2021-08-19 15:19:10 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-10-26 20:07:58 +0300 |
commit | 98173255bddd24cb7d50b5da936f8dff76f5a732 (patch) | |
tree | 43219dba06bb13edcbfbb9aa3904760ebefbeb04 /fs/btrfs/extent-tree.c | |
parent | c46c4247ab046b11806cdb10e04395c2f2cd1e41 (diff) | |
download | linux-98173255bddd24cb7d50b5da936f8dff76f5a732.tar.xz |
btrfs: zoned: calculate free space from zone capacity
Now that we introduced capacity in a block group, we need to calculate free
space using the capacity instead of the length. Thus, bytes we account
capacity - alloc_pointer as free, and account bytes [capacity, length] as
zone unusable.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 0ab456cb4bf8..165acee66b07 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3796,7 +3796,8 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group, goto out; } - avail = block_group->length - block_group->alloc_offset; + WARN_ON_ONCE(block_group->alloc_offset > block_group->zone_capacity); + avail = block_group->zone_capacity - block_group->alloc_offset; if (avail < num_bytes) { if (ffe_ctl->max_extent_size < avail) { /* |