[1/3] btrfs: define support masks for ioctl volume args v2
diff mbox series

Message ID c25c2e84ebc5ef31227ae23d44e09ddc8c343a7b.1582289899.git.dsterba@suse.com
State New
Headers show
Series
  • Clean up supported flags for ioctls
Related show

Commit Message

David Sterba Feb. 21, 2020, 1:02 p.m. UTC
The ioctl data for devices or subvolumes can be passed via
btrfs_ioctl_vol_args or btrfs_ioctl_vol_args_v2. The latter is more
versatile and needs some caution as some of the flags make sense only
for some ioctls.

As we're going to extend the flags, define support masks for each ioctl
class separately.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 include/uapi/linux/btrfs.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Marcos Paulo de Souza Feb. 21, 2020, 1:20 p.m. UTC | #1
On Fri, 2020-02-21 at 14:02 +0100, David Sterba wrote:
> The ioctl data for devices or subvolumes can be passed via
> btrfs_ioctl_vol_args or btrfs_ioctl_vol_args_v2. The latter is more
> versatile and needs some caution as some of the flags make sense only
> for some ioctls.
> 
> As we're going to extend the flags, define support masks for each
> ioctl
> class separately.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  include/uapi/linux/btrfs.h | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
> index 7a8bc8b920f5..49ed71df5e94 100644
> --- a/include/uapi/linux/btrfs.h
> +++ b/include/uapi/linux/btrfs.h
> @@ -97,16 +97,26 @@ struct btrfs_ioctl_qgroup_limit_args {
>  };
>  
>  /*
> - * flags for subvolumes
> + * Arguments for specification of subvolumes or devices, supporting
> by-name or
> + * by-id and flags
>   *
> - * Used by:
> - * struct btrfs_ioctl_vol_args_v2.flags
> + * The set of supported flags depends on the ioctl
>   *
>   * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following
> ioctls:
>   * - BTRFS_IOC_SUBVOL_GETFLAGS
>   * - BTRFS_IOC_SUBVOL_SETFLAGS
>   */
>  
> +/* Supported flags for BTRFS_IOC_RM_DEV_V2 */
> +#define BTRFS_DEVICE_REMOVE_ARGS_MASK				
> 	\
> +	(BTRFS_DEVICE_SPEC_BY_ID)
> +
> +/* Supported flags for BTRFS_IOC_SNAP_CREATE_V2 and
> BTRFS_IOC_SUBVOL_CREATE_V2 */
> +#define BTRFS_SUBVOL_CREATE_ARGS_MASK				
> 	\
> +	(BTRFS_SUBVOL_CREATE_ASYNC |					
> \
> +	 BTRFS_SUBVOL_RDONLY |						
> \
> +	 BTRFS_SUBVOL_QGROUP_INHERIT)
> +
>  struct btrfs_ioctl_vol_args_v2 {
>  	__s64 fd;
>  	__u64 transid;

Looks good to me,
Reviewed-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Patch
diff mbox series

diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index 7a8bc8b920f5..49ed71df5e94 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -97,16 +97,26 @@  struct btrfs_ioctl_qgroup_limit_args {
 };
 
 /*
- * flags for subvolumes
+ * Arguments for specification of subvolumes or devices, supporting by-name or
+ * by-id and flags
  *
- * Used by:
- * struct btrfs_ioctl_vol_args_v2.flags
+ * The set of supported flags depends on the ioctl
  *
  * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls:
  * - BTRFS_IOC_SUBVOL_GETFLAGS
  * - BTRFS_IOC_SUBVOL_SETFLAGS
  */
 
+/* Supported flags for BTRFS_IOC_RM_DEV_V2 */
+#define BTRFS_DEVICE_REMOVE_ARGS_MASK					\
+	(BTRFS_DEVICE_SPEC_BY_ID)
+
+/* Supported flags for BTRFS_IOC_SNAP_CREATE_V2 and BTRFS_IOC_SUBVOL_CREATE_V2 */
+#define BTRFS_SUBVOL_CREATE_ARGS_MASK					\
+	(BTRFS_SUBVOL_CREATE_ASYNC |					\
+	 BTRFS_SUBVOL_RDONLY |						\
+	 BTRFS_SUBVOL_QGROUP_INHERIT)
+
 struct btrfs_ioctl_vol_args_v2 {
 	__s64 fd;
 	__u64 transid;