• Misono Tomohiro's avatar
    btrfs: Factor out the main deletion process from btrfs_ioctl_snap_destroy() · f60a2364
    Misono Tomohiro authored
    Factor out the second half of btrfs_ioctl_snap_destroy() as
    btrfs_delete_subvolume(), which performs some subvolume specific checks
    before deletion:
    
    1. send is not in progress
    2. the subvolume is not the default subvolume
    3. the subvolume does not contain other subvolumes
    
    and actual deletion process. btrfs_delete_subvolume() requires
    inode_lock for both @dir and inode of @dentry. The remaining part of
    btrfs_ioctl_snap_destroy() is mainly permission checks.
    
    Note that call of d_delete() is not included in btrfs_delete_subvolume()
    as this function will also be used by btrfs_rmdir() to delete an empty
    subvolume and in that case d_delete() is called in VFS layer.
    
    As a result, btrfs_unlink_subvol() and may_destroy_subvol()
    become static functions. No functional changes.
    Signed-off-by: default avatarTomohiro Misono <misono.tomohiro@jp.fujitsu.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    [ minor comment updates ]
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    f60a2364
ioctl.c 131 KB