]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: send: enable support for stream v2 and compressed writes
authorOmar Sandoval <osandov@fb.com>
Thu, 17 Mar 2022 17:25:43 +0000 (10:25 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Jul 2022 15:45:32 +0000 (17:45 +0200)
Now that the new support is implemented, allow the ioctl to accept v2
and the compressed flag, and update the version in sysfs.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/send.c
fs/btrfs/send.h
include/uapi/linux/btrfs.h

index bc00393c12339de6f63e8b1781fac548951e2436..6d01dc26d4080b61b0e0174e34a19e91a9135f03 100644 (file)
@@ -701,8 +701,7 @@ static int send_header(struct send_ctx *sctx)
        struct btrfs_stream_header hdr;
 
        strcpy(hdr.magic, BTRFS_SEND_STREAM_MAGIC);
-       hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION);
-
+       hdr.version = cpu_to_le32(sctx->proto);
        return write_buf(sctx->send_filp, &hdr, sizeof(hdr),
                                        &sctx->send_off);
 }
@@ -7755,6 +7754,10 @@ long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
        } else {
                sctx->proto = 1;
        }
+       if ((arg->flags & BTRFS_SEND_FLAG_COMPRESSED) && sctx->proto < 2) {
+               ret = -EINVAL;
+               goto out;
+       }
 
        sctx->send_filp = fget(arg->send_fd);
        if (!sctx->send_filp) {
index 858ce8132614bf77099e9c3e92c38b86f3371408..b0dc07567d09ac37ba7165b6b91411ee2d945537 100644 (file)
@@ -10,7 +10,7 @@
 #include "ctree.h"
 
 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
-#define BTRFS_SEND_STREAM_VERSION 1
+#define BTRFS_SEND_STREAM_VERSION 2
 
 /*
  * In send stream v1, no command is larger than 64K. In send stream v2, no limit
index b6f26a434b10970cc28b1aac2953656a1688cbdb..f54dc91e402576a0691eb6e61b161963eeb7b207 100644 (file)
@@ -788,7 +788,8 @@ struct btrfs_ioctl_received_subvol_args {
        (BTRFS_SEND_FLAG_NO_FILE_DATA | \
         BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
         BTRFS_SEND_FLAG_OMIT_END_CMD | \
-        BTRFS_SEND_FLAG_VERSION)
+        BTRFS_SEND_FLAG_VERSION | \
+        BTRFS_SEND_FLAG_COMPRESSED)
 
 struct btrfs_ioctl_send_args {
        __s64 send_fd;                  /* in */