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>
        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);
 }
        } 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) {
 
 #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
 
        (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 */