Skip to content

Commit

Permalink
btrfs: send: enable support for stream v2 and compressed writes
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
osandov authored and kdave committed Jul 25, 2022
1 parent 3ea4dc5 commit d681559
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions fs/btrfs/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/send.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion include/uapi/linux/btrfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit d681559

Please sign in to comment.