btrfs-progs: send: add option to for the no-data mode

Signed-off-by: David Sterba <dsterba@suse.cz>
master
David Sterba 2015-06-12 13:15:41 +02:00
parent 14de97259b
commit c55415e4cb
2 changed files with 30 additions and 5 deletions

View File

@ -40,6 +40,10 @@ Use this snapshot as a clone source for an incremental send (multiple allowed).
-f <outfile>::
Output is normally written to stdout. To write to a file, use this option.
An alternative would be to use pipes.
--no-data::
Send in NO_FILE_DATA mode. The output stream does not contain any file
data and thus cannot be used to transfer changes. This mode is faster and
useful to show the differences in metadata.
EXIT STATUS
-----------

View File

@ -31,7 +31,7 @@
#include <libgen.h>
#include <mntent.h>
#include <assert.h>
#include <getopt.h>
#include <uuid/uuid.h>
#include "ctree.h"
@ -243,7 +243,8 @@ out:
}
static int do_send(struct btrfs_send *send, u64 parent_root_id,
int is_first_subvol, int is_last_subvol, char *subvol)
int is_first_subvol, int is_last_subvol, char *subvol,
u64 flags)
{
int ret;
pthread_t t_read;
@ -281,6 +282,7 @@ static int do_send(struct btrfs_send *send, u64 parent_root_id,
goto out;
}
io_send.flags = flags;
io_send.clone_sources = (__u64*)send->clone_sources;
io_send.clone_sources_count = send->clone_sources_count;
io_send.parent_root = parent_root_id;
@ -424,7 +426,6 @@ out:
int cmd_send(int argc, char **argv)
{
char *subvol = NULL;
int c;
int ret;
char *outname = NULL;
struct btrfs_send send;
@ -435,11 +436,21 @@ int cmd_send(int argc, char **argv)
u64 parent_root_id = 0;
int full_send = 1;
int new_end_cmd_semantic = 0;
u64 send_flags = 0;
memset(&send, 0, sizeof(send));
send.dump_fd = fileno(stdout);
while ((c = getopt(argc, argv, "vec:f:i:p:")) != -1) {
while (1) {
enum { GETOPT_VAL_SEND_NO_DATA = 256 };
static const struct option long_options[] = {
{ "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA }
};
int c = getopt_long(argc, argv, "vec:f:i:p:", long_options, NULL);
if (c < 0)
break;
switch (c) {
case 'v':
g_verbose++;
@ -530,6 +541,9 @@ int cmd_send(int argc, char **argv)
"ERROR: -i was removed, use -c instead\n");
ret = 1;
goto out;
case GETOPT_VAL_SEND_NO_DATA:
send_flags |= BTRFS_SEND_FLAG_NO_FILE_DATA;
break;
case '?':
default:
fprintf(stderr, "ERROR: send args invalid.\n");
@ -632,6 +646,9 @@ int cmd_send(int argc, char **argv)
}
}
if (send_flags & BTRFS_SEND_FLAG_NO_FILE_DATA)
printf("Mode NO_FILE_DATA enabled\n");
for (i = optind; i < argc; i++) {
int is_first_subvol;
int is_last_subvol;
@ -678,7 +695,7 @@ int cmd_send(int argc, char **argv)
is_last_subvol = 1;
}
ret = do_send(&send, parent_root_id, is_first_subvol,
is_last_subvol, subvol);
is_last_subvol, subvol, send_flags);
if (ret < 0)
goto out;
@ -731,5 +748,9 @@ const char * const cmd_send_usage[] = {
"-f <outfile> Output is normally written to stdout. To write to",
" a file, use this option. An alternative would be to",
" use pipes.",
"--no-data send in NO_FILE_DATA mode, Note: the output stream",
" does not contain any file data and thus cannot be used",
" to transfer changes. This mode is faster and useful to",
" show the differences in metadata.",
NULL
};