Naohiro Aota bf9821ba47 btrfs: zoned: fix zone unusable accounting for freed reserved extent
When btrfs reserves an extent and does not use it (e.g, by an error), it
calls btrfs_free_reserved_extent() to free the reserved extent. In the
process, it calls btrfs_add_free_space() and then it accounts the region
bytes as block_group->zone_unusable.

However, it leaves the space_info->bytes_zone_unusable side not updated. As
a result, ENOSPC can happen while a space_info reservation succeeded. The
reservation is fine because the freed region is not added in
space_info->bytes_zone_unusable, leaving that space as "free". OTOH,
corresponding block group counts it as zone_unusable and its allocation
pointer is not rewound, we cannot allocate an extent from that block group.
That will also negate space_info's async/sync reclaim process, and cause an
ENOSPC error from the extent allocation process.

Fix that by returning the space to space_info->bytes_zone_unusable.
Ideally, since a bio is not submitted for this reserved region, we should
return the space to free space and rewind the allocation pointer. But, it
needs rework on extent allocation handling, so let it work in this way for
now.

Fixes: 169e0da91a21 ("btrfs: zoned: track unusable bytes for zones")
CC: stable@vger.kernel.org # 5.15+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2024-10-17 16:16:46 +02:00
..
2024-08-13 13:53:09 +02:00
2024-07-18 09:50:08 +02:00
2024-07-15 11:31:32 -07:00
2024-09-03 20:43:14 -04:00
2024-07-15 11:14:59 -07:00
2024-07-15 11:31:32 -07:00
2024-05-13 14:14:05 -07:00
2024-07-15 11:14:59 -07:00
2024-07-17 12:53:47 -07:00
2024-07-23 15:21:19 -07:00
2024-07-15 11:31:32 -07:00
2024-09-03 12:32:00 -07:00
2024-07-09 10:40:03 +02:00
2024-07-15 11:14:59 -07:00
2024-07-15 10:52:51 -07:00
2024-07-27 15:11:59 -07:00
2024-07-15 11:14:59 -07:00
2024-07-15 13:28:14 -07:00
\n
2024-07-17 13:11:42 -07:00
2024-07-23 14:32:21 -07:00
2024-07-15 11:14:59 -07:00
2024-09-06 17:30:33 -07:00
2024-09-01 06:55:47 +12:00
2024-07-22 10:50:18 -07:00
2024-07-18 14:48:11 -07:00
2024-05-28 11:52:53 +02:00
2024-05-28 11:52:49 +02:00
2024-08-21 22:32:58 +02:00
2024-09-06 17:30:33 -07:00
2024-04-23 13:27:43 +02:00
2024-05-28 11:52:45 +02:00
2024-07-15 11:31:32 -07:00
2024-08-29 06:20:44 +12:00
2024-07-23 17:30:42 -07:00
2024-07-15 11:14:59 -07:00
2024-04-25 20:56:20 -07:00
2024-05-10 08:26:31 +02:00
2024-07-15 12:34:01 -07:00
2024-09-06 11:08:58 -07:00
2024-03-11 10:21:06 -07:00
2024-07-15 11:54:04 -07:00
2024-07-24 10:53:13 +02:00
2024-07-18 09:50:08 +02:00
2024-07-15 10:52:51 -07:00
2024-03-12 20:03:34 -07:00
2024-06-20 15:19:17 -06:00
2024-05-02 16:28:20 +02:00
2024-05-24 13:34:07 +02:00
2024-07-15 14:20:22 -07:00
2024-04-10 16:23:02 -06:00