History

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.

Marcos Paulo de Souza committed 6 years ago

Commit 949964c1 parent c0c907a2 files · +127 −21Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/btrfs.h+11−1
@@ -42,11 +42,14 @@ struct btrfs_ioctl_vol_args { · 41 unmodified lines
42 42
43#define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3)43#define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3)
44 44
45#define BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4)
46
45#define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED \47#define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED \
46 (BTRFS_SUBVOL_CREATE_ASYNC | \48 (BTRFS_SUBVOL_CREATE_ASYNC | \
47 BTRFS_SUBVOL_RDONLY | \49 BTRFS_SUBVOL_RDONLY | \
48 BTRFS_SUBVOL_QGROUP_INHERIT | \50 BTRFS_SUBVOL_QGROUP_INHERIT | \
49 BTRFS_DEVICE_SPEC_BY_ID)51 BTRFS_DEVICE_SPEC_BY_ID | \
52 BTRFS_SUBVOL_SPEC_BY_ID)
50 53
51#define BTRFS_FSID_SIZE 1654#define BTRFS_FSID_SIZE 16
52#define BTRFS_UUID_SIZE 1655#define BTRFS_UUID_SIZE 16
@@ -117,6 +120,10 @@ struct btrfs_ioctl_qgroup_limit_args { · 64 unmodified lines
117 BTRFS_SUBVOL_RDONLY | \120 BTRFS_SUBVOL_RDONLY | \
118 BTRFS_SUBVOL_QGROUP_INHERIT)121 BTRFS_SUBVOL_QGROUP_INHERIT)
119 122
123/* Supported flags for BTRFS_IOC_SNAP_DESTROY_V2 */
124#define BTRFS_SUBVOL_DELETE_ARGS_MASK \
125 (BTRFS_SUBVOL_SPEC_BY_ID)
126
120struct btrfs_ioctl_vol_args_v2 {127struct btrfs_ioctl_vol_args_v2 {
121 __s64 fd;128 __s64 fd;
122 __u64 transid;129 __u64 transid;
@@ -131,6 +138,7 @@ struct btrfs_ioctl_vol_args_v2 { · 8 unmodified lines
131 union {138 union {
132 char name[BTRFS_SUBVOL_NAME_MAX + 1];139 char name[BTRFS_SUBVOL_NAME_MAX + 1];
133 __u64 devid;140 __u64 devid;
141 __u64 subvolid;
134 };142 };
135};143};
136 144
@@ -959,5 +967,7 @@ enum btrfs_err_code { · 822 unmodified lines
959 struct btrfs_ioctl_get_subvol_rootref_args)967 struct btrfs_ioctl_get_subvol_rootref_args)
960#define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \968#define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \
961 struct btrfs_ioctl_ino_lookup_user_args)969 struct btrfs_ioctl_ino_lookup_user_args)
970#define BTRFS_IOC_SNAP_DESTROY_V2 _IOW(BTRFS_IOCTL_MAGIC, 63, \
971 struct btrfs_ioctl_vol_args_v2)
962 972
963#endif /* _UAPI_LINUX_BTRFS_H */973#endif /* _UAPI_LINUX_BTRFS_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t