btrfs: zoned: serialize log transaction on zoned filesystems
authorNaohiro Aota <naohiro.aota@wdc.com>
Thu, 4 Feb 2021 10:22:19 +0000 (19:22 +0900)
committerDavid Sterba <dsterba@suse.com>
Tue, 9 Feb 2021 01:48:37 +0000 (02:48 +0100)
commitfa1a0f42a0356846fb1acd1d53061d53413a4c45
tree9c6b0a69cc44acc3b2d8bea30baa781af5651125
parent40ab3be102f0a61dbb93093f330b432324a793f1
btrfs: zoned: serialize log transaction on zoned filesystems

This is the 2/3 patch to enable tree-log on zoned filesystems.

Since we can start more than one log transactions per subvolume
simultaneously, nodes from multiple transactions can be allocated
interleaved. Such mixed allocation results in non-sequential writes at
the time of a log transaction commit. The nodes of the global log root
tree (fs_info->log_root_tree), also have the same problem with mixed
allocation.

Serializes log transactions by waiting for a committing transaction when
someone tries to start a new transaction, to avoid the mixed allocation
problem. We must also wait for running log transactions from another
subvolume, but there is no easy way to detect which subvolume root is
running a log transaction. So, this patch forbids starting a new log
transaction when other subvolumes already allocated the global log root
tree.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-log.c