• Jeff Mahoney's avatar
    btrfs: skip superblocks during discard · 86557861
    Jeff Mahoney authored
    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: default avatarJeff Mahoney <jeffm@suse.com>
    Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
    Tested-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarChris Mason <clm@fb.com>
    86557861
extent-tree.c 274 KB