mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Illumos 5765 - add support for estimating send stream size with lzc_send_space when source is a bookmark
5765 add support for estimating send stream size with lzc_send_space when source is a bookmark Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Reviewed by: Steven Hartland <killing@multiplay.co.uk> Reviewed by: Bayard Bell <buffer.g.overflow@gmail.com> Approved by: Albert Lee <trisk@nexenta.com> References: https://www.illumos.org/issues/5765 https://github.com/illumos/illumos-gate/commit/643da460 Porting notes: * Unused variable 'recordsize' in dmu_send_estimate() dropped Ported-by: DHE <git@dehacked.net> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3397
This commit is contained in:
committed by
Brian Behlendorf
parent
19b3b1d2a2
commit
5dc8b7365f
+40
-12
@@ -5245,7 +5245,8 @@ zfs_ioc_send_new(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
* of bytes that will be written to the fd supplied to zfs_ioc_send_new().
|
||||
*
|
||||
* innvl: {
|
||||
* (optional) "fromsnap" -> full snap name to send an incremental from
|
||||
* (optional) "from" -> full snap or bookmark name to send an incremental
|
||||
* from
|
||||
* }
|
||||
*
|
||||
* outnvl: {
|
||||
@@ -5256,7 +5257,6 @@ static int
|
||||
zfs_ioc_send_space(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
{
|
||||
dsl_pool_t *dp;
|
||||
dsl_dataset_t *fromsnap = NULL;
|
||||
dsl_dataset_t *tosnap;
|
||||
int error;
|
||||
char *fromname;
|
||||
@@ -5272,27 +5272,55 @@ zfs_ioc_send_space(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
return (error);
|
||||
}
|
||||
|
||||
error = nvlist_lookup_string(innvl, "fromsnap", &fromname);
|
||||
error = nvlist_lookup_string(innvl, "from", &fromname);
|
||||
if (error == 0) {
|
||||
error = dsl_dataset_hold(dp, fromname, FTAG, &fromsnap);
|
||||
if (error != 0) {
|
||||
dsl_dataset_rele(tosnap, FTAG);
|
||||
dsl_pool_rele(dp, FTAG);
|
||||
return (error);
|
||||
if (strchr(fromname, '@') != NULL) {
|
||||
/*
|
||||
* If from is a snapshot, hold it and use the more
|
||||
* efficient dmu_send_estimate to estimate send space
|
||||
* size using deadlists.
|
||||
*/
|
||||
dsl_dataset_t *fromsnap;
|
||||
error = dsl_dataset_hold(dp, fromname, FTAG, &fromsnap);
|
||||
if (error != 0)
|
||||
goto out;
|
||||
error = dmu_send_estimate(tosnap, fromsnap, &space);
|
||||
dsl_dataset_rele(fromsnap, FTAG);
|
||||
} else if (strchr(fromname, '#') != NULL) {
|
||||
/*
|
||||
* If from is a bookmark, fetch the creation TXG of the
|
||||
* snapshot it was created from and use that to find
|
||||
* blocks that were born after it.
|
||||
*/
|
||||
zfs_bookmark_phys_t frombm;
|
||||
|
||||
error = dsl_bookmark_lookup(dp, fromname, tosnap,
|
||||
&frombm);
|
||||
if (error != 0)
|
||||
goto out;
|
||||
error = dmu_send_estimate_from_txg(tosnap,
|
||||
frombm.zbm_creation_txg, &space);
|
||||
} else {
|
||||
/*
|
||||
* from is not properly formatted as a snapshot or
|
||||
* bookmark
|
||||
*/
|
||||
error = SET_ERROR(EINVAL);
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
// If estimating the size of a full send, use dmu_send_estimate
|
||||
error = dmu_send_estimate(tosnap, NULL, &space);
|
||||
}
|
||||
|
||||
error = dmu_send_estimate(tosnap, fromsnap, &space);
|
||||
fnvlist_add_uint64(outnvl, "space", space);
|
||||
|
||||
if (fromsnap != NULL)
|
||||
dsl_dataset_rele(fromsnap, FTAG);
|
||||
out:
|
||||
dsl_dataset_rele(tosnap, FTAG);
|
||||
dsl_pool_rele(dp, FTAG);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
static zfs_ioc_vec_t zfs_ioc_vec[ZFS_IOC_LAST - ZFS_IOC_FIRST];
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user