Report random flash storage as non-rotating to GEOM_DISK.
While doing it, introduce respective constants in geom_disk.h. MFC after: 1 week
This commit is contained in:
parent
9527fa4f66
commit
17160457b4
@ -761,7 +761,7 @@ ndaregister(struct cam_periph *periph, void *arg)
|
||||
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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -352,13 +352,11 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg)
|
||||
*/
|
||||
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;
|
||||
|
@ -588,12 +588,12 @@ g_disk_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g
|
||||
* 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");
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user