btrfs-progs: wip - send progress

Pass BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE flag and add command line
option. Unfinished.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-06-21 19:44:15 +02:00
parent ef719df5bb
commit 9321c81488
2 changed files with 17 additions and 1 deletions

View file

@ -541,6 +541,7 @@ static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
GETOPT_VAL_SEND_NO_DATA = GETOPT_VAL_FIRST,
GETOPT_VAL_PROTO,
GETOPT_VAL_COMPRESSED_DATA,
GETOPT_VAL_CALC_DATA_SIZE,
};
static const struct option long_options[] = {
{ "verbose", no_argument, NULL, 'v' },
@ -548,6 +549,7 @@ static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
{ "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA },
{ "proto", required_argument, NULL, GETOPT_VAL_PROTO },
{ "compressed-data", no_argument, NULL, GETOPT_VAL_COMPRESSED_DATA },
{ "calc-data-size", no_argument, NULL, GETOPT_VAL_CALC_DATA_SIZE },
{ NULL, 0, NULL, 0 }
};
int c = getopt_long(argc, argv, "vqec:f:i:p:", long_options, NULL);
@ -648,6 +650,9 @@ static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
case GETOPT_VAL_COMPRESSED_DATA:
send_flags |= BTRFS_SEND_FLAG_COMPRESSED;
break;
case GETOPT_VAL_CALC_DATA_SIZE:
send_flags |= BTRFS_SEND_FLAG_CALC_DATA_SIZE;
break;
default:
usage_unknown_option(cmd, argv);
}

13
ioctl.h
View file

@ -667,12 +667,23 @@ BUILD_ASSERT(sizeof(struct btrfs_ioctl_received_subvol_args_32) == 192);
*/
#define BTRFS_SEND_FLAG_COMPRESSED 0x10
/*
* Calculate the amount (in bytes) of new file data between the send and
* parent snapshots, or in case of a full send, the total amount of file data
* we will send.
* This corresponds to the sum of the data lengths of each write and clone
* commands that are sent through the send stream. The receiving end can use
* this information to estimate progress.
*/
#define BTRFS_SEND_FLAG_CALC_DATA_SIZE 0x20
#define BTRFS_SEND_FLAG_MASK \
(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_COMPRESSED)
BTRFS_SEND_FLAG_COMPRESSED | \
BTRFS_SEND_FLAG_CALC_DATA_SIZE)
struct btrfs_ioctl_send_args {
__s64 send_fd; /* in */