aboutsummaryrefslogtreecommitdiff
path: root/sys/geom
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2018-12-12 05:48:27 +0000
committerConrad Meyer <cem@FreeBSD.org>2018-12-12 05:48:27 +0000
commit23c25bd8b165342c046c48d48447645f7a72166a (patch)
tree1831a7c530ccab84b06c5bcd169502db0e4d77a4 /sys/geom
parentb2d7ecdd544e9d1c29e1f249fb0ee798908b9228 (diff)
downloadsrc-23c25bd8b165342c046c48d48447645f7a72166a.tar.gz
src-23c25bd8b165342c046c48d48447645f7a72166a.zip
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
Notes
Notes: svn path=/head/; revision=341840
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/mirror/g_mirror.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c
index 4a29bf25522a..253ae01e4e19 100644
--- a/sys/geom/mirror/g_mirror.c
+++ b/sys/geom/mirror/g_mirror.c
@@ -3061,6 +3061,8 @@ g_mirror_reinit_from_metadata(struct g_mirror_softc *sc,
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 *sc,
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 *