OSDN Git Service

btrfs: add new BTRFS_IOC_SNAP_DESTROY_V2 ioctl
authorMarcos Paulo de Souza <mpdesouza@suse.com>
Fri, 7 Feb 2020 13:05:46 +0000 (10:05 -0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2020 16:01:42 +0000 (17:01 +0100)
commit949964c928430a42e0d4f514d888a58a201b6fcb
tree4c198f91e33a301b93dd9fdf729bfaf5bdae4588
parentc0c907a47dccf2cf26251a8fb4a8e7a3bf79ce84
btrfs: add new BTRFS_IOC_SNAP_DESTROY_V2 ioctl

This ioctl will be responsible for deleting a subvolume using its id.
This can be used when a system has a file system mounted from a
subvolume, rather than the root file system, like below:

/
@subvol1/
@subvol2/
@subvol_default/

If only @subvol_default is mounted, we have no path to reach @subvol1
and @subvol2, thus no way to delete them. Current subvolume delete ioctl
takes a file handle point as argument, and if @subvol_default is
mounted, we can't reach @subvol1 and @subvol2 from the same mount point.

This patch introduces a new ioctl BTRFS_IOC_SNAP_DESTROY_V2 that takes
the extended structure with flags to allow to delete subvolume using
subvolid.

Now, we can use this new ioctl specifying the subvolume id and refer to
the same mount point. It doesn't matter which subvolume was mounted,
since we can reach to the desired one using the subvolume id, and then
delete it.

The full path to the subvolume id is resolved internally and access is
verified as if the subvolume was accessed by path.

The volume args v2 structure is extended to use the existing union for
subvolume id specification, that's valid in case the
BTRFS_SUBVOL_SPEC_BY_ID is set.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c
include/uapi/linux/btrfs.h