• Anand Jain's avatar
    btrfs: introduce device delete by devid · 6b526ed7
    Anand Jain authored
    This introduces new ioctl BTRFS_IOC_RM_DEV_V2, which uses enhanced struct
    btrfs_ioctl_vol_args_v2 to carry devid as an user argument.
    
    The patch won't delete the old ioctl interface and so kernel remains
    backward compatible with user land progs.
    
    Test case/script:
    echo "0 $(blockdev --getsz /dev/sdf) linear /dev/sdf 0" | dmsetup create bad_disk
    mkfs.btrfs -f -d raid1 -m raid1 /dev/sdd /dev/sde /dev/mapper/bad_disk
    mount /dev/sdd /btrfs
    dmsetup suspend bad_disk
    echo "0 $(blockdev --getsz /dev/sdf) error /dev/sdf 0" | dmsetup load bad_disk
    dmsetup resume bad_disk
    echo "bad disk failed. now deleting/replacing"
    btrfs dev del  3  /btrfs
    echo $?
    btrfs fi show /btrfs
    umount /btrfs
    btrfs-show-super /dev/sdd | egrep num_device
    dmsetup remove bad_disk
    wipefs -a /dev/sdf
    Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
    Reported-by: default avatarMartin <m_btrfs@ml1.co.uk>
    [ adjust messages, s/disk/device/ ]
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    6b526ed7
volumes.h 16.7 KB