linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Jens Axboe <jens.axboe@oracle.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	rwheeler@redhat.com, snitzer@redhat.com, neilb@suse.de,
	James.Bottomley@hansenpartnership.com, dgilbert@interlog.com,
	linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 5 of 8] sd: Detect non-rotational devices
Date: Thu, 23 Apr 2009 07:58:21 -0400	[thread overview]
Message-ID: <49F057DD.6090009@garzik.org> (raw)
In-Reply-To: <20090423113841.GK1926@parisc-linux.org>

Matthew Wilcox wrote:
> On Thu, Apr 23, 2009 at 07:09:37AM -0400, Jeff Garzik wrote:
>> Jens Axboe wrote:
>>>> +	/* Block Device Characteristics VPD */
>>>> +	buffer = scsi_get_vpd_page(sdkp->device, 0xb1);
>>>> +
>>>> +	if (buffer == NULL)
>>>> +		return;
>>>> +
>>>> +	rot = get_unaligned_be16(&buffer[4]);
>>> Make sure this works for libata as well, and then kill the rotational
>>> check in there instead.
>> Yep.  libata-scsi.c would need to simulate that VPD page.
> 
> I already did that.  The only problem is that you made me include the stupid:
> 
>         if (ata_id_major_version(args->id) > 7) {
> 
> so of course it doesn't work on any existing hardware.  How about
> applying this patch:
> 
> ----
> 
> libata: fill in b1 page for all drives, not just ATA-8
> 
> Some of the drives on the market fill in the rotational speed and form
> factor correctly, even though they claim support for an earlier version
> of ATA.  The current ata_id_is_ssd() code doesn't check the version
> number and doesn't appear to have caused any trouble.  Besides, SCSI devices
> are also capable of returning garbage in these fields.
> 
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 2733b0c..59358ca 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2144,11 +2144,9 @@ static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf)
>  {
>  	rbuf[1] = 0xb1;
>  	rbuf[3] = 0x3c;
> -	if (ata_id_major_version(args->id) > 7) {
> -		rbuf[4] = args->id[217] >> 8;
> -		rbuf[5] = args->id[217];
> -		rbuf[7] = args->id[168] & 0xf;
> -	}
> +	rbuf[4] = args->id[217] >> 8;
> +	rbuf[5] = args->id[217];
> +	rbuf[7] = args->id[168] & 0xf;

Thus returning undefined garbage for the vast majority of ATA devices? 
Might as well admit that a call to get_random_bytes() is a valid 
implementation, at that point.

Linux users deserve more than that :)

If you want to find a better test than "version > 7", that is fine.

Surely a few minutes of thinking and a few minutes of research will 
yield a reasonable hueristic, that gives a reasonable estimation of 
when/if these fields are valid?

linux/ata.h is filled with examples of proper range checking -- ensuring 
that a range of IDENTIFY DEVICE words are valid.  There are also typical 
tests such as assuming values other than 0x0000 and 0xffff are valid.


>> Also (to mkp or whoever does the work) -- note Linus's comment, and my 
>> provisional patch[1], about libata potentially wanting to detect NONROT 
>> by looking for "*SSD" from IDENTIFY DEVICE'S model string.
> 
> Found it ... and Jens' suggestion that this be done in userspace instead.

It is trivial to do in the kernel, where we already match against model 
info for a long list of quirks.

Therefore, I think the Just Works(tm) value to SSD owners is higher. 
That way old userlands work with SSDs too.

	Jeff




  reply	other threads:[~2009-04-23 11:58 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-23  5:29 [PATCH 0 of 8] I/O topology patch kit Martin K. Petersen
2009-04-23  5:29 ` [PATCH 1 of 8] block: Expose stacked device queues in sysfs Martin K. Petersen
2009-04-23  5:29 ` [PATCH 2 of 8] block: Export I/O topology for block devices and partitions Martin K. Petersen
2009-04-23 10:51   ` Jens Axboe
2009-04-23 11:49     ` Matthew Wilcox
2009-04-23 11:55       ` Jens Axboe
2009-04-23 13:22         ` Matthew Wilcox
2009-04-23 13:30           ` Matthew Wilcox
2009-04-23 13:17     ` Martin K. Petersen
2009-04-23 18:13     ` Konrad Rzeszutek
2009-04-23 18:26       ` Ric Wheeler
2009-04-23 18:44         ` Matthew Wilcox
2009-04-23 18:34       ` Martin K. Petersen
2009-04-23  5:29 ` [PATCH 3 of 8] MD: Use new topology calls to indicate alignment and I/O sizes Martin K. Petersen
2009-04-23  5:29 ` [PATCH 4 of 8] sd: Physical block size and alignment support Martin K. Petersen
2009-04-23 16:37   ` Konrad Rzeszutek
2009-04-23 18:25     ` Martin K. Petersen
2009-04-23 18:44       ` Konrad Rzeszutek
2009-04-23 19:02         ` Martin K. Petersen
2009-04-23  5:29 ` [PATCH 5 of 8] sd: Detect non-rotational devices Martin K. Petersen
2009-04-23 10:52   ` Jens Axboe
2009-04-23 11:09     ` Jeff Garzik
2009-04-23 11:13       ` Jens Axboe
2009-04-23 11:22         ` Jeff Garzik
2009-04-23 11:38       ` Matthew Wilcox
2009-04-23 11:58         ` Jeff Garzik [this message]
2009-04-23 12:03           ` Jens Axboe
2009-04-23 13:16         ` Martin K. Petersen
2009-04-23 13:33           ` Jeff Garzik
2009-04-23 14:10             ` James Bottomley
2009-04-23 14:16               ` Matthew Wilcox
2009-04-23 14:39                 ` Jeff Garzik
2009-04-23 17:25                   ` Matthew Wilcox
2009-04-23 17:37                     ` James Bottomley
2009-04-23  5:29 ` [PATCH 6 of 8] sd: Block limits VPD support Martin K. Petersen
2009-04-23  5:29 ` [PATCH 7 of 8] scsi_debug: Add support for physical block exponent and alignment Martin K. Petersen
2009-04-23  5:29 ` [PATCH 8 of 8] libata: Report disk alignment and physical block size Martin K. Petersen
2009-04-23 13:46   ` Matthew Wilcox
2009-04-23 14:05     ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49F057DD.6090009@garzik.org \
    --to=jeff@garzik.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=dgilbert@interlog.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=matthew@wil.cx \
    --cc=neilb@suse.de \
    --cc=rwheeler@redhat.com \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).