]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
btrfs: skip superblocks during discard
authorJeff Mahoney <jeffm@suse.com>
Mon, 15 Jun 2015 13:41:16 +0000 (09:41 -0400)
committerChris Mason <clm@fb.com>
Wed, 29 Jul 2015 15:15:25 +0000 (08:15 -0700)
commit86557861dfe4f8defde0df40620b97cc60285aa4
tree298d8216e934107e6357d76cb81f1d8c2edbc6e2
parent4d89d377bbb0e34cd1571b57a984c2326cab69b5
btrfs: skip superblocks during discard

Btrfs doesn't track superblocks with extent records so there is nothing
persistent on-disk to indicate that those blocks are in use.  We track
the superblocks in memory to ensure they don't get used by removing them
from the free space cache when we load a block group from disk.  Prior
to 47ab2a6c6a (Btrfs: remove empty block groups automatically), that
was fine since the block group would never be reclaimed so the superblock
was always safe.  Once we started removing the empty block groups, we
were protected by the fact that discards weren't being properly issued
for unused space either via FITRIM or -odiscard.  The block groups were
still being released, but the blocks remained on disk.

In order to properly discard unused block groups, we need to filter out
the superblocks from the discard range.  Superblocks are located at fixed
locations on each device, so it makes sense to filter them out in
btrfs_issue_discard, which is used by both -odiscard and FITRIM.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Tested-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/extent-tree.c