* SCSI post-merge topology bits
@ 2009-05-23 15:43 Martin K. Petersen
2009-05-23 15:43 ` [PATCH 1/3] sd: Physical block size and alignment support Martin K. Petersen
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Martin K. Petersen @ 2009-05-23 15:43 UTC (permalink / raw)
To: james.bottomley, linux-scsi
These are the sd patches that sit on top of the block topology patches
which are now in Jens' for-2.6.31 tree.
Against scsi-post-merge-2.6.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] sd: Physical block size and alignment support
2009-05-23 15:43 SCSI post-merge topology bits Martin K. Petersen
@ 2009-05-23 15:43 ` Martin K. Petersen
2009-06-18 17:02 ` James Bottomley
2009-05-23 15:43 ` [PATCH 2/3] sd: Detect non-rotational devices Martin K. Petersen
2009-05-23 15:43 ` [PATCH 3/3] sd: Block limits VPD support Martin K. Petersen
2 siblings, 1 reply; 5+ messages in thread
From: Martin K. Petersen @ 2009-05-23 15:43 UTC (permalink / raw)
To: james.bottomley, linux-scsi; +Cc: Martin K. Petersen
Extract physical block size and lowest aligned LBA from READ
CAPACITY(16) response and adjust queue parameters.
Report physical block size and alignment when applicable.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/sd.c | 23 +++++++++++++++++++++--
drivers/scsi/sd.h | 1 +
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index bcf3bd4..fd5c580 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1307,6 +1307,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
int sense_valid = 0;
int the_result;
int retries = 3;
+ unsigned int alignment;
unsigned long long lba;
unsigned sector_size;
@@ -1358,6 +1359,16 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
return -EOVERFLOW;
}
+ /* Logical blocks per physical block exponent */
+ sdkp->hw_sector_size = (1 << (buffer[13] & 0xf)) * sector_size;
+
+ /* Lowest aligned logical block */
+ alignment = ((buffer[14] & 0x3f) << 8 | buffer[15]) * sector_size;
+ blk_queue_alignment_offset(sdp->request_queue, alignment);
+ if (alignment && sdkp->first_scan)
+ sd_printk(KERN_NOTICE, sdkp,
+ "physical block alignment offset: %u\n", alignment);
+
sdkp->capacity = lba + 1;
return sector_size;
}
@@ -1409,6 +1420,7 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
}
sdkp->capacity = lba + 1;
+ sdkp->hw_sector_size = sector_size;
return sector_size;
}
@@ -1521,11 +1533,17 @@ got_data:
string_get_size(sz, STRING_UNITS_10, cap_str_10,
sizeof(cap_str_10));
- if (sdkp->first_scan || old_capacity != sdkp->capacity)
+ if (sdkp->first_scan || old_capacity != sdkp->capacity) {
sd_printk(KERN_NOTICE, sdkp,
- "%llu %d-byte hardware sectors: (%s/%s)\n",
+ "%llu %d-byte logical blocks: (%s/%s)\n",
(unsigned long long)sdkp->capacity,
sector_size, cap_str_10, cap_str_2);
+
+ if (sdkp->hw_sector_size != sector_size)
+ sd_printk(KERN_NOTICE, sdkp,
+ "%u-byte physical blocks\n",
+ sdkp->hw_sector_size);
+ }
}
/* Rescale capacity to 512-byte units */
@@ -1538,6 +1556,7 @@ got_data:
else if (sector_size == 256)
sdkp->capacity >>= 1;
+ blk_queue_physical_block_size(sdp->request_queue, sdkp->hw_sector_size);
sdkp->device->sector_size = sector_size;
}
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 708778c..8474b5b 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -45,6 +45,7 @@ struct scsi_disk {
unsigned int openers; /* protected by BKL for now, yuck */
sector_t capacity; /* size in 512-byte sectors */
u32 index;
+ unsigned short hw_sector_size;
u8 media_present;
u8 write_prot;
u8 protection_type;/* Data Integrity Field */
--
1.6.0.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] sd: Detect non-rotational devices
2009-05-23 15:43 SCSI post-merge topology bits Martin K. Petersen
2009-05-23 15:43 ` [PATCH 1/3] sd: Physical block size and alignment support Martin K. Petersen
@ 2009-05-23 15:43 ` Martin K. Petersen
2009-05-23 15:43 ` [PATCH 3/3] sd: Block limits VPD support Martin K. Petersen
2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2009-05-23 15:43 UTC (permalink / raw)
To: james.bottomley, linux-scsi; +Cc: Martin K. Petersen
Detect non-rotational devices and set the queue flag accordingly.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/sd.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fd5c580..2f3a78e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1795,6 +1795,29 @@ void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
}
/**
+ * 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
@@ -1831,6 +1854,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
*/
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);
@@ -1971,6 +1995,8 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
add_disk(gd);
sd_dif_config_host(sdkp);
+ sd_revalidate_disk(gd);
+
sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
sdp->removable ? "removable " : "");
--
1.6.0.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] sd: Block limits VPD support
2009-05-23 15:43 SCSI post-merge topology bits Martin K. Petersen
2009-05-23 15:43 ` [PATCH 1/3] sd: Physical block size and alignment support Martin K. Petersen
2009-05-23 15:43 ` [PATCH 2/3] sd: Detect non-rotational devices Martin K. Petersen
@ 2009-05-23 15:43 ` Martin K. Petersen
2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2009-05-23 15:43 UTC (permalink / raw)
To: james.bottomley, linux-scsi; +Cc: Martin K. Petersen
Query the block limits VPD page and adjust queue minimum and optimal I/O
sizes.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/sd.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2f3a78e..d4eb5a4 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1795,6 +1795,29 @@ void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
}
/**
+ * sd_read_block_limits - Query disk device for preferred I/O sizes.
+ * @disk: disk to query
+ */
+static void sd_read_block_limits(struct scsi_disk *sdkp)
+{
+ unsigned int sector_sz = sdkp->device->sector_size;
+ char *buffer;
+
+ /* Block Limits VPD */
+ buffer = scsi_get_vpd_page(sdkp->device, 0xb0);
+
+ if (buffer == NULL)
+ return;
+
+ blk_queue_io_min(sdkp->disk->queue,
+ get_unaligned_be16(&buffer[6]) * sector_sz);
+ blk_queue_io_opt(sdkp->disk->queue,
+ get_unaligned_be32(&buffer[12]) * sector_sz);
+
+ kfree(buffer);
+}
+
+/**
* sd_read_block_characteristics - Query block dev. characteristics
* @disk: disk to query
*/
@@ -1854,6 +1877,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
*/
if (sdkp->media_present) {
sd_read_capacity(sdkp, buffer);
+ sd_read_block_limits(sdkp);
sd_read_block_characteristics(sdkp);
sd_read_write_protect_flag(sdkp, buffer);
sd_read_cache_type(sdkp, buffer);
--
1.6.0.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] sd: Physical block size and alignment support
2009-05-23 15:43 ` [PATCH 1/3] sd: Physical block size and alignment support Martin K. Petersen
@ 2009-06-18 17:02 ` James Bottomley
0 siblings, 0 replies; 5+ messages in thread
From: James Bottomley @ 2009-06-18 17:02 UTC (permalink / raw)
To: Martin K. Petersen; +Cc: linux-scsi
On Sat, 2009-05-23 at 11:43 -0400, Martin K. Petersen wrote:
> Extract physical block size and lowest aligned LBA from READ
> CAPACITY(16) response and adjust queue parameters.
>
> Report physical block size and alignment when applicable.
Checkpatch reports one trailing whitespace (I fixed it up):
ERROR: trailing whitespace
#40: FILE: drivers/scsi/sd.c:1369:
+^I^Isd_printk(KERN_NOTICE, sdkp, $
total: 1 errors, 0 warnings, 63 lines checked
James
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-18 23:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-23 15:43 SCSI post-merge topology bits Martin K. Petersen
2009-05-23 15:43 ` [PATCH 1/3] sd: Physical block size and alignment support Martin K. Petersen
2009-06-18 17:02 ` James Bottomley
2009-05-23 15:43 ` [PATCH 2/3] sd: Detect non-rotational devices Martin K. Petersen
2009-05-23 15:43 ` [PATCH 3/3] sd: Block limits VPD support Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox