summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-12 13:15:41 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-12 16:44:47 +0200
commitc55415e4cb246265b1cfc1507b3ec1bdba0e3bb3 (patch)
treefc37d9846979e52a5889c2597ff725eb7be5034d
parent14de97259be14d8c0f384dd24c5b1f85a66c0936 (diff)
btrfs-progs: send: add option to for the no-data mode
Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--Documentation/btrfs-send.asciidoc4
-rw-r--r--cmds-send.c31
2 files changed, 30 insertions, 5 deletions
diff --git a/Documentation/btrfs-send.asciidoc b/Documentation/btrfs-send.asciidoc
index 6721428d..1dba8a3d 100644
--- a/Documentation/btrfs-send.asciidoc
+++ b/Documentation/btrfs-send.asciidoc
@@ -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
-----------
diff --git a/cmds-send.c b/cmds-send.c
index e59ba506..5c466588 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -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
};