Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c
Context not available. | |||||
nvlist_t *nvfs, *snaps; | nvlist_t *nvfs, *snaps; | ||||
nvpair_t *snapelem = NULL; | nvpair_t *snapelem = NULL; | ||||
VERIFY(0 == nvpair_value_nvlist(fselem, &nvfs)); | nvfs = fnvpair_value_nvlist(fselem); | ||||
VERIFY(0 == nvlist_lookup_nvlist(nvfs, "snaps", &snaps)); | snaps = fnvlist_lookup_nvlist(nvfs, "snaps"); | ||||
while ((snapelem = | while ((snapelem = | ||||
nvlist_next_nvpair(snaps, snapelem)) != NULL) { | nvlist_next_nvpair(snaps, snapelem)) != NULL) { | ||||
fsavl_node_t *fn; | fsavl_node_t *fn; | ||||
uint64_t guid; | uint64_t guid; | ||||
VERIFY(0 == nvpair_value_uint64(snapelem, &guid)); | guid = fnvpair_value_uint64(snapelem); | ||||
if ((fn = malloc(sizeof (fsavl_node_t))) == NULL) { | if ((fn = malloc(sizeof (fsavl_node_t))) == NULL) { | ||||
fsavl_destroy(fsavl); | fsavl_destroy(fsavl); | ||||
return (NULL); | return (NULL); | ||||
Context not available. | |||||
return (0); | return (0); | ||||
} | } | ||||
VERIFY(0 == nvlist_add_uint64(sd->parent_snaps, snapname, guid)); | fnvlist_add_uint64(sd->parent_snaps, snapname, guid); | ||||
/* | /* | ||||
* NB: if there is no fromsnap here (it's a newly created fs in | * NB: if there is no fromsnap here (it's a newly created fs in | ||||
* an incremental replication), we will substitute the tosnap. | * an incremental replication), we will substitute the tosnap. | ||||
Context not available. | |||||
sd->seento = B_TRUE; | sd->seento = B_TRUE; | ||||
} | } | ||||
VERIFY(0 == nvlist_alloc(&nv, NV_UNIQUE_NAME, 0)); | nv = fnvlist_alloc(); | ||||
send_iterate_prop(zhp, sd->backup, nv); | send_iterate_prop(zhp, sd->backup, nv); | ||||
VERIFY(0 == nvlist_add_nvlist(sd->snapprops, snapname, nv)); | fnvlist_add_nvlist(sd->snapprops, snapname, nv); | ||||
nvlist_free(nv); | fnvlist_free(nv); | ||||
if (sd->holds) { | if (sd->holds) { | ||||
nvlist_t *holds = fnvlist_alloc(); | nvlist_t *holds = fnvlist_alloc(); | ||||
int err = lzc_get_holds(zhp->zfs_name, &holds); | int err = lzc_get_holds(zhp->zfs_name, &holds); | ||||
if (err == 0) { | if (err == 0) { | ||||
VERIFY(0 == nvlist_add_nvlist(sd->snapholds, | fnvlist_add_nvlist(sd->snapholds, snapname, holds); | ||||
snapname, holds)); | |||||
} | } | ||||
fnvlist_free(holds); | fnvlist_free(holds); | ||||
} | } | ||||
Context not available. | |||||
if (zfs_prop_user(propname) || | if (zfs_prop_user(propname) || | ||||
zfs_prop_get_type(prop) == PROP_TYPE_STRING) { | zfs_prop_get_type(prop) == PROP_TYPE_STRING) { | ||||
char *value; | char *value; | ||||
verify(nvlist_lookup_string(propnv, | value = fnvlist_lookup_string(propnv, ZPROP_VALUE); | ||||
ZPROP_VALUE, &value) == 0); | fnvlist_add_string(nv, propname, value); | ||||
VERIFY(0 == nvlist_add_string(nv, propname, value)); | |||||
} else { | } else { | ||||
uint64_t value; | uint64_t value; | ||||
verify(nvlist_lookup_uint64(propnv, | value = fnvlist_lookup_uint64(propnv, ZPROP_VALUE); | ||||
ZPROP_VALUE, &value) == 0); | fnvlist_add_uint64(nv, propname, value); | ||||
VERIFY(0 == nvlist_add_uint64(nv, propname, value)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
sd->parent_snaps = fnvlist_alloc(); | sd->parent_snaps = fnvlist_alloc(); | ||||
sd->snapprops = fnvlist_alloc(); | sd->snapprops = fnvlist_alloc(); | ||||
if (sd->holds) | if (sd->holds) | ||||
VERIFY(0 == nvlist_alloc(&sd->snapholds, NV_UNIQUE_NAME, 0)); | sd->snapholds = fnvlist_alloc(); | ||||
/* | /* | ||||
* If this is a "doall" send, a replicate send or we're just trying | * If this is a "doall" send, a replicate send or we're just trying | ||||
Context not available. | |||||
if (zhp == NULL) | if (zhp == NULL) | ||||
return (EZFS_BADTYPE); | return (EZFS_BADTYPE); | ||||
VERIFY(0 == nvlist_alloc(&sd.fss, NV_UNIQUE_NAME, 0)); | sd.fss = fnvlist_alloc(); | ||||
sd.fsname = fsname; | sd.fsname = fsname; | ||||
sd.fromsnap = fromsnap; | sd.fromsnap = fromsnap; | ||||
sd.tosnap = tosnap; | sd.tosnap = tosnap; | ||||
Context not available. | |||||
sd.props = props; | sd.props = props; | ||||
if ((error = send_iterate_fs(zhp, &sd)) != 0) { | if ((error = send_iterate_fs(zhp, &sd)) != 0) { | ||||
nvlist_free(sd.fss); | fnvlist_free(sd.fss); | ||||
if (avlp != NULL) | if (avlp != NULL) | ||||
*avlp = NULL; | *avlp = NULL; | ||||
*nvlp = NULL; | *nvlp = NULL; | ||||
Context not available. | |||||
} | } | ||||
if (avlp != NULL && (*avlp = fsavl_create(sd.fss)) == NULL) { | if (avlp != NULL && (*avlp = fsavl_create(sd.fss)) == NULL) { | ||||
nvlist_free(sd.fss); | fnvlist_free(sd.fss); | ||||
*nvlp = NULL; | *nvlp = NULL; | ||||
return (EZFS_NOMEM); | return (EZFS_NOMEM); | ||||
} | } | ||||
Context not available. | |||||
zc.zc_fromobj = fromsnap_obj; | zc.zc_fromobj = fromsnap_obj; | ||||
zc.zc_flags = flags; | zc.zc_flags = flags; | ||||
VERIFY(0 == nvlist_alloc(&thisdbg, NV_UNIQUE_NAME, 0)); | thisdbg = fnvlist_alloc(); | ||||
if (fromsnap && fromsnap[0] != '\0') { | if (fromsnap && fromsnap[0] != '\0') { | ||||
VERIFY(0 == nvlist_add_string(thisdbg, | fnvlist_add_string(thisdbg, "fromsnap", fromsnap); | ||||
"fromsnap", fromsnap)); | |||||
} | } | ||||
if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_SEND, &zc) != 0) { | if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_SEND, &zc) != 0) { | ||||
Context not available. | |||||
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, | (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, | ||||
"warning: cannot send '%s'"), zhp->zfs_name); | "warning: cannot send '%s'"), zhp->zfs_name); | ||||
VERIFY(0 == nvlist_add_uint64(thisdbg, "error", errno)); | fnvlist_add_uint64(thisdbg, "error", errno); | ||||
if (debugnv) { | if (debugnv) { | ||||
VERIFY(0 == nvlist_add_nvlist(debugnv, | fnvlist_add_nvlist(debugnv, zhp->zfs_name, thisdbg); | ||||
zhp->zfs_name, thisdbg)); | |||||
} | } | ||||
nvlist_free(thisdbg); | fnvlist_free(thisdbg); | ||||
switch (errno) { | switch (errno) { | ||||
case EXDEV: | case EXDEV: | ||||
Context not available. | |||||
} | } | ||||
if (debugnv) | if (debugnv) | ||||
VERIFY(0 == nvlist_add_nvlist(debugnv, zhp->zfs_name, thisdbg)); | fnvlist_add_nvlist(debugnv, zhp->zfs_name, thisdbg); | ||||
nvlist_free(thisdbg); | fnvlist_free(thisdbg); | ||||
return (0); | return (0); | ||||
} | } | ||||
Context not available. | |||||
nvlist_t *nvfs = fsavl_find(sdd->fsavl, | nvlist_t *nvfs = fsavl_find(sdd->fsavl, | ||||
zhp->zfs_dmustats.dds_guid, &snapname); | zhp->zfs_dmustats.dds_guid, &snapname); | ||||
VERIFY(0 == nvlist_lookup_nvlist(nvfs, | snapprops = fnvlist_lookup_nvlist(nvfs, "snapprops"); | ||||
"snapprops", &snapprops)); | snapprops = fnvlist_lookup_nvlist(snapprops, thissnap); | ||||
VERIFY(0 == nvlist_lookup_nvlist(snapprops, | |||||
thissnap, &snapprops)); | |||||
exclude = !nvlist_exists(snapprops, "is_clone_origin"); | exclude = !nvlist_exists(snapprops, "is_clone_origin"); | ||||
} else { | } else { | ||||
exclude = B_TRUE; | exclude = B_TRUE; | ||||
Context not available. | |||||
nvlist_t *nvfs; | nvlist_t *nvfs; | ||||
uint64_t origin_guid = 0; | uint64_t origin_guid = 0; | ||||
VERIFY(0 == nvpair_value_nvlist(fspair, &nvfs)); | nvfs = fnvpair_value_nvlist(fspair); | ||||
(void) nvlist_lookup_uint64(nvfs, "origin", &origin_guid); | (void) nvlist_lookup_uint64(nvfs, "origin", &origin_guid); | ||||
if (origin_guid != 0) { | if (origin_guid != 0) { | ||||
char *snapname; | char *snapname; | ||||
Context not available. | |||||
origin_guid, &snapname); | origin_guid, &snapname); | ||||
if (origin_nv != NULL) { | if (origin_nv != NULL) { | ||||
nvlist_t *snapprops; | nvlist_t *snapprops; | ||||
VERIFY(0 == nvlist_lookup_nvlist(origin_nv, | snapprops = fnvlist_lookup_nvlist(origin_nv, | ||||
"snapprops", &snapprops)); | "snapprops"); | ||||
VERIFY(0 == nvlist_lookup_nvlist(snapprops, | snapprops = fnvlist_lookup_nvlist(snapprops, | ||||
snapname, &snapprops)); | snapname); | ||||
VERIFY(0 == nvlist_add_boolean( | fnvlist_add_boolean(snapprops, | ||||
snapprops, "is_clone_origin")); | "is_clone_origin"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
uint64_t origin_guid = 0; | uint64_t origin_guid = 0; | ||||
uint64_t parent_guid = 0; | uint64_t parent_guid = 0; | ||||
VERIFY(nvpair_value_nvlist(fspair, &fslist) == 0); | fslist = fnvpair_value_nvlist(fspair); | ||||
if (nvlist_lookup_boolean(fslist, "sent") == 0) | if (nvlist_lookup_boolean(fslist, "sent") == 0) | ||||
continue; | continue; | ||||
VERIFY(nvlist_lookup_string(fslist, "name", &fsname) == 0); | fsname = fnvlist_lookup_string(fslist, "name"); | ||||
(void) nvlist_lookup_uint64(fslist, "origin", &origin_guid); | (void) nvlist_lookup_uint64(fslist, "origin", &origin_guid); | ||||
(void) nvlist_lookup_uint64(fslist, "parentfromsnap", | (void) nvlist_lookup_uint64(fslist, "parentfromsnap", | ||||
&parent_guid); | &parent_guid); | ||||
Context not available. | |||||
if (zhp == NULL) | if (zhp == NULL) | ||||
return (-1); | return (-1); | ||||
err = dump_filesystem(zhp, sdd); | err = dump_filesystem(zhp, sdd); | ||||
VERIFY(nvlist_add_boolean(fslist, "sent") == 0); | fnvlist_add_boolean(fslist, "sent"); | ||||
progress = B_TRUE; | progress = B_TRUE; | ||||
zfs_close(zhp); | zfs_close(zhp); | ||||
if (err) | if (err) | ||||
Context not available. | |||||
fspair = nvlist_next_nvpair(sdd->fss, fspair)) { | fspair = nvlist_next_nvpair(sdd->fss, fspair)) { | ||||
nvlist_t *fslist; | nvlist_t *fslist; | ||||
VERIFY(nvpair_value_nvlist(fspair, &fslist) == 0); | fslist = fnvpair_value_nvlist(fspair); | ||||
(void) nvlist_remove_all(fslist, "sent"); | (void) nvlist_remove_all(fslist, "sent"); | ||||
} | } | ||||
Context not available. | |||||
fnvlist_add_boolean(props, "redact_complete"); | fnvlist_add_boolean(props, "redact_complete"); | ||||
fnvlist_add_boolean(props, zfs_prop_to_name(ZFS_PROP_REDACT_SNAPS)); | fnvlist_add_boolean(props, zfs_prop_to_name(ZFS_PROP_REDACT_SNAPS)); | ||||
error = lzc_get_bookmarks(path, props, &bmarks); | error = lzc_get_bookmarks(path, props, &bmarks); | ||||
nvlist_free(props); | fnvlist_free(props); | ||||
if (error != 0) { | if (error != 0) { | ||||
if (error == ESRCH) { | if (error == ESRCH) { | ||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, | zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, | ||||
Context not available. | |||||
} | } | ||||
ret = zfs_send_resume_impl(hdl, flags, outfd, resume_nvl); | ret = zfs_send_resume_impl(hdl, flags, outfd, resume_nvl); | ||||
nvlist_free(resume_nvl); | fnvlist_free(resume_nvl); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
Context not available. | |||||
ret = zfs_send_resume_impl(hdl, flags, outfd, saved_nvl); | ret = zfs_send_resume_impl(hdl, flags, outfd, saved_nvl); | ||||
out: | out: | ||||
nvlist_free(saved_nvl); | fnvlist_free(saved_nvl); | ||||
nvlist_free(resume_nvl); | fnvlist_free(resume_nvl); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
Context not available. | |||||
fnvlist_add_boolean(hdrnv, "not_recursive"); | fnvlist_add_boolean(hdrnv, "not_recursive"); | ||||
if (raw) { | if (raw) { | ||||
VERIFY0(nvlist_add_boolean(hdrnv, "raw")); | fnvlist_add_boolean(hdrnv, "raw"); | ||||
} | } | ||||
if ((err = gather_nvlist(zhp->zfs_hdl, tofs, | if ((err = gather_nvlist(zhp->zfs_hdl, tofs, | ||||
Context not available. | |||||
if (fssp != NULL) { | if (fssp != NULL) { | ||||
*fssp = fss; | *fssp = fss; | ||||
} else { | } else { | ||||
nvlist_free(fss); | fnvlist_free(fss); | ||||
} | } | ||||
nvlist_free(hdrnv); | fnvlist_free(hdrnv); | ||||
} | } | ||||
if (!dryrun) { | if (!dryrun) { | ||||
Context not available. | |||||
err = dump_filesystems(zhp, &sdd); | err = dump_filesystems(zhp, &sdd); | ||||
fsavl_destroy(fsavl); | fsavl_destroy(fsavl); | ||||
nvlist_free(fss); | fnvlist_free(fss); | ||||
/* Ensure no snaps found is treated as an error. */ | /* Ensure no snaps found is treated as an error. */ | ||||
if (err == 0 && !sdd.seento) | if (err == 0 && !sdd.seento) | ||||
Context not available. | |||||
err = zfs_standard_error(zhp->zfs_hdl, err, errbuf); | err = zfs_standard_error(zhp->zfs_hdl, err, errbuf); | ||||
err_out: | err_out: | ||||
fsavl_destroy(fsavl); | fsavl_destroy(fsavl); | ||||
nvlist_free(fss); | fnvlist_free(fss); | ||||
fnvlist_free(sdd.snapholds); | fnvlist_free(sdd.snapholds); | ||||
if (sdd.cleanup_fd != -1) | if (sdd.cleanup_fd != -1) | ||||
Context not available. | |||||
return (1); | return (1); | ||||
nvfs = fsavl_find(avl, guid1, &snapname); | nvfs = fsavl_find(avl, guid1, &snapname); | ||||
VERIFY(0 == nvlist_lookup_string(nvfs, "name", &fsname)); | fsname = fnvlist_lookup_string(nvfs, "name"); | ||||
(void) snprintf(buf, sizeof (buf), "%s@%s", fsname, snapname); | (void) snprintf(buf, sizeof (buf), "%s@%s", fsname, snapname); | ||||
guid1hdl = zfs_open(hdl, buf, ZFS_TYPE_SNAPSHOT); | guid1hdl = zfs_open(hdl, buf, ZFS_TYPE_SNAPSHOT); | ||||
if (guid1hdl == NULL) | if (guid1hdl == NULL) | ||||
return (-1); | return (-1); | ||||
nvfs = fsavl_find(avl, guid2, &snapname); | nvfs = fsavl_find(avl, guid2, &snapname); | ||||
VERIFY(0 == nvlist_lookup_string(nvfs, "name", &fsname)); | fsname = fnvlist_lookup_string(nvfs, "name"); | ||||
(void) snprintf(buf, sizeof (buf), "%s@%s", fsname, snapname); | (void) snprintf(buf, sizeof (buf), "%s@%s", fsname, snapname); | ||||
guid2hdl = zfs_open(hdl, buf, ZFS_TYPE_SNAPSHOT); | guid2hdl = zfs_open(hdl, buf, ZFS_TYPE_SNAPSHOT); | ||||
if (guid2hdl == NULL) { | if (guid2hdl == NULL) { | ||||
Context not available. | |||||
nvpair_t *fselem = NULL; | nvpair_t *fselem = NULL; | ||||
nvlist_t *stream_fss; | nvlist_t *stream_fss; | ||||
VERIFY(0 == nvlist_lookup_nvlist(stream_nv, "fss", &stream_fss)); | stream_fss = fnvlist_lookup_nvlist(stream_nv, "fss"); | ||||
while ((fselem = nvlist_next_nvpair(stream_fss, fselem)) != NULL) { | while ((fselem = nvlist_next_nvpair(stream_fss, fselem)) != NULL) { | ||||
zfs_handle_t *zhp = NULL; | zfs_handle_t *zhp = NULL; | ||||
Context not available. | |||||
char fsname[ZFS_MAX_DATASET_NAME_LEN]; | char fsname[ZFS_MAX_DATASET_NAME_LEN]; | ||||
keylocation[0] = '\0'; | keylocation[0] = '\0'; | ||||
VERIFY(0 == nvpair_value_nvlist(fselem, &stream_nvfs)); | stream_nvfs = fnvpair_value_nvlist(fselem); | ||||
VERIFY(0 == nvlist_lookup_nvlist(stream_nvfs, "snaps", &snaps)); | snaps = fnvlist_lookup_nvlist(stream_nvfs, "snaps"); | ||||
VERIFY(0 == nvlist_lookup_nvlist(stream_nvfs, "props", &props)); | props = fnvlist_lookup_nvlist(stream_nvfs, "props"); | ||||
stream_encroot = nvlist_exists(stream_nvfs, "is_encroot"); | stream_encroot = nvlist_exists(stream_nvfs, "is_encroot"); | ||||
/* find a snapshot from the stream that exists locally */ | /* find a snapshot from the stream that exists locally */ | ||||
Context not available. | |||||
while ((snapel = nvlist_next_nvpair(snaps, snapel)) != NULL) { | while ((snapel = nvlist_next_nvpair(snaps, snapel)) != NULL) { | ||||
uint64_t guid; | uint64_t guid; | ||||
VERIFY(0 == nvpair_value_uint64(snapel, &guid)); | guid = fnvpair_value_uint64(snapel); | ||||
err = guid_to_name(hdl, top_zfs, guid, B_FALSE, | err = guid_to_name(hdl, top_zfs, guid, B_FALSE, | ||||
fsname); | fsname); | ||||
if (err == 0) | if (err == 0) | ||||
Context not available. | |||||
} | } | ||||
} | } | ||||
VERIFY(0 == nvlist_lookup_string(props, | stream_keylocation = fnvlist_lookup_string(props, | ||||
zfs_prop_to_name(ZFS_PROP_KEYLOCATION), | zfs_prop_to_name(ZFS_PROP_KEYLOCATION)); | ||||
&stream_keylocation)); | |||||
/* | /* | ||||
* Refresh the properties in case the call to | * Refresh the properties in case the call to | ||||
Context not available. | |||||
boolean_t needagain, progress, recursive; | boolean_t needagain, progress, recursive; | ||||
char *s1, *s2; | char *s1, *s2; | ||||
VERIFY(0 == nvlist_lookup_string(stream_nv, "fromsnap", &fromsnap)); | fromsnap = fnvlist_lookup_string(stream_nv, "fromsnap"); | ||||
recursive = (nvlist_lookup_boolean(stream_nv, "not_recursive") == | recursive = (nvlist_lookup_boolean(stream_nv, "not_recursive") == | ||||
ENOENT); | ENOENT); | ||||
Context not available. | |||||
again: | again: | ||||
needagain = progress = B_FALSE; | needagain = progress = B_FALSE; | ||||
VERIFY(0 == nvlist_alloc(&deleted, NV_UNIQUE_NAME, 0)); | deleted = fnvlist_alloc(); | ||||
if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL, | if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL, | ||||
recursive, B_TRUE, B_FALSE, recursive, B_FALSE, B_FALSE, | recursive, B_TRUE, B_FALSE, recursive, B_FALSE, B_FALSE, | ||||
Context not available. | |||||
nextfselem = nvlist_next_nvpair(local_nv, fselem); | nextfselem = nvlist_next_nvpair(local_nv, fselem); | ||||
VERIFY(0 == nvpair_value_nvlist(fselem, &nvfs)); | nvfs = fnvpair_value_nvlist(fselem); | ||||
VERIFY(0 == nvlist_lookup_nvlist(nvfs, "snaps", &snaps)); | snaps = fnvlist_lookup_nvlist(nvfs, "snaps"); | ||||
VERIFY(0 == nvlist_lookup_string(nvfs, "name", &fsname)); | fsname = fnvlist_lookup_string(nvfs, "name"); | ||||
VERIFY(0 == nvlist_lookup_uint64(nvfs, "parentfromsnap", | parent_fromsnap_guid = fnvlist_lookup_uint64(nvfs, | ||||
&parent_fromsnap_guid)); | "parentfromsnap"); | ||||
(void) nvlist_lookup_uint64(nvfs, "origin", &originguid); | (void) nvlist_lookup_uint64(nvfs, "origin", &originguid); | ||||
/* | /* | ||||
Context not available. | |||||
snapelem; snapelem = nvlist_next_nvpair(snaps, snapelem)) { | snapelem; snapelem = nvlist_next_nvpair(snaps, snapelem)) { | ||||
uint64_t thisguid; | uint64_t thisguid; | ||||
VERIFY(0 == nvpair_value_uint64(snapelem, &thisguid)); | thisguid = fnvpair_value_uint64(snapelem); | ||||
stream_nvfs = fsavl_find(stream_avl, thisguid, NULL); | stream_nvfs = fsavl_find(stream_avl, thisguid, NULL); | ||||
if (stream_nvfs != NULL) | if (stream_nvfs != NULL) | ||||
Context not available. | |||||
origin_nvfs = fsavl_find(local_avl, originguid, | origin_nvfs = fsavl_find(local_avl, originguid, | ||||
NULL); | NULL); | ||||
VERIFY(0 == nvlist_lookup_string(origin_nvfs, | origin_fsname = fnvlist_lookup_string( | ||||
"name", &origin_fsname)); | origin_nvfs, "name"); | ||||
error = recv_promote(hdl, fsname, origin_fsname, | error = recv_promote(hdl, fsname, origin_fsname, | ||||
flags); | flags); | ||||
if (error == 0) | if (error == 0) | ||||
Context not available. | |||||
break; | break; | ||||
case -1: | case -1: | ||||
fsavl_destroy(local_avl); | fsavl_destroy(local_avl); | ||||
nvlist_free(local_nv); | fnvlist_free(local_nv); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* | /* | ||||
Context not available. | |||||
nextsnapelem = nvlist_next_nvpair(snaps, snapelem); | nextsnapelem = nvlist_next_nvpair(snaps, snapelem); | ||||
VERIFY(0 == nvpair_value_uint64(snapelem, &thisguid)); | thisguid = fnvpair_value_uint64(snapelem); | ||||
found = fsavl_find(stream_avl, thisguid, | found = fsavl_find(stream_avl, thisguid, | ||||
&stream_snapname); | &stream_snapname); | ||||
Context not available. | |||||
continue; | continue; | ||||
} | } | ||||
VERIFY(0 == nvlist_lookup_string(stream_nvfs, | stream_fsname = fnvlist_lookup_string(stream_nvfs, "name"); | ||||
"name", &stream_fsname)); | stream_parent_fromsnap_guid = fnvlist_lookup_uint64( | ||||
VERIFY(0 == nvlist_lookup_uint64(stream_nvfs, | stream_nvfs, "parentfromsnap"); | ||||
"parentfromsnap", &stream_parent_fromsnap_guid)); | |||||
s1 = strrchr(fsname, '/'); | s1 = strrchr(fsname, '/'); | ||||
s2 = strrchr(stream_fsname, '/'); | s2 = strrchr(stream_fsname, '/'); | ||||
Context not available. | |||||
if (parent != NULL) { | if (parent != NULL) { | ||||
char *pname; | char *pname; | ||||
VERIFY(0 == nvlist_lookup_string(parent, "name", | pname = fnvlist_lookup_string(parent, "name"); | ||||
&pname)); | |||||
(void) snprintf(tryname, sizeof (tryname), | (void) snprintf(tryname, sizeof (tryname), | ||||
"%s%s", pname, strrchr(stream_fsname, '/')); | "%s%s", pname, strrchr(stream_fsname, '/')); | ||||
} else { | } else { | ||||
Context not available. | |||||
strlen(tofs)+1, newname, flags); | strlen(tofs)+1, newname, flags); | ||||
if (renamed != NULL && newname[0] != '\0') { | if (renamed != NULL && newname[0] != '\0') { | ||||
VERIFY(0 == nvlist_add_boolean(renamed, | fnvlist_add_boolean(renamed, newname); | ||||
newname)); | |||||
} | } | ||||
if (error) | if (error) | ||||
Context not available. | |||||
doagain: | doagain: | ||||
fsavl_destroy(local_avl); | fsavl_destroy(local_avl); | ||||
nvlist_free(local_nv); | fnvlist_free(local_nv); | ||||
nvlist_free(deleted); | fnvlist_free(deleted); | ||||
if (needagain && progress) { | if (needagain && progress) { | ||||
/* do another pass to fix up temporary names */ | /* do another pass to fix up temporary names */ | ||||
Context not available. | |||||
if (drr->drr_payloadlen != 0) { | if (drr->drr_payloadlen != 0) { | ||||
nvlist_t *stream_fss; | nvlist_t *stream_fss; | ||||
VERIFY(0 == nvlist_lookup_nvlist(stream_nv, "fss", | stream_fss = fnvlist_lookup_nvlist(stream_nv, "fss"); | ||||
&stream_fss)); | |||||
if ((stream_avl = fsavl_create(stream_fss)) == NULL) { | if ((stream_avl = fsavl_create(stream_fss)) == NULL) { | ||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, | zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, | ||||
"couldn't allocate avl tree")); | "couldn't allocate avl tree")); | ||||
Context not available. | |||||
} | } | ||||
if (!flags->dryrun && !flags->nomount) { | if (!flags->dryrun && !flags->nomount) { | ||||
VERIFY(0 == nvlist_alloc(&renamed, | renamed = fnvlist_alloc(); | ||||
NV_UNIQUE_NAME, 0)); | |||||
} | } | ||||
softerr = recv_incremental_replication(hdl, tofs, flags, | softerr = recv_incremental_replication(hdl, tofs, flags, | ||||
Context not available. | |||||
} | } | ||||
} | } | ||||
nvlist_free(renamed); | fnvlist_free(renamed); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
out: | out: | ||||
fsavl_destroy(stream_avl); | fsavl_destroy(stream_avl); | ||||
nvlist_free(stream_nv); | fnvlist_free(stream_nv); | ||||
if (softerr) | if (softerr) | ||||
error = -2; | error = -2; | ||||
if (anyerr) | if (anyerr) | ||||
Context not available. | |||||
&parent_snapguid); | &parent_snapguid); | ||||
err = nvlist_lookup_nvlist(fs, "props", &rcvprops); | err = nvlist_lookup_nvlist(fs, "props", &rcvprops); | ||||
if (err) { | if (err) { | ||||
VERIFY(0 == nvlist_alloc(&rcvprops, NV_UNIQUE_NAME, 0)); | rcvprops = fnvlist_alloc(); | ||||
newprops = B_TRUE; | newprops = B_TRUE; | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
if (flags->canmountoff) { | if (flags->canmountoff) { | ||||
VERIFY(0 == nvlist_add_uint64(rcvprops, | fnvlist_add_uint64(rcvprops, | ||||
zfs_prop_to_name(ZFS_PROP_CANMOUNT), 0)); | zfs_prop_to_name(ZFS_PROP_CANMOUNT), 0); | ||||
} else if (newprops) { /* nothing in rcvprops, eliminate it */ | } else if (newprops) { /* nothing in rcvprops, eliminate it */ | ||||
nvlist_free(rcvprops); | fnvlist_free(rcvprops); | ||||
rcvprops = NULL; | rcvprops = NULL; | ||||
newprops = B_FALSE; | newprops = B_FALSE; | ||||
} | } | ||||
if (0 == nvlist_lookup_nvlist(fs, "snapprops", &lookup)) { | if (0 == nvlist_lookup_nvlist(fs, "snapprops", &lookup)) { | ||||
VERIFY(0 == nvlist_lookup_nvlist(lookup, | snapprops_nvlist = fnvlist_lookup_nvlist(lookup, | ||||
snapname, &snapprops_nvlist)); | snapname); | ||||
} | } | ||||
if (holds) { | if (holds) { | ||||
if (0 == nvlist_lookup_nvlist(fs, "snapholds", | if (0 == nvlist_lookup_nvlist(fs, "snapholds", | ||||
&lookup)) { | &lookup)) { | ||||
VERIFY(0 == nvlist_lookup_nvlist(lookup, | snapholds_nvlist = fnvlist_lookup_nvlist( | ||||
snapname, &snapholds_nvlist)); | lookup, snapname); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
for (pair = nvlist_next_nvpair(snapholds_nvlist, NULL); | for (pair = nvlist_next_nvpair(snapholds_nvlist, NULL); | ||||
pair != NULL; | pair != NULL; | ||||
pair = nvlist_next_nvpair(snapholds_nvlist, pair)) { | pair = nvlist_next_nvpair(snapholds_nvlist, pair)) { | ||||
VERIFY(0 == nvlist_add_string(holds, destsnap, | fnvlist_add_string(holds, destsnap, nvpair_name(pair)); | ||||
nvpair_name(pair))); | |||||
} | } | ||||
(void) lzc_hold(holds, cleanup_fd, &errors); | (void) lzc_hold(holds, cleanup_fd, &errors); | ||||
nvlist_free(snapholds_nvlist); | fnvlist_free(snapholds_nvlist); | ||||
nvlist_free(holds); | fnvlist_free(holds); | ||||
} | } | ||||
if (err && (ioctl_errno == ENOENT || ioctl_errno == EEXIST)) { | if (err && (ioctl_errno == ENOENT || ioctl_errno == EEXIST)) { | ||||
Context not available. | |||||
*cp = '@'; | *cp = '@'; | ||||
fs = fsavl_find(local_avl, drrb->drr_toguid, NULL); | fs = fsavl_find(local_avl, drrb->drr_toguid, NULL); | ||||
fsavl_destroy(local_avl); | fsavl_destroy(local_avl); | ||||
nvlist_free(local_nv); | fnvlist_free(local_nv); | ||||
if (fs != NULL) { | if (fs != NULL) { | ||||
if (flags->verbose) { | if (flags->verbose) { | ||||
Context not available. | |||||
err = 0; | err = 0; | ||||
out: | out: | ||||
if (prop_errors != NULL) | if (prop_errors != NULL) | ||||
nvlist_free(prop_errors); | fnvlist_free(prop_errors); | ||||
if (tmp_keylocation[0] != '\0') { | if (tmp_keylocation[0] != '\0') { | ||||
VERIFY(0 == nvlist_add_string(rcvprops, | fnvlist_add_string(rcvprops, | ||||
zfs_prop_to_name(ZFS_PROP_KEYLOCATION), tmp_keylocation)); | zfs_prop_to_name(ZFS_PROP_KEYLOCATION), tmp_keylocation); | ||||
} | } | ||||
if (newprops) | if (newprops) | ||||
nvlist_free(rcvprops); | fnvlist_free(rcvprops); | ||||
nvlist_free(oxprops); | fnvlist_free(oxprops); | ||||
nvlist_free(origprops); | fnvlist_free(origprops); | ||||
return (err); | return (err); | ||||
} | } | ||||
Context not available. |