Skip to content

Commit

Permalink
Update manpage and variable names. Also try to be backwards-compatible
Browse files Browse the repository at this point in the history
with older send streams in zfs_ioc_recv()
  • Loading branch information
loli10K committed Dec 1, 2016
1 parent 6c0f4a5 commit a82483f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 37 deletions.
26 changes: 13 additions & 13 deletions lib/libzfs_core/libzfs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ recv_read(int fd, void *buf, int ilen)
* Non-Linux OpenZFS platforms have opted to modify the legacy interface.
*/
static int
recv_impl(const char *snapname, nvlist_t *props, nvlist_t *cmdprops,
recv_impl(const char *snapname, nvlist_t *recvdprops, nvlist_t *localprops,
const char *origin, boolean_t force, boolean_t resumable, int input_fd,
const dmu_replay_record_t *begin_record, int cleanup_fd,
uint64_t *read_bytes, uint64_t *errflags, uint64_t *action_handle,
Expand Down Expand Up @@ -610,11 +610,11 @@ recv_impl(const char *snapname, nvlist_t *props, nvlist_t *cmdprops,

fnvlist_add_string(innvl, "snapname", snapname);

if (props != NULL)
fnvlist_add_nvlist(innvl, "props", props);
if (recvdprops != NULL)
fnvlist_add_nvlist(innvl, "props", recvdprops);

if (cmdprops != NULL)
fnvlist_add_nvlist(innvl, "cmdprops", cmdprops);
if (localprops != NULL)
fnvlist_add_nvlist(innvl, "localprops", localprops);

if (origin != NULL && strlen(origin))
fnvlist_add_string(innvl, "origin", origin);
Expand Down Expand Up @@ -662,7 +662,6 @@ recv_impl(const char *snapname, nvlist_t *props, nvlist_t *cmdprops,
fnvlist_free(outnvl);
} else {
zfs_cmd_t zc = {"\0"};
nvlist_t *allprops;
char *packed = NULL;
size_t size;

Expand All @@ -671,17 +670,18 @@ recv_impl(const char *snapname, nvlist_t *props, nvlist_t *cmdprops,
(void) strlcpy(zc.zc_name, fsname, sizeof (zc.zc_value));
(void) strlcpy(zc.zc_value, snapname, sizeof (zc.zc_value));

allprops = fnvlist_alloc();
if (props != NULL)
fnvlist_add_nvlist(allprops, "props", props);
if (cmdprops != NULL)
fnvlist_add_nvlist(allprops, "cmdprops", cmdprops);
if (!nvlist_empty(allprops)) {
packed = fnvlist_pack(allprops, &size);
if (recvdprops != NULL) {
packed = fnvlist_pack(recvdprops, &size);
zc.zc_nvlist_src = (uint64_t)(uintptr_t)packed;
zc.zc_nvlist_src_size = size;
}

if (localprops != NULL) {
packed = fnvlist_pack(localprops, &size);
zc.zc_nvlist_conf = (uint64_t)(uintptr_t)packed;
zc.zc_nvlist_conf_size = size;
}

if (origin != NULL)
(void) strlcpy(zc.zc_string, origin,
sizeof (zc.zc_string));
Expand Down
8 changes: 5 additions & 3 deletions man/man8/zfs.8
Original file line number Diff line number Diff line change
Expand Up @@ -2973,7 +2973,9 @@ Creates a snapshot whose contents are as specified in the stream provided on sta
.sp
If an incremental stream is received, then the destination file system must already exist, and its most recent snapshot must match the incremental stream's source. For \fBzvols\fR, the destination device link is destroyed and recreated, which means the \fBzvol\fR cannot be accessed during the \fBreceive\fR operation.
.sp
When a snapshot replication package stream that is generated by using the \fBzfs send\fR \fB-R\fR command is received, any snapshots that do not exist on the sending location are destroyed by using the \fBzfs destroy\fR \fB-d\fR command. If \fB-o\fR \fIproperty\fR=\fIvalue\fR or \fB-x\fR \fIproperty\fR is specified, it applies to the effective value of the property throughout the entire subtree of replicated datasets. Effective property values may be set or inherited, depending on the property and whether the dataset is the topmost in the replicated subtree. Received properties are retained in spite of being overridden and may be restored with \fBzfs inherit\fR \fB-rS\fR.
When a snapshot replication package stream that is generated by using the \fBzfs send\fR \fB-R\fR command is received, any snapshots that do not exist on the sending location are destroyed by using the \fBzfs destroy\fR \fB-d\fR command.
.sp
If \fB-o\fR \fIproperty\fR=\fIvalue\fR or \fB-x\fR \fIproperty\fR is specified, it applies to the effective value of the property throughout the entire subtree of replicated datasets. Effective property values will be set (-o) or inherited (-x) on the topmost in the replicated subtree. In descendant datasets, if the property is set by the send stream, it will be overridden by forcing the property to be inherited from the topmost filesystem. Received properties are retained in spite of being overridden and may be restored with \fBzfs inherit\fR \fB-S\fR.
.sp
The name of the snapshot (and file system, if a full stream is received) that this subcommand creates depends on the argument type and the use of the \fB-d\fR or \fB-e\fR options.
.sp
Expand Down Expand Up @@ -3043,11 +3045,11 @@ Print verbose information about the stream and the time required to perform the
.ad
.sp .6
.RS 4n
Sets the specified property as if the command \fBzfs set\fR \fIproperty\fR=\fIvalue\fR was invoked at the same time the received dataset was created from the non-incremental send stream or updated from the incremental send stream.
Sets the specified property as if the command \fBzfs set\fR \fIproperty\fR=\fIvalue\fR was invoked at the same time the received dataset was created from the non-incremental send stream or updated from the incremental send stream. When receiving a stream from \fBzfs send -R\fR, causes the property to be inherited by all descendant datasets, as through \fBzfs inherit\fR \fIproperty\fR was run on any descendant datasets that have this property set on the sending system.
.sp
Any editable ZFS property can also be set at receive time. Set-once properties bound to the received data, such as \fBnormalization\fR and \fBcasesensitivity\fR, cannot be set at receive time even when the datasets are newly created by zfs receive.
.sp
Multiple \fB-o\fR options can be specified. An error results if the same property is specified in multiple \fB-o\fR or \fB-x\fR options.
The \fB-o\fR option may be specified multiple times, for different properties. An error results if the same property is specified in multiple \fB-o\fR or \fB-x\fR options.
.RE

.sp
Expand Down
39 changes: 18 additions & 21 deletions module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4148,7 +4148,7 @@ static boolean_t zfs_ioc_recv_inject_err;
*/
static int
zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, nvlist_t *recvprops,
nvlist_t *cmdprops, boolean_t force, boolean_t resumable, int input_fd,
nvlist_t *localprops, boolean_t force, boolean_t resumable, int input_fd,
dmu_replay_record_t *begin_record, int cleanup_fd, uint64_t *read_bytes,
uint64_t *errflags, uint64_t *action_handle, nvlist_t **errors)
{
Expand Down Expand Up @@ -4224,11 +4224,11 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, nvlist_t *recvprops,
}
}

if (cmdprops != NULL) {
if (localprops != NULL) {
nvlist_t *oprops = fnvlist_alloc();
// nvlist_t *xprops = fnvlist_alloc();
nvpair_t *nvp = NULL;
while ((nvp = nvlist_next_nvpair(cmdprops, nvp)) != NULL) {
while ((nvp = nvlist_next_nvpair(localprops, nvp)) != NULL) {
if (nvpair_type(nvp) == DATA_TYPE_BOOLEAN) {
const char *name = nvpair_name(nvp);
// fnvlist_add_string(xprops, name, "");
Expand Down Expand Up @@ -4354,6 +4354,7 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, nvlist_t *recvprops,
* inputs:
* zc_name name of containing filesystem (unused)
* zc_nvlist_src{_size} nvlist of properties to apply
* zc_nvlist_conf{_size}nvlist of properties to override or exclude
* zc_value name of snapshot to create
* zc_string name of clone origin (if DRR_FLAG_CLONE)
* zc_cookie file descriptor to recv from
Expand All @@ -4373,9 +4374,8 @@ zfs_ioc_recv(zfs_cmd_t *zc)
{
dmu_replay_record_t begin_record;
nvlist_t *errors = NULL;
nvlist_t *props = NULL;
nvlist_t *recvprops = NULL;
nvlist_t *cmdprops = NULL;
nvlist_t *recvdprops = NULL;
nvlist_t *localprops = NULL;
char *origin = NULL;
char *tosnap;
char tofs[ZFS_MAX_DATASET_NAME_LEN];
Expand All @@ -4392,14 +4392,12 @@ zfs_ioc_recv(zfs_cmd_t *zc)

if (zc->zc_nvlist_src != 0 &&
(error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
zc->zc_iflags, &props)) != 0)
zc->zc_iflags, &recvdprops)) != 0)
return (error);

nvlist_lookup_nvlist(props, "props", &recvprops);
if (error && error != ENOENT)
return (error);
nvlist_lookup_nvlist(props, "cmdprops", &cmdprops);
if (error && error != ENOENT)
if (zc->zc_nvlist_conf != 0 &&
(error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
zc->zc_iflags, &localprops)) != 0)
return (error);

if (zc->zc_string[0])
Expand All @@ -4409,13 +4407,12 @@ zfs_ioc_recv(zfs_cmd_t *zc)
begin_record.drr_payloadlen = 0;
begin_record.drr_u.drr_begin = zc->zc_begin_record;

error = zfs_ioc_recv_impl(tofs, tosnap, origin, recvprops, cmdprops,
error = zfs_ioc_recv_impl(tofs, tosnap, origin, recvdprops, localprops,
zc->zc_guid, B_FALSE, zc->zc_cookie, &begin_record,
zc->zc_cleanup_fd, &zc->zc_cookie, &zc->zc_obj,
&zc->zc_action_handle, &errors);
nvlist_free(props);
nvlist_free(recvprops);
nvlist_free(cmdprops);
nvlist_free(recvdprops);
nvlist_free(localprops);

/*
* Now that all props, initial and delayed, are set, report the prop
Expand All @@ -4440,7 +4437,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
* innvl: {
* "snapname" -> full name of the snapshot to create
* (optional) "props" -> received properties to set (nvlist)
* (optional) "cmdprops" -> override and exclude properties (nvlist)
* (optional) "localprops" -> override and exclude properties (nvlist)
* (optional) "origin" -> name of clone origin (DRR_FLAG_CLONE)
* "begin_record" -> non-byteswapped dmu_replay_record_t
* "input_fd" -> file descriptor to read stream from (int32)
Expand All @@ -4464,7 +4461,7 @@ zfs_ioc_recv_new(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
uint_t begin_record_size;
nvlist_t *errors = NULL;
nvlist_t *recvprops = NULL;
nvlist_t *cmdprops = NULL;
nvlist_t *localprops = NULL;
char *snapname = NULL;
char *origin = NULL;
char *tosnap;
Expand Down Expand Up @@ -4519,11 +4516,11 @@ zfs_ioc_recv_new(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
if (error && error != ENOENT)
return (error);

error = nvlist_lookup_nvlist(innvl, "cmdprops", &cmdprops);
error = nvlist_lookup_nvlist(innvl, "localprops", &localprops);
if (error && error != ENOENT)
return (error);

error = zfs_ioc_recv_impl(tofs, tosnap, origin, recvprops, cmdprops,
error = zfs_ioc_recv_impl(tofs, tosnap, origin, recvprops, localprops,
force, resumable, input_fd, begin_record, cleanup_fd, &read_bytes,
&errflags, &action_handle, &errors);

Expand All @@ -4534,7 +4531,7 @@ zfs_ioc_recv_new(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)

nvlist_free(errors);
nvlist_free(recvprops);
nvlist_free(cmdprops);
nvlist_free(localprops);

return (error);
}
Expand Down

0 comments on commit a82483f

Please sign in to comment.