svn commit: r312406 - in stable/10/sys: dev/mmc dev/nand dev/nvd geom
Alexander Motin
mav at FreeBSD.org
Thu Jan 19 11:17:11 UTC 2017
Author: mav
Date: Thu Jan 19 11:17:09 2017
New Revision: 312406
URL: https://svnweb.freebsd.org/changeset/base/312406
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/10/sys/dev/mmc/mmcsd.c
stable/10/sys/dev/nand/nand_geom.c
stable/10/sys/dev/nvd/nvd.c
stable/10/sys/geom/geom_disk.c
stable/10/sys/geom/geom_disk.h
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/dev/mmc/mmcsd.c
==============================================================================
--- stable/10/sys/dev/mmc/mmcsd.c Thu Jan 19 11:16:25 2017 (r312405)
+++ stable/10/sys/dev/mmc/mmcsd.c Thu Jan 19 11:17:09 2017 (r312406)
@@ -169,6 +169,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/10/sys/dev/nand/nand_geom.c
==============================================================================
--- stable/10/sys/dev/nand/nand_geom.c Thu Jan 19 11:16:25 2017 (r312405)
+++ stable/10/sys/dev/nand/nand_geom.c Thu Jan 19 11:17:09 2017 (r312406)
@@ -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/10/sys/dev/nvd/nvd.c
==============================================================================
--- stable/10/sys/dev/nvd/nvd.c Thu Jan 19 11:16:25 2017 (r312405)
+++ stable/10/sys/dev/nvd/nvd.c Thu Jan 19 11:17:09 2017 (r312406)
@@ -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/10/sys/geom/geom_disk.c
==============================================================================
--- stable/10/sys/geom/geom_disk.c Thu Jan 19 11:16:25 2017 (r312405)
+++ stable/10/sys/geom/geom_disk.c Thu Jan 19 11:17:09 2017 (r312406)
@@ -589,12 +589,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/10/sys/geom/geom_disk.h
==============================================================================
--- stable/10/sys/geom/geom_disk.h Thu Jan 19 11:16:25 2017 (r312405)
+++ stable/10/sys/geom/geom_disk.h Thu Jan 19 11:17:09 2017 (r312406)
@@ -113,6 +113,11 @@ struct disk {
#define DISKFLAG_DIRECT_COMPLETION 0x20
#define DISKFLAG_LACKS_ROTRATE 0x40
+#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