Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Feb 2018 00:42:13 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329769 - in head: cddl/contrib/opensolaris/cmd/zdb sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201802220042.w1M0gDrc016556@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Feb 22 00:42:12 2018
New Revision: 329769
URL: https://svnweb.freebsd.org/changeset/base/329769

Log:
  MFV r329766: 8962 zdb should work on non-idle pools
  
  illumos/illumos-gate@e144c4e6c90e7d4dccaad6db660ee42b6e7ba04f
  
  Currently `zdb` consistently fails to examine non-idle pools as it fails
  during the `spa_load()` process. The main problem seems to be that
  `spa_load_verify()` fails as can be seen below:
  
  $ sudo zdb -d -G dcenter
      zdb: can't open 'dcenter': I/O error
  
  ZFS_DBGMSG(zdb):
      spa_open_common: opening dcenter
      spa_load(dcenter): LOADING
      disk vdev '/dev/dsk/c4t11d0s0': best uberblock found for spa dcenter. txg 40824950
      spa_load(dcenter): using uberblock with txg=40824950
      spa_load(dcenter): UNLOADING
      spa_load(dcenter): RELOADING
      spa_load(dcenter): LOADING
      disk vdev '/dev/dsk/c3t10d0s0': best uberblock found for spa dcenter. txg 40824952
      spa_load(dcenter): using uberblock with txg=40824952
      spa_load(dcenter): FAILED: spa_load_verify failed [error=5]
      spa_load(dcenter): UNLOADING
  
  This change makes `spa_load_verify()` a dryrun when ran from `zdb`. This is
  done by creating a global flag in zfs and then setting it in `zdb`.
  
  Reviewed by: George Wilson <george.wilson@delphix.com>
  Reviewed by: Matthew Ahrens <mahrens@delphix.com>
  Reviewed by: Andy Stormont <astormont@racktopsystems.com>
  Approved by: Dan McDonald <danmcd@joyent.com>
  Author: Pavel Zakharov <pavel.zakharov@delphix.com>

Modified:
  head/cddl/contrib/opensolaris/cmd/zdb/zdb.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/cmd/zdb/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Thu Feb 22 00:39:25 2018	(r329768)
+++ head/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Thu Feb 22 00:42:12 2018	(r329769)
@@ -87,11 +87,13 @@ extern int reference_tracking_enable;
 extern boolean_t zfs_recover;
 extern uint64_t zfs_arc_max, zfs_arc_meta_limit;
 extern int zfs_vdev_async_read_max_active;
+extern boolean_t spa_load_verify_dryrun;
 #else
 int reference_tracking_enable;
 boolean_t zfs_recover;
 uint64_t zfs_arc_max, zfs_arc_meta_limit;
 int zfs_vdev_async_read_max_active;
+boolean_t spa_load_verify_dryrun;
 #endif
 
 static const char cmdname[] = "zdb";
@@ -4577,6 +4579,12 @@ main(int argc, char **argv)
 	 * Disable reference tracking for better performance.
 	 */
 	reference_tracking_enable = B_FALSE;
+
+	/*
+	 * Do not fail spa_load when spa_load_verify fails. This is needed
+	 * to load non-idle pools.
+	 */
+	spa_load_verify_dryrun = B_TRUE;
 
 	kernel_init(FREAD);
 	g_zfs = libzfs_init();

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Thu Feb 22 00:39:25 2018	(r329768)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Thu Feb 22 00:42:12 2018	(r329769)
@@ -181,6 +181,12 @@ boolean_t	spa_create_process = B_TRUE;	/* no process =
 extern int	zfs_sync_pass_deferred_free;
 
 /*
+ * Report any spa_load_verify errors found, but do not fail spa_load.
+ * This is used by zdb to analyze non-idle pools.
+ */
+boolean_t	spa_load_verify_dryrun = B_FALSE;
+
+/*
  * This (illegal) pool name is used when temporarily importing a spa_t in order
  * to get the vdev stats associated with the imported devices.
  */
@@ -2088,8 +2094,15 @@ spa_load_verify(spa_t *spa)
 	spa->spa_load_meta_errors = sle.sle_meta_count;
 	spa->spa_load_data_errors = sle.sle_data_count;
 
-	if (!error && sle.sle_meta_count <= policy.zrp_maxmeta &&
-	    sle.sle_data_count <= policy.zrp_maxdata) {
+	if (sle.sle_meta_count != 0 || sle.sle_data_count != 0) {
+		spa_load_note(spa, "spa_load_verify found %llu metadata errors "
+		    "and %llu data errors", (u_longlong_t)sle.sle_meta_count,
+		    (u_longlong_t)sle.sle_data_count);
+	}
+
+	if (spa_load_verify_dryrun ||
+	    (!error && sle.sle_meta_count <= policy.zrp_maxmeta &&
+	    sle.sle_data_count <= policy.zrp_maxdata)) {
 		int64_t loss = 0;
 
 		verify_ok = B_TRUE;
@@ -2106,6 +2119,9 @@ spa_load_verify(spa_t *spa)
 	} else {
 		spa->spa_load_max_txg = spa->spa_uberblock.ub_txg;
 	}
+
+	if (spa_load_verify_dryrun)
+		return (0);
 
 	if (error) {
 		if (error != ENXIO && error != EIO)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802220042.w1M0gDrc016556>