diff options
author | Andriy Gapon <avg@FreeBSD.org> | 2017-03-11 20:26:47 +0200 |
---|---|---|
committer | Prakash Surya <prakash.surya@delphix.com> | 2017-06-29 16:10:42 -0700 |
commit | 77b171372ed21642e04c873ef1e87fe2365520df (patch) | |
tree | 48b2ff7efbe6e719418fc745b0e10711ed8aa585 /usr/src/lib/libzfs/common/libzfs_dataset.c | |
parent | 42418f9e73f0d007aa87675ecc206c26fc8e073e (diff) | |
download | illumos-joyent-77b171372ed21642e04c873ef1e87fe2365520df.tar.gz |
7600 zfs rollback should pass target snapshot to kernel
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/lib/libzfs/common/libzfs_dataset.c')
-rw-r--r-- | usr/src/lib/libzfs/common/libzfs_dataset.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_dataset.c b/usr/src/lib/libzfs/common/libzfs_dataset.c index 73e81c6069..9f55741bc9 100644 --- a/usr/src/lib/libzfs/common/libzfs_dataset.c +++ b/usr/src/lib/libzfs/common/libzfs_dataset.c @@ -3996,14 +3996,19 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) } /* - * We rely on zfs_iter_children() to verify that there are no - * newer snapshots for the given dataset. Therefore, we can - * simply pass the name on to the ioctl() call. There is still - * an unlikely race condition where the user has taken a - * snapshot since we verified that this was the most recent. + * Pass both the filesystem and the wanted snapshot names, + * we would get an error back if the snapshot is destroyed or + * a new snapshot is created before this request is processed. */ - err = lzc_rollback(zhp->zfs_name, NULL, 0); - if (err != 0) { + err = lzc_rollback_to(zhp->zfs_name, snap->zfs_name); + if (err == EXDEV) { + zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN, + "'%s' is not the latest snapshot"), snap->zfs_name); + (void) zfs_error_fmt(zhp->zfs_hdl, EZFS_BUSY, + dgettext(TEXT_DOMAIN, "cannot rollback '%s'"), + zhp->zfs_name); + return (err); + } else if (err != 0) { (void) zfs_standard_error_fmt(zhp->zfs_hdl, errno, dgettext(TEXT_DOMAIN, "cannot rollback '%s'"), zhp->zfs_name); |