diff options
author | avg <avg@FreeBSD.org> | 2017-09-19 09:19:19 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2017-09-19 09:19:19 +0000 |
commit | 03af9b6f36d60060354cb818e846e20f94b2e9f9 (patch) | |
tree | c61a59e60b6f99f12a9864e7eeaf49a70196440b /cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c | |
parent | 1c74a3e176eb7699f6b489d505d4328c62ea76f5 (diff) | |
download | FreeBSD-src-03af9b6f36d60060354cb818e846e20f94b2e9f9.zip FreeBSD-src-03af9b6f36d60060354cb818e846e20f94b2e9f9.tar.gz |
MFC r322230: MFV r322229: 7600 zfs rollback should pass target snapshot to kernel
illumos/illumos-gate@77b171372ed21642e04c873ef1e87fe2365520df
https://github.com/illumos/illumos-gate/commit/77b171372ed21642e04c873ef1e87fe2365520df
https://www.illumos.org/issues/7600
At present, the kernel side code seems to blindly rollback to whatever happens
to be the latest snapshot at the time when the rollback task is processed.
The expected target's name should be passed to the kernel driver and the sync
task should validate that the target exists and that it is the latest snapshot
indeed.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Andriy Gapon <avg@FreeBSD.org>
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c index 27a4144..c38c8c6 100644 --- a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c +++ b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c @@ -765,6 +765,9 @@ lzc_receive_with_header(const char *snapname, nvlist_t *props, * Roll back this filesystem or volume to its most recent snapshot. * If snapnamebuf is not NULL, it will be filled in with the name * of the most recent snapshot. + * Note that the latest snapshot may change if a new one is concurrently + * created or the current one is destroyed. lzc_rollback_to can be used + * to roll back to a specific latest snapshot. * * Return 0 on success or an errno on failure. */ @@ -788,6 +791,27 @@ lzc_rollback(const char *fsname, char *snapnamebuf, int snapnamelen) } /* + * Roll back this filesystem or volume to the specified snapshot, + * if possible. + * + * Return 0 on success or an errno on failure. + */ +int +lzc_rollback_to(const char *fsname, const char *snapname) +{ + nvlist_t *args; + nvlist_t *result; + int err; + + args = fnvlist_alloc(); + fnvlist_add_string(args, "target", snapname); + err = lzc_ioctl(ZFS_IOC_ROLLBACK, fsname, args, &result); + nvlist_free(args); + nvlist_free(result); + return (err); +} + +/* * Creates bookmarks. * * The bookmarks nvlist maps from name of the bookmark (e.g. "pool/fs#bmark") to |