Linux boot Support for 4KB sector drives ?

2013-07-01 Thread Mahesh Rajashekhara
Hello,

Does any of the Linux OS flavors support booting from the 4K sector
(advanced format) drive  in legacy BIOS mode (MBR partitioning scheme) ?

Thanks  Regards,
Mahesh


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] tmscsim: Move 'last_reset' into host structure

2013-07-01 Thread Hannes Reinecke
The 'last_reset' value is only used internally, so move it into
the internal host structure.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/tmscsim.c | 14 +++---
 drivers/scsi/tmscsim.h |  1 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index 9327f5f..1142361 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -521,7 +521,7 @@ dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* 
pDCB, struct dc390_sr
pACB-SelConn++;
return 1;
 }
-if (time_before (jiffies, pACB-pScsiHost-last_reset))
+if (time_before (jiffies, pACB-last_reset))
 {
DEBUG0(printk (DC390: We were just reset and don't accept commands 
yet!\n));
return 1;
@@ -1863,7 +1863,7 @@ dc390_ScsiRstDetect( struct dc390_acb* pACB )
 /* delay half a second */
 udelay (1000);
 DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
-pACB-pScsiHost-last_reset = jiffies + 5*HZ/2
+pACB-last_reset = jiffies + 5*HZ/2
+ HZ * dc390_eepromBuf[pACB-AdapterIndex][EE_DELAY];
 pACB-Connected = 0;
 
@@ -2048,9 +2048,9 @@ static int DC390_bus_reset (struct scsi_cmnd *cmd)
 
dc390_ResetDevParam(pACB);
mdelay(1);
-   pACB-pScsiHost-last_reset = jiffies + 3*HZ/2 
+   pACB-last_reset = jiffies + 3*HZ/2
+ HZ * dc390_eepromBuf[pACB-AdapterIndex][EE_DELAY];
-
+
DC390_write8(ScsiCmd, CLEAR_FIFO_CMD);
DC390_read8(INT_Status);/* Reset Pending INT */
 
@@ -2383,7 +2383,7 @@ static void dc390_init_hw(struct dc390_acb *pACB, u8 
index)
if (pACB-Gmode2  RST_SCSI_BUS) {
dc390_ResetSCSIBus(pACB);
udelay(1000);
-   shost-last_reset = jiffies + HZ/2 +
+   pACB-last_reset = jiffies + HZ/2 +
HZ * dc390_eepromBuf[pACB-AdapterIndex][EE_DELAY];
}
 
@@ -2455,8 +2455,8 @@ static int dc390_probe_one(struct pci_dev *pdev, const 
struct pci_device_id *id)
shost-irq = pdev-irq;
shost-base = io_port;
shost-unique_id = io_port;
-   shost-last_reset = jiffies;
-   
+
+   pACB-last_reset = jiffies;
pACB-pScsiHost = shost;
pACB-IOPortBase = (u16) io_port;
pACB-IRQLevel = pdev-irq;
diff --git a/drivers/scsi/tmscsim.h b/drivers/scsi/tmscsim.h
index 77adc54..3d1bb4a 100644
--- a/drivers/scsi/tmscsim.h
+++ b/drivers/scsi/tmscsim.h
@@ -143,6 +143,7 @@ u8  Ignore_IRQ; /* Not used */
 
 struct pci_dev *pdev;
 
+unsigned long   last_reset;
 unsigned long  Cmds;
 u32SelLost;
 u32SelConn;
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/7] advansys: Remove 'last_reset' references

2013-07-01 Thread Hannes Reinecke
Serves no purpose whatsoever.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/advansys.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index c67e401..d814588 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2511,8 +2511,8 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
struct asc_board *boardp = shost_priv(s);
 
printk(Scsi_Host at addr 0x%p, device %s\n, s, dev_name(boardp-dev));
-   printk( host_busy %u, host_no %d, last_reset %d,\n,
-  s-host_busy, s-host_no, (unsigned)s-last_reset);
+   printk( host_busy %u, host_no %d,\n,
+  s-host_busy, s-host_no);
 
printk( base 0x%lx, io_port 0x%lx, irq %d,\n,
   (ulong)s-base, (ulong)s-io_port, boardp-irq);
@@ -3345,8 +3345,8 @@ static void asc_prt_driver_conf(struct seq_file *m, 
struct Scsi_Host *shost)
shost-host_no);
 
seq_printf(m,
-   host_busy %u, last_reset %lu, max_id %u, max_lun %u, 
max_channel %u\n,
-  shost-host_busy, shost-last_reset, shost-max_id,
+   host_busy %u, max_id %u, max_lun %u, max_channel %u\n,
+  shost-host_busy, shost-max_id,
   shost-max_lun, shost-max_channel);
 
seq_printf(m,
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] scsi: remove check for 'resetting'

2013-07-01 Thread Hannes Reinecke
Field is now unused, so this is dead code.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi.c | 28 
 1 file changed, 28 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 2c0d0ec..ebe3b0a 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -78,11 +78,6 @@ static void scsi_done(struct scsi_cmnd *cmd);
  * Definitions and constants.
  */
 
-#define MIN_RESET_DELAY (2*HZ)
-
-/* Do not call reset on error if we just did a reset within 15 sec. */
-#define MIN_RESET_PERIOD (15*HZ)
-
 /*
  * Note - the initial logging level can be set here to log events at boot time.
  * After the system is up, you may enable logging via the /proc interface.
@@ -658,7 +653,6 @@ EXPORT_SYMBOL(scsi_cmd_get_serial);
 int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 {
struct Scsi_Host *host = cmd-device-host;
-   unsigned long timeout;
int rtn = 0;
 
atomic_inc(cmd-device-iorequest_cnt);
@@ -704,28 +698,6 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
   (cmd-device-lun  5  0xe0);
}
 
-   /*
-* We will wait MIN_RESET_DELAY clock ticks after the last reset so
-* we can avoid the drive not being ready.
-*/
-   timeout = host-last_reset + MIN_RESET_DELAY;
-
-   if (host-resetting  time_before(jiffies, timeout)) {
-   int ticks_remaining = timeout - jiffies;
-   /*
-* NOTE: This may be executed from within an interrupt
-* handler!  This is bad, but for now, it'll do.  The irq
-* level of the interrupt handler has been masked out by the
-* platform dependent interrupt handling code already, so the
-* sti() here will not cause another call to the SCSI host's
-* interrupt handler (assuming there is one irq-level per
-* host).
-*/
-   while (--ticks_remaining = 0)
-   mdelay(1 + 999 / HZ);
-   host-resetting = 0;
-   }
-
scsi_log_send(cmd);
 
/*
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] scsi: Add 'eh_deadline' to limit SCSI EH runtime

2013-07-01 Thread Hannes Reinecke
This patchs adds an 'eh_deadline' sysfs attribute to the scsi
host which limits the overall runtime of the SCSI EH.
The 'eh_deadline' value is stored in the now obsolete field
'resetting'.
When a command is failed the start time of the EH is stored
in 'last_reset'. If the overall runtime of the SCSI EH is longer
than last_reset + eh_deadline, the EH is short-circuited and
falls through to issue a host reset only.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/hosts.c  |   7 +++
 drivers/scsi/scsi_error.c | 130 +++---
 drivers/scsi/scsi_sysfs.c |  37 +
 include/scsi/scsi_host.h  |   4 +-
 4 files changed, 170 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index df0c3c7..f334859 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -316,6 +316,12 @@ static void scsi_host_dev_release(struct device *dev)
kfree(shost);
 }
 
+static unsigned int shost_eh_deadline;
+
+module_param_named(eh_deadline, shost_eh_deadline, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(eh_deadline,
+SCSI EH timeout in seconds (should be between 1 and 2^32-1));
+
 static struct device_type scsi_host_type = {
.name = scsi_host,
.release =  scsi_host_dev_release,
@@ -388,6 +394,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template 
*sht, int privsize)
shost-unchecked_isa_dma = sht-unchecked_isa_dma;
shost-use_clustering = sht-use_clustering;
shost-ordered_tag = sht-ordered_tag;
+   shost-eh_deadline = shost_eh_deadline * HZ;
 
if (sht-supported_mode == MODE_UNKNOWN)
/* means we didn't set it ... default to INITIATOR */
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index f43de1e..84369f2 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -89,6 +89,18 @@ void scsi_schedule_eh(struct Scsi_Host *shost)
 }
 EXPORT_SYMBOL_GPL(scsi_schedule_eh);
 
+static int scsi_host_eh_past_deadline(struct Scsi_Host *shost)
+{
+   if (!shost-last_reset || !shost-eh_deadline)
+   return 0;
+
+   if (time_before(jiffies,
+   shost-last_reset + shost-eh_deadline))
+   return 0;
+
+   return 1;
+}
+
 /**
  * scsi_eh_scmd_add - add scsi cmd to error handling.
  * @scmd:  scmd to run eh on.
@@ -111,6 +123,9 @@ int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag)
if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY))
goto out_unlock;
 
+   if (shost-eh_deadline  !shost-last_reset)
+   shost-last_reset = jiffies;
+
ret = 1;
scmd-eh_eflags |= eh_flag;
list_add_tail(scmd-eh_entry, shost-eh_cmd_q);
@@ -140,6 +155,9 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
trace_scsi_dispatch_cmd_timeout(scmd);
scsi_log_completion(scmd, TIMEOUT_ERROR);
 
+   if (host-eh_deadline  !host-last_reset)
+   host-last_reset = jiffies;
+
if (host-transportt-eh_timed_out)
rtn = host-transportt-eh_timed_out(scmd);
else if (host-hostt-eh_timed_out)
@@ -928,13 +946,26 @@ int scsi_eh_get_sense(struct list_head *work_q,
  struct list_head *done_q)
 {
struct scsi_cmnd *scmd, *next;
+   struct Scsi_Host *shost;
int rtn;
+   unsigned long flags;
 
list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
if ((scmd-eh_eflags  SCSI_EH_CANCEL_CMD) ||
SCSI_SENSE_VALID(scmd))
continue;
 
+   shost = scmd-device-host;
+   spin_lock_irqsave(shost-host_lock, flags);
+   if (scsi_host_eh_past_deadline(shost)) {
+   spin_unlock_irqrestore(shost-host_lock, flags);
+   SCSI_LOG_ERROR_RECOVERY(3,
+   shost_printk(KERN_INFO, shost,
+   skip %s, past eh deadline\n,
+__func__));
+   break;
+   }
+   spin_unlock_irqrestore(shost-host_lock, flags);
SCSI_LOG_ERROR_RECOVERY(2, scmd_printk(KERN_INFO, scmd,
  %s: requesting sense\n,
  current-comm));
@@ -1019,11 +1050,28 @@ static int scsi_eh_test_devices(struct list_head 
*cmd_list,
struct scsi_cmnd *scmd, *next;
struct scsi_device *sdev;
int finish_cmds;
+   unsigned long flags;
 
while (!list_empty(cmd_list)) {
scmd = list_entry(cmd_list-next, struct scsi_cmnd, eh_entry);
sdev = scmd-device;
 
+   if (!try_stu) {
+   spin_lock_irqsave(sdev-host-host_lock, flags);
+   if 

[PATCH 5/7] dc395: Move 'last_reset' into internal host structure

2013-07-01 Thread Hannes Reinecke
'last_reset' is only used internally, so move it into the
internal host structure.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/dc395x.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 694e13c..42e8624 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -308,6 +308,8 @@ struct AdapterCtlBlk {
struct timer_list waiting_timer;
struct timer_list selto_timer;
 
+   unsigned long last_reset;
+
u16 srb_count;
 
u8 sel_timeout;
@@ -860,9 +862,9 @@ static void waiting_set_timer(struct AdapterCtlBlk *acb, 
unsigned long to)
init_timer(acb-waiting_timer);
acb-waiting_timer.function = waiting_timeout;
acb-waiting_timer.data = (unsigned long) acb;
-   if (time_before(jiffies + to, acb-scsi_host-last_reset - HZ / 2))
+   if (time_before(jiffies + to, acb-last_reset - HZ / 2))
acb-waiting_timer.expires =
-   acb-scsi_host-last_reset - HZ / 2 + 1;
+   acb-last_reset - HZ / 2 + 1;
else
acb-waiting_timer.expires = jiffies + to + 1;
add_timer(acb-waiting_timer);
@@ -1319,7 +1321,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
udelay(500);
 
/* We may be in serious trouble. Wait some seconds */
-   acb-scsi_host-last_reset =
+   acb-last_reset =
jiffies + 3 * HZ / 2 +
HZ * acb-eeprom.delay_time;
 
@@ -1462,9 +1464,9 @@ static void selto_timer(struct AdapterCtlBlk *acb)
acb-selto_timer.function = selection_timeout_missed;
acb-selto_timer.data = (unsigned long) acb;
if (time_before
-   (jiffies + HZ, acb-scsi_host-last_reset + HZ / 2))
+   (jiffies + HZ, acb-last_reset + HZ / 2))
acb-selto_timer.expires =
-   acb-scsi_host-last_reset + HZ / 2 + 1;
+   acb-last_reset + HZ / 2 + 1;
else
acb-selto_timer.expires = jiffies + HZ + 1;
add_timer(acb-selto_timer);
@@ -1535,7 +1537,7 @@ static u8 start_scsi(struct AdapterCtlBlk* acb, struct 
DeviceCtlBlk* dcb,
}
/* Allow starting of SCSI commands half a second before we allow the 
mid-level
 * to queue them again after a reset */
-   if (time_before(jiffies, acb-scsi_host-last_reset - HZ / 2)) {
+   if (time_before(jiffies, acb-last_reset - HZ / 2)) {
dprintkdbg(DBG_KG, start_scsi: Refuse cmds (reset wait)\n);
return 1;
}
@@ -3031,7 +3033,7 @@ static void disconnect(struct AdapterCtlBlk *acb)
dprintkl(KERN_ERR, disconnect: No such device\n);
udelay(500);
/* Suspend queue for a while */
-   acb-scsi_host-last_reset =
+   acb-last_reset =
jiffies + HZ / 2 +
HZ * acb-eeprom.delay_time;
clear_fifo(acb, disconnectEx);
@@ -3053,7 +3055,7 @@ static void disconnect(struct AdapterCtlBlk *acb)
waiting_process_next(acb);
} else if (srb-state  SRB_ABORT_SENT) {
dcb-flag = ~ABORT_DEV_;
-   acb-scsi_host-last_reset = jiffies + HZ / 2 + 1;
+   acb-last_reset = jiffies + HZ / 2 + 1;
dprintkl(KERN_ERR, disconnect: SRB_ABORT_SENT\n);
doing_srb_done(acb, DID_ABORT, srb-cmd, 1);
waiting_process_next(acb);
@@ -3649,7 +3651,7 @@ static void scsi_reset_detect(struct AdapterCtlBlk *acb)
/*DC395x_write8(acb, TRM_S1040_DMA_CONTROL,STOPDMAXFER); */
udelay(500);
/* Maybe we locked up the bus? Then lets wait even longer ... */
-   acb-scsi_host-last_reset =
+   acb-last_reset =
jiffies + 5 * HZ / 2 +
HZ * acb-eeprom.delay_time;
 
@@ -4426,7 +4428,7 @@ static void adapter_init_scsi_host(struct Scsi_Host *host)
host-dma_channel = -1;
host-unique_id = acb-io_port_base;
host-irq = acb-irq_level;
-   host-last_reset = jiffies;
+   acb-last_reset = jiffies;
 
host-max_id = 16;
if (host-max_id - 1 == eeprom-scsi_id)
@@ -4484,7 +4486,7 @@ static void adapter_init_chip(struct AdapterCtlBlk *acb)
/*spin_unlock_irq (io_request_lock); */
udelay(500);
 
-   acb-scsi_host-last_reset =
+   acb-last_reset =
jiffies + HZ / 2 +
HZ * acb-eeprom.delay_time;
 
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 08/15] scsi_transport_srp: Add transport layer error handling

2013-07-01 Thread Bart Van Assche

On 06/30/13 23:05, David Dillow wrote:

On Fri, 2013-06-28 at 14:53 +0200, Bart Van Assche wrote:

+int srp_tmo_valid(int fast_io_fail_tmo, int dev_loss_tmo)
+{
+   return (fast_io_fail_tmo  0 || dev_loss_tmo  0 ||
+   fast_io_fail_tmo  dev_loss_tmo) 
+   fast_io_fail_tmo  LONG_MAX / HZ 
+   dev_loss_tmo  LONG_MAX / HZ ? 0 : -EINVAL;
+}


They should also be capped by SCSI_DEVICE_BLOCK_MAX_TIMEOUT instead of
LONG_MAX / HZ, I think.


The fast_io_fail_tmo should indeed be capped by that value. However, I'm 
not sure about dev_loss_tmo. I think there are several use cases (e.g. 
initiator-side mirroring) where it's useful to set dev_loss_tmo to a 
larger value than ten minutes.



+static ssize_t store_srp_rport_fast_io_fail_tmo(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct srp_rport *rport = transport_class_to_srp_rport(dev);
+   char ch[16], *p;
+   int res;
+   int fast_io_fail_tmo;
+
+   sprintf(ch, %.*s, min_t(int, sizeof(ch) - 1, count), buf);
+   p = strchr(ch, '\n');
+   if (p)
+   *p = '\0';


Again, no need for the sprintf if you don't modify the buffer? Instead
of using strchr() to make the strcmp() work with newlines, just do

if (!strcmp(buf, off) || !strcmp(buf, off\n)) {
fast_io_fail_tmo = 1;
} else {
res = kstrtoint(buf, 0, fast_io_fail_tmo);
...

instead?

Same comment applies for store_srp_rport_dev_loss_tmo().


OK, will remove the temporary char arrays.

Bart.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 2/6] Avoid calling __scsi_remove_device() twice

2013-07-01 Thread James Bottomley

On Thu, 2013-06-27 at 16:53 +0200, Bart Van Assche wrote:
 If something goes wrong during LUN scanning, e.g. a transport layer
 failure occurs, then __scsi_remove_device() can get invoked by the
 LUN scanning code for a SCSI device in state SDEV_CREATED_BLOCK. If
 this happens then the SCSI device has not yet been added to sysfs
 (is_visible == 0).  Make sure that in that case the transition into
 state SDEV_DEL occurs. This avoids that __scsi_remove_device() gets
 invoked a second time by scsi_forget_host().

The patch summary of this one isn't true.  How about enable destruction
of blocked devices which fail LUN scanning

James


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 2/6] Avoid calling __scsi_remove_device() twice

2013-07-01 Thread Bart Van Assche

On 07/01/13 09:05, James Bottomley wrote:


On Thu, 2013-06-27 at 16:53 +0200, Bart Van Assche wrote:

If something goes wrong during LUN scanning, e.g. a transport layer
failure occurs, then __scsi_remove_device() can get invoked by the
LUN scanning code for a SCSI device in state SDEV_CREATED_BLOCK. If
this happens then the SCSI device has not yet been added to sysfs
(is_visible == 0).  Make sure that in that case the transition into
state SDEV_DEL occurs. This avoids that __scsi_remove_device() gets
invoked a second time by scsi_forget_host().


The patch summary of this one isn't true.  How about enable destruction
of blocked devices which fail LUN scanning


Hello James,

Do you want me to repost the patch series or is this something you can 
fix up ?


Thanks,

Bart.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] scsi: Return ENODATA on medium error

2013-07-01 Thread Hannes Reinecke
When a medium error is detected the SCSI stack should return
ENODATA to the upper layers.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 block/blk-core.c  | 3 +++
 drivers/scsi/scsi_error.c | 2 +-
 drivers/scsi/scsi_lib.c   | 5 +
 include/scsi/scsi.h   | 1 +
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 170607c..1093ca1 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2318,6 +2318,9 @@ bool blk_update_request(struct request *req, int error, 
unsigned int nr_bytes)
case -ENOSPC:
error_type = critical space allocation;
break;
+   case -ENODATA:
+   error_type = critical medium;
+   break;
case -EIO:
default:
error_type = I/O;
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index aeec0e7..7f794d4 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -391,7 +391,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
if (sshdr.asc == 0x11 || /* UNRECOVERED READ ERR */
sshdr.asc == 0x13 || /* AMNF DATA FIELD */
sshdr.asc == 0x14) { /* RECORD NOT FOUND */
-   set_host_byte(scmd, DID_TARGET_FAILURE);
+   set_host_byte(scmd, DID_MEDIUM_ERROR);
return SUCCESS;
}
return NEEDS_RETRY;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8a2f92d..70ca1f6 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -711,6 +711,7 @@ EXPORT_SYMBOL(scsi_release_buffers);
  * -EREMOTEIO  permanent target failure, do not retry
  * -EBADE  permanent nexus failure, retry on other path
  * -ENOSPC No write space available
+ * -ENODATAMedium error
  * -EIOunspecified I/O error
  */
 static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
@@ -733,6 +734,10 @@ static int __scsi_error_from_host_byte(struct scsi_cmnd 
*cmd, int result)
set_host_byte(cmd, DID_OK);
error = -ENOSPC;
break;
+   case DID_MEDIUM_ERROR:
+   set_host_byte(cmd, DID_OK);
+   error = -ENODATA;
+   break;
default:
error = -EIO;
break;
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 7d5b8e2..95ce204 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -453,6 +453,7 @@ static inline int scsi_is_wlun(unsigned int lun)
 #define DID_NEXUS_FAILURE 0x11  /* Permanent nexus failure, retry on other
 * paths might yield different results */
 #define DID_ALLOC_FAILURE 0x12  /* Space allocation on the device failed */
+#define DID_MEDIUM_ERROR  0x13  /* Medium error */
 #define DRIVER_OK   0x00   /* Driver status   */
 
 /*
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 0/5] scsi: More detailed I/O errors

2013-07-01 Thread Hannes Reinecke
As discussed at LSF the SCSI stack already knows about several
error conditions, it's just not well documented.
Also there are some more conditions upper layers might be
interested in.

This patchset improves the documentation of the existing
I/O error codes and adds three more error codes, ENOSPC
for thin provisioning failure, ENODATA for medium error,
and ENXIO for an invalid or removed device.

Changes since the initial version:
- Correctly document all return codes in
  __scsi_error_from_host_byte()
- Set hostbyte status in scsi_check_sense()
- Return ENXIO on invalid or removed device

Hannes Reinecke (5):
  scsi: Document enhanced error codes
  scsi: Set hostbyte status in scsi_check_sense()
  scsi: return ENOSPC on thin provisioning failure
  scsi: Return ENODATA on medium error
  scsi: Return ENXIO on invalid device

 block/blk-core.c  |  9 +
 drivers/scsi/scsi_error.c | 28 +---
 drivers/scsi/scsi_lib.c   | 29 -
 include/scsi/scsi.h   |  3 ++-
 4 files changed, 52 insertions(+), 17 deletions(-)

-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] scsi: Document enhanced error codes

2013-07-01 Thread Hannes Reinecke
Document the various error codes returned on I/O failure.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi_lib.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 86d5220..d3fc50f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -700,6 +700,18 @@ void scsi_release_buffers(struct scsi_cmnd *cmd)
 }
 EXPORT_SYMBOL(scsi_release_buffers);
 
+/**
+ * __scsi_error_from_host_byte - translate SCSI error code into errno
+ * @cmd:   SCSI command (unused)
+ * @result:scsi error code
+ *
+ * Translate SCSI error code into standard UNIX errno.
+ * Return values:
+ * -ENOLINKtemporary transport failure
+ * -EREMOTEIO  permanent target failure, do not retry
+ * -EBADE  permanent nexus failure, retry on other path
+ * -EIOunspecified I/O error
+ */
 static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
 {
int error = 0;
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] scsi: Return ENXIO on invalid device

2013-07-01 Thread Hannes Reinecke
The scsi stack already uses DID_NO_CONNECT internally to signal
an invalid or removed device. This should be mapped to ENXIO,
as this then allows us to use a correct error code in
scsi_prep_return().

Signed-off-by: Hannes Reinecke h...@suse.de
---
 block/blk-core.c| 3 +++
 drivers/scsi/scsi_lib.c | 7 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 1093ca1..875b9da 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2321,6 +2321,9 @@ bool blk_update_request(struct request *req, int error, 
unsigned int nr_bytes)
case -ENODATA:
error_type = critical medium;
break;
+   case -ENXIO:
+   error_type = invalid device;
+   break;
case -EIO:
default:
error_type = I/O;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 70ca1f6..86d9980 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -712,6 +712,7 @@ EXPORT_SYMBOL(scsi_release_buffers);
  * -EBADE  permanent nexus failure, retry on other path
  * -ENOSPC No write space available
  * -ENODATAMedium error
+ * -ENXIO  Invalid or removed device
  * -EIOunspecified I/O error
  */
 static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
@@ -738,6 +739,10 @@ static int __scsi_error_from_host_byte(struct scsi_cmnd 
*cmd, int result)
set_host_byte(cmd, DID_OK);
error = -ENODATA;
break;
+   case DID_NO_CONNECT:
+   set_host_byte(cmd, DID_OK);
+   error = -ENXIO;
+   break;
default:
error = -EIO;
break;
@@ -1286,7 +1291,7 @@ int scsi_prep_return(struct request_queue *q, struct 
request *req, int ret)
 
switch (ret) {
case BLKPREP_KILL:
-   req-errors = DID_NO_CONNECT  16;
+   req-errors = -ENXIO;
/* release the command and kill it */
if (req-special) {
struct scsi_cmnd *cmd = req-special;
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] scsi: Set hostbyte status in scsi_check_sense()

2013-07-01 Thread Hannes Reinecke
We should be modifying the host_byte status in scsi_check_sense()
directly; this saves us to introduce a special return code for
each and every condition.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi_error.c | 21 +++--
 include/scsi/scsi.h   |  1 -
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 84369f2..e5cb162 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -248,7 +248,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host 
*shost,
  * @scmd:  Cmd to have sense checked.
  *
  * Return value:
- * SUCCESS or FAILED or NEEDS_RETRY or TARGET_ERROR
+ * SUCCESS or FAILED or NEEDS_RETRY or ADD_TO_MLQUEUE
  *
  * Notes:
  * When a deferred error is detected the current command has
@@ -379,13 +379,15 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
case MISCOMPARE:
case BLANK_CHECK:
case DATA_PROTECT:
-   return TARGET_ERROR;
+   set_host_byte(scmd, DID_TARGET_FAILURE);
+   return SUCCESS;
 
case MEDIUM_ERROR:
if (sshdr.asc == 0x11 || /* UNRECOVERED READ ERR */
sshdr.asc == 0x13 || /* AMNF DATA FIELD */
sshdr.asc == 0x14) { /* RECORD NOT FOUND */
-   return TARGET_ERROR;
+   set_host_byte(scmd, DID_TARGET_FAILURE);
+   return SUCCESS;
}
return NEEDS_RETRY;
 
@@ -393,14 +395,14 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
if (scmd-device-retry_hwerror)
return ADD_TO_MLQUEUE;
else
-   return TARGET_ERROR;
+   set_host_byte(scmd, DID_TARGET_FAILURE);
 
case ILLEGAL_REQUEST:
if (sshdr.asc == 0x20 || /* Invalid command operation code */
sshdr.asc == 0x21 || /* Logical block address out of range 
*/
sshdr.asc == 0x24 || /* Invalid field in cdb */
sshdr.asc == 0x26) { /* Parameter value invalid */
-   return TARGET_ERROR;
+   set_host_byte(scmd, DID_TARGET_FAILURE);
}
return SUCCESS;
 
@@ -863,7 +865,6 @@ retry:
case SUCCESS:
case NEEDS_RETRY:
case FAILED:
-   case TARGET_ERROR:
break;
case ADD_TO_MLQUEUE:
rtn = NEEDS_RETRY;
@@ -1690,14 +1691,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
rtn = scsi_check_sense(scmd);
if (rtn == NEEDS_RETRY)
goto maybe_retry;
-   else if (rtn == TARGET_ERROR) {
-   /*
-* Need to modify host byte to signal a
-* permanent target failure
-*/
-   set_host_byte(scmd, DID_TARGET_FAILURE);
-   rtn = SUCCESS;
-   }
/* if rtn == FAILED, we have no sense information;
 * returning FAILED will wake the error handler thread
 * to collect the sense and redo the decide
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 66216c1..07d4bd916 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -481,7 +481,6 @@ static inline int scsi_is_wlun(unsigned int lun)
 #define TIMEOUT_ERROR   0x2007
 #define SCSI_RETURN_NOT_HANDLED   0x2008
 #define FAST_IO_FAIL   0x2009
-#define TARGET_ERROR0x200A
 
 /*
  * Midlevel queue return values.
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] scsi: return ENOSPC on thin provisioning failure

2013-07-01 Thread Hannes Reinecke
When the thin provisioning hard threshold is reached we
should return ENOSPC to inform upper layers about this fact.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 block/blk-core.c  | 3 +++
 drivers/scsi/scsi_error.c | 7 ++-
 drivers/scsi/scsi_lib.c   | 5 +
 include/scsi/scsi.h   | 1 +
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index d5745b5..170607c 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2315,6 +2315,9 @@ bool blk_update_request(struct request *req, int error, 
unsigned int nr_bytes)
case -EBADE:
error_type = critical nexus;
break;
+   case -ENOSPC:
+   error_type = critical space allocation;
+   break;
case -EIO:
default:
error_type = I/O;
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index e5cb162..aeec0e7 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -374,11 +374,16 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
return SUCCESS;
 
/* these are not supported */
+   case DATA_PROTECT:
+   if (sshdr.asc == 0x27  sshdr.ascq == 0x07) {
+   /* Thin provisioning hard threshold reached */
+   set_host_byte(scmd, DID_ALLOC_FAILURE);
+   return SUCCESS;
+   }
case COPY_ABORTED:
case VOLUME_OVERFLOW:
case MISCOMPARE:
case BLANK_CHECK:
-   case DATA_PROTECT:
set_host_byte(scmd, DID_TARGET_FAILURE);
return SUCCESS;
 
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d3fc50f..8a2f92d 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -710,6 +710,7 @@ EXPORT_SYMBOL(scsi_release_buffers);
  * -ENOLINKtemporary transport failure
  * -EREMOTEIO  permanent target failure, do not retry
  * -EBADE  permanent nexus failure, retry on other path
+ * -ENOSPC No write space available
  * -EIOunspecified I/O error
  */
 static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
@@ -728,6 +729,10 @@ static int __scsi_error_from_host_byte(struct scsi_cmnd 
*cmd, int result)
set_host_byte(cmd, DID_OK);
error = -EBADE;
break;
+   case DID_ALLOC_FAILURE:
+   set_host_byte(cmd, DID_OK);
+   error = -ENOSPC;
+   break;
default:
error = -EIO;
break;
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 07d4bd916..7d5b8e2 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -452,6 +452,7 @@ static inline int scsi_is_wlun(unsigned int lun)
 * other paths */
 #define DID_NEXUS_FAILURE 0x11  /* Permanent nexus failure, retry on other
 * paths might yield different results */
+#define DID_ALLOC_FAILURE 0x12  /* Space allocation on the device failed */
 #define DRIVER_OK   0x00   /* Driver status   */
 
 /*
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 3/6] Restrict device state changes allowed via sysfs

2013-07-01 Thread Hannes Reinecke
On 06/27/2013 04:54 PM, Bart Van Assche wrote:
 Restrict the SCSI device state changes allowd via sysfs to the
 OFFLINERUNNING transitions. Other transitions may confuse
 the SCSI mid-layer. As an example, changing the state of a SCSI
 device via sysfs into cancel or deleted prevents removal of
 a SCSI device by scsi_remove_host().
 
 Signed-off-by: Bart Van Assche bvanass...@acm.org
 Cc: Tejun Heo t...@kernel.org
 Cc: James Bottomley jbottom...@parallels.com
 Cc: Mike Christie micha...@cs.wisc.edu
 Cc: Hannes Reinecke h...@suse.de
 Cc: David Milburn dmilb...@redhat.com
 ---
  drivers/scsi/scsi_sysfs.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
 index 931a7d9..013c6de 100644
 --- a/drivers/scsi/scsi_sysfs.c
 +++ b/drivers/scsi/scsi_sysfs.c
 @@ -605,7 +605,7 @@ store_state_field(struct device *dev, struct 
 device_attribute *attr,
   break;
   }
   }
 - if (!state)
 + if (state != SDEV_OFFLINE  state != SDEV_RUNNING)
   return -EINVAL;
  
   if (scsi_device_set_state(sdev, state))
 
Acked-by: Hannes Reinecke h...@suse.de

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 6/6] Avoid re-enabling I/O after the transport became offline

2013-07-01 Thread Hannes Reinecke
On 06/27/2013 04:57 PM, Bart Van Assche wrote:
 Disallow the SDEV_TRANSPORT_OFFLINE to SDEV_CANCEL transition such
 that no I/O is sent to devices for which the transport is offline.
 Notes:
 - Functions like sd_shutdown() use scsi_execute_req() and hence
   set the REQ_PREEMPT flag. Such requests are passed to the LLD
   queuecommand callback in the SDEV_CANCEL state.
 - This patch does not affect Fibre Channel LLD drivers since these
   drivers invoke fc_remote_port_chkready() before submitting a SCSI
   request to the HBA. That prevents a timeout to occur in state
   SDEV_CANCEL if the transport is offline.
 
 Signed-off-by: Bart Van Assche bvanass...@acm.org
 Cc: Mike Christie micha...@cs.wisc.edu
 Cc: James Bottomley jbottom...@parallels.com
 Cc: Hannes Reinecke h...@suse.de
 Cc: Tejun Heo t...@kernel.org
 ---
  drivers/scsi/scsi_lib.c   |1 -
  drivers/scsi/scsi_sysfs.c |4 +++-
  2 files changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
 index 6a4fde7..63875c3 100644
 --- a/drivers/scsi/scsi_lib.c
 +++ b/drivers/scsi/scsi_lib.c
 @@ -2180,7 +2180,6 @@ scsi_device_set_state(struct scsi_device *sdev, enum 
 scsi_device_state state)
   case SDEV_RUNNING:
   case SDEV_QUIESCE:
   case SDEV_OFFLINE:
 - case SDEV_TRANSPORT_OFFLINE:
   case SDEV_BLOCK:
   break;
   default:
 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
 index dfbaa34..666b741 100644
 --- a/drivers/scsi/scsi_sysfs.c
 +++ b/drivers/scsi/scsi_sysfs.c
 @@ -959,14 +959,16 @@ void __scsi_remove_device(struct scsi_device *sdev)
  {
   struct Scsi_Host *shost = sdev-host;
   struct device *dev = sdev-sdev_gendev;
 + enum scsi_device_state sdev_state;
   int res;
  
   if (sdev-is_visible) {
   spin_lock_irq(shost-host_lock);
 + sdev_state = sdev-sdev_state;
   res = scsi_device_set_state(sdev, SDEV_CANCEL);
   spin_unlock_irq(shost-host_lock);
  
 - if (res != 0)
 + if (res != 0  sdev_state != SDEV_TRANSPORT_OFFLINE)
   return;
  
   bsg_unregister_queue(sdev-request_queue);
 
Hmm. This is really subtle. Do you mind adding inserting a comment
here on why this is required?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/5] scsi: Return ENODATA on medium error

2013-07-01 Thread Jun'ichi Nomura
On 07/01/13 17:12, Hannes Reinecke wrote:
 When a medium error is detected the SCSI stack should return
 ENODATA to the upper layers.

Hi Hannes,

since you change the error code from -EREMOTEIO to -ENODATA/-ENOSPC,
upper layers that checks -EREMOTEIO have to be updated as well.

Something like below for dm-multipath.
It seems btrfs checking -EREMOTEIO, too.

-- 
Jun'ichi Nomura, NEC Corporation

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index bdf26f5..15bf881 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1261,6 +1261,21 @@ static void activate_path(struct work_struct *work)
pg_init_done, pgpath);
 }
 
+static int maybe_path_failure(int error)
+{
+   switch(error) {
+   case -EOPNOTSUPP:
+   case -EREMOTEIO:
+   case -EILSEQ:
+   case -ENOSPC:
+   case -ENODATA:
+   return 0;
+   }
+
+   /* Anything else could be a path failure */
+   return 1;
+}
+
 /*
  * end_io handling
  */
@@ -1284,7 +1299,7 @@ static int do_end_io(struct multipath *m, struct request 
*clone,
if (!error  !clone-errors)
return 0;   /* I/O complete */
 
-   if (error == -EOPNOTSUPP || error == -EREMOTEIO || error == -EILSEQ)
+   if (!maybe_path_failure(error))
return error;
 
if (mpio-pgpath)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/5] scsi: Return ENODATA on medium error

2013-07-01 Thread Hannes Reinecke
On 07/01/2013 11:12 AM, Jun'ichi Nomura wrote:
 On 07/01/13 17:12, Hannes Reinecke wrote:
 When a medium error is detected the SCSI stack should return
 ENODATA to the upper layers.
 
 Hi Hannes,
 
 since you change the error code from -EREMOTEIO to -ENODATA/-ENOSPC,
 upper layers that checks -EREMOTEIO have to be updated as well.
 
 Something like below for dm-multipath.
 It seems btrfs checking -EREMOTEIO, too.
 
Good point.

Will be updating the patchset.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V1 1/4] scsi_transport_iscsi: Exporting new attrs for iscsi session and connection in sysfs

2013-07-01 Thread Vikas Chaudhary


-Original Message-
From: James Bottomley jbottom...@parallels.com
Date: Saturday 29 June 2013 1:24 AM
To: Vikas vikas.chaudh...@qlogic.com
Cc: Mike Christie micha...@cs.wisc.edu, scsi
linux-scsi@vger.kernel.org, Lalit Chandivade
lalit.chandiv...@qlogic.com, Adheer Chandravanshi
adheer.chandravan...@qlogic.com
Subject: Re: [PATCH V1 1/4] scsi_transport_iscsi: Exporting new attrs for
iscsi session and connection in sysfs

On Wed, 2013-06-26 at 08:11 -0400, vikas.chaudh...@qlogic.com wrote:
 From: Adheer Chandravanshi adheer.chandravan...@qlogic.com
 
 Exporting new iSCSI Session and Connection parameters to sysfs

This doesn't apply:

patching file drivers/scsi/scsi_transport_iscsi.c
Hunk #5 FAILED at 3537.
Hunk #6 succeeded at 3644 (offset 6 lines).
Hunk #7 FAILED at 3709.
2 out of 7 hunks FAILED -- saving rejects to file
drivers/scsi/scsi_transport_iscsi.c.rej
patching file include/scsi/iscsi_if.h
Hunk #1 FAILED at 489.
1 out of 1 hunk FAILED -- saving rejects to file
include/scsi/iscsi_if.h.rej

It looks like it needs regenerating against scsi-misc, please (I think
it's conflicting with the ibft boot session sysfs entries).


Yes, Its conflicting with ibft boot session sysfs entries.
I am resending updated patches in next emails.

Thanks,
Vikas.

attachment: winmail.dat

[PATCH V2 4/4] qla4xxx: Update driver version to 5.03.00-k10

2013-07-01 Thread vikas.chaudhary
From: Vikas Chaudhary vikas.chaudh...@qlogic.com

Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_version.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_version.h 
b/drivers/scsi/qla4xxx/ql4_version.h
index fe873cf..c5edd0d 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,4 +5,4 @@
  * See LICENSE.qla4xxx for copyright and licensing details.
  */
 
-#define QLA4XXX_DRIVER_VERSION 5.03.00-k9
+#define QLA4XXX_DRIVER_VERSION 5.03.00-k10
-- 
1.7.1


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 2/4] libiscsi: Exporting new attrs for iscsi session and connection in sysfs

2013-07-01 Thread vikas.chaudhary
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/libiscsi.c |   97 +++
 include/scsi/libiscsi.h |   31 +++
 2 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index ae69dfc..86153e0 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2812,6 +2812,8 @@ void iscsi_session_teardown(struct iscsi_cls_session 
*cls_session)
kfree(session-boot_nic);
kfree(session-boot_target);
kfree(session-ifacename);
+   kfree(session-portal_type);
+   kfree(session-discovery_parent_type);
 
iscsi_destroy_session(cls_session);
iscsi_host_dec_session_cnt(shost);
@@ -3257,6 +3259,11 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
return iscsi_switch_str_param(session-boot_nic, buf);
case ISCSI_PARAM_BOOT_TARGET:
return iscsi_switch_str_param(session-boot_target, buf);
+   case ISCSI_PARAM_PORTAL_TYPE:
+   return iscsi_switch_str_param(session-portal_type, buf);
+   case ISCSI_PARAM_DISCOVERY_PARENT_TYPE:
+   return iscsi_switch_str_param(session-discovery_parent_type,
+ buf);
default:
return -ENOSYS;
}
@@ -3343,6 +3350,51 @@ int iscsi_session_get_param(struct iscsi_cls_session 
*cls_session,
break;
case ISCSI_PARAM_BOOT_TARGET:
len = sprintf(buf, %s\n, session-boot_target);
+   case ISCSI_PARAM_AUTO_SND_TGT_DISABLE:
+   len = sprintf(buf, %u\n, session-auto_snd_tgt_disable);
+   break;
+   case ISCSI_PARAM_DISCOVERY_SESS:
+   len = sprintf(buf, %u\n, session-discovery_sess);
+   break;
+   case ISCSI_PARAM_PORTAL_TYPE:
+   len = sprintf(buf, %s\n, session-portal_type);
+   break;
+   case ISCSI_PARAM_CHAP_AUTH_EN:
+   len = sprintf(buf, %u\n, session-chap_auth_en);
+   break;
+   case ISCSI_PARAM_DISCOVERY_LOGOUT_EN:
+   len = sprintf(buf, %u\n, session-discovery_logout_en);
+   break;
+   case ISCSI_PARAM_BIDI_CHAP_EN:
+   len = sprintf(buf, %u\n, session-bidi_chap_en);
+   break;
+   case ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL:
+   len = sprintf(buf, %u\n, session-discovery_auth_optional);
+   break;
+   case ISCSI_PARAM_DEF_TIME2WAIT:
+   len = sprintf(buf, %d\n, session-time2wait);
+   break;
+   case ISCSI_PARAM_DEF_TIME2RETAIN:
+   len = sprintf(buf, %d\n, session-time2retain);
+   break;
+   case ISCSI_PARAM_TSID:
+   len = sprintf(buf, %u\n, session-tsid);
+   break;
+   case ISCSI_PARAM_ISID:
+   len = sprintf(buf, %02x%02x%02x%02x%02x%02x\n,
+ session-isid[0], session-isid[1],
+ session-isid[2], session-isid[3],
+ session-isid[4], session-isid[5]);
+   break;
+   case ISCSI_PARAM_DISCOVERY_PARENT_IDX:
+   len = sprintf(buf, %u\n, session-discovery_parent_idx);
+   break;
+   case ISCSI_PARAM_DISCOVERY_PARENT_TYPE:
+   if (session-discovery_parent_type)
+   len = sprintf(buf, %s\n,
+ session-discovery_parent_type);
+   else
+   len = sprintf(buf, \n);
break;
default:
return -ENOSYS;
@@ -3433,6 +3485,51 @@ int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
case ISCSI_PARAM_PERSISTENT_ADDRESS:
len = sprintf(buf, %s\n, conn-persistent_address);
break;
+   case ISCSI_PARAM_STATSN:
+   len = sprintf(buf, %u\n, conn-statsn);
+   break;
+   case ISCSI_PARAM_MAX_SEGMENT_SIZE:
+   len = sprintf(buf, %u\n, conn-max_segment_size);
+   break;
+   case ISCSI_PARAM_KEEPALIVE_TMO:
+   len = sprintf(buf, %u\n, conn-keepalive_tmo);
+   break;
+   case ISCSI_PARAM_LOCAL_PORT:
+   len = sprintf(buf, %u\n, conn-local_port);
+   break;
+   case ISCSI_PARAM_TCP_TIMESTAMP_STAT:
+   len = sprintf(buf, %u\n, conn-tcp_timestamp_stat);
+   break;
+   case ISCSI_PARAM_TCP_NAGLE_DISABLE:
+   len = sprintf(buf, %u\n, conn-tcp_nagle_disable);
+   break;
+   case ISCSI_PARAM_TCP_WSF_DISABLE:
+   len = sprintf(buf, %u\n, conn-tcp_wsf_disable);
+   break;
+   case ISCSI_PARAM_TCP_TIMER_SCALE:
+   len = sprintf(buf, %u\n, 

[PATCH V2 3/4] qla4xxx: Exporting new attrs for iscsi session and connection in sysfs

2013-07-01 Thread vikas.chaudhary
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_os.c |  203 +
 1 files changed, 146 insertions(+), 57 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 4d231c1..84d9361 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -378,6 +378,44 @@ static umode_t qla4_attr_is_visible(int param_type, int 
param)
case ISCSI_PARAM_PASSWORD:
case ISCSI_PARAM_USERNAME_IN:
case ISCSI_PARAM_PASSWORD_IN:
+   case ISCSI_PARAM_AUTO_SND_TGT_DISABLE:
+   case ISCSI_PARAM_DISCOVERY_SESS:
+   case ISCSI_PARAM_PORTAL_TYPE:
+   case ISCSI_PARAM_CHAP_AUTH_EN:
+   case ISCSI_PARAM_DISCOVERY_LOGOUT_EN:
+   case ISCSI_PARAM_BIDI_CHAP_EN:
+   case ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL:
+   case ISCSI_PARAM_DEF_TIME2WAIT:
+   case ISCSI_PARAM_DEF_TIME2RETAIN:
+   case ISCSI_PARAM_HDRDGST_EN:
+   case ISCSI_PARAM_DATADGST_EN:
+   case ISCSI_PARAM_INITIAL_R2T_EN:
+   case ISCSI_PARAM_IMM_DATA_EN:
+   case ISCSI_PARAM_PDU_INORDER_EN:
+   case ISCSI_PARAM_DATASEQ_INORDER_EN:
+   case ISCSI_PARAM_MAX_SEGMENT_SIZE:
+   case ISCSI_PARAM_TCP_TIMESTAMP_STAT:
+   case ISCSI_PARAM_TCP_WSF_DISABLE:
+   case ISCSI_PARAM_TCP_NAGLE_DISABLE:
+   case ISCSI_PARAM_TCP_TIMER_SCALE:
+   case ISCSI_PARAM_TCP_TIMESTAMP_EN:
+   case ISCSI_PARAM_TCP_XMIT_WSF:
+   case ISCSI_PARAM_TCP_RECV_WSF:
+   case ISCSI_PARAM_IP_FRAGMENT_DISABLE:
+   case ISCSI_PARAM_IPV4_TOS:
+   case ISCSI_PARAM_IPV6_TC:
+   case ISCSI_PARAM_IPV6_FLOW_LABEL:
+   case ISCSI_PARAM_IS_FW_ASSIGNED_IPV6:
+   case ISCSI_PARAM_KEEPALIVE_TMO:
+   case ISCSI_PARAM_LOCAL_PORT:
+   case ISCSI_PARAM_ISID:
+   case ISCSI_PARAM_TSID:
+   case ISCSI_PARAM_DEF_TASKMGMT_TMO:
+   case ISCSI_PARAM_ERL:
+   case ISCSI_PARAM_STATSN:
+   case ISCSI_PARAM_EXP_STATSN:
+   case ISCSI_PARAM_DISCOVERY_PARENT_IDX:
+   case ISCSI_PARAM_DISCOVERY_PARENT_TYPE:
return S_IRUGO;
default:
return 0;
@@ -2257,6 +2295,101 @@ static int qla4xxx_copy_to_fwddb_param(struct 
iscsi_bus_flash_session *sess,
return rc;
 }
 
+static void qla4xxx_copy_to_sess_conn_params(struct iscsi_conn *conn,
+struct iscsi_session *sess,
+struct dev_db_entry *fw_ddb_entry)
+{
+   unsigned long options = 0;
+   uint16_t ddb_link;
+   uint16_t disc_parent;
+
+   options = le16_to_cpu(fw_ddb_entry-options);
+   conn-is_fw_assigned_ipv6 = test_bit(OPT_IS_FW_ASSIGNED_IPV6, options);
+   sess-auto_snd_tgt_disable = test_bit(OPT_AUTO_SENDTGTS_DISABLE,
+ options);
+   sess-discovery_sess = test_bit(OPT_DISC_SESSION, options);
+
+   options = le16_to_cpu(fw_ddb_entry-iscsi_options);
+   conn-hdrdgst_en = test_bit(ISCSIOPT_HEADER_DIGEST_EN, options);
+   conn-datadgst_en = test_bit(ISCSIOPT_DATA_DIGEST_EN, options);
+   sess-imm_data_en = test_bit(ISCSIOPT_IMMEDIATE_DATA_EN, options);
+   sess-initial_r2t_en = test_bit(ISCSIOPT_INITIAL_R2T_EN, options);
+   sess-dataseq_inorder_en = test_bit(ISCSIOPT_DATA_SEQ_IN_ORDER,
+   options);
+   sess-pdu_inorder_en = test_bit(ISCSIOPT_DATA_PDU_IN_ORDER, options);
+   sess-chap_auth_en = test_bit(ISCSIOPT_CHAP_AUTH_EN, options);
+   sess-discovery_logout_en = test_bit(ISCSIOPT_DISCOVERY_LOGOUT_EN,
+options);
+   sess-bidi_chap_en = test_bit(ISCSIOPT_BIDI_CHAP_EN, options);
+   sess-discovery_auth_optional =
+   test_bit(ISCSIOPT_DISCOVERY_AUTH_OPTIONAL, options);
+   if (test_bit(ISCSIOPT_ERL1, options))
+   sess-erl |= BIT_1;
+   if (test_bit(ISCSIOPT_ERL0, options))
+   sess-erl |= BIT_0;
+
+   options = le16_to_cpu(fw_ddb_entry-tcp_options);
+   conn-tcp_timestamp_stat = test_bit(TCPOPT_TIMESTAMP_STAT, options);
+   conn-tcp_nagle_disable = test_bit(TCPOPT_NAGLE_DISABLE, options);
+   conn-tcp_wsf_disable = test_bit(TCPOPT_WSF_DISABLE, options);
+   if (test_bit(TCPOPT_TIMER_SCALE3, options))
+   conn-tcp_timer_scale |= BIT_3;
+   if (test_bit(TCPOPT_TIMER_SCALE2, options))
+   

[PATCH V2 1/4] scsi_transport_iscsi: Exporting new attrs for iscsi session and connection in sysfs

2013-07-01 Thread vikas.chaudhary
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Exporting new iSCSI Session and Connection parameters to sysfs

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/scsi_transport_iscsi.c |  123 ++-
 include/scsi/iscsi_if.h |   32 +
 2 files changed, 154 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index abf7c40..e4a989f 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -25,7 +25,6 @@
 #include linux/slab.h
 #include linux/bsg-lib.h
 #include linux/idr.h
-#include linux/list.h
 #include net/tcp.h
 #include scsi/scsi.h
 #include scsi/scsi_host.h
@@ -3327,6 +3326,23 @@ iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN);
 iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS);
 iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO);
 iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO);
+iscsi_conn_attr(local_port, ISCSI_PARAM_LOCAL_PORT);
+iscsi_conn_attr(statsn, ISCSI_PARAM_STATSN);
+iscsi_conn_attr(keepalive_tmo, ISCSI_PARAM_KEEPALIVE_TMO);
+iscsi_conn_attr(max_segment_size, ISCSI_PARAM_MAX_SEGMENT_SIZE);
+iscsi_conn_attr(tcp_timestamp_stat, ISCSI_PARAM_TCP_TIMESTAMP_STAT);
+iscsi_conn_attr(tcp_wsf_disable, ISCSI_PARAM_TCP_WSF_DISABLE);
+iscsi_conn_attr(tcp_nagle_disable, ISCSI_PARAM_TCP_NAGLE_DISABLE);
+iscsi_conn_attr(tcp_timer_scale, ISCSI_PARAM_TCP_TIMER_SCALE);
+iscsi_conn_attr(tcp_timestamp_enable, ISCSI_PARAM_TCP_TIMESTAMP_EN);
+iscsi_conn_attr(fragment_disable, ISCSI_PARAM_IP_FRAGMENT_DISABLE);
+iscsi_conn_attr(ipv4_tos, ISCSI_PARAM_IPV4_TOS);
+iscsi_conn_attr(ipv6_traffic_class, ISCSI_PARAM_IPV6_TC);
+iscsi_conn_attr(ipv6_flow_label, ISCSI_PARAM_IPV6_FLOW_LABEL);
+iscsi_conn_attr(is_fw_assigned_ipv6, ISCSI_PARAM_IS_FW_ASSIGNED_IPV6);
+iscsi_conn_attr(tcp_xmit_wsf, ISCSI_PARAM_TCP_XMIT_WSF);
+iscsi_conn_attr(tcp_recv_wsf, ISCSI_PARAM_TCP_RECV_WSF);
+
 
 #define iscsi_conn_ep_attr_show(param) \
 static ssize_t show_conn_ep_param_##param(struct device *dev,  \
@@ -3379,6 +3395,22 @@ static struct attribute *iscsi_conn_attrs[] = {
dev_attr_conn_persistent_port.attr,
dev_attr_conn_ping_tmo.attr,
dev_attr_conn_recv_tmo.attr,
+   dev_attr_conn_local_port.attr,
+   dev_attr_conn_statsn.attr,
+   dev_attr_conn_keepalive_tmo.attr,
+   dev_attr_conn_max_segment_size.attr,
+   dev_attr_conn_tcp_timestamp_stat.attr,
+   dev_attr_conn_tcp_wsf_disable.attr,
+   dev_attr_conn_tcp_nagle_disable.attr,
+   dev_attr_conn_tcp_timer_scale.attr,
+   dev_attr_conn_tcp_timestamp_enable.attr,
+   dev_attr_conn_fragment_disable.attr,
+   dev_attr_conn_ipv4_tos.attr,
+   dev_attr_conn_ipv6_traffic_class.attr,
+   dev_attr_conn_ipv6_flow_label.attr,
+   dev_attr_conn_is_fw_assigned_ipv6.attr,
+   dev_attr_conn_tcp_xmit_wsf.attr,
+   dev_attr_conn_tcp_recv_wsf.attr,
NULL,
 };
 
@@ -3416,6 +3448,38 @@ static umode_t iscsi_conn_attr_is_visible(struct kobject 
*kobj,
param = ISCSI_PARAM_PING_TMO;
else if (attr == dev_attr_conn_recv_tmo.attr)
param = ISCSI_PARAM_RECV_TMO;
+   else if (attr == dev_attr_conn_local_port.attr)
+   param = ISCSI_PARAM_LOCAL_PORT;
+   else if (attr == dev_attr_conn_statsn.attr)
+   param = ISCSI_PARAM_STATSN;
+   else if (attr == dev_attr_conn_keepalive_tmo.attr)
+   param = ISCSI_PARAM_KEEPALIVE_TMO;
+   else if (attr == dev_attr_conn_max_segment_size.attr)
+   param = ISCSI_PARAM_MAX_SEGMENT_SIZE;
+   else if (attr == dev_attr_conn_tcp_timestamp_stat.attr)
+   param = ISCSI_PARAM_TCP_TIMESTAMP_STAT;
+   else if (attr == dev_attr_conn_tcp_wsf_disable.attr)
+   param = ISCSI_PARAM_TCP_WSF_DISABLE;
+   else if (attr == dev_attr_conn_tcp_nagle_disable.attr)
+   param = ISCSI_PARAM_TCP_NAGLE_DISABLE;
+   else if (attr == dev_attr_conn_tcp_timer_scale.attr)
+   param = ISCSI_PARAM_TCP_TIMER_SCALE;
+   else if (attr == dev_attr_conn_tcp_timestamp_enable.attr)
+   param = ISCSI_PARAM_TCP_TIMESTAMP_EN;
+   else if (attr == dev_attr_conn_fragment_disable.attr)
+   param = ISCSI_PARAM_IP_FRAGMENT_DISABLE;
+   else if (attr == dev_attr_conn_ipv4_tos.attr)
+   param = ISCSI_PARAM_IPV4_TOS;
+   else if (attr == dev_attr_conn_ipv6_traffic_class.attr)
+   param = ISCSI_PARAM_IPV6_TC;
+   else if (attr == dev_attr_conn_ipv6_flow_label.attr)
+   param = ISCSI_PARAM_IPV6_FLOW_LABEL;
+   else if (attr == dev_attr_conn_is_fw_assigned_ipv6.attr)
+   param = ISCSI_PARAM_IS_FW_ASSIGNED_IPV6;
+   else if (attr == dev_attr_conn_tcp_xmit_wsf.attr)
+ 

Re: [PATCH v12 6/6] Avoid re-enabling I/O after the transport became offline

2013-07-01 Thread Bart Van Assche
On 07/01/13 10:27, Hannes Reinecke wrote:
 On 06/27/2013 04:57 PM, Bart Van Assche wrote:
 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
 index dfbaa34..666b741 100644
 --- a/drivers/scsi/scsi_sysfs.c
 +++ b/drivers/scsi/scsi_sysfs.c
 @@ -959,14 +959,16 @@ void __scsi_remove_device(struct scsi_device *sdev)
   {
  struct Scsi_Host *shost = sdev-host;
  struct device *dev = sdev-sdev_gendev;
 +enum scsi_device_state sdev_state;
  int res;
   
  if (sdev-is_visible) {
  spin_lock_irq(shost-host_lock);
 +sdev_state = sdev-sdev_state;
  res = scsi_device_set_state(sdev, SDEV_CANCEL);
  spin_unlock_irq(shost-host_lock);
   
 -if (res != 0)
 +if (res != 0  sdev_state != SDEV_TRANSPORT_OFFLINE)
  return;
   
  bsg_unregister_queue(sdev-request_queue);

 Hmm. This is really subtle. Do you mind adding inserting a comment
 here on why this is required?

How about inserting the following comment just above the last if-statement
in the code cited above ?

/*
 * The transition from SDEV_TRANSPORT_OFFLINE into SDEV_CANCEL
 * is not allowed since this transition would re-enable I/O. If
 * the device state was already SDEV_TRANSPORT_OFFLINE,
 * proceed with device removal.
 */

Bart.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 6/6] Avoid re-enabling I/O after the transport became offline

2013-07-01 Thread Hannes Reinecke
On 07/01/2013 02:05 PM, Bart Van Assche wrote:
 On 07/01/13 10:27, Hannes Reinecke wrote:
 On 06/27/2013 04:57 PM, Bart Van Assche wrote:
 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
 index dfbaa34..666b741 100644
 --- a/drivers/scsi/scsi_sysfs.c
 +++ b/drivers/scsi/scsi_sysfs.c
 @@ -959,14 +959,16 @@ void __scsi_remove_device(struct scsi_device *sdev)
   {
 struct Scsi_Host *shost = sdev-host;
 struct device *dev = sdev-sdev_gendev;
 +   enum scsi_device_state sdev_state;
 int res;
   
 if (sdev-is_visible) {
 spin_lock_irq(shost-host_lock);
 +   sdev_state = sdev-sdev_state;
 res = scsi_device_set_state(sdev, SDEV_CANCEL);
 spin_unlock_irq(shost-host_lock);
   
 -   if (res != 0)
 +   if (res != 0  sdev_state != SDEV_TRANSPORT_OFFLINE)
 return;
   
 bsg_unregister_queue(sdev-request_queue);

 Hmm. This is really subtle. Do you mind adding inserting a comment
 here on why this is required?
 
 How about inserting the following comment just above the last if-statement
 in the code cited above ?
 
   /*
* The transition from SDEV_TRANSPORT_OFFLINE into SDEV_CANCEL
* is not allowed since this transition would re-enable I/O. If
* the device state was already SDEV_TRANSPORT_OFFLINE,
* proceed with device removal.
*/
 
 Bart.
 
Perfect.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 08/15] scsi_transport_srp: Add transport layer error handling

2013-07-01 Thread David Dillow
On Mon, 2013-07-01 at 09:01 +0200, Bart Van Assche wrote:
 On 06/30/13 23:05, David Dillow wrote:
  On Fri, 2013-06-28 at 14:53 +0200, Bart Van Assche wrote:
  +int srp_tmo_valid(int fast_io_fail_tmo, int dev_loss_tmo)
  +{
  +  return (fast_io_fail_tmo  0 || dev_loss_tmo  0 ||
  +  fast_io_fail_tmo  dev_loss_tmo) 
  +  fast_io_fail_tmo  LONG_MAX / HZ 
  +  dev_loss_tmo  LONG_MAX / HZ ? 0 : -EINVAL;
  +}
 
  They should also be capped by SCSI_DEVICE_BLOCK_MAX_TIMEOUT instead of
  LONG_MAX / HZ, I think.
 
 The fast_io_fail_tmo should indeed be capped by that value. However, I'm 
 not sure about dev_loss_tmo. I think there are several use cases (e.g. 
 initiator-side mirroring) where it's useful to set dev_loss_tmo to a 
 larger value than ten minutes.

Ah, yes, very good point.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] scsi: Set hostbyte status in scsi_check_sense()

2013-07-01 Thread Hannes Reinecke
We should be modifying the host_byte status in scsi_check_sense()
directly; this saves us to introduce a special return code for
each and every condition.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi_error.c | 21 +++--
 include/scsi/scsi.h   |  1 -
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 84369f2..e5cb162 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -248,7 +248,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host 
*shost,
  * @scmd:  Cmd to have sense checked.
  *
  * Return value:
- * SUCCESS or FAILED or NEEDS_RETRY or TARGET_ERROR
+ * SUCCESS or FAILED or NEEDS_RETRY or ADD_TO_MLQUEUE
  *
  * Notes:
  * When a deferred error is detected the current command has
@@ -379,13 +379,15 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
case MISCOMPARE:
case BLANK_CHECK:
case DATA_PROTECT:
-   return TARGET_ERROR;
+   set_host_byte(scmd, DID_TARGET_FAILURE);
+   return SUCCESS;
 
case MEDIUM_ERROR:
if (sshdr.asc == 0x11 || /* UNRECOVERED READ ERR */
sshdr.asc == 0x13 || /* AMNF DATA FIELD */
sshdr.asc == 0x14) { /* RECORD NOT FOUND */
-   return TARGET_ERROR;
+   set_host_byte(scmd, DID_TARGET_FAILURE);
+   return SUCCESS;
}
return NEEDS_RETRY;
 
@@ -393,14 +395,14 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
if (scmd-device-retry_hwerror)
return ADD_TO_MLQUEUE;
else
-   return TARGET_ERROR;
+   set_host_byte(scmd, DID_TARGET_FAILURE);
 
case ILLEGAL_REQUEST:
if (sshdr.asc == 0x20 || /* Invalid command operation code */
sshdr.asc == 0x21 || /* Logical block address out of range 
*/
sshdr.asc == 0x24 || /* Invalid field in cdb */
sshdr.asc == 0x26) { /* Parameter value invalid */
-   return TARGET_ERROR;
+   set_host_byte(scmd, DID_TARGET_FAILURE);
}
return SUCCESS;
 
@@ -863,7 +865,6 @@ retry:
case SUCCESS:
case NEEDS_RETRY:
case FAILED:
-   case TARGET_ERROR:
break;
case ADD_TO_MLQUEUE:
rtn = NEEDS_RETRY;
@@ -1690,14 +1691,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
rtn = scsi_check_sense(scmd);
if (rtn == NEEDS_RETRY)
goto maybe_retry;
-   else if (rtn == TARGET_ERROR) {
-   /*
-* Need to modify host byte to signal a
-* permanent target failure
-*/
-   set_host_byte(scmd, DID_TARGET_FAILURE);
-   rtn = SUCCESS;
-   }
/* if rtn == FAILED, we have no sense information;
 * returning FAILED will wake the error handler thread
 * to collect the sense and redo the decide
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 66216c1..07d4bd916 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -481,7 +481,6 @@ static inline int scsi_is_wlun(unsigned int lun)
 #define TIMEOUT_ERROR   0x2007
 #define SCSI_RETURN_NOT_HANDLED   0x2008
 #define FAST_IO_FAIL   0x2009
-#define TARGET_ERROR0x200A
 
 /*
  * Midlevel queue return values.
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] scsi: Document enhanced error codes

2013-07-01 Thread Hannes Reinecke
Document the various error codes returned on I/O failure.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi_lib.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 86d5220..d3fc50f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -700,6 +700,18 @@ void scsi_release_buffers(struct scsi_cmnd *cmd)
 }
 EXPORT_SYMBOL(scsi_release_buffers);
 
+/**
+ * __scsi_error_from_host_byte - translate SCSI error code into errno
+ * @cmd:   SCSI command (unused)
+ * @result:scsi error code
+ *
+ * Translate SCSI error code into standard UNIX errno.
+ * Return values:
+ * -ENOLINKtemporary transport failure
+ * -EREMOTEIO  permanent target failure, do not retry
+ * -EBADE  permanent nexus failure, retry on other path
+ * -EIOunspecified I/O error
+ */
 static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
 {
int error = 0;
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 0/4] scsi: More detailed I/O errors

2013-07-01 Thread Hannes Reinecke
As discussed at LSF the SCSI stack already knows about several
error conditions, it's just not well documented.
Also there are some more conditions upper layers might be
interested in.

This patchset improves the documentation of the existing
I/O error codes and adds two more error codes, ENOSPC
for thin provisioning failure and ENODATA for medium error.

Changes since the initial version:
- Correctly document all return codes in
  __scsi_error_from_host_byte()
- Set hostbyte status in scsi_check_sense()

Changes since v2:
- Modify dm-mpath to handle ENOSPC

Hannes Reinecke (4):
  scsi: Document enhanced error codes
  scsi: Set hostbyte status in scsi_check_sense()
  scsi: return ENOSPC on thin provisioning failure
  scsi: Return ENODATA on medium error

 block/blk-core.c  |  6 ++
 drivers/md/dm-mpath.c | 16 +++-
 drivers/scsi/scsi_error.c | 28 +---
 drivers/scsi/scsi_lib.c   | 22 ++
 include/scsi/scsi.h   |  3 ++-
 5 files changed, 58 insertions(+), 17 deletions(-)

-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] scsi: return ENOSPC on thin provisioning failure

2013-07-01 Thread Hannes Reinecke
When the thin provisioning hard threshold is reached we
should return ENOSPC to inform upper layers about this fact.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 block/blk-core.c  | 3 +++
 drivers/scsi/scsi_error.c | 7 ++-
 drivers/scsi/scsi_lib.c   | 5 +
 include/scsi/scsi.h   | 1 +
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index d5745b5..170607c 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2315,6 +2315,9 @@ bool blk_update_request(struct request *req, int error, 
unsigned int nr_bytes)
case -EBADE:
error_type = critical nexus;
break;
+   case -ENOSPC:
+   error_type = critical space allocation;
+   break;
case -EIO:
default:
error_type = I/O;
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index e5cb162..aeec0e7 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -374,11 +374,16 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
return SUCCESS;
 
/* these are not supported */
+   case DATA_PROTECT:
+   if (sshdr.asc == 0x27  sshdr.ascq == 0x07) {
+   /* Thin provisioning hard threshold reached */
+   set_host_byte(scmd, DID_ALLOC_FAILURE);
+   return SUCCESS;
+   }
case COPY_ABORTED:
case VOLUME_OVERFLOW:
case MISCOMPARE:
case BLANK_CHECK:
-   case DATA_PROTECT:
set_host_byte(scmd, DID_TARGET_FAILURE);
return SUCCESS;
 
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d3fc50f..8a2f92d 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -710,6 +710,7 @@ EXPORT_SYMBOL(scsi_release_buffers);
  * -ENOLINKtemporary transport failure
  * -EREMOTEIO  permanent target failure, do not retry
  * -EBADE  permanent nexus failure, retry on other path
+ * -ENOSPC No write space available
  * -EIOunspecified I/O error
  */
 static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
@@ -728,6 +729,10 @@ static int __scsi_error_from_host_byte(struct scsi_cmnd 
*cmd, int result)
set_host_byte(cmd, DID_OK);
error = -EBADE;
break;
+   case DID_ALLOC_FAILURE:
+   set_host_byte(cmd, DID_OK);
+   error = -ENOSPC;
+   break;
default:
error = -EIO;
break;
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 07d4bd916..7d5b8e2 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -452,6 +452,7 @@ static inline int scsi_is_wlun(unsigned int lun)
 * other paths */
 #define DID_NEXUS_FAILURE 0x11  /* Permanent nexus failure, retry on other
 * paths might yield different results */
+#define DID_ALLOC_FAILURE 0x12  /* Space allocation on the device failed */
 #define DRIVER_OK   0x00   /* Driver status   */
 
 /*
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] scsi: Return ENODATA on medium error

2013-07-01 Thread Hannes Reinecke
When a medium error is detected the SCSI stack should return
ENODATA to the upper layers.

Cc: Jun'ichi Nomura j-nom...@ce.jp.nec.com
Signed-off-by: Hannes Reinecke h...@suse.de
---
 block/blk-core.c  |  3 +++
 drivers/md/dm-mpath.c | 16 +++-
 drivers/scsi/scsi_error.c |  2 +-
 drivers/scsi/scsi_lib.c   |  5 +
 include/scsi/scsi.h   |  1 +
 5 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 170607c..1093ca1 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2318,6 +2318,9 @@ bool blk_update_request(struct request *req, int error, 
unsigned int nr_bytes)
case -ENOSPC:
error_type = critical space allocation;
break;
+   case -ENODATA:
+   error_type = critical medium;
+   break;
case -EIO:
default:
error_type = I/O;
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index bdf26f5..57896cea 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1261,6 +1261,20 @@ static void activate_path(struct work_struct *work)
pg_init_done, pgpath);
 }
 
+static int noretry_error(int error)
+{
+   switch(error) {
+   case -EOPNOTSUPP:
+   case -EREMOTEIO:
+   case -EILSEQ:
+   case -ENODATA:
+   return 1;
+   }
+
+   /* Anything else could be a path failure, so should be retried */
+   return 0;
+}
+
 /*
  * end_io handling
  */
@@ -1284,7 +1298,7 @@ static int do_end_io(struct multipath *m, struct request 
*clone,
if (!error  !clone-errors)
return 0;   /* I/O complete */
 
-   if (error == -EOPNOTSUPP || error == -EREMOTEIO || error == -EILSEQ)
+   if (noretry_error(error))
return error;
 
if (mpio-pgpath)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index aeec0e7..7f794d4 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -391,7 +391,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
if (sshdr.asc == 0x11 || /* UNRECOVERED READ ERR */
sshdr.asc == 0x13 || /* AMNF DATA FIELD */
sshdr.asc == 0x14) { /* RECORD NOT FOUND */
-   set_host_byte(scmd, DID_TARGET_FAILURE);
+   set_host_byte(scmd, DID_MEDIUM_ERROR);
return SUCCESS;
}
return NEEDS_RETRY;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8a2f92d..70ca1f6 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -711,6 +711,7 @@ EXPORT_SYMBOL(scsi_release_buffers);
  * -EREMOTEIO  permanent target failure, do not retry
  * -EBADE  permanent nexus failure, retry on other path
  * -ENOSPC No write space available
+ * -ENODATAMedium error
  * -EIOunspecified I/O error
  */
 static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
@@ -733,6 +734,10 @@ static int __scsi_error_from_host_byte(struct scsi_cmnd 
*cmd, int result)
set_host_byte(cmd, DID_OK);
error = -ENOSPC;
break;
+   case DID_MEDIUM_ERROR:
+   set_host_byte(cmd, DID_OK);
+   error = -ENODATA;
+   break;
default:
error = -EIO;
break;
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 7d5b8e2..95ce204 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -453,6 +453,7 @@ static inline int scsi_is_wlun(unsigned int lun)
 #define DID_NEXUS_FAILURE 0x11  /* Permanent nexus failure, retry on other
 * paths might yield different results */
 #define DID_ALLOC_FAILURE 0x12  /* Space allocation on the device failed */
+#define DID_MEDIUM_ERROR  0x13  /* Medium error */
 #define DRIVER_OK   0x00   /* Driver status   */
 
 /*
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Can not see/access devices on Marvell 88SE9485 + SiI 3726 PMP

2013-07-01 Thread Hajo Möller
Hi,

I've got a box which recently got a Marvell 88SE9485 PCIe card
(Supermicro AOC-SAS2LP-MV8), which is connected by a mSAS-4x SATA-cable
to some 5 HDD backplanes (CFI-B53PM, chip is a SiI 3726).

The HBA's BIOS can see and access the HDDs through the backplanes, which
various Linux distributions could not.
I tried Ubuntu 12.04.2, Ubuntu 13.04, Debian 7.0 and a current Arch Linux.
All logs in this mail are from a fresh Ubuntu 12.04.2 install.

lspci shows the controller as:
01:00.0 RAID bus controller: Marvell Technology Group Ltd. Device 9485
(rev 03)

lshw does not show the attached disks, nor are there device nodes in
/dev/ for those disks.

Unplugging a disk results in this (/var/log/kern.log):
kernel: [  276.995910]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2062:phy 4 ctrl sts=0x.
kernel: [  276.995914]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2064:phy 4 irq sts = 0x01201001
kernel: [  278.950547]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2062:phy 4 ctrl sts=0x00111000.
kernel: [  278.950551]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2064:phy 4 irq sts = 0x0081
kernel: [  279.502757]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
838:get all reg link rate is 0x111000
kernel: [  279.502760]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
843:get link rate is 9
kernel: [  279.582118] mvsas :01:00.0: Phy0 : No sig fis
kernel: [  279.582121]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2006:phy0 Attached Device
kernel: [  283.953502]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2048:Get signature time out, reset phy 4
kernel: [  283.953517]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2062:phy 4 ctrl sts=0x.
kernel: [  283.953519]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2064:phy 4 irq sts = 0x1001
kernel: [  284.449485]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2062:phy 4 ctrl sts=0x00111000.
kernel: [  284.449488]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2064:phy 4 irq sts = 0x0081
kernel: [  286.445635]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
838:get all reg link rate is 0x111000
kernel: [  286.445638]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
843:get link rate is 9
kernel: [  286.524997] mvsas :01:00.0: Phy0 : No sig fis
kernel: [  286.525000]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2006:phy0 Attached Device

Replugging the disk:
kernel: [  310.738784]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2062:phy 4 ctrl sts=0x00111000.
kernel: [  310.738788]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2064:phy 4 irq sts = 0x0001
kernel: [  310.738791]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
2113:notify plug in on phy[0]
kernel: [  310.758632]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
838:get all reg link rate is 0x111000
kernel: [  310.758634]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
843:get link rate is 9
kernel: [  310.877669]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
1175:phy 4 attach dev info is 20001
kernel: [  310.877671]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
1177:phy 4 attach sas addr is 4
kernel: [  310.877678]
/build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
277:phy 4 byte dmaded.
kernel: [  310.877689] sas: sas_form_port: phy0 belongs to port0 already(1)!

According to Marvell's product brief the controller has Built-in
support for SATA Port Multipliers with FIS-based switching, which its
BIOS seems to confirm.

The PMPs used to work when connected via a Syba SY-PEX40008 (SiI3124)
controller, which has bugs on its own when more than three drives per
PMP are concurrently active.

Any help is greatly appreciated,

Hajo
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/9] mpt2sas: Enable new EH timeout handler

2013-07-01 Thread Hannes Reinecke
Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/mpt2sas/mpt2sas_scsih.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c 
b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index c6bdc92..a557e74 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -2565,6 +2565,16 @@ _scsih_tm_display_info(struct MPT2SAS_ADAPTER *ioc, 
struct scsi_cmnd *scmd)
 }
 
 /**
+ * _scsih_timed_out - eh timeout handler
+ * @scmd: pointer to scsi command object
+ */
+static enum blk_eh_timer_return
+_scsih_timed_out(struct scsi_cmnd *scmd)
+{
+   return scsi_abort_command(scmd);
+}
+
+/**
  * _scsih_abort - eh threads main abort routine
  * @scmd: pointer to scsi command object
  *
@@ -7513,8 +7523,9 @@ static struct scsi_host_template scsih_driver_template = {
.slave_destroy  = _scsih_slave_destroy,
.scan_finished  = _scsih_scan_finished,
.scan_start = _scsih_scan_start,
-   .change_queue_depth = _scsih_change_queue_depth,
+   .change_queue_depth = _scsih_change_queue_depth,
.change_queue_type  = _scsih_change_queue_type,
+   .eh_timed_out   = _scsih_timed_out,
.eh_abort_handler   = _scsih_abort,
.eh_device_reset_handler= _scsih_dev_reset,
.eh_target_reset_handler= _scsih_target_reset,
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 0/9] New EH command timeout handler

2013-07-01 Thread Hannes Reinecke
This patchset implements a new SCSI EH command timeout handler
which will be sending command aborts inline without actually
engaging SCSI EH.
SCSI EH will only be invoked if command abort fails.

In addition the commands will be returned directly
if the command abort succeeded, cutting down recovery
times dramatically.

With the original SCSI EH I got:
# time dd if=/dev/zero of=/dev/dm-2 bs=4k count=4k oflag=direct
4096+0 records in
4096+0 records out
16777216 bytes (17 MB) copied, 142.652 s, 118 kB/s

real2m22.657s
user0m0.013s
sys 0m0.145s

With this patchset I got:
# time dd if=/dev/zero of=/dev/dm-2 bs=4k count=4k oflag=direct
4096+0 records in
4096+0 records out
16777216 bytes (17 MB) copied, 52.1579 s, 322 kB/s

real0m52.163s
user0m0.012s
sys 0m0.145s

Test was to disable RSCN on the target port, disable the
target port, and then start the 'dd' command as indicated.

As a proof-of-concept I've also enabled the new timeout
handler for virtio, so that things can be tested out
more easily.
As requested I've also hooked in the new SCSI timeout
handler to SAS.

Changes to the original version:
- Use a private list in scsi_eh_abort_handler to avoid
  list starvation (pointed out by Joern Engel)
- Terminate command aborts when the first abort fails
- Do not attempt command aborts if the host is already in recovery
  or if the device is removed.
- Flush abort workqueue if the device is removed.

Changes to v2:
- Removed eh_entry initialisation
- Convert to per-command workqueue

Comments etc are welcome.


Hannes Reinecke (9):
  scsi: Fix erratic device offline during EH
  blk-timeout: add BLK_EH_SCHEDULED return code
  scsi: improved eh timeout handler
  virtio_scsi: Enable new EH timeout handler
  libsas: Enable new EH timeout handler
  mptsas: Enable new EH timeout handler
  mpt2sas: Enable new EH timeout handler
  mpt3sas: Enable new EH timeout handler
  scsi_transport_fc: Enable new EH timeout handler

 drivers/message/fusion/mptsas.c  |   3 +-
 drivers/message/fusion/mptscsih.c|   7 ++
 drivers/message/fusion/mptscsih.h|   1 +
 drivers/scsi/libsas/sas_scsi_host.c  |   2 +-
 drivers/scsi/mpt2sas/mpt2sas_scsih.c |  13 ++-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |  11 +++
 drivers/scsi/scsi.c  |   1 +
 drivers/scsi/scsi_error.c| 171 ++-
 drivers/scsi/scsi_priv.h |   2 +
 drivers/scsi/scsi_transport_fc.c |   2 +-
 drivers/scsi/virtio_scsi.c   |   8 ++
 include/linux/blkdev.h   |   1 +
 include/scsi/scsi_cmnd.h |   2 +
 13 files changed, 199 insertions(+), 25 deletions(-)

-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/9] virtio_scsi: Enable new EH timeout handler

2013-07-01 Thread Hannes Reinecke
Signed-off-by: Hannes Reinecke h...@suse.de
Acked-by: Paolo Bonzini pbonz...@redhat.com
---
 drivers/scsi/virtio_scsi.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 2168258..f23b9ef 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -630,6 +630,12 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
return virtscsi_tmf(vscsi, cmd);
 }
 
+static enum blk_eh_timer_return virtscsi_timedout(struct scsi_cmnd *scmd)
+{
+   scsi_abort_command(scmd);
+   return BLK_EH_SCHEDULED;
+}
+
 static int virtscsi_abort(struct scsi_cmnd *sc)
 {
struct virtio_scsi *vscsi = shost_priv(sc-device-host);
@@ -683,6 +689,7 @@ static struct scsi_host_template 
virtscsi_host_template_single = {
.queuecommand = virtscsi_queuecommand_single,
.eh_abort_handler = virtscsi_abort,
.eh_device_reset_handler = virtscsi_device_reset,
+   .eh_timed_out = virtscsi_timedout,
 
.can_queue = 1024,
.dma_boundary = UINT_MAX,
@@ -699,6 +706,7 @@ static struct scsi_host_template 
virtscsi_host_template_multi = {
.queuecommand = virtscsi_queuecommand_multi,
.eh_abort_handler = virtscsi_abort,
.eh_device_reset_handler = virtscsi_device_reset,
+   .eh_timed_out = virtscsi_timedout,
 
.can_queue = 1024,
.dma_boundary = UINT_MAX,
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/9] mpt3sas: Enable new EH timeout handler

2013-07-01 Thread Hannes Reinecke
Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index dcbf7c8..3a35ddc 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -2228,6 +2228,16 @@ _scsih_tm_display_info(struct MPT3SAS_ADAPTER *ioc, 
struct scsi_cmnd *scmd)
 }
 
 /**
+ * _scsih_timed_out - eh timeout handler
+ * @scmd: pointer to scsi command object
+ */
+static enum blk_eh_timer_return
+_scsih_timed_out(struct scsi_cmnd *scmd)
+{
+   return scsi_abort_command(scmd);
+}
+
+/**
  * _scsih_abort - eh threads main abort routine
  * @scmd: pointer to scsi command object
  *
@@ -7230,6 +7240,7 @@ static struct scsi_host_template scsih_driver_template = {
.scan_start = _scsih_scan_start,
.change_queue_depth = _scsih_change_queue_depth,
.change_queue_type  = _scsih_change_queue_type,
+   .eh_timed_out   = _scsih_timed_out,
.eh_abort_handler   = _scsih_abort,
.eh_device_reset_handler= _scsih_dev_reset,
.eh_target_reset_handler= _scsih_target_reset,
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/9] blk-timeout: add BLK_EH_SCHEDULED return code

2013-07-01 Thread Hannes Reinecke
Add a 'BLK_EH_SCHEDULED' return code for blk-timeout to indicate
that a delayed error recovery has been initiated.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi_error.c | 4 
 include/linux/blkdev.h| 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index d708067..e76e895 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -163,6 +163,10 @@ enum blk_eh_timer_return scsi_times_out(struct request 
*req)
else if (host-hostt-eh_timed_out)
rtn = host-hostt-eh_timed_out(scmd);
 
+   /* Check for asynchronous command aborts */
+   if (rtn == BLK_EH_SCHEDULED)
+   return BLK_EH_NOT_HANDLED;
+
scmd-result |= DID_TIME_OUT  16;
 
if (unlikely(rtn == BLK_EH_NOT_HANDLED 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2fdb4a4..d846e2b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -238,6 +238,7 @@ enum blk_eh_timer_return {
BLK_EH_NOT_HANDLED,
BLK_EH_HANDLED,
BLK_EH_RESET_TIMER,
+   BLK_EH_SCHEDULED,
 };
 
 typedef enum blk_eh_timer_return (rq_timed_out_fn)(struct request *);
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/9] scsi: improved eh timeout handler

2013-07-01 Thread Hannes Reinecke
When a command runs into a timeout we need to send an 'ABORT TASK'
TMF. This is typically done by the 'eh_abort_handler' LLDD callback.

Conceptually, however, this function is a normal SCSI command, so
there is no need to enter the error handler.

This patch implements a new scsi_abort_command() function which
invokes an asynchronous function scsi_eh_abort_handler() to
abort the commands via the usual 'eh_abort_handler'.

If abort succeeds the command is either retried or terminated,
depending on the number of allowed retries. However, 'eh_eflags'
records the abort, so if the retry would fail again the
command is pushed onto the error handler without trying to
abort it (again); it'll be cleared up from SCSI EH.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi.c   |   1 +
 drivers/scsi/scsi_error.c | 139 ++
 drivers/scsi/scsi_priv.h  |   2 +
 include/scsi/scsi_cmnd.h  |   2 +
 4 files changed, 132 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index ebe3b0a..06257cf 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -297,6 +297,7 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, 
gfp_t gfp_mask)
 
cmd-device = dev;
INIT_LIST_HEAD(cmd-list);
+   INIT_WORK(cmd-abort_work, scmd_eh_abort_handler);
spin_lock_irqsave(dev-list_lock, flags);
list_add_tail(cmd-list, dev-cmd_list);
spin_unlock_irqrestore(dev-list_lock, flags);
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index e76e895..835f7e4 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -55,6 +55,7 @@ static void scsi_eh_done(struct scsi_cmnd *scmd);
 #define HOST_RESET_SETTLE_TIME  (10)
 
 static int scsi_eh_try_stu(struct scsi_cmnd *scmd);
+static int scsi_try_to_abort_cmd(struct scsi_host_template *, struct scsi_cmnd 
*);
 
 /* called with shost-host_lock held */
 void scsi_eh_wakeup(struct Scsi_Host *shost)
@@ -102,6 +103,111 @@ static int scsi_host_eh_past_deadline(struct Scsi_Host 
*shost)
 }
 
 /**
+ * scmd_eh_abort_handler - Handle command aborts
+ * @work:  command to be aborted.
+ */
+void
+scmd_eh_abort_handler(struct work_struct *work)
+{
+   struct scsi_cmnd *scmd =
+   container_of(work, struct scsi_cmnd, abort_work);
+   struct scsi_device *sdev = scmd-device;
+   unsigned long flags;
+   int rtn;
+
+   spin_lock_irqsave(sdev-host-host_lock, flags);
+   if (scsi_host_eh_past_deadline(sdev-host)) {
+   spin_unlock_irqrestore(sdev-host-host_lock, flags);
+   SCSI_LOG_ERROR_RECOVERY(3,
+   scmd_printk(KERN_INFO, scmd,
+   eh timeout, not aborting\n));
+   } else {
+   spin_unlock_irqrestore(sdev-host-host_lock, flags);
+   SCSI_LOG_ERROR_RECOVERY(3,
+   scmd_printk(KERN_INFO, scmd,
+   aborting command %p\n, scmd));
+   rtn = scsi_try_to_abort_cmd(sdev-host-hostt, scmd);
+   if (rtn == SUCCESS) {
+   scmd-result |= DID_TIME_OUT  16;
+   if (!scsi_noretry_cmd(scmd) 
+   (++scmd-retries = scmd-allowed)) {
+   SCSI_LOG_ERROR_RECOVERY(3,
+   scmd_printk(KERN_WARNING, scmd,
+   retry aborted command\n));
+   scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY);
+   } else {
+   SCSI_LOG_ERROR_RECOVERY(3,
+   scmd_printk(KERN_WARNING, scmd,
+   finish aborted 
command\n));
+   scsi_finish_command(scmd);
+   }
+   return;
+   }
+   SCSI_LOG_ERROR_RECOVERY(3,
+   scmd_printk(KERN_INFO, scmd,
+   abort command failed, rtn %d\n, rtn));
+   }
+
+   if (scsi_eh_scmd_add(scmd, 0)) {
+   SCSI_LOG_ERROR_RECOVERY(3,
+   scmd_printk(KERN_WARNING, scmd,
+   terminate aborted command\n));
+   scmd-result |= DID_TIME_OUT  16;
+   scsi_finish_command(scmd);
+   }
+}
+
+/**
+ * scsi_abort_command - schedule a command abort
+ * @scmd:  scmd to abort.
+ *
+ * We only need to abort commands after a command timeout
+ */
+enum blk_eh_timer_return
+scsi_abort_command(struct scsi_cmnd *scmd)
+{
+   struct scsi_device *sdev = scmd-device;
+   struct Scsi_Host *shost = sdev-host;
+   unsigned long flags;
+
+   if (scmd-eh_eflags  SCSI_EH_ABORT_SCHEDULED) {
+   /*
+* command abort timed 

[PATCH 1/9] scsi: Fix erratic device offline during EH

2013-07-01 Thread Hannes Reinecke
Commit 18a4d0a22ed6c54b67af7718c305cd010f09ddf8
(Handle disk devices which can not process medium access commands)
was introduced to offline any device which cannot process medium
access commands.
However, commit 3eef6257de48ff84a5d98ca533685df8a3beaeb8
(Reduce error recovery time by reducing use of TURs) reduced
the number of TURs by sending it only on the first failing
command, which might or might not be a medium access command.
So in combination this results in an erratic device offlining
during EH; if the command where the TUR was sent upon happens
to be a medium access command the device will be set offline,
if not everything proceeds as normal.

So instead of checking the EH command in the -eh_action
callback we should rather call -eh_action when we're
about to finish the command _and_ have sent a TUR previously.
This should then set the device offline as advertised.

Cc: Martin K. Petersen martin.peter...@oracle.com
Cc: Ewan Milne emi...@redhat.com
Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi_error.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 7f794d4..d708067 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -885,12 +885,6 @@ retry:
 
scsi_eh_restore_cmnd(scmd, ses);
 
-   if (scmd-request-cmd_type != REQ_TYPE_BLOCK_PC) {
-   struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd);
-   if (sdrv-eh_action)
-   rtn = sdrv-eh_action(scmd, cmnd, cmnd_size, rtn);
-   }
-
return rtn;
 }
 
@@ -908,6 +902,18 @@ static int scsi_request_sense(struct scsi_cmnd *scmd)
return scsi_send_eh_cmnd(scmd, NULL, 0, SENSE_TIMEOUT, ~0);
 }
 
+static int scsi_eh_action(struct scsi_cmnd *scmd, int rtn)
+{
+   static unsigned char tur_command[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
+
+   if (scmd-request-cmd_type != REQ_TYPE_BLOCK_PC) {
+   struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd);
+   if (sdrv-eh_action)
+   rtn = sdrv-eh_action(scmd, tur_command, 6, rtn);
+   }
+   return rtn;
+}
+
 /**
  * scsi_eh_finish_cmd - Handle a cmd that eh is finished with.
  * @scmd:  Original SCSI cmd that eh has finished.
@@ -1085,7 +1091,9 @@ static int scsi_eh_test_devices(struct list_head 
*cmd_list,
 
list_for_each_entry_safe(scmd, next, cmd_list, eh_entry)
if (scmd-device == sdev) {
-   if (finish_cmds)
+   if (finish_cmds 
+   (try_stu ||
+scsi_eh_action(scmd, SUCCESS) == SUCCESS))
scsi_eh_finish_cmd(scmd, done_q);
else
list_move_tail(scmd-eh_entry, work_q);
@@ -1224,7 +1232,8 @@ static int scsi_eh_stu(struct Scsi_Host *shost,
!scsi_eh_tur(stu_scmd)) {
list_for_each_entry_safe(scmd, next,
  work_q, eh_entry) {
-   if (scmd-device == sdev)
+   if (scmd-device == sdev 
+   scsi_eh_action(scmd, SUCCESS) == 
SUCCESS)
scsi_eh_finish_cmd(scmd, 
done_q);
}
}
@@ -1291,7 +1300,8 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host 
*shost,
!scsi_eh_tur(bdr_scmd)) {
list_for_each_entry_safe(scmd, next,
 work_q, eh_entry) {
-   if (scmd-device == sdev)
+   if (scmd-device == sdev 
+   scsi_eh_action(scmd, rtn) != FAILED)
scsi_eh_finish_cmd(scmd,
   done_q);
}
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 9/9] scsi_transport_fc: Enable new EH timeout handler

2013-07-01 Thread Hannes Reinecke
Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/scsi_transport_fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index e106c27..1e1de9f 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -2079,7 +2079,7 @@ fc_timed_out(struct scsi_cmnd *scmd)
if (rport-port_state == FC_PORTSTATE_BLOCKED)
return BLK_EH_RESET_TIMER;
 
-   return BLK_EH_NOT_HANDLED;
+   return scsi_abort_command(scmd);
 }
 
 /*
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/9] mptsas: Enable new EH timeout handler

2013-07-01 Thread Hannes Reinecke
Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/message/fusion/mptsas.c   | 3 ++-
 drivers/message/fusion/mptscsih.c | 7 +++
 drivers/message/fusion/mptscsih.h | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index dd239bd..b3c87b2 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1986,7 +1986,8 @@ static struct scsi_host_template mptsas_driver_template = 
{
.slave_configure= mptsas_slave_configure,
.target_destroy = mptsas_target_destroy,
.slave_destroy  = mptscsih_slave_destroy,
-   .change_queue_depth = mptscsih_change_queue_depth,
+   .change_queue_depth = mptscsih_change_queue_depth,
+   .eh_timed_out   = mptscsih_timed_out,
.eh_abort_handler   = mptscsih_abort,
.eh_device_reset_handler= mptscsih_dev_reset,
.eh_host_reset_handler  = mptscsih_host_reset,
diff --git a/drivers/message/fusion/mptscsih.c 
b/drivers/message/fusion/mptscsih.c
index 727819c..e743e84 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1679,6 +1679,13 @@ mptscsih_get_tm_timeout(MPT_ADAPTER *ioc)
}
 }
 
+enum blk_eh_timer_return
+mptscsih_timed_out(struct scsi_cmnd *SCpnt)
+{
+   return scsi_abort_command(SCpnt);
+}
+EXPORT_SYMBOL(mptscsih_timed_out);
+
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  * mptscsih_abort - Abort linux scsi_cmnd routine, new_eh variant
diff --git a/drivers/message/fusion/mptscsih.h 
b/drivers/message/fusion/mptscsih.h
index 83f5031..3f2dd05 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -118,6 +118,7 @@ extern int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 
type, u8 channel,
u8 id, int lun, int ctx2abort, ulong timeout);
 extern void mptscsih_slave_destroy(struct scsi_device *device);
 extern int mptscsih_slave_configure(struct scsi_device *device);
+enum blk_eh_timer_return mptscsih_timed_out(struct scsi_cmnd *SCpnt);
 extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
 extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
 extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/9] libsas: Enable new EH timeout handler

2013-07-01 Thread Hannes Reinecke
Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/libsas/sas_scsi_host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c 
b/drivers/scsi/libsas/sas_scsi_host.c
index 6e795a1..9d5bd29 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -864,7 +864,7 @@ enum blk_eh_timer_return sas_scsi_timed_out(struct 
scsi_cmnd *cmd)
 {
scmd_printk(KERN_DEBUG, cmd, command %p timed out\n, cmd);
 
-   return BLK_EH_NOT_HANDLED;
+   return scsi_abort_command(cmd);
 }
 
 int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Can not see/access devices on Marvell 88SE9485 + SiI 3726 PMP

2013-07-01 Thread James Bottomley
On Mon, 2013-07-01 at 16:09 +0200, Hajo Möller wrote:
 Hi,
 
 I've got a box which recently got a Marvell 88SE9485 PCIe card
 (Supermicro AOC-SAS2LP-MV8), which is connected by a mSAS-4x SATA-cable
 to some 5 HDD backplanes (CFI-B53PM, chip is a SiI 3726).
 
 The HBA's BIOS can see and access the HDDs through the backplanes, which
 various Linux distributions could not.
 I tried Ubuntu 12.04.2, Ubuntu 13.04, Debian 7.0 and a current Arch Linux.
 All logs in this mail are from a fresh Ubuntu 12.04.2 install.
 
 lspci shows the controller as:
 01:00.0 RAID bus controller: Marvell Technology Group Ltd. Device 9485
 (rev 03)
 
 lshw does not show the attached disks, nor are there device nodes in
 /dev/ for those disks.
 
 Unplugging a disk results in this (/var/log/kern.log):
 kernel: [  276.995910]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2062:phy 4 ctrl sts=0x.
 kernel: [  276.995914]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2064:phy 4 irq sts = 0x01201001
 kernel: [  278.950547]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2062:phy 4 ctrl sts=0x00111000.
 kernel: [  278.950551]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2064:phy 4 irq sts = 0x0081
 kernel: [  279.502757]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
 838:get all reg link rate is 0x111000
 kernel: [  279.502760]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
 843:get link rate is 9
 kernel: [  279.582118] mvsas :01:00.0: Phy0 : No sig fis
 kernel: [  279.582121]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2006:phy0 Attached Device
 kernel: [  283.953502]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2048:Get signature time out, reset phy 4
 kernel: [  283.953517]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2062:phy 4 ctrl sts=0x.
 kernel: [  283.953519]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2064:phy 4 irq sts = 0x1001
 kernel: [  284.449485]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2062:phy 4 ctrl sts=0x00111000.
 kernel: [  284.449488]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2064:phy 4 irq sts = 0x0081
 kernel: [  286.445635]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
 838:get all reg link rate is 0x111000
 kernel: [  286.445638]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
 843:get link rate is 9
 kernel: [  286.524997] mvsas :01:00.0: Phy0 : No sig fis
 kernel: [  286.525000]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2006:phy0 Attached Device
 
 Replugging the disk:
 kernel: [  310.738784]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2062:phy 4 ctrl sts=0x00111000.
 kernel: [  310.738788]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2064:phy 4 irq sts = 0x0001
 kernel: [  310.738791]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 2113:notify plug in on phy[0]
 kernel: [  310.758632]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
 838:get all reg link rate is 0x111000
 kernel: [  310.758634]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_94xx.c
 843:get link rate is 9
 kernel: [  310.877669]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 1175:phy 4 attach dev info is 20001
 kernel: [  310.877671]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 1177:phy 4 attach sas addr is 4
 kernel: [  310.877678]
 /build/buildd/linux-lts-quantal-3.5.0/drivers/scsi/mvsas/mv_sas.c
 277:phy 4 byte dmaded.
 kernel: [  310.877689] sas: sas_form_port: phy0 belongs to port0 already(1)!
 
 According to Marvell's product brief the controller has Built-in
 support for SATA Port Multipliers with FIS-based switching, which its
 BIOS seems to confirm.
 
 The PMPs used to work when connected via a Syba SY-PEX40008 (SiI3124)
 controller, which has bugs on its own when more than three drives per
 PMP are concurrently active.
 
 Any help is greatly appreciated,

mv_sas is a libsas based driver.  libsas doesn't have any support for
SATA PMPs.  When it was added they were left as a todo item but then in
the field everyone deployed enterprise type SATA devices in SAS expander
chassis, so PMP support just got forgotten.

James


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 2/6] Avoid calling __scsi_remove_device() twice

2013-07-01 Thread James Bottomley
On Mon, 2013-07-01 at 09:14 +0200, Bart Van Assche wrote:
 On 07/01/13 09:05, James Bottomley wrote:
 
  On Thu, 2013-06-27 at 16:53 +0200, Bart Van Assche wrote:
  If something goes wrong during LUN scanning, e.g. a transport layer
  failure occurs, then __scsi_remove_device() can get invoked by the
  LUN scanning code for a SCSI device in state SDEV_CREATED_BLOCK. If
  this happens then the SCSI device has not yet been added to sysfs
  (is_visible == 0).  Make sure that in that case the transition into
  state SDEV_DEL occurs. This avoids that __scsi_remove_device() gets
  invoked a second time by scsi_forget_host().
 
  The patch summary of this one isn't true.  How about enable destruction
  of blocked devices which fail LUN scanning
 
 Hello James,
 
 Do you want me to repost the patch series or is this something you can 
 fix up ?

I can fix it up, but if you repost, please change it.

Thanks,

James

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 5/6] Avoid that scsi_device_set_state() triggers a race

2013-07-01 Thread James Bottomley

On Thu, 2013-06-27 at 16:56 +0200, Bart Van Assche wrote:
 Make concurrent invocations of scsi_device_set_state() safe.

Firstly, I don't understand from this where you think the races are.
Secondly, shouldn't this be the device lock? and thirdly, if we accept
that locking is required, encapsulate it in the function: Having the
callers manage locking is asking for trouble.  The latter may require a
new lock for the state to avoid entanglement.

James





--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 5/6] Avoid that scsi_device_set_state() triggers a race

2013-07-01 Thread Bart Van Assche

On 07/01/13 16:49, James Bottomley wrote:

On Thu, 2013-06-27 at 16:56 +0200, Bart Van Assche wrote:

Make concurrent invocations of scsi_device_set_state() safe.


Firstly, I don't understand from this where you think the races are.
Secondly, shouldn't this be the device lock? and thirdly, if we accept
that locking is required, encapsulate it in the function: Having the
callers manage locking is asking for trouble.  The latter may require a
new lock for the state to avoid entanglement.


Today there is no guarantee that scsi_device_set_state() calls are 
serialized, so two scsi_device_set_state() invocations may be in 
progress concurrently. It is e.g. possible that both calls report 
device state has been changed successfully to their callers although 
only one of these two state changes will be effective due to the race.


At the time I wrote this patch I think there was a caller that invoked 
scsi_device_set_state() with the host lock held. Hence my choice for the 
host lock. However, I can't find that caller anymore. So the suggestion 
to use the device lock instead makes sense to me. I'll double check 
whether there are no callers of that function that already hold the 
device lock.


Bart.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] block: Fix possible sleep in invalid context

2013-07-01 Thread Sujit Reddy Thumma
When block runtime PM is enabled following warning is seen
while resuming the device.

BUG: sleeping function called from invalid context at
.../drivers/base/power/runtime.c:923
in_atomic(): 1, irqs_disabled(): 128, pid: 12, name: kworker/0:1
[c0014448] (unwind_backtrace+0x0/0x120) from
[c03120e4] (__pm_runtime_suspend+0x34/0xa0) from
[c021c33c] (blk_post_runtime_resume+0x4c/0x5c) from
[c03297cc] (scsi_runtime_resume+0x90/0xb4) from
[c0310940] (__rpm_callback+0x30/0x58) from
[c0310980] (rpm_callback+0x18/0x28) from
[c0311ab0] (rpm_resume+0x3dc/0x540) from
[c03120a4] (pm_runtime_work+0x8c/0x98) from
[c007767c] (process_one_work+0x238/0x3e4) from
[c0077b90] (worker_thread+0x1ac/0x2ac) from
[c007cfdc] (kthread+0x88/0x94) from
[c000ece0] (kernel_thread_exit+0x0/0x8)

Fix this by releasing spin_lock_irq() before calling
pm_runtime_autosuspend() in blk_post_runtime_resume().

Signed-off-by: Sujit Reddy Thumma sthu...@codeaurora.org
Cc: sta...@vger.kernel.org
---
 block/blk-core.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 33c33bc..2456116 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3159,16 +3159,18 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
  */
 void blk_post_runtime_resume(struct request_queue *q, int err)
 {
-   spin_lock_irq(q-queue_lock);
if (!err) {
+   spin_lock_irq(q-queue_lock);
q-rpm_status = RPM_ACTIVE;
__blk_run_queue(q);
pm_runtime_mark_last_busy(q-dev);
+   spin_unlock_irq(q-queue_lock);
pm_runtime_autosuspend(q-dev);
} else {
+   spin_lock_irq(q-queue_lock);
q-rpm_status = RPM_SUSPENDED;
+   spin_unlock_irq(q-queue_lock);
}
-   spin_unlock_irq(q-queue_lock);
 }
 EXPORT_SYMBOL(blk_post_runtime_resume);
 #endif
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Upgrade Your Account!!!

2013-07-01 Thread Admin Portal


Attention,

Important message from ADMIN- Please confirm your email address by clicking 
this link:

http://upd.jimdo.com/

Webmaster

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 5/6] Avoid that scsi_device_set_state() triggers a race

2013-07-01 Thread James Bottomley
On Mon, 2013-07-01 at 17:17 +0200, Bart Van Assche wrote:
 On 07/01/13 16:49, James Bottomley wrote:
  On Thu, 2013-06-27 at 16:56 +0200, Bart Van Assche wrote:
  Make concurrent invocations of scsi_device_set_state() safe.
 
  Firstly, I don't understand from this where you think the races are.
  Secondly, shouldn't this be the device lock? and thirdly, if we accept
  that locking is required, encapsulate it in the function: Having the
  callers manage locking is asking for trouble.  The latter may require a
  new lock for the state to avoid entanglement.
 
 Today there is no guarantee that scsi_device_set_state() calls are 
 serialized, so two scsi_device_set_state() invocations may be in 
 progress concurrently. It is e.g. possible that both calls report 
 device state has been changed successfully to their callers although 
 only one of these two state changes will be effective due to the race.

We could say the above about a significant fraction of the functions in
the kernel; it's not a reason to add fine grained locking to them all.

I want to know what the actual races you're trying to fix are; what
causes them and, in particular, is adding yet another fine grained lock
going to mitigate them effectively or should they be mediated in a
different way.

James

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 0/7] Limit overall SCSI EH runtime

2013-07-01 Thread Jörn Engel
On Mon, 1 July 2013 08:50:48 +0200, Hannes Reinecke wrote:
 
 This patchset implements a new 'eh_deadline' attribute to the
 SCSI host. It will limit the overall SCSI EH runtime by a given
 timeout. If the timeout is reached all intermediate EH steps
 will be skipped and host reset will be scheduled immediately.

I have mixed opinions about the concept.

Having a command timeout is of limited use if you can still spend
several minutes after the timeout in random processing.  Userspace
either needs -EIO reasonably quickly after a command timeout or will
have to implement it's own timeout mechanism.  I prefer having a
single implementation in the kernel, so your patches are a step in the
right direction.

Host reset is an expensive and harmful operation.  You lose access to
all devices behind the host.  At best this is a performance blip, at
worst someone actually cared about some realtime properties.  My main
grump is that a single bad device can trigger this behaviour,
essentially doing a DoS on the rest of the system.  While that problem
is somewhat orthogonal, your patchset can only make matters worse.

Ideally we would have a way to detect the system geometry and next the
error location.  If a single device is bad, don't ever do a host
reset.  If you have redundant paths, never do a host reset on both
controllers at the same time.  Etc, etc.

Getting there will be a lot of work and the result may be too
error-prone to maintain without constantly breaking one exotic setup
or another.  But if someone could pull it off, it would be really nice
to have.

That said, now I should actually read your patches. ;)

Jörn

--
Measure. Don't tune for speed until you've measured, and even then
don't unless one part of the code overwhelms the rest.
-- Rob Pike
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 0/7] Limit overall SCSI EH runtime

2013-07-01 Thread James Bottomley
On Mon, 2013-07-01 at 13:44 -0400, Jörn Engel wrote:
 If a single device is bad, don't ever do a host
 reset.

This isn't a tenable position.  Sometimes a device looks bad because the
host state for it has gone insane.  At that point, the only safe action
is a reset of the host to sane state.

I could be persuaded that you should never do the transport equivalent
of a bus reset (on non-SPI transports, at least), which is actually hard
to do on some of the modern transports, but I don't think you can get
away without having a host reset in the eh arsenal.

James

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] block: Fix possible sleep in invalid context

2013-07-01 Thread Andrew Morton
On Mon,  1 Jul 2013 20:58:35 +0530 Sujit Reddy Thumma sthu...@codeaurora.org 
wrote:

 When block runtime PM is enabled following warning is seen
 while resuming the device.
 
 BUG: sleeping function called from invalid context at
 .../drivers/base/power/runtime.c:923
 in_atomic(): 1, irqs_disabled(): 128, pid: 12, name: kworker/0:1
 [c0014448] (unwind_backtrace+0x0/0x120) from
 [c03120e4] (__pm_runtime_suspend+0x34/0xa0) from
 [c021c33c] (blk_post_runtime_resume+0x4c/0x5c) from
 [c03297cc] (scsi_runtime_resume+0x90/0xb4) from
 [c0310940] (__rpm_callback+0x30/0x58) from
 [c0310980] (rpm_callback+0x18/0x28) from
 [c0311ab0] (rpm_resume+0x3dc/0x540) from
 [c03120a4] (pm_runtime_work+0x8c/0x98) from
 [c007767c] (process_one_work+0x238/0x3e4) from
 [c0077b90] (worker_thread+0x1ac/0x2ac) from
 [c007cfdc] (kthread+0x88/0x94) from
 [c000ece0] (kernel_thread_exit+0x0/0x8)
 
 Fix this by releasing spin_lock_irq() before calling
 pm_runtime_autosuspend() in blk_post_runtime_resume().
 
 --- a/block/blk-core.c
 +++ b/block/blk-core.c
 @@ -3159,16 +3159,18 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
   */
  void blk_post_runtime_resume(struct request_queue *q, int err)
  {
 - spin_lock_irq(q-queue_lock);
   if (!err) {
 + spin_lock_irq(q-queue_lock);
   q-rpm_status = RPM_ACTIVE;
   __blk_run_queue(q);
   pm_runtime_mark_last_busy(q-dev);
 + spin_unlock_irq(q-queue_lock);
   pm_runtime_autosuspend(q-dev);
   } else {
 + spin_lock_irq(q-queue_lock);
   q-rpm_status = RPM_SUSPENDED;
 + spin_unlock_irq(q-queue_lock);
   }
 - spin_unlock_irq(q-queue_lock);
  }
  EXPORT_SYMBOL(blk_post_runtime_resume);
  #endif

I suppose we can do this cleanly enough:

--- a/block/blk-core.c~block-fix-possible-sleep-in-invalid-context-fix
+++ a/block/blk-core.c
@@ -3159,15 +3159,14 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
  */
 void blk_post_runtime_resume(struct request_queue *q, int err)
 {
+   spin_lock_irq(q-queue_lock);
if (!err) {
-   spin_lock_irq(q-queue_lock);
q-rpm_status = RPM_ACTIVE;
__blk_run_queue(q);
pm_runtime_mark_last_busy(q-dev);
spin_unlock_irq(q-queue_lock);
pm_request_autosuspend(q-dev);
} else {
-   spin_lock_irq(q-queue_lock);
q-rpm_status = RPM_SUSPENDED;
spin_unlock_irq(q-queue_lock);
}
_


I wonder if we actually need locking around that second write to
q-rpm_status.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] block: Fix possible sleep in invalid context

2013-07-01 Thread James Bottomley
On Mon, 2013-07-01 at 15:17 -0700, Andrew Morton wrote:
 On Mon,  1 Jul 2013 20:58:35 +0530 Sujit Reddy Thumma 
 sthu...@codeaurora.org wrote:
 
  When block runtime PM is enabled following warning is seen
  while resuming the device.
  
  BUG: sleeping function called from invalid context at
  .../drivers/base/power/runtime.c:923
  in_atomic(): 1, irqs_disabled(): 128, pid: 12, name: kworker/0:1
  [c0014448] (unwind_backtrace+0x0/0x120) from
  [c03120e4] (__pm_runtime_suspend+0x34/0xa0) from
  [c021c33c] (blk_post_runtime_resume+0x4c/0x5c) from
  [c03297cc] (scsi_runtime_resume+0x90/0xb4) from
  [c0310940] (__rpm_callback+0x30/0x58) from
  [c0310980] (rpm_callback+0x18/0x28) from
  [c0311ab0] (rpm_resume+0x3dc/0x540) from
  [c03120a4] (pm_runtime_work+0x8c/0x98) from
  [c007767c] (process_one_work+0x238/0x3e4) from
  [c0077b90] (worker_thread+0x1ac/0x2ac) from
  [c007cfdc] (kthread+0x88/0x94) from
  [c000ece0] (kernel_thread_exit+0x0/0x8)
  
  Fix this by releasing spin_lock_irq() before calling
  pm_runtime_autosuspend() in blk_post_runtime_resume().
  
  --- a/block/blk-core.c
  +++ b/block/blk-core.c
  @@ -3159,16 +3159,18 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
*/
   void blk_post_runtime_resume(struct request_queue *q, int err)
   {
  -   spin_lock_irq(q-queue_lock);
  if (!err) {
  +   spin_lock_irq(q-queue_lock);
  q-rpm_status = RPM_ACTIVE;
  __blk_run_queue(q);
  pm_runtime_mark_last_busy(q-dev);
  +   spin_unlock_irq(q-queue_lock);
  pm_runtime_autosuspend(q-dev);
  } else {
  +   spin_lock_irq(q-queue_lock);
  q-rpm_status = RPM_SUSPENDED;
  +   spin_unlock_irq(q-queue_lock);
  }
  -   spin_unlock_irq(q-queue_lock);
   }
   EXPORT_SYMBOL(blk_post_runtime_resume);
   #endif
 
 I suppose we can do this cleanly enough:
 
 --- a/block/blk-core.c~block-fix-possible-sleep-in-invalid-context-fix
 +++ a/block/blk-core.c
 @@ -3159,15 +3159,14 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
   */
  void blk_post_runtime_resume(struct request_queue *q, int err)
  {
 + spin_lock_irq(q-queue_lock);
   if (!err) {
 - spin_lock_irq(q-queue_lock);
   q-rpm_status = RPM_ACTIVE;
   __blk_run_queue(q);
   pm_runtime_mark_last_busy(q-dev);
   spin_unlock_irq(q-queue_lock);
   pm_request_autosuspend(q-dev);
   } else {
 - spin_lock_irq(q-queue_lock);
   q-rpm_status = RPM_SUSPENDED;
   spin_unlock_irq(q-queue_lock);
   }
 _
 
 
 I wonder if we actually need locking around that second write to
 q-rpm_status.

Shouldn't: it's an int, which makes it a 32 bit quantity we believe to
have atomic write properties on every platform.

James


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 0/7] Limit overall SCSI EH runtime

2013-07-01 Thread Jörn Engel
On Mon, 1 July 2013 19:23:25 +, James Bottomley wrote:
 On Mon, 2013-07-01 at 13:44 -0400, Jörn Engel wrote:
  If a single device is bad, don't ever do a host
  reset.
 
 This isn't a tenable position.  Sometimes a device looks bad because the
 host state for it has gone insane.  At that point, the only safe action
 is a reset of the host to sane state.
 
 I could be persuaded that you should never do the transport equivalent
 of a bus reset (on non-SPI transports, at least), which is actually hard
 to do on some of the modern transports, but I don't think you can get
 away without having a host reset in the eh arsenal.

Fair enough.  Hardware being hardware and hardware bugs being hard to
fix, I see your point.

However, we shouldn't screw the poor user who has paid a premium for a
second HBA to get some redundancy and reset both of them at the same
time.  That would, you know, defeat the redundancy. ;)

Jörn

--
A victorious army first wins and then seeks battle.
-- Sun Tzu
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] block: Fix possible sleep in invalid context

2013-07-01 Thread Andrew Morton
On Mon, 01 Jul 2013 15:24:11 -0700 James Bottomley 
james.bottom...@hansenpartnership.com wrote:

  --- a/block/blk-core.c~block-fix-possible-sleep-in-invalid-context-fix
  +++ a/block/blk-core.c
  @@ -3159,15 +3159,14 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
*/
   void blk_post_runtime_resume(struct request_queue *q, int err)
   {
  +   spin_lock_irq(q-queue_lock);
  if (!err) {
  -   spin_lock_irq(q-queue_lock);
  q-rpm_status = RPM_ACTIVE;
  __blk_run_queue(q);
  pm_runtime_mark_last_busy(q-dev);
  spin_unlock_irq(q-queue_lock);
  pm_request_autosuspend(q-dev);
  } else {
  -   spin_lock_irq(q-queue_lock);
  q-rpm_status = RPM_SUSPENDED;
  spin_unlock_irq(q-queue_lock);
  }
  _
  
  
  I wonder if we actually need locking around that second write to
  q-rpm_status.
 
 Shouldn't: it's an int, which makes it a 32 bit quantity we believe to
 have atomic write properties on every platform.

Yes, but.  If there's some other code path which does:

spin_lock(queue_lock);
x = q-rpm_status;
...
y = q-rpm_status;
...
assumes x == y
spin_unlock(queue_lock);

then it blows up if we make the suggested change.  Stranger things have
happened...

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH -next] [SCSI] ufshcd-pltfrm: remove redundant dev_err call in ufshcd_pltfrm_probe()

2013-07-01 Thread Wei Yongjun
From: Wei Yongjun yongjun_...@trendmicro.com.cn

There is a error message within devm_ioremap_resource
already, so remove the dev_err call to avoid redundant
error message.

Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index c42db40..2bd7417 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -110,7 +110,6 @@ static int ufshcd_pltfrm_probe(struct platform_device *pdev)
 
mmio_base = devm_ioremap_resource(dev, mem_res);
if (IS_ERR(mmio_base)) {
-   dev_err(dev, memory map failed\n);
err = PTR_ERR(mmio_base);
goto out;
}

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] block: Fix possible sleep in invalid context

2013-07-01 Thread Aaron Lu
On 07/01/2013 11:28 PM, Sujit Reddy Thumma wrote:
 When block runtime PM is enabled following warning is seen
 while resuming the device.
 
 BUG: sleeping function called from invalid context at
 .../drivers/base/power/runtime.c:923
 in_atomic(): 1, irqs_disabled(): 128, pid: 12, name: kworker/0:1
 [c0014448] (unwind_backtrace+0x0/0x120) from
 [c03120e4] (__pm_runtime_suspend+0x34/0xa0) from
 [c021c33c] (blk_post_runtime_resume+0x4c/0x5c) from
 [c03297cc] (scsi_runtime_resume+0x90/0xb4) from
 [c0310940] (__rpm_callback+0x30/0x58) from
 [c0310980] (rpm_callback+0x18/0x28) from
 [c0311ab0] (rpm_resume+0x3dc/0x540) from
 [c03120a4] (pm_runtime_work+0x8c/0x98) from
 [c007767c] (process_one_work+0x238/0x3e4) from
 [c0077b90] (worker_thread+0x1ac/0x2ac) from
 [c007cfdc] (kthread+0x88/0x94) from
 [c000ece0] (kernel_thread_exit+0x0/0x8)
 
 Fix this by releasing spin_lock_irq() before calling
 pm_runtime_autosuspend() in blk_post_runtime_resume().

Hi Sujit,

Thanks for testing out block layer runtime PM!

As for the problem here, it is already fixed by:

commit c60855cdb976c632b3bf8922eeab8a0e78edfc04
Author: Aaron Lu aaron...@intel.com
Date:   Fri May 17 15:47:20 2013 +0800

blkpm: avoid sleep when holding queue lock

-Aaron

 
 Signed-off-by: Sujit Reddy Thumma sthu...@codeaurora.org
 Cc: sta...@vger.kernel.org
 ---
  block/blk-core.c |6 --
  1 files changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/block/blk-core.c b/block/blk-core.c
 index 33c33bc..2456116 100644
 --- a/block/blk-core.c
 +++ b/block/blk-core.c
 @@ -3159,16 +3159,18 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
   */
  void blk_post_runtime_resume(struct request_queue *q, int err)
  {
 - spin_lock_irq(q-queue_lock);
   if (!err) {
 + spin_lock_irq(q-queue_lock);
   q-rpm_status = RPM_ACTIVE;
   __blk_run_queue(q);
   pm_runtime_mark_last_busy(q-dev);
 + spin_unlock_irq(q-queue_lock);
   pm_runtime_autosuspend(q-dev);
   } else {
 + spin_lock_irq(q-queue_lock);
   q-rpm_status = RPM_SUSPENDED;
 + spin_unlock_irq(q-queue_lock);
   }
 - spin_unlock_irq(q-queue_lock);
  }
  EXPORT_SYMBOL(blk_post_runtime_resume);
  #endif
 

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] scsi: Return ENODATA on medium error

2013-07-01 Thread Jun'ichi Nomura
Hi Hannes,

On 07/01/13 22:16, Hannes Reinecke wrote:
 When a medium error is detected the SCSI stack should return
 ENODATA to the upper layers.
 
 Cc: Jun'ichi Nomura j-nom...@ce.jp.nec.com
 Signed-off-by: Hannes Reinecke h...@suse.de
 ---
  block/blk-core.c  |  3 +++
  drivers/md/dm-mpath.c | 16 +++-
  drivers/scsi/scsi_error.c |  2 +-
  drivers/scsi/scsi_lib.c   |  5 +
  include/scsi/scsi.h   |  1 +
  5 files changed, 25 insertions(+), 2 deletions(-)
..
 diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
 index bdf26f5..57896cea 100644
 --- a/drivers/md/dm-mpath.c
 +++ b/drivers/md/dm-mpath.c

Thank you for including the change.
But I think this change to dm should be a separate patch in this series
(prerequisite to the SCSI error code change) and Cc to dm-devel.

 @@ -1261,6 +1261,20 @@ static void activate_path(struct work_struct *work)
   pg_init_done, pgpath);
  }
  
 +static int noretry_error(int error)
 +{
 + switch(error) {
 + case -EOPNOTSUPP:
 + case -EREMOTEIO:
 + case -EILSEQ:
 + case -ENODATA:

case -ENOSPC:

We don't want to fail the path for -ENOSPC, do we?

 + return 1;
 + }
 +
 + /* Anything else could be a path failure, so should be retried */
 + return 0;
 +}
 +
  /*
   * end_io handling
   */
 @@ -1284,7 +1298,7 @@ static int do_end_io(struct multipath *m, struct 
 request *clone,
   if (!error  !clone-errors)
   return 0;   /* I/O complete */
  
 - if (error == -EOPNOTSUPP || error == -EREMOTEIO || error == -EILSEQ)
 + if (noretry_error(error))
   return error;
  
   if (mpio-pgpath)

-- 
Jun'ichi Nomura, NEC Corporation
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] block: Fix possible sleep in invalid context

2013-07-01 Thread Sujit Reddy Thumma

On 7/2/2013 8:34 AM, Aaron Lu wrote:

Fix this by releasing spin_lock_irq() before calling
pm_runtime_autosuspend() in blk_post_runtime_resume().

Hi Sujit,

Thanks for testing out block layer runtime PM!

As for the problem here, it is already fixed by:

commit c60855cdb976c632b3bf8922eeab8a0e78edfc04
Author: Aaron Luaaron...@intel.com
Date:   Fri May 17 15:47:20 2013 +0800

 blkpm: avoid sleep when holding queue lock


Thanks Aaron. I see that is merged in 3.10-rc6.
Please ignore this patch.

--
Regards,
Sujit
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] SCSI command, sense key + additional sense strings

2013-07-01 Thread Douglas Gilbert

It has been several years since the SCSI constants.c
file has been updated. The attached is against lk 3.10
and brings the command strings, sense keys and additional
sense code strings into sync with spc4r36g.pdf.

Certain SCSI command names that previously only took the
opcode (i.e. byte 0 of the cdb) into account, have been
split into several command names using the associated
service action field to differentiate. For example,
persistent reservations that previously had 2 commands
(i.e. in and out) have been expanded to 12 commands
(e.g. Persistent reserve in, read reservation).

Changelog:
  - sync SCSI command names, sense key strings and additional
sense code strings with SPC-4 draft revision 36g


Signed-off-by: Douglas Gilbert dgilb...@interlog.com
--- a/drivers/scsi/constants.c310	2012-12-12 06:16:21.0 -0500
+++ b/drivers/scsi/constants.c	2013-07-01 20:24:03.053736253 -0400
@@ -1,10 +1,10 @@
-/* 
+/*
  * ASCII values for a number of symbolic constants, printing functions,
  * etc.
  * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422)
  * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002)
  *   by D. Gilbert and aeb (20020609)
- * Update to SPC-4 T10/1713-D Rev 20, 22 May 2009, D. Gilbert 20090624
+ * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701
  */
 
 #include linux/blkdev.h
@@ -21,12 +21,13 @@
 
 
 /* Commands with service actions that change the command name */
-#define MAINTENANCE_IN 0xa3
-#define MAINTENANCE_OUT 0xa4
 #define SERVICE_ACTION_IN_12 0xab
 #define SERVICE_ACTION_OUT_12 0xa9
+#define SERVICE_ACTION_BIDIRECTIONAL 0x9d
 #define SERVICE_ACTION_IN_16 0x9e
 #define SERVICE_ACTION_OUT_16 0x9f
+#define THIRD_PARTY_COPY_OUT 0x83
+#define THIRD_PARTY_COPY_IN 0x84
 
 
 
@@ -36,11 +37,11 @@ static const char * cdb_byte0_names[] =
 /* 04-07 */ Format Unit/Medium, Read Block Limits, NULL,
 	Reassign Blocks,
 /* 08-0d */ Read(6), NULL, Write(6), Seek(6), NULL, NULL,
-/* 0e-12 */ NULL, Read Reverse, Write Filemarks, Space, Inquiry,  
+/* 0e-12 */ NULL, Read Reverse, Write Filemarks, Space, Inquiry,
 /* 13-16 */ Verify(6), Recover Buffered Data, Mode Select(6),
 	Reserve(6),
 /* 17-1a */ Release(6), Copy, Erase, Mode Sense(6),
-/* 1b-1d */ Start/Stop Unit, Receive Diagnostic, Send Diagnostic, 
+/* 1b-1d */ Start/Stop Unit, Receive Diagnostic, Send Diagnostic,
 /* 1e-1f */ Prevent/Allow Medium Removal, NULL,
 /* 20-22 */  NULL, NULL, NULL,
 /* 23-28 */ Read Format Capacities, Set Window,
@@ -48,16 +49,16 @@ static const char * cdb_byte0_names[] =
 /* 29-2d */ Read Generation, Write(10), Seek(10), Erase(10),
 Read updated block,
 /* 2e-31 */ Write Verify(10), Verify(10), Search High, Search Equal,
-/* 32-34 */ Search Low, Set Limits, Prefetch/Read Position, 
+/* 32-34 */ Search Low, Set Limits, Prefetch/Read Position,
 /* 35-37 */ Synchronize Cache(10), Lock/Unlock Cache(10),
-	Read Defect Data(10), 
-/* 38-3c */ Medium Scan, Compare, Copy Verify, Write Buffer, 
-Read Buffer, 
+	Read Defect Data(10),
+/* 38-3c */ Medium Scan, Compare, Copy Verify, Write Buffer,
+Read Buffer,
 /* 3d-3f */ Update Block, Read Long(10),  Write Long(10),
 /* 40-41 */ Change Definition, Write Same(10),
 /* 42-48 */ Unmap/Read sub-channel, Read TOC/PMA/ATIP,
 	Read density support, Play audio(10), Get configuration,
-	Play audio msf, Play audio track/index,
+	Play audio msf, Sanitize/Play audio track/index,
 /* 49-4f */ Play track relative(10), Get event status notification,
 Pause/resume, Log Select, Log Sense, Stop play/scan,
 NULL,
@@ -72,17 +73,17 @@ static const char * cdb_byte0_names[] =
 /* 70-77 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 /* 78-7f */ NULL, NULL, NULL, NULL, NULL, NULL, Extended CDB,
 	Variable length,
-/* 80-84 */ Xdwrite(16), Rebuild(16), Regenerate(16), Extended copy,
-Receive copy results,
+/* 80-84 */ Xdwrite(16), Rebuild(16), Regenerate(16),
+	Third party copy out, Third party copy in,
 /* 85-89 */ ATA command pass through(16), Access control in,
-	Access control out, Read(16), Memory Export Out(16),
+	Access control out, Read(16), Compare and Write,
 /* 8a-8f */ Write(16), ORWrite, Read attributes, Write attributes,
 Write and verify(16), Verify(16),
 /* 90-94 */ Pre-fetch(16), Synchronize cache(16),
 Lock/unlock cache(16), Write same(16), NULL,
 /* 95-99 */ NULL, NULL, NULL, NULL, NULL,
-/* 9a-9f */ NULL, NULL, NULL, NULL, Service action in(16),
-Service action out(16),
+/* 9a-9f */ NULL, NULL, NULL, Service action bidirectional,
+	Service action in(16), Service action out(16),
 /* a0-a5 */ Report luns, ATA command pass through(12)/Blank,
 Security protocol in, Maintenance in, Maintenance out,
 	Move medium/play audio(12),
@@ -122,6 +123,7 @@ static const struct value_name_pair main
 	{0x6, Set identifying information},
 	{0xa, Set target port groups},
 	{0xb, Change

RE: [patch] [SCSI] megaraid_sas: fix a bug for 64 bit arches

2013-07-01 Thread Saxena, Sumit
-Original Message-
From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
Sent: Saturday, June 29, 2013 2:51 AM
To: DL-MegaRAID Linux; Saxena, Sumit
Cc: James E.J. Bottomley; linux-scsi@vger.kernel.org; kernel-
janit...@vger.kernel.org
Subject: [patch] [SCSI] megaraid_sas: fix a bug for 64 bit arches

On 64 bit then -1UL and -1U are not equal, so these conditions don't
work as intended and it breaks error handling.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 8056eac..4f401f7 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -585,7 +585,7 @@ u8 get_arm(struct megasas_instance *instance, u32
ld, u8 span, u64 stripe,
   case 1:
   /* start with logical arm */
   arm = get_arm_from_strip(instance, ld, stripe, map);
-  if (arm != -1UL)
+  if (arm != -1U)
   arm *= 2;
   break;
   }
@@ -637,7 +637,7 @@ static u8 mr_spanset_get_phy_params(struct
megasas_instance *instance, u32 ld,

   if (raid-level == 6) {
   logArm = get_arm_from_strip(instance, ld, stripRow, map);
-  if (logArm == -1UL)
+  if (logArm == -1U)
   return FALSE;
   rowMod = mega_mod64(row, SPAN_ROW_SIZE(map, ld, span));
   armQ = SPAN_ROW_SIZE(map, ld, span) - 1 - rowMod;

Acked-by: Sumit Saxena sumit.sax...@lsi.com


Sumit


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 0/7] Limit overall SCSI EH runtime

2013-07-01 Thread Hannes Reinecke
On 07/01/2013 10:55 PM, Jörn Engel wrote:
 On Mon, 1 July 2013 19:23:25 +, James Bottomley wrote:
 On Mon, 2013-07-01 at 13:44 -0400, Jörn Engel wrote:
 If a single device is bad, don't ever do a host
 reset.

 This isn't a tenable position.  Sometimes a device looks bad because the
 host state for it has gone insane.  At that point, the only safe action
 is a reset of the host to sane state.

 I could be persuaded that you should never do the transport equivalent
 of a bus reset (on non-SPI transports, at least), which is actually hard
 to do on some of the modern transports, but I don't think you can get
 away without having a host reset in the eh arsenal.
 
 Fair enough.  Hardware being hardware and hardware bugs being hard to
 fix, I see your point.
 
 However, we shouldn't screw the poor user who has paid a premium for a
 second HBA to get some redundancy and reset both of them at the same
 time.  That would, you know, defeat the redundancy. ;)
 
Which would arguably a setup issue.

We've had SAN issues where the HBA lost track of the remote port
state (RSCNs being eaten by the switch firmware), so the only chance
of recovery was indeed a host reset.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html