Re: [PATCH v2] btrfs: send: prepare for v2 protocol
From: Anand Jain <hidden>
Date: 2021-10-30 01:11:56
quoted hunk ↗ jump to hunk
@@ -312,6 +314,15 @@ static void inconsistent_snapshot_error(struct send_ctx *sctx, sctx->parent_root->root_key.objectid : 0)); } +static bool proto_cmd_ok(const struct send_ctx *sctx, int cmd)
(Now I understand the use of this function). 2nd arg can be- enum btrfs_send_cmd cmd
quoted hunk ↗ jump to hunk
@@ -771,10 +771,16 @@ struct btrfs_ioctl_received_subvol_args { */ #define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4 +/* + * Read the protocol version in the structure + */ +#define BTRFS_SEND_FLAG_VERSION 0x8 + #define BTRFS_SEND_FLAG_MASK \ (BTRFS_SEND_FLAG_NO_FILE_DATA | \ BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \ - BTRFS_SEND_FLAG_OMIT_END_CMD) + BTRFS_SEND_FLAG_OMIT_END_CMD | \ + BTRFS_SEND_FLAG_VERSION)
Kernel use BTRFS_SEND_FLAG_MASK like this:
long btrfs_ioctl_send()
<snip>
if (arg->flags & ~BTRFS_SEND_FLAG_MASK) {
ret = -EINVAL;
goto out;
}
So the newer btrfs-progs that sets BTRFS_SEND_FLAG_VERSION on an older
kernel will fail.
So long we have had good backward compatibility of btrfs-progs with the
older kernels, could we pls maintain that?
How about creating a new send IOCTL so that when the older kernel
returns -ENOTTY and the newer-progs can fail back to the older send ioctl.
That is similar to what we did with
BTRFS_IOC_SNAP_CREATE_V2:
BTRFS_IOC_SUBVOL_CREATE_V2:
BTRFS_IOC_RM_DEV_V2:
BTRFS_IOC_TREE_SEARCH_V2:
BTRFS_IOC_LOGICAL_INO_V2:
BTRFS_IOC_BALANCE_V2:
Thanks, Anand