]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: free data reloc tree on failed mount
authorJosef Bacik <josef@toxicpanda.com>
Thu, 3 Sep 2020 18:29:50 +0000 (14:29 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 7 Sep 2020 12:51:15 +0000 (14:51 +0200)
commit08a7d822672219176f5a8e9f063e0412cd34c1ff
treedd712e17d7a082985f6147f96330ba09d3b57299
parent73d6f4ac708cc0b58928105ea18851661bc1eb3e
btrfs: free data reloc tree on failed mount

While testing a weird problem with -o degraded, I noticed I was getting
leaked root errors

  BTRFS warning (device loop0): writable mount is not allowed due to too many missing devices
  BTRFS error (device loop0): open_ctree failed
  BTRFS error (device loop0): leaked root -9-0 refcount 1

This is the DATA_RELOC root, which gets read before the other fs roots,
but is included in the fs roots radix tree.  Handle this by adding a
btrfs_drop_and_free_fs_root() on the data reloc root if it exists.  This
is ok to do here if we fail further up because we will only drop the ref
if we delete the root from the radix tree, and all other cleanup won't
be duplicated.

CC: stable@vger.kernel.org # 5.8+
Reviewed-by: Nikolay Borisov <nborisov@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/disk-io.c