-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix receiving custom snapshot properties #5189
Conversation
@loli10K thanks for digging in to this and opening a pull request. I won't be able to look at this carefully until tomorrow but in the meanwhile it would be great if you could added a simple test case for sending user properties. To my surprise I didn't see one in @dweeezil can you look at this. Your previous commit dropped this hunk e890dd8. |
@behlendorf the commit message is a typo of mine, the issue is actually on the receiving side: should i add a EDIT: first take on the script pushed, can still be improved probably ... i'm not very good with test cases. |
@loli10K adding it as a recv test as you've done is fine. Thanks for adding the test case. |
Adding new test cases revealed that the initial fix is not working correctly. Without the first commit (initialize With the "fix" commit ZFS is able to receive the snapshot properties but instead fails to receive the dataset properties with: Back to the debugger. EDIT: patch works ok on 0.6.5, the problem is only present on 0.7.0 |
Update: the problem with my initial patch is the incompatibility with the implementation of Workflow before 43e52ed:
Everything seems to work with the previous code. Now with the new
This patch won't let ZFS receive the dataset properties because it updates I just applied the same patch on the commit just before 43e52ed and it seems to work. EDIT: i've squashed all the work in a single commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow. Your updated code should, and does, work with lzc_receive_one()
. It's just that props
is copied in to the kernel latter. Now that shouldn't be a problem but if it is we could always use nvlist_dup()
to make a copy of it and then free it latter.
Also if you rebase this patch on the latest master version you should be able to eliminate some of the test failures.
@@ -3122,6 +3122,11 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, | |||
VERIFY(0 == nvlist_add_uint64(props, | |||
zfs_prop_to_name(ZFS_PROP_CANMOUNT), 0)); | |||
} | |||
if (0 == nvlist_lookup_nvlist(fs, "snapprops", | |||
&snapprops_nvlist)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense to introduce a local variable in this block simply to be used to lookup the snapprops nvlist. As was done with props
in the original version of this function. That way snapprops_nvlist
will only be non-NULL when snapname exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right about the non-NULL condition, i just thought that if the first nvlist_lookup_nvlist
doesn't exit with errors and incorrectly sets snapprops_nvlist
then we either find snapname
in the second lookup (overwriting the nvlist with the correct value) or we fail the VERIFY()
.
# | ||
|
||
# | ||
# Copyright 2016, [name of copyright owner]. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You wrote the test case, feel free to add your name here. Or your companies name if that's more appropriate.
7105482
to
d4e77bb
Compare
@@ -3090,6 +3090,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, | |||
uint64_t errflags = 0; | |||
uint64_t parent_snapguid = 0; | |||
prop_changelist_t *clp = NULL; | |||
nvlist_t *lookup_nvlist = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest moving this in to the if (stream_avl != NULL)
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and rebased on current master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally this LGTM and I presume you're not seeing any problems with it when testing it on master?
Please refresh this to address the last two remaining style concerns and add a more descriptive comment. Then add your Signed-off-by
to the commit message.
@@ -3110,6 +3110,8 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, | |||
ENOENT); | |||
|
|||
if (stream_avl != NULL) { | |||
nvlist_t *lookup_nvlist = NULL; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[style] No need for an empty line here.
@@ -3125,6 +3127,11 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, | |||
VERIFY(0 == nvlist_add_uint64(props, | |||
zfs_prop_to_name(ZFS_PROP_CANMOUNT), 0)); | |||
} | |||
if (0 == nvlist_lookup_nvlist(fs, "snapprops", | |||
&lookup_nvlist)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[style] Four space indent here for continued conditional.
+ if (0 == nvlist_lookup_nvlist(fs, "snapprops",
+ &lookup_nvlist)) {
Or better yet if you picked a shorter variable name this could all be done on one line. Since the scope of this variable is so small it doesn't need to be super descriptive.
if (0 == nvlist_lookup_nvlist(fs, "snapprops", &lookup)) {
The variable snapprops_nvlist was never initialized, so properties were not applied to the received snapshot. Additionally, add zfs_receive_013_pos.ksh script to ZFS test suite to exercise 'zfs receive' functionality for user properties. Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Sorry for all the trouble, i will try to keep these things in mind for the next PR. EDIT: no, no problems, but i'm still running 0.6.X on my systems so this was not tested intensively. |
@loli10K thanks for digging in to this issue. |
We never initialize
snapprops_nvlist
inzfs_receive_one
, so custom properties aren't applied to the received snapshot.Should fix #4338, more info in comments.