From ba0ba69e50efeda7190b59f27c23ada0edf6f36b Mon Sep 17 00:00:00 2001 From: Tom Caputi Date: Fri, 10 Jan 2020 13:16:58 -0500 Subject: Add 'zfs send --saved' flag This commit adds the --saved (-S) to the 'zfs send' command. This flag allows a user to send a partially received dataset, which can be useful when migrating a backup server to new hardware. This flag is compatible with resumable receives, so even if the saved send is interrupted, it can be resumed. The flag does not require any user / kernel ABI changes or any new feature flags in the send stream format. Reviewed-by: Paul Dagnelie Reviewed-by: Alek Pinchuk Reviewed-by: Paul Zuchowski Reviewed-by: Christian Schwarz Reviewed-by: Matt Ahrens Reviewed-by: Brian Behlendorf Signed-off-by: Tom Caputi Closes #9007 --- include/libzfs.h | 4 ++++ include/libzfs_core.h | 1 + include/sys/dmu_send.h | 10 ++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/libzfs.h b/include/libzfs.h index 0518c800e..8069d4cd4 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -677,6 +677,9 @@ typedef struct sendflags { /* include snapshot holds in send stream */ boolean_t holds; + + /* stream represents a partially received dataset */ + boolean_t saved; } sendflags_t; typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *); @@ -688,6 +691,7 @@ extern int zfs_send_one(zfs_handle_t *, const char *, int, sendflags_t *, extern int zfs_send_progress(zfs_handle_t *, int, uint64_t *, uint64_t *); extern int zfs_send_resume(libzfs_handle_t *, sendflags_t *, int outfd, const char *); +extern int zfs_send_saved(zfs_handle_t *, sendflags_t *, int, const char *); extern nvlist_t *zfs_send_resume_token_to_nvlist(libzfs_handle_t *hdl, const char *token); diff --git a/include/libzfs_core.h b/include/libzfs_core.h index bd0b0c4f7..c4b4f8e71 100644 --- a/include/libzfs_core.h +++ b/include/libzfs_core.h @@ -79,6 +79,7 @@ enum lzc_send_flags { LZC_SEND_FLAG_LARGE_BLOCK = 1 << 1, LZC_SEND_FLAG_COMPRESS = 1 << 2, LZC_SEND_FLAG_RAW = 1 << 3, + LZC_SEND_FLAG_SAVED = 1 << 4, }; int lzc_send(const char *, const char *, int, enum lzc_send_flags); diff --git a/include/sys/dmu_send.h b/include/sys/dmu_send.h index 2f3dfc39f..d6d050e01 100644 --- a/include/sys/dmu_send.h +++ b/include/sys/dmu_send.h @@ -51,14 +51,16 @@ struct dmu_send_outparams; int dmu_send(const char *tosnap, const char *fromsnap, boolean_t embedok, boolean_t large_block_ok, boolean_t compressok, boolean_t rawok, - uint64_t resumeobj, uint64_t resumeoff, const char *redactbook, int outfd, - offset_t *off, struct dmu_send_outparams *dsop); + boolean_t savedok, uint64_t resumeobj, uint64_t resumeoff, + const char *redactbook, int outfd, offset_t *off, + struct dmu_send_outparams *dsop); int dmu_send_estimate_fast(struct dsl_dataset *ds, struct dsl_dataset *fromds, zfs_bookmark_phys_t *frombook, boolean_t stream_compressed, - uint64_t *sizep); + boolean_t saved, uint64_t *sizep); int dmu_send_obj(const char *pool, uint64_t tosnap, uint64_t fromsnap, boolean_t embedok, boolean_t large_block_ok, boolean_t compressok, - boolean_t rawok, int outfd, offset_t *off, struct dmu_send_outparams *dso); + boolean_t rawok, boolean_t savedok, int outfd, offset_t *off, + struct dmu_send_outparams *dso); typedef int (*dmu_send_outfunc_t)(objset_t *os, void *buf, int len, void *arg); typedef struct dmu_send_outparams { -- cgit v1.2.3