-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
zfs promote .../%recv should be an error #6339
Conversation
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 prefer to extended the existing zfs_promote_006_neg.ksh
test case. It wouldn't be a terrible idea to extend the other *_neg test cases where a '%' in the name isn't allowed to check for this.
lib/libzfs/libzfs_dataset.c
Outdated
@@ -3751,6 +3751,10 @@ zfs_promote(zfs_handle_t *zhp) | |||
return (zfs_error(hdl, EZFS_BADTYPE, errbuf)); | |||
} | |||
|
|||
if (!zfs_validate_name(hdl, zhp->zfs_name, zhp->zfs_type, B_TRUE)) { | |||
return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); | |||
} |
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.
nit: no need for the { }
here.
@behlendorf i'll update |
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.
@loli10K no problem, and don't worry I know this isn't quite right to merge. I've reverted the approved status for now.
@@ -50,30 +51,44 @@ | |||
verify_runnable "both" | |||
|
|||
snap=$TESTPOOL/$TESTFS@$TESTSNAP | |||
incr=$TESTPOOL/$TESTFS@incr$TESTSNAP | |||
clone=$TESTPOOL/$TESTCLONE | |||
destfs=$TESTPOOL/destfs |
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.
nit: maybe recvfs
instead of destfs
?
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.
recvfs
is objectively more appropriate here
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.
Thanks for the corrections! Noticed one more thing. Do you mind squashing your commits as well?
typeset mountpoint="$TESTDIR/create_recv_clone" | ||
typeset sendfile="$TESTDIR/create_recv_clone.zsnap" | ||
|
||
[[ -z $recvfs ]] && log_fail "Recv filesystem's name is undefined." |
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 could enforce recvfs
doesn't exist by calling datasetexists
and failing if that returns true. Likewise with sendfs
, you'd want to make sure it doesn't exist.
@loli10K when you get a chance could you rebase this on master. |
If we are in the middle of an incremental 'zfs receive', the child .../%recv will exist. If we run 'zfs promote' .../%recv, it will "work", but then zfs gets confused about the status of the new dataset. Attempting to do this promote should be an error. Similarly renaming .../%recv datasets should not be allowed. Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
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.
Thanks for rebasing this and extending the test coverage. This LGTM!
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com> git-svn-id: svn+ssh://svn.freebsd.org/base/head@329783 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com>
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com>
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com> git-svn-id: https://svn.freebsd.org/base/vendor-sys/illumos/dist@329781 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com> git-svn-id: https://svn.freebsd.org/base/head@329783 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com> git-svn-id: https://svn.freebsd.org/base/vendor/illumos/dist@329781 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com> git-svn-id: svn+ssh://svn.freebsd.org/base/head@329783 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com>
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com> git-svn-id: https://svn.freebsd.org/base/stable/11@332535 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
illumos/illumos-gate@add927f Reported on the ZFSonLinux openzfs/zfs#4843, fixed by openzfs/zfs#6339: If we are in the middle of an incremental zfs receive, the child .../%recv will exist. If you concurrently run zfs promote .../%recv, it will "work", but then zfs gets confused. For example, there's no obvious way to destroy the containing filesystem (because it is now a clone of its invisible child). Attempting to do this promote should be an error. We could fix this by having zfs_ioc_promote() check if zc_name contains a %, similar to zfs_ioc_rename(). Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: loli10K <ezomori.nozomu@gmail.com>
If we are in the middle of an incremental 'zfs receive', the child .../%recv will exist. If we run 'zfs promote' .../%recv, it will "work", but then zfs gets confused about the status of the new dataset. Attempting to do this promote should be an error. Similarly renaming .../%recv datasets should not be allowed. Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes openzfs#4843 Closes openzfs#6339
Description
Add more input validation in
zfs_ioc_promote()
(and its userland counterpart) so we don't promote temporary ".../%recv" datasets.NOTE: I have not added tests to cover my changes yet: should we update "zfs_promote_006_neg.ksh" ('zfs promote' will fail with invalid arguments) or add a new script?
Motivation and Context
Fix #4843
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.