Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Feb 2020 15:59:46 +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: r358339 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <202002261559.01QFxk27041511@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Feb 26 15:59:46 2020
New Revision: 358339
URL: https://svnweb.freebsd.org/changeset/base/358339

Log:
  MFZoL: Fix issue with scanning dedup blocks as scan ends
  
  This patch fixes an issue discovered by ztest where
  dsl_scan_ddt_entry() could add I/Os to the dsl scan queues
  between when the scan had finished all required work and
  when the scan was marked as complete. This caused the scan
  to spin indefinitely without ending.
  
  Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
  Reviewed-by: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com>
  Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
  Signed-off-by: Tom Caputi <tcaputi@datto.com>
  Closes #8010
  zfsonlinux/zfs@5e0bd0ae056e26de36dee3c199c6fcff8f14ee15
  
  MFC after:	1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c	Wed Feb 26 15:56:07 2020	(r358338)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c	Wed Feb 26 15:59:46 2020	(r358339)
@@ -2365,6 +2365,20 @@ dsl_scan_ddt_entry(dsl_scan_t *scn, enum zio_checksum 
 	if (!dsl_scan_is_running(scn))
 		return;
 
+	/*
+	 * This function is special because it is the only thing
+	 * that can add scan_io_t's to the vdev scan queues from
+	 * outside dsl_scan_sync(). For the most part this is ok
+	 * as long as it is called from within syncing context.
+	 * However, dsl_scan_sync() expects that no new sio's will
+	 * be added between when all the work for a scan is done
+	 * and the next txg when the scan is actually marked as
+	 * completed. This check ensures we do not issue new sio's
+	 * during this period.
+	 */
+	if (scn->scn_done_txg != 0)
+		return;
+
 	for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
 		if (ddp->ddp_phys_birth == 0 ||
 		    ddp->ddp_phys_birth > scn->scn_phys.scn_max_txg)
@@ -3416,6 +3430,8 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
 				   (longlong_t)tx->tx_txg);
 		}
 	} else if (scn->scn_is_sorted && scn->scn_bytes_pending != 0) {
+		ASSERT(scn->scn_clearing);
+
 		/* need to issue scrubbing IOs from per-vdev queues */
 		scn->scn_zio_root = zio_root(dp->dp_spa, NULL,
 		    NULL, ZIO_FLAG_CANFAIL);



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