diff options
author | Alan Somers <asomers@FreeBSD.org> | 2023-04-07 16:07:50 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2023-04-10 16:27:10 +0000 |
commit | 9309a460b23a8cda8d47c5f775da7fc6472d9925 (patch) | |
tree | f1ae1b9ba34b640e876141d6efee5aea48c82986 /sys/geom | |
parent | 38594ff9c0c9568b5082ba3273103904a6afd38e (diff) | |
download | src-9309a460b23a8cda8d47c5f775da7fc6472d9925.tar.gz src-9309a460b23a8cda8d47c5f775da7fc6472d9925.zip |
Implement GEOM::rotation_rate for gmirror
If all of the mirror's children have the same rotation rate, report
that. But if they have mixed rotation rates, or if any child has an
unknown rotation rate, report "Unknown".
MFC after: 2 weeks
Sponsored by: Axcient
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D39458
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/mirror/g_mirror.c | 29 | ||||
-rw-r--r-- | sys/geom/mirror/g_mirror.h | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index 94e615c8038d..9153345cc7e2 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <geom/geom.h> #include <geom/geom_dbg.h> +#include <geom/geom_disk.h> #include <geom/mirror/g_mirror.h> FEATURE(geom_mirror, "GEOM mirroring support"); @@ -479,6 +480,10 @@ g_mirror_init_disk(struct g_mirror_softc *sc, struct g_provider *pp, error = g_getattr("GEOM::candelete", disk->d_consumer, &i); if (error == 0 && i != 0) disk->d_flags |= G_MIRROR_DISK_FLAG_CANDELETE; + error = g_getattr("GEOM::rotation_rate", disk->d_consumer, + &disk->d_rotation_rate); + if (error) + disk->d_rotation_rate = DISK_RR_UNKNOWN; if (md->md_provider[0] != '\0') disk->d_flags |= G_MIRROR_DISK_FLAG_HARDCODED; disk->d_sync.ds_consumer = NULL; @@ -1148,6 +1153,27 @@ g_mirror_kernel_dump(struct bio *bp) } static void +g_mirror_rotation_rate(struct bio *bp) +{ + struct g_mirror_softc *sc; + struct g_mirror_disk *disk; + bool first = true; + uint16_t rr = DISK_RR_UNKNOWN; + + sc = bp->bio_to->private; + LIST_FOREACH(disk, &sc->sc_disks, d_next) { + if (first) + rr = disk->d_rotation_rate; + else if (rr != disk->d_rotation_rate) { + rr = DISK_RR_UNKNOWN; + break; + } + first = false; + } + g_handleattr(bp, "GEOM::rotation_rate", &rr, sizeof(rr)); +} + +static void g_mirror_start(struct bio *bp) { struct g_mirror_softc *sc; @@ -1176,6 +1202,9 @@ g_mirror_start(struct bio *bp) } else if (strcmp("GEOM::kerneldump", bp->bio_attribute) == 0) { g_mirror_kernel_dump(bp); return; + } else if (!strcmp(bp->bio_attribute, "GEOM::rotation_rate")) { + g_mirror_rotation_rate(bp); + return; } /* FALLTHROUGH */ default: diff --git a/sys/geom/mirror/g_mirror.h b/sys/geom/mirror/g_mirror.h index 7cec94adae18..09436ec164e6 100644 --- a/sys/geom/mirror/g_mirror.h +++ b/sys/geom/mirror/g_mirror.h @@ -139,6 +139,7 @@ struct g_mirror_disk { u_int d_init_ndisks; /* Initial number of mirror components */ uint32_t d_init_slice; /* Initial slice size */ uint8_t d_init_balance;/* Initial balance */ + uint16_t d_rotation_rate;/* Disk's rotation rate */ uint64_t d_init_mediasize;/* Initial mediasize */ }; #define d_name d_consumer->provider->name |