• Liu Bo's avatar
    Btrfs: fix trim 0 bytes after a device delete · 2cac13e4
    Liu Bo authored
    A user reported a bug of btrfs's trim, that is we will trim 0 bytes
    after a device delete.
    
    The reproducer:
    
    $ mkfs.btrfs disk1
    $ mkfs.btrfs disk2
    $ mount disk1 /mnt
    $ fstrim -v /mnt
    $ btrfs device add disk2 /mnt
    $ btrfs device del disk1 /mnt
    $ fstrim -v /mnt
    
    This is because after we delete the device, the block group may start from
    a non-zero place, which will confuse trim to discard nothing.
    Reported-by: default avatarLutz Euler <lutz.euler@freenet.de>
    Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
    2cac13e4
extent-tree.c 211 KB