public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi_debug: unify scsi_level in proc and sysfs
@ 2014-01-21  9:52 Sha Zhengju
  2014-01-21 15:07 ` Douglas Gilbert
  0 siblings, 1 reply; 3+ messages in thread
From: Sha Zhengju @ 2014-01-21  9:52 UTC (permalink / raw)
  To: linux-scsi; +Cc: Sha Zhengju

From: Sha Zhengju <handai.szj@taobao.com>

There're severel interfaces to show scsi_level value of scsi_debug,
but they're not in consistent. E.g:

1)
#cat /sys/bus/pseudo/drivers/scsi_debug/scsi_level
5

2)
#cat /proc/scsi/scsi_debug/7
scsi_debug adapter driver, version 1.82 [20100324]
num_tgts=1, shared (ram) size=1024 MB, opts=0x0, every_nth=0(curr:0)
delay=1, max_luns=1, scsi_level=5
sector_size=512 bytes, cylinders=130, heads=255, sectors=63
number of aborts=0, device_reset=0, bus_resets=0, host_resets=0
dix_reads=0 dix_writes=0 dif_errors=0

3)
#cat /sys/bus/scsi/devices/7\:0\:0\:0/scsi_level (or lsscsi -l)
6

According to the description in scsi.h, "struct scsi_device::scsi_level
values. For SCSI devices other than those prior to SCSI-2 (i.e. over
12 years old) this value is (resp[2] + 1) where 'resp' is a byte array
of the response to an INQUIRY". For scsi_debug, the resp[2] of INQUIRY
is 5 which indicates using SPC-3, but the sysfs's scsi_level will show 6.

The aboving 1) and 2) entry export resp[2] of INQUIRY directly, unify
them with 3) which is resp[2] + 1.

Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
---
 drivers/scsi/scsi_debug.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 80b8b10..a52d0687 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -2866,7 +2866,7 @@ static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host)
 	    SCSI_DEBUG_VERSION, scsi_debug_version_date, scsi_debug_num_tgts,
 	    scsi_debug_dev_size_mb, scsi_debug_opts, scsi_debug_every_nth,
 	    scsi_debug_cmnd_count, scsi_debug_delay,
-	    scsi_debug_max_luns, scsi_debug_scsi_level,
+	    scsi_debug_max_luns, scsi_debug_scsi_level + 1,
 	    scsi_debug_sector_size, sdebug_cylinders_per, sdebug_heads,
 	    sdebug_sectors_per, num_aborts, num_dev_resets, num_bus_resets,
 	    num_host_resets, dix_reads, dix_writes, dif_errors);
@@ -3091,7 +3091,7 @@ DRIVER_ATTR(no_uld, S_IRUGO, sdebug_no_uld_show, NULL);
 
 static ssize_t sdebug_scsi_level_show(struct device_driver * ddp, char * buf)
 {
-        return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level);
+        return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level + 1);
 }
 DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-22  5:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-21  9:52 [PATCH] scsi_debug: unify scsi_level in proc and sysfs Sha Zhengju
2014-01-21 15:07 ` Douglas Gilbert
2014-01-22  5:48   ` Sha Zhengju

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox