svn commit: r312405 - in stable/11/sys: cam/nvme dev/mmc dev/nand dev/nvd geom
Alexander Motin
mav at FreeBSD.org
Thu Jan 19 11:16:27 UTC 2017
Author: mav
Date: Thu Jan 19 11:16:25 2017
New Revision: 312405
URL: https://svnweb.freebsd.org/changeset/base/312405
Log:
MFC r311971: Report random flash storage as non-rotating to GEOM_DISK.
While doing it, introduce respective constants in geom_disk.h.
Modified:
stable/11/sys/cam/nvme/nvme_da.c
stable/11/sys/dev/mmc/mmcsd.c
stable/11/sys/dev/nand/nand_geom.c
stable/11/sys/dev/nvd/nvd.c
stable/11/sys/geom/geom_disk.c
stable/11/sys/geom/geom_disk.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/cam/nvme/nvme_da.c
==============================================================================
--- stable/11/sys/cam/nvme/nvme_da.c Thu Jan 19 08:01:35 2017 (r312404)
+++ stable/11/sys/cam/nvme/nvme_da.c Thu Jan 19 11:16:25 2017 (r312405)
@@ -761,7 +761,7 @@ ndaregister(struct cam_periph *periph, v
MIN(sizeof(softc->disk->d_descr), sizeof(cd->mn)));
strlcpy(softc->disk->d_ident, cd->sn,
MIN(sizeof(softc->disk->d_ident), sizeof(cd->sn)));
- disk->d_rotation_rate = 0; /* Spinning rust need not apply */
+ disk->d_rotation_rate = DISK_RR_NON_ROTATING;
disk->d_open = ndaopen;
disk->d_close = ndaclose;
disk->d_strategy = ndastrategy;
Modified: stable/11/sys/dev/mmc/mmcsd.c
==============================================================================
--- stable/11/sys/dev/mmc/mmcsd.c Thu Jan 19 08:01:35 2017 (r312404)
+++ stable/11/sys/dev/mmc/mmcsd.c Thu Jan 19 11:16:25 2017 (r312405)
@@ -170,6 +170,7 @@ mmcsd_attach(device_t dev)
d->d_delmaxsize = mmc_get_erase_sector(dev) * d->d_sectorsize;
strlcpy(d->d_ident, mmc_get_card_sn_string(dev), sizeof(d->d_ident));
strlcpy(d->d_descr, mmc_get_card_id_string(dev), sizeof(d->d_descr));
+ d->d_rotation_rate = DISK_RR_NON_ROTATING;
/*
* Display in most natural units. There's no cards < 1MB. The SD
Modified: stable/11/sys/dev/nand/nand_geom.c
==============================================================================
--- stable/11/sys/dev/nand/nand_geom.c Thu Jan 19 08:01:35 2017 (r312404)
+++ stable/11/sys/dev/nand/nand_geom.c Thu Jan 19 11:16:25 2017 (r312405)
@@ -394,6 +394,7 @@ create_geom_disk(struct nand_chip *chip)
snprintf(ndisk->d_ident, sizeof(ndisk->d_ident),
"nand: Man:0x%02x Dev:0x%02x", chip->id.man_id, chip->id.dev_id);
+ ndisk->d_rotation_rate = DISK_RR_NON_ROTATING;
disk_create(ndisk, DISK_VERSION);
@@ -415,6 +416,7 @@ create_geom_disk(struct nand_chip *chip)
snprintf(rdisk->d_ident, sizeof(rdisk->d_ident),
"nand_raw: Man:0x%02x Dev:0x%02x", chip->id.man_id,
chip->id.dev_id);
+ disk->d_rotation_rate = DISK_RR_NON_ROTATING;
disk_create(rdisk, DISK_VERSION);
Modified: stable/11/sys/dev/nvd/nvd.c
==============================================================================
--- stable/11/sys/dev/nvd/nvd.c Thu Jan 19 08:01:35 2017 (r312404)
+++ stable/11/sys/dev/nvd/nvd.c Thu Jan 19 11:16:25 2017 (r312405)
@@ -338,13 +338,11 @@ nvd_new_disk(struct nvme_namespace *ns,
*/
nvme_strvis(disk->d_ident, nvme_ns_get_serial_number(ns),
sizeof(disk->d_ident), NVME_SERIAL_NUMBER_LENGTH);
-
nvme_strvis(descr, nvme_ns_get_model_number(ns), sizeof(descr),
NVME_MODEL_NUMBER_LENGTH);
-
-#if __FreeBSD_version >= 900034
strlcpy(disk->d_descr, descr, sizeof(descr));
-#endif
+
+ disk->d_rotation_rate = DISK_RR_NON_ROTATING;
ndisk->ns = ns;
ndisk->disk = disk;
Modified: stable/11/sys/geom/geom_disk.c
==============================================================================
--- stable/11/sys/geom/geom_disk.c Thu Jan 19 08:01:35 2017 (r312404)
+++ stable/11/sys/geom/geom_disk.c Thu Jan 19 11:16:25 2017 (r312405)
@@ -586,12 +586,12 @@ g_disk_dumpconf(struct sbuf *sb, const c
* special cases, and there's also a valid range.
*/
sbuf_printf(sb, "%s<rotationrate>", indent);
- if (dp->d_rotation_rate == 0) /* Old drives don't */
- sbuf_printf(sb, "unknown"); /* report RPM. */
- else if (dp->d_rotation_rate == 1) /* Since 0 is used */
- sbuf_printf(sb, "0"); /* above, SSDs use 1. */
- else if ((dp->d_rotation_rate >= 0x041) &&
- (dp->d_rotation_rate <= 0xfffe))
+ if (dp->d_rotation_rate == DISK_RR_UNKNOWN) /* Old drives */
+ sbuf_printf(sb, "unknown"); /* don't report RPM. */
+ else if (dp->d_rotation_rate == DISK_RR_NON_ROTATING)
+ sbuf_printf(sb, "0");
+ else if ((dp->d_rotation_rate >= DISK_RR_MIN) &&
+ (dp->d_rotation_rate <= DISK_RR_MAX))
sbuf_printf(sb, "%u", dp->d_rotation_rate);
else
sbuf_printf(sb, "invalid");
Modified: stable/11/sys/geom/geom_disk.h
==============================================================================
--- stable/11/sys/geom/geom_disk.h Thu Jan 19 08:01:35 2017 (r312404)
+++ stable/11/sys/geom/geom_disk.h Thu Jan 19 11:16:25 2017 (r312405)
@@ -119,6 +119,11 @@ struct disk {
#define DISKFLAG_DIRECT_COMPLETION 0x20
#define DISKFLAG_CANZONE 0x80
+#define DISK_RR_UNKNOWN 0
+#define DISK_RR_NON_ROTATING 1
+#define DISK_RR_MIN 0x0401
+#define DISK_RR_MAX 0xfffe
+
struct disk *disk_alloc(void);
void disk_create(struct disk *disk, int version);
void disk_destroy(struct disk *disk);
More information about the svn-src-stable
mailing list