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
4242
4343 #define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3)
4444
45+#define BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4)
46+
4547 #define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED \
4648 (BTRFS_SUBVOL_CREATE_ASYNC | \
4749 BTRFS_SUBVOL_RDONLY | \
4850 BTRFS_SUBVOL_QGROUP_INHERIT | \
49− BTRFS_DEVICE_SPEC_BY_ID)
51+ BTRFS_DEVICE_SPEC_BY_ID | \
52+ BTRFS_SUBVOL_SPEC_BY_ID)
5053
5154 #define BTRFS_FSID_SIZE 16
5255 #define BTRFS_UUID_SIZE 16
@@ -117,6 +120,10 @@ struct btrfs_ioctl_qgroup_limit_args { · 64 unmodified lines
117120 BTRFS_SUBVOL_RDONLY | \
118121 BTRFS_SUBVOL_QGROUP_INHERIT)
119122
123+/* Supported flags for BTRFS_IOC_SNAP_DESTROY_V2 */
124+#define BTRFS_SUBVOL_DELETE_ARGS_MASK \
125+ (BTRFS_SUBVOL_SPEC_BY_ID)
126+
120127 struct btrfs_ioctl_vol_args_v2 {
121128 __s64 fd;
122129 __u64 transid;
@@ -131,6 +138,7 @@ struct btrfs_ioctl_vol_args_v2 { · 8 unmodified lines
131138 union {
132139 char name[BTRFS_SUBVOL_NAME_MAX + 1];
133140 __u64 devid;
141+ __u64 subvolid;
134142 };
135143 };
136144
@@ -959,5 +967,7 @@ enum btrfs_err_code { · 822 unmodified lines
959967 struct btrfs_ioctl_get_subvol_rootref_args)
960968 #define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \
961969 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)
962972
963973 #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