diff --git a/common/send-stream.c b/common/send-stream.c index b7e1eaeb..e51b973d 100644 --- a/common/send-stream.c +++ b/common/send-stream.c @@ -44,7 +44,7 @@ struct btrfs_send_stream { int fd; int cmd; - struct btrfs_send_attribute cmd_attrs[BTRFS_SEND_A_MAX + 1]; + struct btrfs_send_attribute cmd_attrs[__BTRFS_SEND_A_MAX + 1]; u32 version; /* @@ -183,7 +183,7 @@ static int read_cmd(struct btrfs_send_stream *sctx) } tlv_type = le16_to_cpu(*(__le16 *)data); - if (tlv_type == 0 || tlv_type > BTRFS_SEND_A_MAX) { + if (tlv_type == 0 || tlv_type > __BTRFS_SEND_A_MAX) { error("invalid tlv in cmd tlv_type = %hu", tlv_type); ret = -EINVAL; goto out; @@ -228,7 +228,7 @@ static int tlv_get(struct btrfs_send_stream *sctx, int attr, void **data, int *l int ret; struct btrfs_send_attribute *send_attr; - if (attr <= 0 || attr > BTRFS_SEND_A_MAX) { + if (attr <= 0 || attr > __BTRFS_SEND_A_MAX) { error("invalid attribute requested, attr = %d", attr); ret = -EINVAL; goto out; diff --git a/kernel-shared/send.h b/kernel-shared/send.h index db1bec19..34de60ff 100644 --- a/kernel-shared/send.h +++ b/kernel-shared/send.h @@ -20,16 +20,27 @@ #ifndef __BTRFS_SEND_H__ #define __BTRFS_SEND_H__ +#include "kernel-lib/sizes.h" #include "kernel-shared/ctree.h" #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream" +/* Conditional support for the upcoming protocol version. */ +#ifdef CONFIG_BTRFS_DEBUG +#define BTRFS_SEND_STREAM_VERSION 3 +#else #define BTRFS_SEND_STREAM_VERSION 2 +#endif /* - * In send stream v1, no command is larger than 64KiB. In send stream v2, no limit - * should be assumed. + * In send stream v1, no command is larger than 64K. In send stream v2, no + * limit should be assumed, the buffer size is set to be a header with + * compressed extent size. */ -#define BTRFS_SEND_BUF_SIZE_V1 (64 * 1024) +#define BTRFS_SEND_BUF_SIZE_V1 SZ_64K +#define BTRFS_SEND_BUF_SIZE_V2 ALIGN(SZ_16K + BTRFS_MAX_COMPRESSED, PAGE_SIZE) + +struct inode; +struct btrfs_ioctl_send_args; enum btrfs_tlv_type { BTRFS_TLV_U8, @@ -102,6 +113,7 @@ enum btrfs_send_cmd { BTRFS_SEND_C_ENCODED_WRITE = 25, BTRFS_SEND_C_MAX_V2 = 25, + /* Version 3 */ BTRFS_SEND_C_ENABLE_VERITY = 26, BTRFS_SEND_C_MAX_V3 = 26, /* End */ @@ -179,8 +191,9 @@ enum { BTRFS_SEND_A_VERITY_SIG_DATA = 35, BTRFS_SEND_A_MAX_V3 = 35, - /* End */ - BTRFS_SEND_A_MAX = 35, + __BTRFS_SEND_A_MAX = 35, }; +long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg); + #endif