From 46de1a6ec3dbb0db203baa6c46cb64ba9b000ea2 Mon Sep 17 00:00:00 2001 From: Stefan Behrens Date: Tue, 9 Apr 2013 19:08:40 +0200 Subject: Btrfs-progs: btrfs-receive optionally honors the end-cmd A new option is added to btrfs-receive to change the behavior when an is received in the Btrfs send stream. The traditional behavior (which still is the default) is to continue to read the stream until an EOF condition is encountered. If an is received, afterwards either an EOF or a new is expected. The new behavior (if the -e option is set on the command line) is to terminate after an is read without the need for an EOF. This allows the stream (e.g. a single TCP stream) to carry additional data or even multiple Btrfs send streams. Old btrfs-send tools used to encode multiple snapshots like this (with 2 snapshots in this example): + + + + + + EOF If the new -e option is set, the expected format is like this: + + + The btrfs-send tool is changed in a seperate commit to always use the new format, i.e. to send an only at the end. Note that the currently existing receivers treat only as an indication that a new is following. This means, you can just skip the sequence without loosing compatibility. As long as an EOF is following, the currently existing receivers handle the new format (if the two new flags are used) exactly as the old one. The goal of changing the semantic of is to be able to use a single stream (one TCP connection) to multiplex a request/response handshake plus Btrfs send streams, all in the same stream. In this case you cannot evaluate an EOF condition as an end of the Btrfs send stream. You need something else, and the is just perfect for this purpose. Signed-off-by: Stefan Behrens --- send-stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'send-stream.c') diff --git a/send-stream.c b/send-stream.c index a3628e45..1a498f3f 100644 --- a/send-stream.c +++ b/send-stream.c @@ -439,7 +439,8 @@ out: } int btrfs_read_and_process_send_stream(int fd, - struct btrfs_send_ops *ops, void *user) + struct btrfs_send_ops *ops, void *user, + int honor_end_cmd) { int ret; struct btrfs_send_stream s; @@ -476,7 +477,8 @@ int btrfs_read_and_process_send_stream(int fd, if (ret < 0) goto out; if (ret) { - ret = 0; + if (!honor_end_cmd) + ret = 0; goto out; } } -- cgit v1.2.3