Add support for a group of btrfs ioctls - 2
v2 cover Add support for a group of btrfs ioctls - 2
This series covers support for following btrfs ioctls
*BTRFS_IOC_DEFAULT_SUBVOL *BTRFS_IOC_QUOTA_RESCAN
*BTRFS_IOC_GET_SUBVOL_ROOTREF *BTRFS_IOC_QUOTA_RESCAN_WAIT
*BTRFS_IOC_QUOTA_CTL *BTRFS_IOC_SCRUB
*BTRFS_IOC_QGROUP_CREATE *BTRFS_IOC_SCRUB_CANCEL
*BTRFS_IOC_QGROUP_ASSIGN *BTRFS_IOC_SCRUB_PROGRESS
*BTRFS_IOC_INO_PATHS *BTRFS_IOC_QGROUP_LIMIT
*BTRFS_IOC_LOGICAL_INO *BTRFS_IOC_QUOTA_RESCAN_STATUS *BTRFS_IOC_LOGICAL_INO_V2
*BTRFS_IOC_INO_LOOKUP_USER
*BTRFS_IOC_INO_LOOKUP
The functionalities of individual ioctls were described in this series patch commit messages. Since all of these ioctls are added in kernel version 3.9, their definitions in file 'linux-user/ioctls.h' are enwrapped in an #ifdef directive.
Testing method:
Mini test programs were written for these ioctls. These test programs can be found on a repository which is located on the link:
https://github.com/bozutaf/btrfs-tests
bozutaf/btrfs-tests
Contribute to bozutaf/btrfs-tests development by creating an account on GitHub. github.com
These test programs were compiled (sometimes using cross compilers) for following architectures:
* Intel 64-bit (little endian)
* Power pc 32-bit (big endian)
* Power pc 64-bit (big endian)
The corresponding native programs were executed without using QEMU on an intel x86_64 host.
All applicable compiled programs were in turn executed through QEMU and the results obtained were the same ones gotten for native execution
v2:
* added Signed-off-by tag (forgot in v1...)
Based-on: <[email protected]>
Filip Bozuta (4):
linux-user: Add support for a group of btrfs inode ioctls
linux-user: Add support for two btrfs ioctls used for subvolume
linux-user: Add support for btrfs ioctls used to manage quota
linux-user: Add support for btrfs ioctls used to scrub a filesystem
linux-user/ioctls.h | 65 +++++++++++++++++++++++++++ linux-user/syscall_defs.h | 34 ++++++++++++++ linux-user/syscall_types.h | 90 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+)
Signature · 1 line
2.25.1
PATCH v2 1/4 linux-user: Add support for a group of btrfs inode ioctls
This patch implements functionality of following ioctls:
BTRFS_IOC_INO_LOOKUP - Reading tree root id and path
Read tree root id and path for a given file or directory. The name and tree root id are returned in an ioctl's third argument that represents a pointer to a following type:
struct btrfs_ioctl_ino_lookup_args {
__u64 treeid;
__u64 objectid;
char name[BTRFS_INO_LOOKUP_PATH_MAX];
};
Before calling this ioctl, field 'objectid' should be filled with the object id value for which the tree id and path are to be read. Value 'BTRFS_FIRST_FREE_OBJECTID' represents the object id for the first available btrfs object (directory or file).
BTRFS_IOC_INO_PATHS - Reading paths to all files
Read path to all files with a certain inode number. The paths
are returned in the ioctl's third argument which represents
a pointer to a following type:
struct btrfs_ioctl_ino_path_args {
__u64 inum; /* in */
__u64 size; /* in */
__u64 reserved[4];
/* struct btrfs_data_container *fspath; out */
__u64 fspath; /* out */
};
Before calling this ioctl, the 'inum' and 'size' field should
be filled with the aproppriate inode number and size of the
directory where file paths should be looked for. For now, the
paths are returned in an '__u64' (unsigned long long) value
'fspath'.BTRFS_IOC_LOGICAL_INO - Reading inode numbers
Read inode numbers for files on a certain logical adress. The
inode numbers are returned in the ioctl's third argument which
represents a pointer to a following type:
struct btrfs_ioctl_logical_ino_args {
__u64 logical; /* in */
__u64 size; /* in */
__u64 reserved[3]; /* must be 0 for now */
__u64 flags; /* in, v2 only */
/* struct btrfs_data_container *inodes; out */
__u64 inodes;
};
Before calling this ioctl, the 'logical' and 'size' field should
be filled with the aproppriate logical adress and size of where
the inode numbers of files should be looked for. For now, the
inode numbers are returned in an '__u64' (unsigned long long)
value 'inodes'.BTRFS_IOC_LOGICAL_INO_V2 - Reading inode numbers
Same as the above mentioned ioctl except that it allows passing a flags 'BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET'.
BTRFS_IOC_INO_LOOKUP_USER - Reading subvolume name and path
Read name and path of a subvolume. The tree root id and
path are read in an ioctl's third argument which represents a
pointer to a following type:
struct btrfs_ioctl_ino_lookup_user_args {
/* in, inode number containing the subvolume of 'subvolid' */
__u64 dirid;
/* in */
__u64 treeid;
/* out, name of the subvolume of 'treeid' */
char name[BTRFS_VOL_NAME_MAX + 1];
/*
* out, constructed path from the directory with which the ioctl is
* called to dirid
*/
char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
};
Before calling this ioctl, the 'dirid' and 'treeid' field should
be filled with aproppriate values which represent the inode number
of the directory that contains the subvolume and treeid of the
subvolume.Implementation notes:
All of the ioctls in this patch use structure types as third arguments. That is the reason why aproppriate thunk definitions were added in file 'syscall_types.h'.
--- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall_defs.h | 10 ++++++++++ linux-user/syscall_types.h | 24 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
linux-user/ioctls.h +20 -0
@@ -202,6 +202,10 @@IOCTL (BTRFS_IOC_SNAP_DESTROY ,IOC_W , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))#endif +#ifdef BTRFS_IOC_INO_LOOKUP +IOCTL (BTRFS_IOC_INO_LOOKUP ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG))#endif
@@ -212,6 +216,14 @@IOCTL (BTRFS_IOC_DEV_INFO ,IOC_RW , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args)))#endif +#ifdef BTRFS_IOC_INO_PATHS +IOCTL (BTRFS_IOC_INO_PATHS ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_path_args))) +#endif +#ifdef BTRFS_IOC_LOGICAL_INO +IOCTL (BTRFS_IOC_LOGICAL_INO ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) +#endif #ifdef BTRFS_IOC_GET_DEV_STATS IOCTL (BTRFS_IOC_GET_DEV_STATS ,IOC_RW ,MK_PTR (MK_STRUCT (STRUCT_btrfs_ioctl_get_dev_stats)))
@@ -228,10 +240,18 @@IOCTL (BTRFS_IOC_GET_SUPPORTED_FEATURES ,IOC_R , MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3)))#endif +#ifdef BTRFS_IOC_LOGICAL_INO_V2 +IOCTL (BTRFS_IOC_LOGICAL_INO_V2 ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL (BTRFS_IOC_GET_SUBVOL_INFO ,IOC_R , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args)))#endif +#ifdef BTRFS_IOC_INO_LOOKUP_USER +IOCTL (BTRFS_IOC_INO_LOOKUP_USER ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args))) +#endif #ifdef CONFIG_USBFS /* USB ioctls */
linux-user/syscall_defs.h +10 -0
@@ -982,12 +982,18 @@ struct target_rtc_pll_info { 14, struct btrfs_ioctl_vol_args)#define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOW(BTRFS_IOCTL_MAGIC, \ 15, struct btrfs_ioctl_vol_args) +#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 18, struct btrfs_ioctl_ino_lookup_args)#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 25, abi_ullong)#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, \ 26, abi_ullong)#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 30, struct btrfs_ioctl_dev_info_args) +#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 35, struct btrfs_ioctl_ino_path_args) +#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 36, struct btrfs_ioctl_logical_ino_args)#define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 52, struct btrfs_ioctl_get_dev_stats)#define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IOR(BTRFS_IOCTL_MAGIC, \
@@ -996,8 +1002,12 @@ struct target_rtc_pll_info { 57, struct btrfs_ioctl_feature_flags[2])#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 57, struct btrfs_ioctl_feature_flags[3]) +#define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 59, struct btrfs_ioctl_logical_ino_args)#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 60, struct btrfs_ioctl_get_subvol_info_args) +#define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 62, struct btrfs_ioctl_ino_lookup_user_args)/* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
linux-user/syscall_types.h +24 -0
@@ -349,6 +349,30 @@ STRUCT(btrfs_ioctl_get_subvol_info_args, MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* rtime */ MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ +STRUCT (btrfs_ioctl_ino_lookup_args, +TYPE_ULONGLONG ,/* treeid */ +TYPE_ULONGLONG ,/* objectid */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_PATH_MAX)) /* name */ + +STRUCT (btrfs_ioctl_ino_path_args, +TYPE_ULONGLONG ,/* inum */ +TYPE_ULONGLONG ,/* size */ +TYPE_ULONGLONG ,/* reserved */ + TYPE_ULONGLONG) /* fspath */ + +STRUCT (btrfs_ioctl_logical_ino_args, +TYPE_ULONGLONG ,/* logical */ +TYPE_ULONGLONG ,/* size */ +TYPE_ULONGLONG ,/* reserved */ +TYPE_ULONGLONG ,/* flags */ + TYPE_ULONGLONG) /* inodes */ + +STRUCT (btrfs_ioctl_ino_lookup_user_args, +TYPE_ULONGLONG ,/* dirid */ +TYPE_ULONGLONG ,/* treeid */ +MK_ARRAY (TYPE_CHAR ,BTRFS_VOL_NAME_MAX +1 ),/* name */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ + STRUCT(btrfs_ioctl_dev_info_args, TYPE_ULONGLONG, /* devid */ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */
Signature · 1 line
2.25.1
Re: [PATCH v2 1/4] linux-user: Add support for a group of btrfs inode ioctls
Le 17/07/2020 à 16:44, Filip Bozuta a écrit :
Quoted 104 lines
This patch implements functionality of following ioctls:
BTRFS_IOC_INO_LOOKUP- Reading tree root id and pathRead tree root id and path for a given file or directory. The name and tree root id are returned in an ioctl's third argument that represents a pointer to a following type:
struct
btrfs_ioctl_ino_lookup_args{
__u64treeid;
__u64objectid;
char name[BTRFS_INO_LOOKUP_PATH_MAX];
};Before calling this ioctl, field 'objectid' should be filled with the object id value for which the tree id and path are to be read. Value '
BTRFS_FIRST_FREE_OBJECTID' represents the object id for the first available btrfs object (directory or file).
BTRFS_IOC_INO_PATHS- Reading paths to all filesRead path to all files with a certain inode number. The paths are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_ino_path_args { __u64 inum; /* in */ __u64 size; /* in */ __u64 reserved[4]; /* struct btrfs_data_container *fspath; out */ __u64 fspath; /* out */ }; Before calling this ioctl, the 'inum' and 'size' field should be filled with the aproppriate inode number and size of the directory where file paths should be looked for. For now, the paths are returned in an '__u64' (unsigned long long) value 'fspath'.
BTRFS_IOC_LOGICAL_INO- Reading inode numbersRead inode numbers for files on a certain logical adress. The inode numbers are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_logical_ino_args { __u64 logical; /* in */ __u64 size; /* in */ __u64 reserved[3]; /* must be 0 for now */ __u64 flags; /* in, v2 only */ /* struct btrfs_data_container *inodes; out */ __u64 inodes; }; Before calling this ioctl, the 'logical' and 'size' field should be filled with the aproppriate logical adress and size of where the inode numbers of files should be looked for. For now, the inode numbers are returned in an '__u64' (unsigned long long) value 'inodes'.
BTRFS_IOC_LOGICAL_INO_V2- Reading inode numbersSame as the above mentioned ioctl except that it allows passing a flags '
BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET'.
BTRFS_IOC_INO_LOOKUP_USER- Reading subvolume name and pathRead name and path of a subvolume. The tree root id and path are read in an ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_ino_lookup_user_args { /* in, inode number containing the subvolume of 'subvolid' */ __u64 dirid; /* in */ __u64 treeid; /* out, name of the subvolume of 'treeid' */ char name[BTRFS_VOL_NAME_MAX + 1]; /* * out, constructed path from the directory with which the ioctl is * called to dirid */ char path[BTRFS_INO_LOOKUP_USER_PATH_MAX]; }; Before calling this ioctl, the 'dirid' and 'treeid' field should be filled with aproppriate values which represent the inode number of the directory that contains the subvolume and treeid of the subvolume.Implementation notes:
All of the ioctls in this patch use structure types as third arguments. That is the reason why aproppriate thunk definitions were added in file '
syscall_types.h'.Signed-off-by Filip Bozuta <[email protected]>--- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall_defs.h | 10 ++++++++++ linux-user/syscall_types.h | 24 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
...
Quoted 24 lines
linux-user/syscall_defs.h +6
-0@@ -982,12 +982,18 @@ struct target_rtc_pll_info { 14, struct btrfs_ioctl_vol_args)#define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOW(BTRFS_IOCTL_MAGIC, \ 15, struct btrfs_ioctl_vol_args) +#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 18, struct btrfs_ioctl_ino_lookup_args)#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 25, abi_ullong)#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, \ 26, abi_ullong)#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 30, struct btrfs_ioctl_dev_info_args) +#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 35, struct btrfs_ioctl_ino_path_args) +#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 36, struct btrfs_ioctl_logical_ino_args)#define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 52, struct btrfs_ioctl_get_dev_stats)#define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IOR(BTRFS_IOCTL_MAGIC, \
linux-user/syscall_defs.h struct target_rtc_pll_info { · line 1010
Quoted 9 lines
linux-user/syscall_defs.h +4
-0@@ -996,8 +1002,12 @@ struct target_rtc_pll_info { 57, struct btrfs_ioctl_feature_flags[2])#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 57, struct btrfs_ioctl_feature_flags[3]) +#define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 59, struct btrfs_ioctl_logical_ino_args)#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 60, struct btrfs_ioctl_get_subvol_info_args) +#define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 62, struct btrfs_ioctl_ino_lookup_user_args)
Use the 'U' variant.
Quoted 10 lines
linux-user/syscall_defs.h +0
-0/* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)linux-user/syscall_types.h +0
-0@@ -349,6 +349,30 @@ STRUCT(btrfs_ioctl_get_subvol_info_args,MK_STRUCT (STRUCT_btrfs_ioctl_timespec),/* rtime */ MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */
linux-user/syscall_types.h STRUCT(btrfs_ioctl_get_subvol_info_args, · line 360
Quoted 10 lines
linux-user/syscall_types.h +9
-0+STRUCT (btrfs_ioctl_ino_lookup_args, +TYPE_ULONGLONG ,/* treeid */ +TYPE_ULONGLONG ,/* objectid */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_PATH_MAX)) /* name */ + +STRUCT(btrfs_ioctl_ino_path_args, + TYPE_ULONGLONG, /* inum */ + TYPE_ULONGLONG, /* size */ + TYPE_ULONGLONG, /* reserved */
This is reserved[4], use MK_ARRAY() here
linux-user/syscall_types.h STRUCT(btrfs_ioctl_get_subvol_info_args, · line 366
Quoted 6 lines
linux-user/syscall_types.h +6
-0+ TYPE_ULONGLONG) /* fspath */ + +STRUCT(btrfs_ioctl_logical_ino_args, + TYPE_ULONGLONG, /* logical */ + TYPE_ULONGLONG, /* size */ + TYPE_ULONGLONG, /* reserved */
reserved[3]
linux-user/syscall_types.h STRUCT(btrfs_ioctl_get_subvol_info_args, · line 378
Quoted 13 lines
linux-user/syscall_types.h +9
-0+ TYPE_ULONGLONG, /* flags */ + TYPE_ULONGLONG) /* inodes */ + +STRUCT (btrfs_ioctl_ino_lookup_user_args, +TYPE_ULONGLONG ,/* dirid */ +TYPE_ULONGLONG ,/* treeid */ +MK_ARRAY (TYPE_CHAR ,BTRFS_VOL_NAME_MAX +1 ),/* name */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ + STRUCT(btrfs_ioctl_dev_info_args, TYPE_ULONGLONG, /* devid */ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */
Thanks,
Laurent
PATCH v2 2/4 linux-user: Add support for two btrfs ioctls used for subvolume
In reply to Filip BozutaThis patch implements functionality for following ioctl:
BTRFS_IOC_DEFAULT_SUBVOL - Setting a default subvolume
Set a default subvolume for a btrfs filesystem. The third ioctl's argument is a '__u64' (unsigned long long) which represents the id of a subvolume that is to be set as the default.
BTRFS_IOC_GET_SUBVOL_ROOTREF - Getting tree and directory id of subvolumes
Read tree and directory id of subvolumes from a btrfs
filesystem. The tree and directory id's are returned in the
ioctl's third argument which represents a pointer to a
following type:
struct btrfs_ioctl_get_subvol_rootref_args {
/* in/out, minimum id of rootref's treeid to be searched */
__u64 min_treeid;
/* out */
struct {
__u64 treeid;
__u64 dirid;
} rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM];
/* out, number of found items */
__u8 num_items;
__u8 align[7];
};
Before calling this ioctl, 'min_treeid' field should be filled
with value that represent the minimum value for the tree id.Implementation notes:
Ioctl BTRFS_IOC_GET_SUBVOL_ROOTREF uses the above mentioned structure type as third argument. That is the reason why a aproppriate thunk structure definition is added in file 'syscall_types.h'.
--- linux-user/ioctls.h | 7 +++++++ linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 11 +++++++++++ 3 files changed, 22 insertions(+)
linux-user/ioctls.h +7 -0
@@ -206,6 +206,9 @@IOCTL (BTRFS_IOC_INO_LOOKUP ,IOC_RW , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args)))#endif +#ifdef BTRFS_IOC_DEFAULT_SUBVOL + IOCTL(BTRFS_IOC_DEFAULT_SUBVOL, IOC_W, MK_PTR(TYPE_ULONGLONG)) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG))#endif
@@ -248,6 +251,10 @@IOCTL (BTRFS_IOC_GET_SUBVOL_INFO ,IOC_R , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args)))#endif +#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF +IOCTL (BTRFS_IOC_GET_SUBVOL_ROOTREF ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_rootref_args))) +#endif #ifdef BTRFS_IOC_INO_LOOKUP_USER IOCTL (BTRFS_IOC_INO_LOOKUP_USER ,IOC_RW ,MK_PTR (MK_STRUCT (STRUCT_btrfs_ioctl_ino_lookup_user_args)))
linux-user/syscall_defs.h +4 -0
@@ -984,6 +984,8 @@ struct target_rtc_pll_info { 15, struct btrfs_ioctl_vol_args)#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 18, struct btrfs_ioctl_ino_lookup_args) +#define TARGET_BTRFS_IOC_DEFAULT_SUBVOL TARGET_IOW(BTRFS_IOCTL_MAGIC, \ + 19, abi_ullong)#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 25, abi_ullong)#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, \
@@ -1006,6 +1008,8 @@ struct target_rtc_pll_info { 59, struct btrfs_ioctl_logical_ino_args)#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 60, struct btrfs_ioctl_get_subvol_info_args) +#define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 61, struct btrfs_ioctl_get_subvol_rootref_args)#define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 62, struct btrfs_ioctl_ino_lookup_user_args)
linux-user/syscall_types.h +11 -0
@@ -381,6 +381,17 @@ STRUCT(btrfs_ioctl_dev_info_args, MK_ARRAY(TYPE_ULONGLONG, 379), /* unused */ MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */ +STRUCT (rootref, +TYPE_ULONGLONG ,/* treeid */ + TYPE_ULONGLONG) /* dirid */ + +STRUCT (btrfs_ioctl_get_subvol_rootref_args, +TYPE_ULONGLONG ,/* min_treeid */ +MK_ARRAY (MK_STRUCT (STRUCT_rootref), +BTRFS_MAX_ROOTREF_BUFFER_NUM ),/* rootref */ +TYPE_CHAR ,/* num_items */ + MK_ARRAY(TYPE_CHAR, 7)) /* align */ + STRUCT(btrfs_ioctl_get_dev_stats, TYPE_ULONGLONG, /* devid */ TYPE_ULONGLONG, /* nr_items */
Signature · 1 line
2.25.1
Re: [PATCH v2 2/4] linux-user: Add support for two btrfs ioctls used for subvolume
Le 17/07/2020 à 16:44, Filip Bozuta a écrit :
Quoted 86 lines
This patch implements functionality for following ioctl:
BTRFS_IOC_DEFAULT_SUBVOL- Setting a default subvolumeSet a default subvolume for a btrfs filesystem. The third ioctl's argument is a '
__u64' (unsigned long long) which represents the id of a subvolume that is to be set as the default.
BTRFS_IOC_GET_SUBVOL_ROOTREF- Getting tree and directory id of subvolumesRead tree and directory id of subvolumes from a btrfs filesystem. The tree and directory id's are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_get_subvol_rootref_args { /* in/out, minimum id of rootref's treeid to be searched */ __u64 min_treeid; /* out */ struct { __u64 treeid; __u64 dirid; } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM]; /* out, number of found items */ __u8 num_items; __u8 align[7]; }; Before calling this ioctl, 'min_treeid' field should be filled with value that represent the minimum value for the tree id.Implementation notes:
Ioctl
BTRFS_IOC_GET_SUBVOL_ROOTREFuses the above mentioned structure type as third argument. That is the reason why a aproppriate thunk structure definition is added in file 'syscall_types.h'.Signed-off-by Filip Bozuta <[email protected]>--- linux-user/ioctls.h | 7 +++++++ linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 11 +++++++++++ 3 files changed, 22 insertions(+)linux-user/ioctls.h +7
-0@@ -206,6 +206,9 @@IOCTL (BTRFS_IOC_INO_LOOKUP ,IOC_RW , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args)))#endif +#ifdef BTRFS_IOC_DEFAULT_SUBVOL + IOCTL(BTRFS_IOC_DEFAULT_SUBVOL, IOC_W, MK_PTR(TYPE_ULONGLONG)) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG))#endif @@ -248,6 +251,10 @@IOCTL (BTRFS_IOC_GET_SUBVOL_INFO ,IOC_R , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args)))#endif +#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF +IOCTL (BTRFS_IOC_GET_SUBVOL_ROOTREF ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_rootref_args))) +#endif #ifdef BTRFS_IOC_INO_LOOKUP_USER IOCTL (BTRFS_IOC_INO_LOOKUP_USER ,IOC_RW ,MK_PTR (MK_STRUCT (STRUCT_btrfs_ioctl_ino_lookup_user_args)))linux-user/syscall_defs.h +2
-0@@ -984,6 +984,8 @@ struct target_rtc_pll_info { 15, struct btrfs_ioctl_vol_args)#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 18, struct btrfs_ioctl_ino_lookup_args) +#define TARGET_BTRFS_IOC_DEFAULT_SUBVOL TARGET_IOW(BTRFS_IOCTL_MAGIC, \ + 19, abi_ullong)#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 25, abi_ullong)#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, \
linux-user/syscall_defs.h struct target_rtc_pll_info { · line 1012
Quoted 5 lines
linux-user/syscall_defs.h +2
-0@@ -1006,6 +1008,8 @@ struct target_rtc_pll_info { 59, struct btrfs_ioctl_logical_ino_args)#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IOR(BTRFS_IOCTL_MAGIC, \ 60, struct btrfs_ioctl_get_subvol_info_args) +#define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 61, struct btrfs_ioctl_get_subvol_rootref_args)
This one needs TARGET_IOWRU(), the first one can be kept as it uses abi_ullong.
with that changed:
Thanks,
Laurent
PATCH v2 3/4 linux-user: Add support for btrfs ioctls used to manage quota
In reply to Filip BozutaThis patch implements functionality for following ioctls:
BTRFS_IOC_QUOTA_CTL - Enabling/Disabling quota support
Enable or disable quota support for a btrfs filesystem. Quota support is enabled or disabled using the ioctls third argument which represents a pointer to a following type:
struct btrfs_ioctl_quota_ctl_args {
__u64 cmd;
__u64 status;
};
Before calling this ioctl, the 'cmd' field should be filled with one of the values 'BTRFS_QUOTA_CTL_ENABLE' (enabling quota) 'BTRFS_QUOTA_CTL_DISABLE' (disabling quota).
BTRFS_IOC_QGROUP_CREATE - Creating/Removing a subvolume quota group
Create or remove a subvolume quota group. The subvolume quota group is created or removed using the ioctl's third argument which represents a pointer to a following type:
struct btrfs_ioctl_qgroup_create_args {
__u64 create;
__u64 qgroupid;
};
Before calling this ioctl, the 'create' field should be filled with the aproppriate value depending on if the user wants to create or remove a quota group (0 for removing, everything else for creating). Also, the 'qgroupid' field should be filled with the value for the quota group id that is to be created.
BTRFS_IOC_QGROUP_ASSIGN - Asigning or removing a quota group as child group
Asign or remove a quota group as child quota group of another group in the btrfs filesystem. The asignment is done using the ioctl's third argument which represents a pointert to a following type:
struct btrfs_ioctl_qgroup_assign_args {
__u64 assign;
__u64 src;
__u64 dst;
};
Before calling this ioctl, the 'assign' field should be filled with the aproppriate value depending on if the user wants to asign or remove a quota group as a child quota group of another group (0 for removing, everythin else for asigning). Also, the 'src' and 'dst' fields should be filled with the aproppriate quota group id values depending on which quota group needs to asigned or removed as child quota group of another group ('src' gets asigned or removed as child group of 'dst').
BTRFS_IOC_QGROUP_LIMIT - Limiting the size of a quota group
Limit the size of a quota group. The size of the quota group is limited
with the ioctls third argument which represents a pointer to a following
type:
struct btrfs_ioctl_qgroup_limit_args {
__u64 qgroupid;
struct btrfs_qgroup_limit lim;
};
Before calling this ioctl, the 'qgroup' id field should be filled with
aproppriate value of the quota group id for which the size is to be
limited. The second field is of following type:
struct btrfs_qgroup_limit {
__u64 flags;
__u64 max_rfer;
__u64 max_excl;
__u64 rsv_rfer;
__u64 rsv_excl;
};
The 'max_rfer' field should be filled with the size to which the quota
group should be limited. The 'flags' field can be used for passing
additional options and can have values which can be found on:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs.h#L67BTRFS_IOC_QUOTA_RESCAN_STATUS - Checking status of running rescan operation
Check status of a running rescan operation. The status is checked using the ioctl's third argument which represents a pointer to a following type:
struct btrfs_ioctl_quota_rescan_args {
__u64 flags;
__u64 progress;
__u64 reserved[6];
};
If there is a rescan operation running, 'flags' field is set to 1, and 'progress' field is set to aproppriate value which represents the progress of the operation.
BTRFS_IOC_QUOTA_RESCAN - Starting a rescan operation
Start ar rescan operation to Trash all quota groups and scan the metadata again with the current config. Before calling this ioctl, BTRFS_IOC_QUOTA_RESCAN_STATUS sould be run to check if there is already a rescan operation runing. After that ioctl call, the received 'struct btrfs_ioctl_quota_rescan_args' should be than passed as this ioctls third argument.
BTRFS_IOC_QUOTA_RESCAN_WAIT - Waiting for a rescan operation to finish
Wait until a rescan operation is finished (if there is a rescan operation running). The third ioctls argument is ignored.
Implementation notes:
Almost all of the ioctls in this patch use structure types as third arguments. That is the reason why aproppriate thunk definitions were added in file 'syscall_types.h'.
--- linux-user/ioctls.h | 27 +++++++++++++++++++++++++++ linux-user/syscall_defs.h | 14 ++++++++++++++ linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)
linux-user/ioctls.h +27 -0
@@ -227,6 +227,33 @@IOCTL (BTRFS_IOC_LOGICAL_INO ,IOC_RW , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args)))#endif +#ifdef BTRFS_IOC_QUOTA_CTL +IOCTL (BTRFS_IOC_QUOTA_CTL ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_ctl_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_ASSIGN +IOCTL (BTRFS_IOC_QGROUP_ASSIGN ,IOC_W , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_assign_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_CREATE +IOCTL (BTRFS_IOC_QGROUP_CREATE ,IOC_W , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_create_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_LIMIT +IOCTL (BTRFS_IOC_QGROUP_LIMIT ,IOC_R , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_limit_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN +IOCTL (BTRFS_IOC_QUOTA_RESCAN ,IOC_W , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN_STATUS +IOCTL (BTRFS_IOC_QUOTA_RESCAN_STATUS ,IOC_R , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN_WAIT + IOCTL(BTRFS_IOC_QUOTA_RESCAN_WAIT, 0, TYPE_NULL) +#endif #ifdef BTRFS_IOC_GET_DEV_STATS IOCTL (BTRFS_IOC_GET_DEV_STATS ,IOC_RW ,MK_PTR (MK_STRUCT (STRUCT_btrfs_ioctl_get_dev_stats)))
linux-user/syscall_defs.h +14 -0
@@ -996,6 +996,20 @@ struct target_rtc_pll_info { 35, struct btrfs_ioctl_ino_path_args)#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 36, struct btrfs_ioctl_logical_ino_args) +#define TARGET_BTRFS_IOC_QUOTA_CTL TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 40, struct btrfs_ioctl_quota_ctl_args) +#define TARGET_BTRFS_IOC_QGROUP_ASSIGN TARGET_IOW(BTRFS_IOCTL_MAGIC, \ + 41, struct btrfs_ioctl_qgroup_assign_args) +#define TARGET_BTRFS_IOC_QGROUP_CREATE TARGET_IOW(BTRFS_IOCTL_MAGIC, \ + 42, struct btrfs_ioctl_qgroup_create_args) +#define TARGET_BTRFS_IOC_QGROUP_LIMIT TARGET_IOR(BTRFS_IOCTL_MAGIC, \ + 43, struct btrfs_ioctl_qgroup_limit_args) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN TARGET_IOW(BTRFS_IOCTL_MAGIC, \ + 44, struct btrfs_ioctl_quota_rescan_args) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN_STATUS TARGET_IOR(BTRFS_IOCTL_MAGIC, \ + 45, struct btrfs_ioctl_quota_rescan_args) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN_WAIT TARGET_IO(BTRFS_IOCTL_MAGIC, \ + 46)#define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 52, struct btrfs_ioctl_get_dev_stats)#define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IOR(BTRFS_IOCTL_MAGIC, \
linux-user/syscall_types.h +29 -0
@@ -400,6 +400,35 @@ STRUCT(btrfs_ioctl_get_dev_stats, MK_ARRAY(TYPE_ULONGLONG, 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ +STRUCT (btrfs_ioctl_quota_ctl_args, +TYPE_ULONGLONG ,/* cmd */ + TYPE_ULONGLONG) /* status */ + +STRUCT (btrfs_ioctl_quota_rescan_args, +TYPE_ULONGLONG ,/* flags */ +TYPE_ULONGLONG ,/* progress */ + MK_ARRAY(TYPE_ULONGLONG, 6)) /* reserved */ + +STRUCT (btrfs_ioctl_qgroup_assign_args, +TYPE_ULONGLONG ,/* assign */ +TYPE_ULONGLONG ,/* src */ + TYPE_ULONGLONG) /* dst */ + +STRUCT (btrfs_ioctl_qgroup_create_args, +TYPE_ULONGLONG ,/* create */ + TYPE_ULONGLONG) /* qgroupid */ + +STRUCT (btrfs_qgroup_limit, +TYPE_ULONGLONG ,/* flags */ +TYPE_ULONGLONG ,/* max_rfer */ +TYPE_ULONGLONG ,/* max_excl */ +TYPE_ULONGLONG ,/* rsv_rfer */ + TYPE_ULONGLONG) /* rsv_excl */ + +STRUCT (btrfs_ioctl_qgroup_limit_args, +TYPE_ULONGLONG ,/* qgroupid */ + MK_STRUCT(STRUCT_btrfs_qgroup_limit)) /* lim */ + STRUCT(btrfs_ioctl_feature_flags, TYPE_ULONGLONG, /* compat_flags */ TYPE_ULONGLONG, /* compat_ro_flags */
Signature · 1 line
2.25.1
Re: [PATCH v2 3/4] linux-user: Add support for btrfs ioctls used to manage quota
Le 17/07/2020 à 16:44, Filip Bozuta a écrit :
Quoted 172 lines
This patch implements functionality for following ioctls:
BTRFS_IOC_QUOTA_CTL- Enabling/Disabling quota supportEnable or disable quota support for a btrfs filesystem. Quota support is enabled or disabled using the ioctls third argument which represents a pointer to a following type:
struct
btrfs_ioctl_quota_ctl_args{
__u64cmd;
__u64status;
};Before calling this ioctl, the 'cmd' field should be filled with one of the values '
BTRFS_QUOTA_CTL_ENABLE' (enabling quota) 'BTRFS_QUOTA_CTL_DISABLE' (disabling quota).
BTRFS_IOC_QGROUP_CREATE- Creating/Removing a subvolume quota groupCreate or remove a subvolume quota group. The subvolume quota group is created or removed using the ioctl's third argument which represents a pointer to a following type:
struct
btrfs_ioctl_qgroup_create_args{
__u64create;
__u64qgroupid;
};Before calling this ioctl, the 'create' field should be filled with the aproppriate value depending on if the user wants to create or remove a quota group (0 for removing, everything else for creating). Also, the 'qgroupid' field should be filled with the value for the quota group id that is to be created.
BTRFS_IOC_QGROUP_ASSIGN- Asigning or removing a quota group as child groupAsign or remove a quota group as child quota group of another group in the btrfs filesystem. The asignment is done using the ioctl's third argument which represents a pointert to a following type:
struct
btrfs_ioctl_qgroup_assign_args{
__u64assign;
__u64src;
__u64dst;
};Before calling this ioctl, the 'assign' field should be filled with the aproppriate value depending on if the user wants to asign or remove a quota group as a child quota group of another group (0 for removing, everythin else for asigning). Also, the 'src' and 'dst' fields should be filled with the aproppriate quota group id values depending on which quota group needs to asigned or removed as child quota group of another group ('src' gets asigned or removed as child group of 'dst').
BTRFS_IOC_QGROUP_LIMIT- Limiting the size of a quota groupLimit the size of a quota group. The size of the quota group is limited with the ioctls third argument which represents a pointer to a following type: struct btrfs_ioctl_qgroup_limit_args { __u64 qgroupid; struct btrfs_qgroup_limit lim; }; Before calling this ioctl, the 'qgroup' id field should be filled with aproppriate value of the quota group id for which the size is to be limited. The second field is of following type: struct btrfs_qgroup_limit { __u64 flags; __u64 max_rfer; __u64 max_excl; __u64 rsv_rfer; __u64 rsv_excl; }; The 'max_rfer' field should be filled with the size to which the quota group should be limited. The 'flags' field can be used for passing additional options and can have values which can be found on: https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs.h#L67
BTRFS_IOC_QUOTA_RESCAN_STATUS- Checking status of running rescan operationCheck status of a running rescan operation. The status is checked using the ioctl's third argument which represents a pointer to a following type:
struct
btrfs_ioctl_quota_rescan_args{
__u64flags;
__u64progress;
__u64reserved[6];
};If there is a rescan operation running, 'flags' field is set to 1, and 'progress' field is set to aproppriate value which represents the progress of the operation.
BTRFS_IOC_QUOTA_RESCAN- Starting a rescan operationStart ar rescan operation to Trash all quota groups and scan the metadata again with the current config. Before calling this ioctl,
BTRFS_IOC_QUOTA_RESCAN_STATUSsould be run to check if there is already a rescan operation runing. After that ioctl call, the received 'structbtrfs_ioctl_quota_rescan_args' should be than passed as this ioctls third argument.
BTRFS_IOC_QUOTA_RESCAN_WAIT- Waiting for a rescan operation to finishWait until a rescan operation is finished (if there is a rescan operation running). The third ioctls argument is ignored.
Implementation notes:
Almost all of the ioctls in this patch use structure types as third arguments. That is the reason why aproppriate thunk definitions were added in file '
syscall_types.h'.Signed-off-by Filip Bozuta <[email protected]>--- linux-user/ioctls.h | 27 +++++++++++++++++++++++++++ linux-user/syscall_defs.h | 14 ++++++++++++++ linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)linux-user/ioctls.h +27
-0@@ -227,6 +227,33 @@IOCTL (BTRFS_IOC_LOGICAL_INO ,IOC_RW , MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args)))#endif +#ifdef BTRFS_IOC_QUOTA_CTL +IOCTL (BTRFS_IOC_QUOTA_CTL ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_ctl_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_ASSIGN +IOCTL (BTRFS_IOC_QGROUP_ASSIGN ,IOC_W , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_assign_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_CREATE +IOCTL (BTRFS_IOC_QGROUP_CREATE ,IOC_W , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_create_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_LIMIT +IOCTL (BTRFS_IOC_QGROUP_LIMIT ,IOC_R , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_limit_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN +IOCTL (BTRFS_IOC_QUOTA_RESCAN ,IOC_W , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN_STATUS +IOCTL (BTRFS_IOC_QUOTA_RESCAN_STATUS ,IOC_R , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN_WAIT + IOCTL(BTRFS_IOC_QUOTA_RESCAN_WAIT, 0, TYPE_NULL) +#endif #ifdef BTRFS_IOC_GET_DEV_STATS IOCTL (BTRFS_IOC_GET_DEV_STATS ,IOC_RW ,MK_PTR (MK_STRUCT (STRUCT_btrfs_ioctl_get_dev_stats)))linux-user/syscall_defs.h +2
-0@@ -996,6 +996,20 @@ struct target_rtc_pll_info { 35, struct btrfs_ioctl_ino_path_args)#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 36, struct btrfs_ioctl_logical_ino_args) +#define TARGET_BTRFS_IOC_QUOTA_CTL TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 40, struct btrfs_ioctl_quota_ctl_args)
linux-user/syscall_defs.h struct target_rtc_pll_info { · line 1010
Quoted 10 lines
linux-user/syscall_defs.h +10
-0+#define TARGET_BTRFS_IOC_QGROUP_ASSIGN TARGET_IOW(BTRFS_IOCTL_MAGIC, \ + 41, struct btrfs_ioctl_qgroup_assign_args) +#define TARGET_BTRFS_IOC_QGROUP_CREATE TARGET_IOW(BTRFS_IOCTL_MAGIC, \ + 42, struct btrfs_ioctl_qgroup_create_args) +#define TARGET_BTRFS_IOC_QGROUP_LIMIT TARGET_IOR(BTRFS_IOCTL_MAGIC, \ + 43, struct btrfs_ioctl_qgroup_limit_args) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN TARGET_IOW(BTRFS_IOCTL_MAGIC, \ + 44, struct btrfs_ioctl_quota_rescan_args) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN_STATUS TARGET_IOR(BTRFS_IOCTL_MAGIC, \ + 45, struct btrfs_ioctl_quota_rescan_args)
With the 'U' variant:
Thanks,
Laurent
PATCH v2 4/4 linux-user: Add support for btrfs ioctls used to scrub a filesystem
In reply to Filip BozutaThis patch implements functionality for following ioctls:
BTRFS_IOC_SCRUB - Starting a btrfs filesystem scrub
Start a btrfs filesystem scrub. The third ioctls argument
is a pointer to a following type:
struct btrfs_ioctl_scrub_args {
__u64 devid; /* in */
__u64 start; /* in */
__u64 end; /* in */
__u64 flags; /* in */
struct btrfs_scrub_progress progress; /* out */
/* pad to 1k */
__u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
};
Before calling this ioctl, field 'devid' should be filled
with value that represents the device id of the btrfs filesystem
for which the scrub is to be started.BTRFS_IOC_SCRUB_CANCEL - Canceling scrub of a btrfs filesystem
Cancel a btrfs filesystem scrub if it is running. The third ioctls argument is ignored.
BTRFS_IOC_SCRUB_PROGRESS - Getting status of a running scrub
Read the status of a running btrfs filesystem scrub. The third ioctls argument is a pointer to the above mentioned 'struct btrfs_ioctl_scrub_args'. Similarly as with 'BTRFS_IOC_SCRUB', the 'devid' field should be filled with value that represents the id of the btrfs device for which the scrub has started. The status of a running scrub is returned in the field 'progress' which is of type 'struct btrfs_scrub_progress' and its definition can be found at:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs.h#L150
Implementation nots:
Ioctls in this patch use type 'struct btrfs_ioctl_scrub_args' as their third argument. That is the reason why an aproppriate thunk type definition is added in file 'syscall_types.h'.
--- linux-user/ioctls.h | 11 +++++++++++ linux-user/syscall_defs.h | 6 ++++++ linux-user/syscall_types.h | 26 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+)
linux-user/ioctls.h +11 -0
@@ -215,6 +215,17 @@#ifdef BTRFS_IOC_SUBVOL_SETFLAGS IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG))#endif +#ifdef BTRFS_IOC_SCRUB +IOCTL (BTRFS_IOC_SCRUB ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args))) +#endif +#ifdef BTRFS_IOC_SCRUB_CANCEL + IOCTL(BTRFS_IOC_SCRUB_CANCEL, 0, TYPE_NULL) +#endif +#ifdef BTRFS_IOC_SCRUB_PROGRESS +IOCTL (BTRFS_IOC_SCRUB_PROGRESS ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args))) +#endif #ifdef BTRFS_IOC_DEV_INFO IOCTL (BTRFS_IOC_DEV_INFO ,IOC_RW ,MK_PTR (MK_STRUCT (STRUCT_btrfs_ioctl_dev_info_args)))
linux-user/syscall_defs.h +6 -0
@@ -990,6 +990,12 @@ struct target_rtc_pll_info { 25, abi_ullong)#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, \ 26, abi_ullong) +#define TARGET_BTRFS_IOC_SCRUB TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 27, struct btrfs_ioctl_scrub_args) +#define TARGET_BTRFS_IOC_SCRUB_CANCEL TARGET_IO(BTRFS_IOCTL_MAGIC, \ + 28) +#define TARGET_BTRFS_IOC_SCRUB_PROGRESS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 29, struct btrfs_ioctl_scrub_args)#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 30, struct btrfs_ioctl_dev_info_args)#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\
linux-user/syscall_types.h +26 -0
@@ -373,6 +373,32 @@ STRUCT(btrfs_ioctl_ino_lookup_user_args, MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), /* name */ MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ +STRUCT (btrfs_scrub_progress, +TYPE_ULONGLONG ,/* data_extents_scrubbed */ +TYPE_ULONGLONG ,/* tree_extents_scrubbed */ +TYPE_ULONGLONG ,/* data_bytes_scrubbed */ +TYPE_ULONGLONG ,/* tree_bytes_scrubbed */ +TYPE_ULONGLONG ,/* read_errors */ +TYPE_ULONGLONG ,/* csum_errors */ +TYPE_ULONGLONG ,/* verify_errors */ +TYPE_ULONGLONG ,/* no_csum */ +TYPE_ULONGLONG ,/* csum_discards */ +TYPE_ULONGLONG ,/* super_errors */ +TYPE_ULONGLONG ,/* malloc_errors */ +TYPE_ULONGLONG ,/* uncorrectable_errors */ +TYPE_ULONGLONG ,/* corrected_er */ +TYPE_ULONGLONG ,/* last_physical */ + TYPE_ULONGLONG) /* unverified_errors */ + +STRUCT (btrfs_ioctl_scrub_args, +TYPE_ULONGLONG ,/* devid */ +TYPE_ULONGLONG ,/* start */ +TYPE_ULONGLONG ,/* end */ +TYPE_ULONGLONG ,/* flags */ +MK_STRUCT (STRUCT_btrfs_scrub_progress),/* progress */ +MK_ARRAY (TYPE_ULONGLONG , + (1024 - 32 - sizeof(struct btrfs_scrub_progress)) / 8)) /* unused */ + STRUCT(btrfs_ioctl_dev_info_args, TYPE_ULONGLONG, /* devid */ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */
Signature · 1 line
2.25.1
Re: [PATCH v2 4/4] linux-user: Add support for btrfs ioctls used to scrub a filesystem
Le 17/07/2020 à 16:44, Filip Bozuta a écrit :
Quoted 78 lines
This patch implements functionality for following ioctls:
BTRFS_IOC_SCRUB- Starting a btrfs filesystem scrubStart a btrfs filesystem scrub. The third ioctls argument is a pointer to a following type: struct btrfs_ioctl_scrub_args { __u64 devid; /* in */ __u64 start; /* in */ __u64 end; /* in */ __u64 flags; /* in */ struct btrfs_scrub_progress progress; /* out */ /* pad to 1k */ __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8]; }; Before calling this ioctl, field 'devid' should be filled with value that represents the device id of the btrfs filesystem for which the scrub is to be started.
BTRFS_IOC_SCRUB_CANCEL- Canceling scrub of a btrfs filesystemCancel a btrfs filesystem scrub if it is running. The third ioctls argument is ignored.
BTRFS_IOC_SCRUB_PROGRESS- Getting status of a running scrubRead the status of a running btrfs filesystem scrub. The third ioctls argument is a pointer to the above mentioned 'struct
btrfs_ioctl_scrub_args'. Similarly as with 'BTRFS_IOC_SCRUB', the 'devid' field should be filled with value that represents the id of the btrfs device for which the scrub has started. The status of a running scrub is returned in the field 'progress' which is of type 'structbtrfs_scrub_progress' and its definition can be found at:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs.h#L150Implementation nots:
Ioctls in this patch use type 'struct
btrfs_ioctl_scrub_args' as their third argument. That is the reason why an aproppriate thunk type definition is added in file 'syscall_types.h'.Signed-off-by Filip Bozuta <[email protected]>--- linux-user/ioctls.h | 11 +++++++++++ linux-user/syscall_defs.h | 6 ++++++ linux-user/syscall_types.h | 26 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+)linux-user/ioctls.h +11
-0@@ -215,6 +215,17 @@#ifdef BTRFS_IOC_SUBVOL_SETFLAGS IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG))#endif +#ifdef BTRFS_IOC_SCRUB +IOCTL (BTRFS_IOC_SCRUB ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args))) +#endif +#ifdef BTRFS_IOC_SCRUB_CANCEL + IOCTL(BTRFS_IOC_SCRUB_CANCEL, 0, TYPE_NULL) +#endif +#ifdef BTRFS_IOC_SCRUB_PROGRESS +IOCTL (BTRFS_IOC_SCRUB_PROGRESS ,IOC_RW , + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args))) +#endif #ifdef BTRFS_IOC_DEV_INFO IOCTL (BTRFS_IOC_DEV_INFO ,IOC_RW ,MK_PTR (MK_STRUCT (STRUCT_btrfs_ioctl_dev_info_args)))linux-user/syscall_defs.h +0
-0
linux-user/syscall_defs.h struct target_rtc_pll_info { · line 998
Quoted 9 lines
linux-user/syscall_defs.h +6
-0@@ -990,6 +990,12 @@ struct target_rtc_pll_info { 25, abi_ullong)#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, \ 26, abi_ullong) +#define TARGET_BTRFS_IOC_SCRUB TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 27, struct btrfs_ioctl_scrub_args) +#define TARGET_BTRFS_IOC_SCRUB_CANCEL TARGET_IO(BTRFS_IOCTL_MAGIC, \ + 28) +#define TARGET_BTRFS_IOC_SCRUB_PROGRESS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ + 29, struct btrfs_ioctl_scrub_args)
Use the 'U' variant.
Quoted 27 lines
linux-user/syscall_defs.h +0
-0#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWR(BTRFS_IOCTL_MAGIC,\ 30, struct btrfs_ioctl_dev_info_args)#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWR(BTRFS_IOCTL_MAGIC,\linux-user/syscall_types.h +16
-0@@ -373,6 +373,32 @@ STRUCT(btrfs_ioctl_ino_lookup_user_args, MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), /* name */ MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ +STRUCT (btrfs_scrub_progress, +TYPE_ULONGLONG ,/* data_extents_scrubbed */ +TYPE_ULONGLONG ,/* tree_extents_scrubbed */ +TYPE_ULONGLONG ,/* data_bytes_scrubbed */ +TYPE_ULONGLONG ,/* tree_bytes_scrubbed */ +TYPE_ULONGLONG ,/* read_errors */ +TYPE_ULONGLONG ,/* csum_errors */ +TYPE_ULONGLONG ,/* verify_errors */ +TYPE_ULONGLONG ,/* no_csum */ +TYPE_ULONGLONG ,/* csum_discards */ +TYPE_ULONGLONG ,/* super_errors */ +TYPE_ULONGLONG ,/* malloc_errors */ +TYPE_ULONGLONG ,/* uncorrectable_errors */ +TYPE_ULONGLONG ,/* corrected_er */ +TYPE_ULONGLONG ,/* last_physical */ +TYPE_ULONGLONG )/* unverified_errors */
linux-user/syscall_types.h STRUCT(btrfs_ioctl_ino_lookup_user_args, · line 401
Quoted 10 lines
linux-user/syscall_types.h +9
-0+ +STRUCT (btrfs_ioctl_scrub_args, +TYPE_ULONGLONG ,/* devid */ +TYPE_ULONGLONG ,/* start */ +TYPE_ULONGLONG ,/* end */ +TYPE_ULONGLONG ,/* flags */ +MK_STRUCT (STRUCT_btrfs_scrub_progress),/* progress */ +MK_ARRAY (TYPE_ULONGLONG , + (1024 -32 -sizeof (struct btrfs_scrub_progress )) /8 ))/* unused */
The clean way would be to define a target_btrfs_scrub_progress and to use it in the sizeof(). But I don't know if it's worth to define it as it is only made of u64 and the result will be the same for all the guest types (and the same as for the host one).
With the 'U' variant:
Thanks,
Laurent