@@ -7136,7 +7136,7 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
sctx->clone_roots_cnt = arg->clone_sources_count;
- sctx->send_max_size = BTRFS_SEND_BUF_SIZE;
+ sctx->send_max_size = BTRFS_SEND_BUF_SIZE_V1;
sctx->send_buf = kvmalloc(sctx->send_max_size, GFP_KERNEL);
if (!sctx->send_buf) {
ret = -ENOMEM;
@@ -12,7 +12,11 @@
#define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
#define BTRFS_SEND_STREAM_VERSION 1
-#define BTRFS_SEND_BUF_SIZE SZ_64K
+/*
+ * In send stream v1, no command is larger than 64k. In send stream v2, no limit
+ * should be assumed.
+ */
+#define BTRFS_SEND_BUF_SIZE_V1 SZ_64K
enum btrfs_tlv_type {
BTRFS_TLV_U8,
@@ -76,6 +80,13 @@ enum btrfs_send_cmd {
BTRFS_SEND_C_END,
BTRFS_SEND_C_UPDATE_EXTENT,
+
+ /* The following commands were added in send stream v2. */
+
+ BTRFS_SEND_C_FALLOCATE,
+ BTRFS_SEND_C_SETFLAGS,
+ BTRFS_SEND_C_ENCODED_WRITE,
+
__BTRFS_SEND_C_MAX,
};
#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
@@ -106,6 +117,11 @@ enum {
BTRFS_SEND_A_PATH_LINK,
BTRFS_SEND_A_FILE_OFFSET,
+ /*
+ * In send stream v2, this attribute is special: it must be the last
+ * attribute in a command, its header contains only the type, and its
+ * length is implicitly the remaining length of the command.
+ */
BTRFS_SEND_A_DATA,
BTRFS_SEND_A_CLONE_UUID,
@@ -114,6 +130,18 @@ enum {
BTRFS_SEND_A_CLONE_OFFSET,
BTRFS_SEND_A_CLONE_LEN,
+ /* The following attributes were added in send stream v2. */
+
+ BTRFS_SEND_A_FALLOCATE_MODE,
+
+ BTRFS_SEND_A_SETFLAGS_FLAGS,
+
+ BTRFS_SEND_A_UNENCODED_FILE_LEN,
+ BTRFS_SEND_A_UNENCODED_LEN,
+ BTRFS_SEND_A_UNENCODED_OFFSET,
+ BTRFS_SEND_A_COMPRESSION,
+ BTRFS_SEND_A_ENCRYPTION,
+
__BTRFS_SEND_A_MAX,
};
#define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
@@ -769,6 +769,19 @@ struct btrfs_ioctl_received_subvol_args {
*/
#define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4
+/*
+ * Use version 2 of the send stream, which adds new commands and supports larger
+ * writes.
+ */
+#define BTRFS_SEND_FLAG_STREAM_V2 0x8
+
+/*
+ * Send compressed data using the ENCODED_WRITE command instead of decompressing
+ * the data and sending it with the WRITE command. This requires
+ * BTRFS_SEND_FLAG_STREAM_V2.
+ */
+#define BTRFS_SEND_FLAG_COMPRESSED 0x10
+
#define BTRFS_SEND_FLAG_MASK \
(BTRFS_SEND_FLAG_NO_FILE_DATA | \
BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \