From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Paulson-Ellis Date: Fri, 06 Jan 2006 13:34:59 +0000 Subject: Re: [PATCH] /dev/disk/by-id incomplete and unhelpful for SATA drives Message-Id: <43BE7203.8060404@edesix.com> List-Id: References: <20051221185518.GA9100@vrfy.org> <43A9CFE0.2070103@edesix.com> <20051222043527.GA13175@vrfy.org> <43AA8D0B.10504@edesix.com> <20051222183525.GA17871@devserv.devel.redhat.com> <43AB40E2.1050009@edesix.com> <20060106013640.GA27841@aracnet.com> <43BDDCAE.7000506@torque.net> <43BE6506.7090901@torque.net> In-Reply-To: <43BE6506.7090901@torque.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: dougg@torque.net Cc: patman@aracnet.com, Bill Nottingham , linux-hotplug-devel@lists.sourceforge.net, linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, jgarzik@pobox.com Douglas Gilbert wrote: > Douglas Gilbert wrote: > [snip] I can confirm that your patch works for me too. Original scsi_id output: # scsi_id -g -x -s /block/sda | grep ID_SERIAL ID_SERIAL TA_Maxtor_6Y160M0_Linux_ATA-SCSI_simulator After my patch: # scsi_id -g -x -s /block/sda | grep ID_SERIAL ID_SERIAL TA_Maxtor_6Y160M0_Y4DCTR3E After your patch: # scsi_id -g -x -s /block/sda | grep ID_SERIAL ID_SERIAL=1ATA_Maxtor_6Y160M0_Y4DCTR3E Note that it is still a bit different to the page 0x80 output, but I=20 don't think this matters (unless that '0' or '1' is a bug not a=20 feature). For my purposes, it just needs to be unique. # ( scsi_id -p 0x80 -g -x -s /block/sda ; \ scsi_id -p 0x83 -g -x -s /block/sda ) | grep ID_SERIAL ID_SERIAL=3DSATA_Maxtor_6Y160M0_Y4DCTR3E ID_SERIAL=1ATA_Maxtor_6Y160M0_Y4DCTR3E Many thanks, Chris. >=20 >=20 > The attachment adds the second item above to the patch > suggested by Chris Paulson-Ellis in: > http://marc.theaimsgroup.com/?l=3Dlinux-hotplug-devel&m=113529667019652&w= =3D2 >=20 > The patch is against lk 2.6.15 and was tested on a sil > controller with a Seagate ST380013AS sata disk. >=20 > Changelog: > - make existing libata VPD device identification page (0x83) > supply the ATA serial number in the libata "vendor > specific" designator (from Chris Paulson-Ellis) > - add a "t10 vendor id based" designator as defined in > SAT rev 07a (section 10.3.4.2.3) that supplies ATA > model and serial numbers > - make the libata VPD page 0x83 more extensible (for > adding more designators in the future). >=20 > Signed-off-by: Douglas Gilbert >=20 > Doug Gilbert >=20 >=20 >=20 > ------------------------------------------------------------------------ >=20 > --- linux/drivers/scsi/libata-scsi.c 2006-01-04 08:50:42.000000000 +1000 > +++ linux/drivers/scsi/libata-scsi.c2615vpd 2006-01-06 20:16:25.000000000= +1000 > @@ -1532,16 +1532,16 @@ > return 0; > } > =20 > -static const char *inq_83_str =3D "Linux ATA-SCSI simulator"; > - > /** > * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity > * @args: device IDENTIFY data / SCSI command of interest. > * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. > * @buflen: Response buffer length. > * > - * Returns device identification. Currently hardcoded to > - * return "Linux ATA-SCSI simulator". > + * Yields two logocal unit device identification designators: > + * - vendor specific ASCII containing the ATA serial number > + * - SAT defined "t10 vendor id based" containing ASCII vendor > + * name ("ATA "), model and serial numbers. > * > * LOCKING: > * spin_lock_irqsave(host_set lock) > @@ -1550,16 +1550,39 @@ > unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, > unsigned int buflen) > { > + int num; > + const int sat_model_serial_desc_len =3D 68; > + const int ata_model_byte_len =3D 40; > + > rbuf[1] =3D 0x83; /* this page code */ > - rbuf[3] =3D 4 + strlen(inq_83_str); /* page len */ > + num =3D 4; > =20 > - /* our one and only identification descriptor (vendor-specific) */ > - if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) { > - rbuf[4 + 0] =3D 2; /* code set: ASCII */ > - rbuf[4 + 3] =3D strlen(inq_83_str); > - memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str)); > + if (buflen > (ATA_SERNO_LEN + num + 3)) { > + /* piv=3D0, assoc=3Dlu, code_set=ACSII, designator=3Dvendor */ > + rbuf[num + 0] =3D 2;=09 > + rbuf[num + 3] =3D ATA_SERNO_LEN; > + num +=3D 4; > + ata_dev_id_string(args->id, (unsigned char *) rbuf + num, > + ATA_ID_SERNO_OFS, ATA_SERNO_LEN); > + num +=3D ATA_SERNO_LEN; > } > - > + if (buflen > (sat_model_serial_desc_len + num + 3)) { > + /* SAT defined lu model and serial numbers descriptor */ > + /* piv=3D0, assoc=3Dlu, code_set=ACSII, designator=3Dt10 vendor id */ > + rbuf[num + 0] =3D 2;=09 > + rbuf[num + 1] =3D 1;=09 > + rbuf[num + 3] =3D sat_model_serial_desc_len; > + num +=3D 4; > + strncpy(rbuf + num, "ATA ", 8); > + num +=3D 8; > + ata_dev_id_string(args->id, (unsigned char *) rbuf + num, > + ATA_ID_PROD_OFS, ata_model_byte_len); > + num +=3D ata_model_byte_len; > + ata_dev_id_string(args->id, (unsigned char *) rbuf + num, > + ATA_ID_SERNO_OFS, ATA_SERNO_LEN); > + num +=3D ATA_SERNO_LEN; > + } > + rbuf[3] =3D num - 4; /* page len (assume less than 256 bytes) */ > return 0; > } > =20 >=20 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dclick _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel