svn commit: r294027 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

Alan Somers asomers at FreeBSD.org
Thu Jan 14 18:19:07 UTC 2016


Author: asomers
Date: Thu Jan 14 18:19:05 2016
New Revision: 294027
URL: https://svnweb.freebsd.org/changeset/base/294027

Log:
  Fix race condition involving ZFS remove events
  
  When a ZFS drive disappears, ZFS sends a resource.fs.zfs.removed event to
  userland. A userland program like zfsd(8) can use that event, for example to
  activate a hotspare. The current code contains a race condition: vdev_geom
  will sent the sysevent _before_ spa.c would update the vdev's status,
  causing userland processes to see pool state that does not reflect the
  device removal. This change moves the sysevent to spa.c, closing the race.
  
  Reviewed by:	delphij, Sean Eric Fagan
  MFC after:	4 weeks
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D4902

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Thu Jan 14 18:04:49 2016	(r294026)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c	Thu Jan 14 18:19:05 2016	(r294027)
@@ -5952,6 +5952,8 @@ spa_async_remove(spa_t *spa, vdev_t *vd)
 		vd->vdev_stat.vs_checksum_errors = 0;
 
 		vdev_state_dirty(vd->vdev_top);
+		/* Tell userspace that the vdev is gone. */
+		zfs_post_remove(spa, vd);
 	}
 
 	for (int c = 0; c < vd->vdev_children; c++)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	Thu Jan 14 18:04:49 2016	(r294026)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	Thu Jan 14 18:19:05 2016	(r294027)
@@ -160,7 +160,6 @@ vdev_geom_orphan(struct g_consumer *cp)
 	 * async removal support to invoke a close on this
 	 * vdev once it is safe to do so.
 	 */
-	zfs_post_remove(vd->vdev_spa, vd);
 	vd->vdev_remove_wanted = B_TRUE;
 	spa_async_request(vd->vdev_spa, SPA_ASYNC_REMOVE);
 }


More information about the svn-src-head mailing list