Blame SOURCES/1105-btrfs-progs-receive-add-send-stream-v2-cmds-and-attr.patch

dbfe2d
From 8ff6d9258385e4a0ae462e0cea8409e4fae05dc1 Mon Sep 17 00:00:00 2001
dbfe2d
From: Omar Sandoval <osandov@fb.com>
dbfe2d
Date: Tue, 8 Feb 2022 11:02:02 -0800
dbfe2d
Subject: [PATCH] btrfs-progs: receive: add send stream v2 cmds and attrs to
dbfe2d
 send.h
dbfe2d
dbfe2d
Update our copy of send.h from the kernel. This adds the new commands
dbfe2d
and attributes for v2 as well as explicit enum numbering.
dbfe2d
dbfe2d
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
dbfe2d
Signed-off-by: Boris Burkov <boris@bur.io>
dbfe2d
Signed-off-by: Omar Sandoval <osandov@fb.com>
dbfe2d
---
dbfe2d
 kernel-shared/send.h | 138 ++++++++++++++++++++++++++-----------------
dbfe2d
 1 file changed, 85 insertions(+), 53 deletions(-)
dbfe2d
dbfe2d
diff --git a/kernel-shared/send.h b/kernel-shared/send.h
dbfe2d
index e986b6c8..b902d054 100644
dbfe2d
--- a/kernel-shared/send.h
dbfe2d
+++ b/kernel-shared/send.h
dbfe2d
@@ -38,7 +38,6 @@ extern "C" {
dbfe2d
  * should be assumed.
dbfe2d
  */
dbfe2d
 #define BTRFS_SEND_BUF_SIZE_V1 (64 * 1024)
dbfe2d
-#define BTRFS_SEND_READ_SIZE (1024 * 48)
dbfe2d
 
dbfe2d
 enum btrfs_tlv_type {
dbfe2d
 	BTRFS_TLV_U8,
dbfe2d
@@ -72,77 +71,110 @@ struct btrfs_tlv_header {
dbfe2d
 
dbfe2d
 /* commands */
dbfe2d
 enum btrfs_send_cmd {
dbfe2d
-	BTRFS_SEND_C_UNSPEC,
dbfe2d
+	BTRFS_SEND_C_UNSPEC = 0,
dbfe2d
 
dbfe2d
-	BTRFS_SEND_C_SUBVOL,
dbfe2d
-	BTRFS_SEND_C_SNAPSHOT,
dbfe2d
+	/* Version 1 */
dbfe2d
+	BTRFS_SEND_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TRFS_SEND_C_UTIMES,
dbfe2d
+	BTRFS_SEND_C_TRUNCATE = 17,
dbfe2d
+	BTRFS_SEND_C_CHMOD = 18,
dbfe2d
+	BTRFS_SEND_C_CHOWN = 19,
dbfe2d
+	BTRFS_SEND_C_UTIMES = 20,
dbfe2d
 
dbfe2d
-	BTRFS_SEND_C_END,
dbfe2d
-	BTRFS_SEND_C_UPDATE_EXTENT,
dbfe2d
-	__BTRFS_SEND_C_MAX,
dbfe2d
+	BTRFS_SEND_C_END = 21,
dbfe2d
+	BTRFS_SEND_C_UPDATE_EXTENT = 22,
dbfe2d
+	BTRFS_SEND_C_MAX_V1 = 22,
dbfe2d
+
dbfe2d
+	/* Version 2 */
dbfe2d
+	BTRFS_SEND_C_FALLOCATE = 23,
dbfe2d
+	BTRFS_SEND_C_SETFLAGS = 24,
dbfe2d
+	BTRFS_SEND_C_ENCODED_WRITE = 25,
dbfe2d
+	BTRFS_SEND_C_MAX_V2 = 25,
dbfe2d
+
dbfe2d
+	/* End */
dbfe2d
+	BTRFS_SEND_C_MAX = 25,
dbfe2d
 };
dbfe2d
-#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
dbfe2d
 
dbfe2d
 /* attributes in send stream */
dbfe2d
 enum {
dbfe2d
-	BTRFS_SEND_A_UNSPEC,
dbfe2d
+	BTRFS_SEND_A_UNSPEC = 0,
dbfe2d
 
dbfe2d
-	BTRFS_SEND_A_UUID,
dbfe2d
-	BTRFS_SEND_A_CTRANSID,
dbfe2d
+	/* Version 1 */
dbfe2d
+	BTRFS_SEND_A_UUID = 1,
dbfe2d
+	BTRFS_SEND_A_CTRANSID = 2,
dbfe2d
 
dbfe2d
-	BTRFS_SEND_A_INO,
dbfe2d
-	BTRFS_SEND_A_SIZE,
dbfe2d
-	BTRFS_SEND_A_MODE,
dbfe2d
-	BTRFS_SEND_A_UID,
dbfe2d
-	BTRFS_SEND_A_GID,
dbfe2d
-	BTRFS_SEND_A_RDEV,
dbfe2d
-	BTRFS_SEND_A_CTIME,
dbfe2d
-	BTRFS_SEND_A_MTIME,
dbfe2d
-	BTRFS_SEND_A_ATIME,
dbfe2d
-	BTRFS_SEND_A_OTIME,
dbfe2d
+	BTRFS_SEND_A_INO = 3,
dbfe2d
+	BTRFS_SEND_A_SIZE = 4,
dbfe2d
+	BTRFS_SEND_A_MODE = 5,
dbfe2d
+	BTRFS_SEND_A_UID = 6,
dbfe2d
+	BTRFS_SEND_A_GID = 7,
dbfe2d
+	BTRFS_SEND_A_RDEV = 8,
dbfe2d
+	BTRFS_SEND_A_CTIME = 9,
dbfe2d
+	BTRFS_SEND_A_MTIME = 10,
dbfe2d
+	BTRFS_SEND_A_ATIME = 11,
dbfe2d
+	BTRFS_SEND_A_OTIME = 12,
dbfe2d
 
dbfe2d
-	BTRFS_SEND_A_XATTR_NAME,
dbfe2d
-	BTRFS_SEND_A_XATTR_DATA,
dbfe2d
+	BTRFS_SEND_A_XATTR_NAME = 13,
dbfe2d
+	BTRFS_SEND_A_XATTR_DATA = 14,
dbfe2d
 
dbfe2d
-	BTRFS_SEND_A_PATH,
dbfe2d
-	BTRFS_SEND_A_PATH_TO,
dbfe2d
-	BTRFS_SEND_A_PATH_LINK,
dbfe2d
+	BTRFS_SEND_A_PATH = 15,
dbfe2d
+	BTRFS_SEND_A_PATH_TO = 16,
dbfe2d
+	BTRFS_SEND_A_PATH_LINK = 17,
dbfe2d
 
dbfe2d
-	BTRFS_SEND_A_FILE_OFFSET,
dbfe2d
-	BTRFS_SEND_A_DATA,
dbfe2d
+	BTRFS_SEND_A_FILE_OFFSET = 18,
dbfe2d
+	/*
dbfe2d
+	 * As of send stream v2, this attribute is special: it must be the last
dbfe2d
+	 * attribute in a command, its header contains only the type, and its
dbfe2d
+	 * length is implicitly the remaining length of the command.
dbfe2d
+	 */
dbfe2d
+	BTRFS_SEND_A_DATA = 19,
dbfe2d
 
dbfe2d
-	BTRFS_SEND_A_CLONE_UUID,
dbfe2d
-	BTRFS_SEND_A_CLONE_CTRANSID,
dbfe2d
-	BTRFS_SEND_A_CLONE_PATH,
dbfe2d
-	BTRFS_SEND_A_CLONE_OFFSET,
dbfe2d
-	BTRFS_SEND_A_CLONE_LEN,
dbfe2d
+	BTRFS_SEND_A_CLONE_UUID = 20,
dbfe2d
+	BTRFS_SEND_A_CLONE_CTRANSID = 21,
dbfe2d
+	BTRFS_SEND_A_CLONE_PATH = 22,
dbfe2d
+	BTRFS_SEND_A_CLONE_OFFSET = 23,
dbfe2d
+	BTRFS_SEND_A_CLONE_LEN = 24,
dbfe2d
 
dbfe2d
-	__BTRFS_SEND_A_MAX,
dbfe2d
+	BTRFS_SEND_A_MAX_V1 = 24,
dbfe2d
+
dbfe2d
+	/* Version 2 */
dbfe2d
+	BTRFS_SEND_A_FALLOCATE_MODE = 25,
dbfe2d
+
dbfe2d
+	BTRFS_SEND_A_SETFLAGS_FLAGS = 26,
dbfe2d
+
dbfe2d
+	BTRFS_SEND_A_UNENCODED_FILE_LEN = 27,
dbfe2d
+	BTRFS_SEND_A_UNENCODED_LEN = 28,
dbfe2d
+	BTRFS_SEND_A_UNENCODED_OFFSET = 29,
dbfe2d
+	/*
dbfe2d
+	 * COMPRESSION and ENCRYPTION default to NONE (0) if omitted from
dbfe2d
+	 * BTRFS_SEND_C_ENCODED_WRITE.
dbfe2d
+	 */
dbfe2d
+	BTRFS_SEND_A_COMPRESSION = 30,
dbfe2d
+	BTRFS_SEND_A_ENCRYPTION = 31,
dbfe2d
+	BTRFS_SEND_A_MAX_V2 = 31,
dbfe2d
+
dbfe2d
+	/* End */
dbfe2d
+	BTRFS_SEND_A_MAX = 31,
dbfe2d
 };
dbfe2d
-#define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
dbfe2d
 
dbfe2d
 #ifdef __cplusplus
dbfe2d
 }
dbfe2d
-- 
dbfe2d
2.35.1
dbfe2d