aboutsummaryrefslogtreecommitdiff
path: root/sys/geom
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2016-10-06 00:05:45 +0000
committerMark Johnston <markj@FreeBSD.org>2016-10-06 00:05:45 +0000
commit903618cd655ab060f92521dffe625303fac3739d (patch)
treebd35c80eb5f15979085be8c0a82199548c63cc2c /sys/geom
parentfff048e4bcfd3589e9a837c21b2b5f10c1145402 (diff)
downloadsrc-903618cd655ab060f92521dffe625303fac3739d.tar.gz
src-903618cd655ab060f92521dffe625303fac3739d.zip
gmirror: Bump the syncid if broken disks are found during startup.
Consider a mirror with two components, m1 and m2. Suppose a hardware error results in the removal of m2, with m1's genid bumped. Suppose further that a replacement mirror component m3 is created and synchronized, after which the system is shut down uncleanly. During a subsequent bootup, if gmirror tastes m1 and m2 first, m2 will be removed from the mirror because it is broken, but the mirror will be started without bumping the syncid on m1 because all elements of the mirror are accounted for. Then m3 will be added to the already-running mirror with the same syncid as m1, so the components will not be synchronized despite the unclean shutdown. Handle this scenario by bumping the syncid of healthy components if any broken mirrors are discovered during mirror startup. MFC after: 3 weeks Sponsored by: Dell EMC Isilon
Notes
Notes: svn path=/head/; revision=306743
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/mirror/g_mirror.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c
index 176b4e38b8a4..da4790edac2b 100644
--- a/sys/geom/mirror/g_mirror.c
+++ b/sys/geom/mirror/g_mirror.c
@@ -2255,6 +2255,7 @@ g_mirror_update_device(struct g_mirror_softc *sc, bool force)
{
struct g_mirror_disk *pdisk, *tdisk;
u_int dirty, ndisks, genid, syncid;
+ bool broken;
KASSERT(sc->sc_provider == NULL,
("Non-NULL provider in STARTING state (%s).", sc->sc_name));
@@ -2322,12 +2323,18 @@ g_mirror_update_device(struct g_mirror_softc *sc, bool force)
/*
* Remove all disks without the biggest genid.
*/
+ broken = false;
LIST_FOREACH_SAFE(disk, &sc->sc_disks, d_next, tdisk) {
if (disk->d_genid < genid) {
G_MIRROR_DEBUG(0,
"Component %s (device %s) broken, skipping.",
g_mirror_get_diskname(disk), sc->sc_name);
g_mirror_destroy_disk(disk);
+ /*
+ * Bump the syncid in case we discover a healthy
+ * replacement disk after starting the mirror.
+ */
+ broken = true;
}
}
@@ -2418,7 +2425,7 @@ g_mirror_update_device(struct g_mirror_softc *sc, bool force)
/* Reset hint. */
sc->sc_hint = NULL;
sc->sc_syncid = syncid;
- if (force) {
+ if (force || broken) {
/* Remember to bump syncid on first write. */
sc->sc_bump_id |= G_MIRROR_BUMP_SYNCID;
}