Skip to content

Commit

Permalink
send_iterate_prop() should be aware of index properties as strings
Browse files Browse the repository at this point in the history
(gdb) bt
\#0  0x00007f31952a35d7 in raise () from /lib64/libc.so.6
\#1  0x00007f31952a4cc8 in abort () from /lib64/libc.so.6
\#2  0x00007f319529c546 in __assert_fail_base () from /lib64/libc.so.6
\#3  0x00007f319529c5f2 in __assert_fail () from /lib64/libc.so.6
\#4  0x00007f319529c66b in __assert () from /lib64/libc.so.6
\#5  0x00007f319659e024 in send_iterate_prop (zhp=zhp@entry=0x19cf500, nv=0x19da110) at libzfs_sendrecv.c:724
\openzfs#6  0x00007f319659e35d in send_iterate_fs (zhp=zhp@entry=0x19cf500, arg=arg@entry=0x7ffc515d6380) at libzfs_sendrecv.c:762
\openzfs#7  0x00007f319659f3ca in gather_nvlist (hdl=<optimized out>, fsname=fsname@entry=0x19cf250 "tpool/test", fromsnap=fromsnap@entry=0x7ffc515d7531 "snap1", tosnap=tosnap@entry=0x7ffc515d7542 "snap2", recursive=B_FALSE,
    nvlp=nvlp@entry=0x7ffc515d6470, avlp=avlp@entry=0x7ffc515d6478) at libzfs_sendrecv.c:809
\openzfs#8  0x00007f31965a408f in zfs_send (zhp=zhp@entry=0x19cf240, fromsnap=fromsnap@entry=0x7ffc515d7531 "snap1", tosnap=tosnap@entry=0x7ffc515d7542 "snap2", flags=flags@entry=0x7ffc515d6d30, outfd=outfd@entry=1,
    filter_func=filter_func@entry=0x0, cb_arg=cb_arg@entry=0x0, debugnvp=debugnvp@entry=0x0) at libzfs_sendrecv.c:1461
\openzfs#9  0x000000000040a981 in zfs_do_send (argc=<optimized out>, argv=0x7ffc515d6ff0) at zfs_main.c:3841
\openzfs#10 0x0000000000404d10 in main (argc=6, argv=0x7ffc515d6fc8) at zfs_main.c:6724
(gdb) fr 5
\#5  0x00007f319659e024 in send_iterate_prop (zhp=zhp@entry=0x19cf500, nv=0x19da110) at libzfs_sendrecv.c:724
724                             verify(nvlist_lookup_uint64(propnv,
(gdb) list
719                             verify(nvlist_lookup_string(propnv,
720                                 ZPROP_VALUE, &value) == 0);
721                             VERIFY(0 == nvlist_add_string(nv, propname, value));
722                     } else {
723                             uint64_t value;
724                             verify(nvlist_lookup_uint64(propnv,
725                                 ZPROP_VALUE, &value) == 0);
726                             VERIFY(0 == nvlist_add_uint64(nv, propname, value));
727                     }
728             }
(gdb) p prop
$1 = ZFS_PROP_RELATIME
  • Loading branch information
ryao committed Nov 9, 2015
1 parent 1c6b08e commit 5ef8c9e
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions lib/libzfs/libzfs_sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ send_iterate_prop(zfs_handle_t *zhp, nvlist_t *nv)
while ((elem = nvlist_next_nvpair(zhp->zfs_props, elem)) != NULL) {
char *propname = nvpair_name(elem);
zfs_prop_t prop = zfs_name_to_prop(propname);
char *strval;
uint64_t intval;
nvlist_t *propnv;

if (!zfs_prop_user(propname)) {
Expand Down Expand Up @@ -713,17 +715,41 @@ send_iterate_prop(zfs_handle_t *zhp, nvlist_t *nv)
continue;
}

if (zfs_prop_user(propname) ||
zfs_prop_get_type(prop) == PROP_TYPE_STRING) {
char *value;
verify(nvlist_lookup_string(propnv,
ZPROP_VALUE, &value) == 0);
VERIFY(0 == nvlist_add_string(nv, propname, value));
} else {
uint64_t value;
verify(nvlist_lookup_uint64(propnv,
ZPROP_VALUE, &value) == 0);
VERIFY(0 == nvlist_add_uint64(nv, propname, value));
switch (nvpair_type(elem)){
case DATA_TYPE_STRING:
switch (zfs_prop_get_type(prop)) {
default:
if (!zfs_prop_user(propname))
VERIFY(0);
case PROP_TYPE_STRING:
strval = fnvlist_lookup_string(propnv,
ZPROP_VALUE);
fnvlist_add_string(nv, propname, strval);
break;
/*
* XXX: Index properties as strings are translated into
* index properties as integers for backward
* compatibility for now, but we should switch to
* sending strings in send streams in the future.
*/
case PROP_TYPE_INDEX:
nvpair_value_string(elem, &strval);
VERIFY0(zfs_prop_string_to_index(prop,
strval, &intval));
fnvlist_add_uint64(nv, propname, intval);
break;
VERIFY(0); /* not allowed */
}
break;

case DATA_TYPE_UINT64:
nvpair_value_uint64(elem, &intval);
fnvlist_add_uint64(nv, propname, intval);
break;

default:
VERIFY(0); /* not allowed */
break;
}
}
}
Expand Down

0 comments on commit 5ef8c9e

Please sign in to comment.