linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: rwheeler@redhat.com, snitzer@redhat.com, jeff@garzik.org,
	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 12:52:45 +0200	[thread overview]
Message-ID: <20090423105245.GX4593@kernel.dk> (raw)
In-Reply-To: <d14109aa6209be628074.1240464572@sermon.lab.mkp.net>

On Thu, Apr 23 2009, Martin K. Petersen wrote:
> Detect non-rotational devices and set the queue flag accordingly.
> 
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> 
> ---
> 1 file changed, 27 insertions(+)
> drivers/scsi/sd.c |   27 +++++++++++++++++++++++++++
> 
> 
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -50,6 +50,7 @@
>  #include <linux/string_helpers.h>
>  #include <linux/async.h>
>  #include <asm/uaccess.h>
> +#include <asm/unaligned.h>
>  
>  #include <scsi/scsi.h>
>  #include <scsi/scsi_cmnd.h>
> @@ -1800,6 +1801,29 @@ void sd_read_app_tag_own(struct scsi_dis
>  }
>  
>  /**
> + * sd_read_block_characteristics - Query block dev. characteristics
> + * @disk: disk to query
> + */
> +static void sd_read_block_characteristics(struct scsi_disk *sdkp)
> +{
> +	char *buffer;
> +	u16 rot;
> +
> +	/* Block Device Characteristics VPD */
> +	buffer = scsi_get_vpd_page(sdkp->device, 0xb1);
> +
> +	if (buffer == NULL)
> +		return;
> +
> +	rot = get_unaligned_be16(&buffer[4]);
> +
> +	if (rot == 1)
> +		queue_flag_set_unlocked(QUEUE_FLAG_NONROT, sdkp->disk->queue);
> +
> +	kfree(buffer);
> +}
> +
> +/**
>   *	sd_revalidate_disk - called the first time a new disk is seen,
>   *	performs disk spin up, read_capacity, etc.
>   *	@disk: struct gendisk we care about
> @@ -1836,6 +1860,7 @@ static int sd_revalidate_disk(struct gen
>  	 */
>  	if (sdkp->media_present) {
>  		sd_read_capacity(sdkp, buffer);
> +		sd_read_block_characteristics(sdkp);
>  		sd_read_write_protect_flag(sdkp, buffer);
>  		sd_read_cache_type(sdkp, buffer);
>  		sd_read_app_tag_own(sdkp, buffer);
> @@ -1976,6 +2001,8 @@ static void sd_probe_async(void *data, a
>  	add_disk(gd);
>  	sd_dif_config_host(sdkp);
>  
> +	sd_revalidate_disk(gd);
> +
>  	sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
>  		  sdp->removable ? "removable " : "");

Make sure this works for libata as well, and then kill the rotational
check in there instead.

-- 
Jens Axboe


  reply	other threads:[~2009-04-23 10:52 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 [this message]
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
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=20090423105245.GX4593@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=dgilbert@interlog.com \
    --cc=jeff@garzik.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --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).