summaryrefslogtreecommitdiff
path: root/usr/src/common/zfs/zfs_comutil.c
diff options
context:
space:
mode:
authorTim Haley <Tim.Haley@Sun.COM>2009-10-30 18:47:17 -0600
committerTim Haley <Tim.Haley@Sun.COM>2009-10-30 18:47:17 -0600
commit468c413a79615e77179e8d98f22a7e513a8135bd (patch)
tree1b240a69a1bcdf6a38627a29a8cd43adae87f5b3 /usr/src/common/zfs/zfs_comutil.c
parentf4f00ee6d3f12bbd07ebfdc3f8d93438792db6f0 (diff)
downloadillumos-joyent-468c413a79615e77179e8d98f22a7e513a8135bd.tar.gz
PSARC 2009/479 zpool recovery support
6667683 need a way to rollback to an uberblock from a previous txg 6885998 bad ASSERT() in traverse_zil_block()
Diffstat (limited to 'usr/src/common/zfs/zfs_comutil.c')
-rw-r--r--usr/src/common/zfs/zfs_comutil.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/usr/src/common/zfs/zfs_comutil.c b/usr/src/common/zfs/zfs_comutil.c
index 74517a3f69..fdc8ce4c3b 100644
--- a/usr/src/common/zfs/zfs_comutil.c
+++ b/usr/src/common/zfs/zfs_comutil.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file is intended for functions that ought to be common between user
* land (libzfs) and the kernel. When many common routines need to be shared
@@ -33,10 +31,13 @@
#if defined(_KERNEL)
#include <sys/systm.h>
+#else
+#include <string.h>
#endif
#include <sys/types.h>
#include <sys/fs/zfs.h>
+#include <sys/int_limits.h>
#include <sys/nvpair.h>
/*
@@ -63,3 +64,41 @@ zfs_allocatable_devs(nvlist_t *nv)
}
return (B_FALSE);
}
+
+void
+zpool_get_rewind_policy(nvlist_t *nvl, zpool_rewind_policy_t *zrpp)
+{
+ nvlist_t *policy;
+ nvpair_t *elem;
+ char *nm;
+
+ /* Defaults */
+ zrpp->zrp_request = ZPOOL_NO_REWIND;
+ zrpp->zrp_maxmeta = 0;
+ zrpp->zrp_maxdata = UINT32_MAX;
+ zrpp->zrp_txg = UINT64_MAX;
+
+ if (nvl == NULL)
+ return;
+
+ elem = NULL;
+ while ((elem = nvlist_next_nvpair(nvl, elem)) != NULL) {
+ nm = nvpair_name(elem);
+ if (strcmp(nm, ZPOOL_REWIND_POLICY) == 0) {
+ if (nvpair_value_nvlist(elem, &policy) == 0)
+ zpool_get_rewind_policy(policy, zrpp);
+ return;
+ } else if (strcmp(nm, ZPOOL_REWIND_REQUEST) == 0) {
+ if (nvpair_value_uint32(elem,
+ &zrpp->zrp_request) == 0)
+ if (zrpp->zrp_request & ~ZPOOL_REWIND_MASK)
+ zrpp->zrp_request = ZPOOL_NO_REWIND;
+ } else if (strcmp(nm, ZPOOL_REWIND_REQUEST_TXG) == 0) {
+ (void) nvpair_value_uint64(elem, &zrpp->zrp_txg);
+ } else if (strcmp(nm, ZPOOL_REWIND_META_THRESH) == 0) {
+ (void) nvpair_value_uint32(elem, &zrpp->zrp_maxmeta);
+ } else if (strcmp(nm, ZPOOL_REWIND_DATA_THRESH) == 0) {
+ (void) nvpair_value_uint32(elem, &zrpp->zrp_maxdata);
+ }
+ }
+}