From: Mark Fasheh <mfasheh@suse.de>
To: chris.mason@fusionio.com, linux-btrfs@vger.kernel.org
Cc: ablock84@googlemail.com, aschnell@suse.de, Anand.Jain@oracle.com,
Mark Fasheh <mfasheh@suse.de>
Subject: [PATCH 1/4] btrfs-progs: Add support for BTRFS_SEND_FLAG_NO_FILE_DATA
Date: Wed, 16 Jan 2013 14:30:05 -0800 [thread overview]
Message-ID: <1358375408-25285-2-git-send-email-mfasheh@suse.de> (raw)
In-Reply-To: <1358375408-25285-1-git-send-email-mfasheh@suse.de>
The flag and command are synced from kernel to user. Also, this patch adds a
callback for the BTRFS_SEND_C_UPDATE_EXTENT in struct btrfs_send_ops.
read_and_process_cmd() is updated to decode BTRFS_SEND_C_UPDATE_EXTENT and
send the values through the right callback. I did not add a callback
definition to cmds-receive.c as that code never uses
BTRFS_SEND_FLAG_NO_FILE_DATA.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
ioctl.h | 7 +++++++
send-stream.c | 6 ++++++
send-stream.h | 1 +
send.h | 1 +
4 files changed, 15 insertions(+)
diff --git a/ioctl.h b/ioctl.h
index 6fda3a1..b7f1ce3 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -321,6 +321,13 @@ struct btrfs_ioctl_received_subvol_args {
__u64 reserved[16]; /* in */
};
+/*
+ * Caller doesn't want file data in the send stream, even if the
+ * search of clone sources doesn't find an extent. UPDATE_EXTENT
+ * commands will be sent instead of WRITE commands.
+ */
+#define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1
+
struct btrfs_ioctl_send_args {
__s64 send_fd; /* in */
__u64 clone_sources_count; /* in */
diff --git a/send-stream.c b/send-stream.c
index 55fa728..a3628e4 100644
--- a/send-stream.c
+++ b/send-stream.c
@@ -418,6 +418,12 @@ static int read_and_process_cmd(struct btrfs_send_stream *s)
TLV_GET_TIMESPEC(s, BTRFS_SEND_A_CTIME, &ct);
ret = s->ops->utimes(path, &at, &mt, &ct, s->user);
break;
+ case BTRFS_SEND_C_UPDATE_EXTENT:
+ TLV_GET_STRING(s, BTRFS_SEND_A_PATH, &path);
+ TLV_GET_U64(s, BTRFS_SEND_A_FILE_OFFSET, &offset);
+ TLV_GET_U64(s, BTRFS_SEND_A_SIZE, &tmp);
+ ret = s->ops->update_extent(path, offset, tmp, s->user);
+ break;
case BTRFS_SEND_C_END:
ret = 1;
break;
diff --git a/send-stream.h b/send-stream.h
index b69b7f1..9a17e32 100644
--- a/send-stream.h
+++ b/send-stream.h
@@ -49,6 +49,7 @@ struct btrfs_send_ops {
int (*utimes)(const char *path, struct timespec *at,
struct timespec *mt, struct timespec *ct,
void *user);
+ int (*update_extent)(const char *path, u64 offset, u64 len, void *user);
};
int btrfs_read_and_process_send_stream(int fd,
diff --git a/send.h b/send.h
index 9934e94..48d425a 100644
--- a/send.h
+++ b/send.h
@@ -86,6 +86,7 @@ enum btrfs_send_cmd {
BTRFS_SEND_C_UTIMES,
BTRFS_SEND_C_END,
+ BTRFS_SEND_C_UPDATE_EXTENT,
__BTRFS_SEND_C_MAX,
};
#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
--
1.7.10.4
next prev parent reply other threads:[~2013-01-16 22:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 22:30 [PATCH 0/4] btrfs-progs: better support for external users of send, V2 Mark Fasheh
2013-01-16 22:30 ` Mark Fasheh [this message]
2013-01-16 22:30 ` [PATCH 2/4] btrfs-progs: libify some parts of btrfs-progs Mark Fasheh
2013-01-16 22:30 ` [PATCH 3/4] btrfs-progs: add send-test Mark Fasheh
2013-01-16 22:30 ` [PATCH 4/4] btrfs-progs: make libbtrfs usable from C++ Mark Fasheh
2013-01-17 6:38 ` [PATCH 0/4] btrfs-progs: better support for external users of send, V2 Arne Jansen
2013-01-18 21:44 ` Mark Fasheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358375408-25285-2-git-send-email-mfasheh@suse.de \
--to=mfasheh@suse.de \
--cc=Anand.Jain@oracle.com \
--cc=ablock84@googlemail.com \
--cc=aschnell@suse.de \
--cc=chris.mason@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).