Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Dec 2018 05:48:27 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341840 - head/sys/geom/mirror
Message-ID:  <201812120548.wBC5mRZ8066447@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Wed Dec 12 05:48:27 2018
New Revision: 341840
URL: https://svnweb.freebsd.org/changeset/base/341840

Log:
  gmirror: Fix a bug introduced in r341674
  
  r341674 inadvertently introduced a bug where newer mirror components being
  tasted would clear the high sc_flags that are not controlled by component
  metadata, such as G_MIRROR_DEVICE_FLAG_TASTING.  This could plausibly expose
  a small window of time during STARTING where device destruction might race
  with mirror component addition, probably resulting in a crash.
  
  Reviewed by:	markj
  X-MFC-With:	r341674
  Differential Revision:	https://reviews.freebsd.org/D18521

Modified:
  head/sys/geom/mirror/g_mirror.c

Modified: head/sys/geom/mirror/g_mirror.c
==============================================================================
--- head/sys/geom/mirror/g_mirror.c	Wed Dec 12 05:18:53 2018	(r341839)
+++ head/sys/geom/mirror/g_mirror.c	Wed Dec 12 05:48:27 2018	(r341840)
@@ -3061,6 +3061,8 @@ g_mirror_reinit_from_metadata(struct g_mirror_softc *s
     const struct g_mirror_metadata *md)
 {
 
+	sx_assert(&sc->sc_lock, SX_XLOCKED);
+
 	sc->sc_genid = md->md_genid;
 	sc->sc_syncid = md->md_syncid;
 
@@ -3068,7 +3070,8 @@ g_mirror_reinit_from_metadata(struct g_mirror_softc *s
 	sc->sc_balance = md->md_balance;
 	sc->sc_mediasize = md->md_mediasize;
 	sc->sc_ndisks = md->md_all;
-	sc->sc_flags = md->md_mflags;
+	sc->sc_flags &= ~G_MIRROR_DEVICE_FLAG_MASK;
+	sc->sc_flags |= (md->md_mflags & G_MIRROR_DEVICE_FLAG_MASK);
 }
 
 struct g_geom *



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