svn commit: r254421 - vendor-sys/illumos/dist/uts/common/fs/zfs vendor-sys/illumos/dist/uts/common/fs/zfs/sys vendor/illumos/dist/lib/libzfs/common vendor/illumos/dist/lib/libzfs_core/common

Xin LI delphij at FreeBSD.org
Fri Aug 16 19:27:30 UTC 2013


Author: delphij
Date: Fri Aug 16 19:27:29 2013
New Revision: 254421
URL: http://svnweb.freebsd.org/changeset/base/254421

Log:
  Update vendor/illumos/dist and vendor-sys/illumos/dist
  to illumos-gate 14137:f7523d207d74:
  
  Illumos ZFS issues:
    3996 want a libzfs_core API to rollback to latest snapshot

Modified:
  vendor/illumos/dist/lib/libzfs/common/libzfs_dataset.c
  vendor/illumos/dist/lib/libzfs_core/common/libzfs_core.c
  vendor/illumos/dist/lib/libzfs_core/common/libzfs_core.h

Changes in other areas also in this revision:
Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_dataset.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dsl_dataset.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c

Modified: vendor/illumos/dist/lib/libzfs/common/libzfs_dataset.c
==============================================================================
--- vendor/illumos/dist/lib/libzfs/common/libzfs_dataset.c	Fri Aug 16 19:23:44 2013	(r254420)
+++ vendor/illumos/dist/lib/libzfs/common/libzfs_dataset.c	Fri Aug 16 19:27:29 2013	(r254421)
@@ -3518,7 +3518,6 @@ zfs_rollback(zfs_handle_t *zhp, zfs_hand
 {
 	rollback_data_t cb = { 0 };
 	int err;
-	zfs_cmd_t zc = { 0 };
 	boolean_t restore_resv = 0;
 	uint64_t old_volsize, new_volsize;
 	zfs_prop_t resv_prop;
@@ -3550,22 +3549,15 @@ zfs_rollback(zfs_handle_t *zhp, zfs_hand
 		    (old_volsize == zfs_prop_get_int(zhp, resv_prop));
 	}
 
-	(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
-
-	if (ZFS_IS_VOLUME(zhp))
-		zc.zc_objset_type = DMU_OST_ZVOL;
-	else
-		zc.zc_objset_type = DMU_OST_ZFS;
-
 	/*
 	 * 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.
-	 *
 	 */
-	if ((err = zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_ROLLBACK, &zc)) != 0) {
+	err = lzc_rollback(zhp->zfs_name, NULL, 0);
+	if (err != 0) {
 		(void) zfs_standard_error_fmt(zhp->zfs_hdl, errno,
 		    dgettext(TEXT_DOMAIN, "cannot rollback '%s'"),
 		    zhp->zfs_name);

Modified: vendor/illumos/dist/lib/libzfs_core/common/libzfs_core.c
==============================================================================
--- vendor/illumos/dist/lib/libzfs_core/common/libzfs_core.c	Fri Aug 16 19:23:44 2013	(r254420)
+++ vendor/illumos/dist/lib/libzfs_core/common/libzfs_core.c	Fri Aug 16 19:27:29 2013	(r254421)
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  */
 
@@ -581,3 +581,27 @@ out:
 	free((void*)(uintptr_t)zc.zc_nvlist_dst);
 	return (error);
 }
+
+/*
+ * 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.
+ *
+ * Return 0 on success or an errno on failure.
+ */
+int
+lzc_rollback(const char *fsname, char *snapnamebuf, int snapnamelen)
+{
+	nvlist_t *args;
+	nvlist_t *result;
+	int err;
+
+	args = fnvlist_alloc();
+	err = lzc_ioctl(ZFS_IOC_ROLLBACK, fsname, args, &result);
+	nvlist_free(args);
+	if (err == 0 && snapnamebuf != NULL) {
+		const char *snapname = fnvlist_lookup_string(result, "target");
+		(void) strlcpy(snapnamebuf, snapname, snapnamelen);
+	}
+	return (err);
+}

Modified: vendor/illumos/dist/lib/libzfs_core/common/libzfs_core.h
==============================================================================
--- vendor/illumos/dist/lib/libzfs_core/common/libzfs_core.h	Fri Aug 16 19:23:44 2013	(r254420)
+++ vendor/illumos/dist/lib/libzfs_core/common/libzfs_core.h	Fri Aug 16 19:27:29 2013	(r254421)
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
  */
 
 #ifndef	_LIBZFS_CORE_H
@@ -58,6 +58,7 @@ int lzc_send_space(const char *snapname,
 
 boolean_t lzc_exists(const char *dataset);
 
+int lzc_rollback(const char *fsname, char *snapnamebuf, int snapnamelen);
 
 #ifdef	__cplusplus
 }


More information about the svn-src-all mailing list