• Josef Bacik's avatar
    btrfs: fix ->free_chunk_space math in btrfs_shrink_device · e9fd2c05
    Josef Bacik authored
    There are two bugs in how we adjust ->free_chunk_space in
    btrfs_shrink_device.  First we're removing the entire diff between
    new_size and old_size from ->free_chunk_space.  This only works if we're
    reducing the free area, which we could potentially not be.  So adjust
    the math to only subtract the diff in the free space from
    ->free_chunk_space.
    
    Additionally in the error case we're unconditionally adding the diff
    back into ->free_chunk_space, which we need to only do if this device is
    writeable.
    Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    e9fd2c05
volumes.c 214 KB