]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: remove free space items when disabling space cache v1
authorBoris Burkov <boris@bur.io>
Wed, 18 Nov 2020 23:06:25 +0000 (15:06 -0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 9 Dec 2020 18:16:09 +0000 (19:16 +0100)
commit9a66cd499bef33df86aa02e4661485b74da9b079
tree412321f25d6f2ec44657c6f8bcbe2dd94605e662
parentd58cf667d74fe9b0140d005eae27a8087daa72bd
btrfs: remove free space items when disabling space cache v1

When the filesystem transitions from space cache v1 to v2 or to
nospace_cache, it removes the old cached data, but does not remove
the FREE_SPACE items nor the free space inodes they point to. This
doesn't cause any issues besides being a bit inefficient, since these
items no longer do anything useful.

To fix it, when we are mounting, and plan to disable the space cache,
destroy each block group's free space item and free space inode.
The code to remove the items is lifted from the existing use case of
removing the block group, with a light adaptation to handle whether or
not we have already looked up the free space inode.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/free-space-cache.c
fs/btrfs/free-space-cache.h