]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: hold a ref on the root->reloc_root
authorJosef Bacik <josef@toxicpanda.com>
Fri, 13 Mar 2020 15:44:47 +0000 (11:44 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2020 16:01:58 +0000 (17:01 +0100)
commit4184b2917e129d4cb62dae889740ccf70edaaa8f
tree9bff9e2a4f1e0346fff5ed17d60ef503d555eeef
parent6a1fd6ef643519c601f0c9f1a8a4e5eb09205a78
btrfs: hold a ref on the root->reloc_root

We previously were relying on root->reloc_root to be cleaned up by the
drop snapshot, or the error handling.  However if btrfs_drop_snapshot()
failed it wouldn't drop the ref for the root.  Also we sort of depend on
the right thing to happen with moving reloc roots between lists and the
fs root they belong to, which makes it hard to figure out who owns the
reference.

Fix this by explicitly holding a reference on the reloc root for
roo->reloc_root.  This means that we hold two references on reloc roots,
one for whichever reloc_roots list it's attached to, and the
root->reloc_root we're on.

This makes it easier to reason out who owns a reference on the root, and
when it needs to be dropped.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c