]> git.itanic.dy.fi Git - linux-stable/commit
btrfs: zoned: defer advancing meta write pointer
authorNaohiro Aota <naohiro.aota@wdc.com>
Mon, 7 Aug 2023 16:12:34 +0000 (01:12 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 09:14:30 +0000 (11:14 +0200)
commit1c33e31e80f0df42c2a994cfd0a1e654d28d8d2a
tree3cf140a5a0c3396c5b9159d56b937350af95081c
parent28c26c6feecce35cb88845c9662cb054fe130f29
btrfs: zoned: defer advancing meta write pointer

[ Upstream commit 0356ad41e0ddb8cf0ea4d68820c92598413e445b ]

We currently advance the meta_write_pointer in
btrfs_check_meta_write_pointer(). That makes it necessary to revert it
when locking the buffer failed. Instead, we can advance it just before
sending the buffer.

Also, this is necessary for the following commit. In the commit, it needs
to release the zoned_meta_io_lock to allow IOs to come in and wait for them
to fill the currently active block group. If we advance the
meta_write_pointer before locking the extent buffer, the following extent
buffer can pass the meta_write_pointer check, resulting in an unaligned
write failure.

Advancing the pointer is still thread-safe as the extent buffer is locked.

Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
Stable-dep-of: 13bb483d32ab ("btrfs: zoned: activate metadata block group on write time")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/extent_io.c
fs/btrfs/zoned.c
fs/btrfs/zoned.h