Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Mar 2018 22:06:12 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r331702 - vendor-sys/illumos/dist/uts/common/fs/zfs
Message-ID:  <201803282206.w2SM6CX3030776@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Mar 28 22:06:12 2018
New Revision: 331702
URL: https://svnweb.freebsd.org/changeset/base/331702

Log:
  9187 racing condition between vdev label and spa_last_synced_txg in vdev_validate
  
  illumos/illumos-gate@d1de72cfa29ab77ff80e2bb0e668a6afa5bccaf0
  
  ztest failed with uncorrectable IO error despite having the fix for #7163.
  Both sides of the mirror have CANT_OPEN_BAD_LABEL, which also distinguishes
  it from that issue.
  
  Definitely seems like a racing condition between the vdev_validate and spa_sync:
  1. Thread A (spa_sync): vdev label is updated to latest txg
  2. Thread B (vdev_validate): vdev label's txg is compared to spa_last_synced_txg and is ahead.
  3. Thread A (spa_sync): spa_last_synced_txg is updated to latest txg.
  
  Solution: do not check txg in vdev_validate unless config lock is held.
  
  Reviewed by: George Wilson <george.wilson@delphix.com>
  Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
  Approved by: Robert Mustacchi <rm@joyent.com>
  Author: Pavel Zakharov <pavel.zakharov@delphix.com>

Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c
==============================================================================
--- vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c	Wed Mar 28 22:01:27 2018	(r331701)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c	Wed Mar 28 22:06:12 2018	(r331702)
@@ -1573,8 +1573,11 @@ vdev_validate(vdev_t *vd)
 	/*
 	 * If we are performing an extreme rewind, we allow for a label that
 	 * was modified at a point after the current txg.
+	 * If config lock is not held do not check for the txg. spa_sync could
+	 * be updating the vdev's label before updating spa_last_synced_txg.
 	 */
-	if (spa->spa_extreme_rewind || spa_last_synced_txg(spa) == 0)
+	if (spa->spa_extreme_rewind || spa_last_synced_txg(spa) == 0 ||
+	    spa_config_held(spa, SCL_CONFIG, RW_WRITER) != SCL_CONFIG)
 		txg = UINT64_MAX;
 	else
 		txg = spa_last_synced_txg(spa);



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