btrfs: track owning root in btrfs_ref
authorBoris Burkov <boris@bur.io>
Tue, 28 Mar 2023 23:04:02 +0000 (16:04 -0700)
committerDavid Sterba <dsterba@suse.com>
Thu, 12 Oct 2023 14:44:11 +0000 (16:44 +0200)
commit457cb1ddf5e8d895e9c551cad6b84bafae41f32c
tree99dec5946fbd722fb68e1862135a544a0b0f223b
parent610647d7efd1ab06e9cd7ed6f0abe84b16385da7
btrfs: track owning root in btrfs_ref

While data extents require us to store additional inline refs to track
the original owner on free, this information is available implicitly for
metadata. It is found in the owner field of the header of the tree
block. Even if other trees refer to this block and the original ref goes
away, we will not rewrite that header field, so it will reliably give the
original owner.

In addition, there is a relocation case where a new data extent needs to
have an owning root separate from the referring root wired through
delayed refs.

To use it for recording simple quota deltas, we need to wire this root
id through from when we create the delayed ref until we fully process
it. Store it in the generic btrfs_ref struct of the delayed ref.

Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-ref.h
fs/btrfs/extent-tree.c
fs/btrfs/file.c
fs/btrfs/inode-item.c
fs/btrfs/relocation.c
fs/btrfs/tree-log.c