Add GEOM attribute to report physical device name, and report it
via 'diskinfo -v'. This avoids the need to track it down via CAM, and should also work for disks that don't use CAM. And since it's inherited thru the GEOM hierarchy, in most cases one doesn't need to walk the GEOM graph either, eg you can use it on a partition instead of disk itself. Reviewed by: allanjude, imp Sponsored by: Klara Inc Differential Revision: https://reviews.freebsd.org/D22249
This commit is contained in:
parent
461587dc9b
commit
b5961be1ab
@ -3420,6 +3420,8 @@ adasetgeom(struct ada_softc *softc, struct ccb_getdev *cgd)
|
||||
softc->disk->d_fwheads = softc->params.heads;
|
||||
ata_disk_firmware_geom_adjust(softc->disk);
|
||||
softc->disk->d_rotation_rate = cgd->ident_data.media_rotation_rate;
|
||||
snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment),
|
||||
"%s%d", softc->cpi.dev_name, softc->cpi.unit_number);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1532,6 +1532,8 @@ sdda_add_part(struct cam_periph *periph, u_int type, const char *name,
|
||||
part->disk->d_hba_device = cpi.hba_device;
|
||||
part->disk->d_hba_subvendor = cpi.hba_subvendor;
|
||||
part->disk->d_hba_subdevice = cpi.hba_subdevice;
|
||||
snprintf(part->disk->d_attachment, sizeof(part->disk->d_attachment),
|
||||
"%s%d", cpi.dev_name, cpi.unit_number);
|
||||
|
||||
part->disk->d_sectorsize = mmc_get_sector_size(periph);
|
||||
part->disk->d_mediasize = media_size;
|
||||
|
@ -815,6 +815,8 @@ ndaregister(struct cam_periph *periph, void *arg)
|
||||
disk->d_hba_device = cpi.hba_device;
|
||||
disk->d_hba_subvendor = cpi.hba_subvendor;
|
||||
disk->d_hba_subdevice = cpi.hba_subdevice;
|
||||
snprintf(disk->d_attachment, sizeof(disk->d_attachment),
|
||||
"%s%d", cpi.dev_name, cpi.unit_number);
|
||||
disk->d_stripesize = disk->d_sectorsize;
|
||||
disk->d_stripeoffset = 0;
|
||||
disk->d_devstat = devstat_new_entry(periph->periph_name,
|
||||
|
@ -702,6 +702,8 @@ cdregister(struct cam_periph *periph, void *arg)
|
||||
softc->disk->d_hba_device = cpi.hba_device;
|
||||
softc->disk->d_hba_subvendor = cpi.hba_subvendor;
|
||||
softc->disk->d_hba_subdevice = cpi.hba_subdevice;
|
||||
snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment),
|
||||
"%s%d", cpi.dev_name, cpi.unit_number);
|
||||
|
||||
/*
|
||||
* Acquire a reference to the periph before we register with GEOM.
|
||||
|
@ -2875,6 +2875,8 @@ daregister(struct cam_periph *periph, void *arg)
|
||||
softc->disk->d_hba_device = cpi.hba_device;
|
||||
softc->disk->d_hba_subvendor = cpi.hba_subvendor;
|
||||
softc->disk->d_hba_subdevice = cpi.hba_subdevice;
|
||||
snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment),
|
||||
"%s%d", cpi.dev_name, cpi.unit_number);
|
||||
|
||||
/*
|
||||
* Acquire a reference to the periph before we register with GEOM.
|
||||
|
@ -528,7 +528,10 @@ g_disk_start(struct bio *bp)
|
||||
else if (g_handleattr_uint16_t(bp, "GEOM::rotation_rate",
|
||||
dp->d_rotation_rate))
|
||||
break;
|
||||
else
|
||||
else if (g_handleattr_str(bp, "GEOM::attachment",
|
||||
dp->d_attachment))
|
||||
break;
|
||||
else
|
||||
error = ENOIOCTL;
|
||||
break;
|
||||
case BIO_FLUSH:
|
||||
|
@ -118,6 +118,7 @@ struct disk {
|
||||
uint16_t d_hba_subvendor;
|
||||
uint16_t d_hba_subdevice;
|
||||
uint16_t d_rotation_rate;
|
||||
char d_attachment[DISK_IDENT_SIZE];
|
||||
|
||||
/* Fields private to the driver */
|
||||
void *d_drv1;
|
||||
|
@ -251,6 +251,10 @@ main(int argc, char **argv)
|
||||
printf("\t%-12s\t# Disk descr.\n", arg.value.str);
|
||||
if (ioctl(fd, DIOCGIDENT, ident) == 0)
|
||||
printf("\t%-12s\t# Disk ident.\n", ident);
|
||||
strlcpy(arg.name, "GEOM::attachment", sizeof(arg.name));
|
||||
arg.len = sizeof(arg.value.str);
|
||||
if (ioctl(fd, DIOCGATTR, &arg) == 0)
|
||||
printf("\t%-12s\t# Attachment\n", arg.value.str);
|
||||
if (ioctl(fd, DIOCGPHYSPATH, physpath) == 0)
|
||||
printf("\t%-12s\t# Physical path\n", physpath);
|
||||
printf("\t%-12s\t# TRIM/UNMAP support\n",
|
||||
|
Loading…
Reference in New Issue
Block a user