]> www.infradead.org Git - users/hch/configfs.git/commit
btrfs: zoned: properly take lock to read/update block group's zoned variables
authorNaohiro Aota <naohiro.aota@wdc.com>
Thu, 1 Aug 2024 07:47:52 +0000 (16:47 +0900)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 Aug 2024 18:35:56 +0000 (20:35 +0200)
commite30729d4bd4001881be4d1ad4332a5d4985398f8
treefd65b63f6016619dcdb203c443d52993fea3aac2
parent008e2512dc5696ab2dc5bf264e98a9fe9ceb830e
btrfs: zoned: properly take lock to read/update block group's zoned variables

__btrfs_add_free_space_zoned() references and modifies bg's alloc_offset,
ro, and zone_unusable, but without taking the lock. It is mostly safe
because they monotonically increase (at least for now) and this function is
mostly called by a transaction commit, which is serialized by itself.

Still, taking the lock is a safer and correct option and I'm going to add a
change to reset zone_unusable while a block group is still alive. So, add
locking around the operations.

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>
fs/btrfs/free-space-cache.c