Re: [PATCH 18/26] megaraid: Don't use create_proc_read_entry() [RFC]

2013-04-12 Thread Hannes Reinecke
On 04/11/2013 03:30 PM, David Howells wrote:
 Don't use create_proc_read_entry() as that is deprecated, but rather use
 proc_create_data() and seq_file instead.
 
 Signed-off-by: David Howells dhowe...@redhat.com
 cc: Neela Syam Kolli megaraidli...@lsi.com
 cc: James E.J. Bottomley jbottom...@parallels.com
 cc: linux-scsi@vger.kernel.org

Hmm?
What is the general stance on /proc entries for devices?
I was under the impression that it was marked as deprecated.

Is it not? Has it been resurrected?

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: error handler scheduling

2013-04-12 Thread Ren Mingxin

On 03/29/2013 12:02 AM, Elliott, Robert (Server Storage) wrote:

There are several possible reasons for SCSI command timeouts:
 a) the command request did not get to the SCSI target port and logical
unit (e.g., error on the wire)
 b) logical unit is still working on the command
 c) the command completed, but status didn't get to the SCSI initiator port
and application client (e.g., error on the wire)

SCSI doesn't have a good way to detect case (c). For status delivery errors
detected by the logical unit, I once proposed that the logical unit establish
a unit attention condition and record the status delivery problem in a log
page (T10 proposal 04-072) but this proposal didn't draw much interest. The
QUERY TASK task management function can detect case (b) vs. the other cases.

With SSDs, a lengthy timeout derived from ancient SCSI floppy drives doesn't
make sense. Timeouts should scale automatically based on the device type
(e.g., use microseconds for SSDs and seconds for HDDs). The REPORT
SUPPORTED OPERATION CODES command provides some command timeout values
to facilitate this.

For Base feature set drives I'm encouraging an approach like this for
handling command timeouts:

1) at discovery time:
 1a) send REPORT SUPPORTED OPERATION CODES to determine the nominal
 and maximum command timeouts
 1b) send REPORT SUPPORTED TASK MANAGEMENT FUNCTION to determine
 the TMF timeouts

2) send the command (e.g., READ, WRITE, FORMAT UNIT, ...)

If status arrives for the command at any time, exit out of this procedure.
If an I_T nexus loss occurs, then that handling overrides this procedure
as well. Otherwise:

3) if the nominal command timeout is long (e.g., for a command like FORMAT
UNIT with IMMED=0, but not for IO commands like READ and WRITE), then wait
a short time and send QUERY TASK to ensure the command got there:
 3a) if the command is not there (probably lost in delivery, but
 possibly lost status), go to step (2) to resend the command
 3b) if the command is still being processed, keep waiting

4) if the nominal command timeout is reached, send QUERY TASK to determine
what is happening:
 4a) if the command is not there (if step (3) was run, then this
 probably means lost status), go to step (2) to resend the command
 4b) if the command is still being processed, keep waiting

5) if the maximum command timeout is reached, send QUERY TASK to determine
what is happening:
 5a) if the command is not there (since step (4) was run, this
  probably means lost status), go to step (2) to resend the command
 5b) if the command is still being processed, proceed to step (6)
 to abort the command

6) send ABORT TASK to abort the command

7) If ABORT TASK succeeds, either:
 7a) escalate to a stronger TMF or hard reset if this command
keeps having repeated problems; or
 7b) go to step (2) to resend the command

8) If the ABORT TASK timeout is reached, either:
 8a) escalate to a stronger TMF or hard reset, then go to step (2)
 to resend the command; or
 8b) declare the logical unit is unavailable

Doug: for ***, In addition to WSNZ bit now letting the drive not support
the value of zero, T10 proposal 13-052 changes WRITE SAME so the NUMBER
OF LOGICAL BLOCKS set to zero (if supported) must honor the MAXIMUM WRITE
SAME LENGTH field, so the drive can provide a reasonable timeout value
for the command (not worry that the entire capacity might be specified).


Please let me summarize what this thread has talked about the scsi
eh latency:

1) some scsi cmds' timemout values are inappropriate, we can avoid
   timeout by:
   a) sg_format sets the IMMED bit and use TEST UNIT READY or REQUEST
  SENSE polling to monitor - by Douglas
   b) cut big cmd into some reasonable-sized ones - by Douglas
   c) improve timeout values according to device types - by Elliott
2) call -done() on the command after lun reset - by Hannes

And, my question is:
- could we wake up eh thread ASAP instead of waiting for all cmds
  complete to fast scheduling?

BTW: my original question is here:
http://www.spinics.net/lists/linux-scsi/msg65107.html

Thanks,
Ren


---
Rob ElliottHP Server Storage




-Original Message-
From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
ow...@vger.kernel.org] On Behalf Of Douglas Gilbert
Sent: Wednesday, 27 March, 2013 9:39 AM
To: james.sm...@emulex.com
Cc: linux-scsi@vger.kernel.org
Subject: Re: error handler scheduling

On 13-03-26 10:11 PM, James Smart wrote:

In looking through the error handler, if a command times out and is added to

the

eh_cmd_q for the shost, the error handler is only awakened once shost-
host_busy
(total number of i/os posted to the shost) is equal to shost-host_failed
(number of i/o that have been failed and put on the eh_cmd_q).  Which

means, any

other i/o that was outstanding must either complete or have their timeout

fire.


[PATCH 1/5] ibmvfc: Properly set cancel flags when cancelling abort

2013-04-12 Thread Brian King

The flags on a cancel operation are intended to indicate what,
if any, TMF will follow the cancel request. This fixes a case
where we were incorrectly setting the abort task set flag on
the cancel flag when we were cancelling an abort task set.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
---

 drivers/scsi/ibmvscsi/ibmvfc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_abort_cancel_flags 
drivers/scsi/ibmvscsi/ibmvfc.c
--- linux-2.6/drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_abort_cancel_flags  
2013-01-22 07:44:23.0 -0600
+++ linux-2.6-bjking1/drivers/scsi/ibmvscsi/ibmvfc.c2013-01-22 
07:44:56.0 -0600
@@ -2327,7 +2327,7 @@ static int ibmvfc_abort_task_set(struct
timeout = wait_for_completion_timeout(evt-comp, timeout);
 
if (!timeout) {
-   rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
+   rc = ibmvfc_cancel_all(sdev, 0);
if (!rc) {
rc = ibmvfc_wait_for_ops(vhost, sdev-hostdata, 
ibmvfc_match_key);
if (rc == SUCCESS)
_

--
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] ibmvfc: Support FAST_IO_FAIL in EH handlers

2013-04-12 Thread Brian King

Adds support for receiving FAST_IO_FAIL from fc_block_scsi_eh
when in error recovery. This fixes cases of devices being
taken offline when they are no longer accessible on the fabric,
preventing them from coming back online when the fabric recovers.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
---

 drivers/scsi/ibmvscsi/ibmvfc.c |   69 ++---
 1 file changed, 52 insertions(+), 17 deletions(-)

diff -puN drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_block_scsi_eh_fast_fail 
drivers/scsi/ibmvscsi/ibmvfc.c
--- linux-2.6/drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_block_scsi_eh_fast_fail 
2013-01-22 07:51:01.0 -0600
+++ linux-2.6-bjking1/drivers/scsi/ibmvscsi/ibmvfc.c2013-02-06 
14:56:06.0 -0600
@@ -2383,24 +2383,30 @@ out:
  * @cmd:   scsi command to abort
  *
  * Returns:
- * SUCCESS / FAILED
+ * SUCCESS / FAST_IO_FAIL / FAILED
  **/
 static int ibmvfc_eh_abort_handler(struct scsi_cmnd *cmd)
 {
struct scsi_device *sdev = cmd-device;
struct ibmvfc_host *vhost = shost_priv(sdev-host);
-   int cancel_rc, abort_rc;
+   int cancel_rc, block_rc, abort_rc = 0;
int rc = FAILED;
 
ENTER;
-   fc_block_scsi_eh(cmd);
+   block_rc = fc_block_scsi_eh(cmd);
ibmvfc_wait_while_resetting(vhost);
-   cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
-   abort_rc = ibmvfc_abort_task_set(sdev);
+   if (block_rc != FAST_IO_FAIL) {
+   cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
+   abort_rc = ibmvfc_abort_task_set(sdev);
+   } else
+   cancel_rc = ibmvfc_cancel_all(sdev, 0);
 
if (!cancel_rc  !abort_rc)
rc = ibmvfc_wait_for_ops(vhost, sdev, ibmvfc_match_lun);
 
+   if (block_rc == FAST_IO_FAIL  rc != FAILED)
+   rc = FAST_IO_FAIL;
+
LEAVE;
return rc;
 }
@@ -2410,29 +2416,47 @@ static int ibmvfc_eh_abort_handler(struc
  * @cmd:   scsi command struct
  *
  * Returns:
- * SUCCESS / FAILED
+ * SUCCESS / FAST_IO_FAIL / FAILED
  **/
 static int ibmvfc_eh_device_reset_handler(struct scsi_cmnd *cmd)
 {
struct scsi_device *sdev = cmd-device;
struct ibmvfc_host *vhost = shost_priv(sdev-host);
-   int cancel_rc, reset_rc;
+   int cancel_rc, block_rc, reset_rc = 0;
int rc = FAILED;
 
ENTER;
-   fc_block_scsi_eh(cmd);
+   block_rc = fc_block_scsi_eh(cmd);
ibmvfc_wait_while_resetting(vhost);
-   cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_LUN_RESET);
-   reset_rc = ibmvfc_reset_device(sdev, IBMVFC_LUN_RESET, LUN);
+   if (block_rc != FAST_IO_FAIL) {
+   cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_LUN_RESET);
+   reset_rc = ibmvfc_reset_device(sdev, IBMVFC_LUN_RESET, LUN);
+   } else
+   cancel_rc = ibmvfc_cancel_all(sdev, 0);
 
if (!cancel_rc  !reset_rc)
rc = ibmvfc_wait_for_ops(vhost, sdev, ibmvfc_match_lun);
 
+   if (block_rc == FAST_IO_FAIL  rc != FAILED)
+   rc = FAST_IO_FAIL;
+
LEAVE;
return rc;
 }
 
 /**
+ * ibmvfc_dev_cancel_all_noreset - Device iterated cancel all function
+ * @sdev:  scsi device struct
+ * @data:  return code
+ *
+ **/
+static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data)
+{
+   unsigned long *rc = data;
+   *rc |= ibmvfc_cancel_all(sdev, 0);
+}
+
+/**
  * ibmvfc_dev_cancel_all_reset - Device iterated cancel all function
  * @sdev:  scsi device struct
  * @data:  return code
@@ -2449,26 +2473,33 @@ static void ibmvfc_dev_cancel_all_reset(
  * @cmd:   scsi command struct
  *
  * Returns:
- * SUCCESS / FAILED
+ * SUCCESS / FAST_IO_FAIL / FAILED
  **/
 static int ibmvfc_eh_target_reset_handler(struct scsi_cmnd *cmd)
 {
struct scsi_device *sdev = cmd-device;
struct ibmvfc_host *vhost = shost_priv(sdev-host);
struct scsi_target *starget = scsi_target(sdev);
-   int reset_rc;
+   int block_rc;
+   int reset_rc = 0;
int rc = FAILED;
unsigned long cancel_rc = 0;
 
ENTER;
-   fc_block_scsi_eh(cmd);
+   block_rc = fc_block_scsi_eh(cmd);
ibmvfc_wait_while_resetting(vhost);
-   starget_for_each_device(starget, cancel_rc, 
ibmvfc_dev_cancel_all_reset);
-   reset_rc = ibmvfc_reset_device(sdev, IBMVFC_TARGET_RESET, target);
+   if (block_rc != FAST_IO_FAIL) {
+   starget_for_each_device(starget, cancel_rc, 
ibmvfc_dev_cancel_all_reset);
+   reset_rc = ibmvfc_reset_device(sdev, IBMVFC_TARGET_RESET, 
target);
+   } else
+   starget_for_each_device(starget, cancel_rc, 
ibmvfc_dev_cancel_all_noreset);
 
if (!cancel_rc  !reset_rc)
rc = ibmvfc_wait_for_ops(vhost, starget, ibmvfc_match_target);
 
+   if (block_rc == FAST_IO_FAIL  rc != FAILED)
+   rc = FAST_IO_FAIL;
+
 

[PATCH 5/5] ibmvfc: Driver version 1.0.11

2013-04-12 Thread Brian King

Bump driver version to 1.0.11.


Signed-off-by: Brian King brk...@linux.vnet.ibm.com
---

 drivers/scsi/ibmvscsi/ibmvfc.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -puN drivers/scsi/ibmvscsi/ibmvfc.h~ibmvfc_version_1_0_11 
drivers/scsi/ibmvscsi/ibmvfc.h
--- linux/drivers/scsi/ibmvscsi/ibmvfc.h~ibmvfc_version_1_0_11  2013-04-10 
15:51:55.0 -0500
+++ linux-bjking1/drivers/scsi/ibmvscsi/ibmvfc.h2013-04-12 
08:22:33.0 -0500
@@ -29,8 +29,8 @@
 #include viosrp.h
 
 #define IBMVFC_NAMEibmvfc
-#define IBMVFC_DRIVER_VERSION  1.0.10
-#define IBMVFC_DRIVER_DATE (August 24, 2012)
+#define IBMVFC_DRIVER_VERSION  1.0.11
+#define IBMVFC_DRIVER_DATE (April 12, 2013)
 
 #define IBMVFC_DEFAULT_TIMEOUT 60
 #define IBMVFC_ADISC_CANCEL_TIMEOUT45
_

--
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] ibmvfc: Suppress ABTS if target gone

2013-04-12 Thread Brian King

Adds support for a new VIOS feature that allows ibmvfc to
optimize terminate_rport_io by telling the VIOS the target
is no longer accessible on the fabric and that it should
not send an ABTS out on the fabric to the device.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
---

 drivers/scsi/ibmvscsi/ibmvfc.c |   13 +++--
 drivers/scsi/ibmvscsi/ibmvfc.h |3 ++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff -puN drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_supress_abts 
drivers/scsi/ibmvscsi/ibmvfc.c
--- linux-2.6/drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_supress_abts
2013-01-25 14:29:11.0 -0600
+++ linux-2.6-bjking1/drivers/scsi/ibmvscsi/ibmvfc.c2013-01-25 
14:29:24.0 -0600
@@ -2190,10 +2190,12 @@ static int ibmvfc_cancel_all(struct scsi
tmf-common.length = sizeof(*tmf);
tmf-scsi_id = rport-port_id;
int_to_scsilun(sdev-lun, tmf-lun);
+   if (!(vhost-login_buf-resp.capabilities  
IBMVFC_CAN_SUPPRESS_ABTS))
+   type = ~IBMVFC_TMF_SUPPRESS_ABTS;
if (vhost-state == IBMVFC_ACTIVE)
tmf-flags = (type | IBMVFC_TMF_LUA_VALID);
else
-   tmf-flags = IBMVFC_TMF_LUA_VALID;
+   tmf-flags = ((type  IBMVFC_TMF_SUPPRESS_ABTS) | 
IBMVFC_TMF_LUA_VALID);
tmf-cancel_key = (unsigned long)sdev-hostdata;
tmf-my_cancel_key = (unsigned long)starget-hostdata;
 
@@ -2402,7 +2404,7 @@ static int ibmvfc_eh_abort_handler(struc
cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
ibmvfc_abort_task_set(sdev);
} else
-   cancel_rc = ibmvfc_cancel_all(sdev, 0);
+   cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_SUPPRESS_ABTS);
 
if (!cancel_rc)
rc = ibmvfc_wait_for_ops(vhost, sdev, ibmvfc_match_lun);
@@ -2435,7 +2437,7 @@ static int ibmvfc_eh_device_reset_handle
cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_LUN_RESET);
reset_rc = ibmvfc_reset_device(sdev, IBMVFC_LUN_RESET, LUN);
} else
-   cancel_rc = ibmvfc_cancel_all(sdev, 0);
+   cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_SUPPRESS_ABTS);
 
if (!cancel_rc  !reset_rc)
rc = ibmvfc_wait_for_ops(vhost, sdev, ibmvfc_match_lun);
@@ -2456,7 +2458,7 @@ static int ibmvfc_eh_device_reset_handle
 static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data)
 {
unsigned long *rc = data;
-   *rc |= ibmvfc_cancel_all(sdev, 0);
+   *rc |= ibmvfc_cancel_all(sdev, IBMVFC_TMF_SUPPRESS_ABTS);
 }
 
 /**
@@ -2547,8 +2549,7 @@ static void ibmvfc_terminate_rport_io(st
dev_rport = starget_to_rport(scsi_target(sdev));
if (dev_rport != rport)
continue;
-   ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
-   ibmvfc_abort_task_set(sdev);
+   ibmvfc_cancel_all(sdev, IBMVFC_TMF_SUPPRESS_ABTS);
}
 
rc = ibmvfc_wait_for_ops(vhost, rport, ibmvfc_match_rport);
diff -puN drivers/scsi/ibmvscsi/ibmvfc.h~ibmvfc_supress_abts 
drivers/scsi/ibmvscsi/ibmvfc.h
--- linux-2.6/drivers/scsi/ibmvscsi/ibmvfc.h~ibmvfc_supress_abts
2013-01-25 14:29:11.0 -0600
+++ linux-2.6-bjking1/drivers/scsi/ibmvscsi/ibmvfc.h2013-01-25 
14:29:11.0 -0600
@@ -208,10 +208,10 @@ struct ibmvfc_npiv_login_resp {
u16 error;
u32 flags;
 #define IBMVFC_NATIVE_FC   0x01
-#define IBMVFC_CAN_FLUSH_ON_HALT   0x08
u32 reserved;
u64 capabilities;
 #define IBMVFC_CAN_FLUSH_ON_HALT   0x08
+#define IBMVFC_CAN_SUPPRESS_ABTS   0x10
u32 max_cmds;
u32 scsi_id_sz;
u64 max_dma_len;
@@ -351,6 +351,7 @@ struct ibmvfc_tmf {
 #define IBMVFC_TMF_LUN_RESET   0x10
 #define IBMVFC_TMF_TGT_RESET   0x20
 #define IBMVFC_TMF_LUA_VALID   0x40
+#define IBMVFC_TMF_SUPPRESS_ABTS   0x80
u32 cancel_key;
u32 my_cancel_key;
u32 pad;
_

--
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] ibmvfc: Send cancel when link is down

2013-04-12 Thread Brian King

If attempting to abort requests due to a fail fail timeout
or error handling while the link is down, we cannot send
an abort out on the fabric. We can, however, send a cancel
to the VIOS. This fixes ibmvfc to send a cancel in this
case to prevent error handling from failing and/or
escalating.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
---

 drivers/scsi/ibmvscsi/ibmvfc.c |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff -puN drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_cancel_when_link_down 
drivers/scsi/ibmvscsi/ibmvfc.c
--- linux-2.6/drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_cancel_when_link_down   
2013-01-23 08:12:09.0 -0600
+++ linux-2.6-bjking1/drivers/scsi/ibmvscsi/ibmvfc.c2013-01-23 
09:18:46.0 -0600
@@ -2179,7 +2179,7 @@ static int ibmvfc_cancel_all(struct scsi
return 0;
}
 
-   if (vhost-state == IBMVFC_ACTIVE) {
+   if (vhost-logged_in) {
evt = ibmvfc_get_event(vhost);
ibmvfc_init_event(evt, ibmvfc_sync_completion, 
IBMVFC_MAD_FORMAT);
 
@@ -2190,7 +2190,10 @@ static int ibmvfc_cancel_all(struct scsi
tmf-common.length = sizeof(*tmf);
tmf-scsi_id = rport-port_id;
int_to_scsilun(sdev-lun, tmf-lun);
-   tmf-flags = (type | IBMVFC_TMF_LUA_VALID);
+   if (vhost-state == IBMVFC_ACTIVE)
+   tmf-flags = (type | IBMVFC_TMF_LUA_VALID);
+   else
+   tmf-flags = IBMVFC_TMF_LUA_VALID;
tmf-cancel_key = (unsigned long)sdev-hostdata;
tmf-my_cancel_key = (unsigned long)starget-hostdata;
 
@@ -2389,7 +2392,7 @@ static int ibmvfc_eh_abort_handler(struc
 {
struct scsi_device *sdev = cmd-device;
struct ibmvfc_host *vhost = shost_priv(sdev-host);
-   int cancel_rc, block_rc, abort_rc = 0;
+   int cancel_rc, block_rc;
int rc = FAILED;
 
ENTER;
@@ -2397,11 +2400,11 @@ static int ibmvfc_eh_abort_handler(struc
ibmvfc_wait_while_resetting(vhost);
if (block_rc != FAST_IO_FAIL) {
cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
-   abort_rc = ibmvfc_abort_task_set(sdev);
+   ibmvfc_abort_task_set(sdev);
} else
cancel_rc = ibmvfc_cancel_all(sdev, 0);
 
-   if (!cancel_rc  !abort_rc)
+   if (!cancel_rc)
rc = ibmvfc_wait_for_ops(vhost, sdev, ibmvfc_match_lun);
 
if (block_rc == FAST_IO_FAIL  rc != FAILED)
_

--
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] scsi_transport_fc: Make 'port_state' writeable

2013-04-12 Thread Chad Dupuis

Our testing of this patch has not shown any issues however I think we
would be more comfortable with this change if there was a callback back
into the LLDs that want to be notified of the rport state change so we
can sync up our internal fibre channel port structures.  AFAICT the
changes required to add the callback to your original patch are fairly
small...something along the lines of:

diff --git a/drivers/scsi/scsi_transport_fc.c
b/drivers/scsi/scsi_transport_fc.c
index f3bba1a..6d3bc06 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -959,6 +959,7 @@ store_fc_rport_port_state(struct device *dev,
   unsigned long flags;
   struct fc_rport *rport = transport_class_to_rport(dev);
   struct Scsi_Host *shost = rport_to_shost(rport);
+   struct fc_internal *i = to_fc_internal(shost-transportt);

   spin_lock_irqsave(shost-host_lock, flags);
   if (!strncmp(buf, Blocked, 7)) {
@@ -968,6 +969,8 @@ store_fc_rport_port_state(struct device *dev,
   }
   spin_unlock_irqrestore(shost-host_lock, flags);
   fc_remote_port_delete(rport);
+   if (i-f-rport_state_change)
+   i-f-rport_state_change(rport);
   } else if (!strncmp(buf, Online, 6)) {
   if (rport-port_state != FC_PORTSTATE_BLOCKED) {
   spin_unlock_irqrestore(shost-host_lock, flags);
@@ -999,6 +1002,8 @@ store_fc_rport_port_state(struct device *dev,
   scsi_queue_work(shost, rport-scan_work);
   spin_unlock_irqrestore(shost-host_lock, flags);
   }
+   if (i-f-rport_state_change)
+   i-f-rport_state_change(rport);
   } else
   return -EINVAL;

diff --git a/include/scsi/scsi_transport_fc.h
b/include/scsi/scsi_transport_fc.h
index b797e8f..71c3ec5 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -698,6 +698,12 @@ struct fc_function_template {
   int (*bsg_request)(struct fc_bsg_job *);
   int (*bsg_timeout)(struct fc_bsg_job *);

+   /*
+* Allow low-level drivers to be notified of state change if they
want
+* to be notified.
+*/
+   void(*rport_state_change)(struct fc_rport *);
+
   /* allocation lengths for host-specific data */
   u32 dd_fcrport_size;
   u32 dd_fcvport_size;
--
1.7.6.1

On Fri, 5 Apr 2013, James Smart wrote:


I understand your points. But you will need to contact the different LLD
maintainers to ensure receiving a devloss_tmo_callbk() on an rport they
had not called fc_remote_port_delete() for.  I know there's work on my
side to validate it's ok.  First glance was ok, but..

-- james s


On 4/4/2013 2:26 AM, Hannes Reinecke wrote:

On 04/01/2013 11:06 PM, James Smart wrote:

I think lpfc survives your rport state change as : part of the lld
behavior on the callback, to clean up reference counts, is to abort
all i/o that is outstanding to the rport.   So the ref checking not
only protects lpfc from prematurely freeing a structure (my real
concern), but also just happens to abort all i/o.  We got lucky.

I still believe the I_T_nexus reset is the right way to solve this.


Yes, but this would be an even more intrusive patch.
And we would need to implement yet another callback into the LLDDs
which need to be implemented there, too.

But for this to make any sense we would need to revamp the scsi
error handler, as the current problem is that error recovery takes
too long. Adding yet another callback will make the escalation chain
even longer.

So yeah, in the long run I_T nexus reset is the correct way of doing
things, but in the short term I would opt to make port_state
writeable to simulate an I_T nexus reset.

Cheers,

Hannes








This message and any attached documents contain information from QLogic 
Corporation or its wholly-owned subsidiaries that may be confidential. If you 
are not the intended recipient, you may not read, copy, distribute, or use this 
information. If you have received this transmission in error, please notify the 
sender immediately by reply e-mail and then delete this message.

--
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: [scsi:misc 46/59] drivers/scsi/qla2xxx/qla_mr.c:3007:7: warning: large integer implicitly truncated to unsigned type

2013-04-12 Thread James Bottomley
[linux-scsi cc added]
On Fri, 2013-04-12 at 09:34 +0800, kbuild test robot wrote:
 tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git misc
 head:   9e45dd73234af9a59613dc2989dcc2df2dab847f
 commit: 8ae6d9c7eb1004bc134813287010d57a863ba13b [46/59] [SCSI] qla2xxx: 
 Enhancements to support ISPFx00.
 config: make ARCH=powerpc allmodconfig
 
 All warnings:
 
drivers/scsi/qla2xxx/qla_mr.c: In function 'qlafx00_build_scsi_iocbs':
  drivers/scsi/qla2xxx/qla_mr.c:3007:7: warning: large integer implicitly 
  truncated to unsigned type [-Woverflow]
  drivers/scsi/qla2xxx/qla_mr.c:3011:7: warning: large integer implicitly 
  truncated to unsigned type [-Woverflow]
 
 vim +3007 drivers/scsi/qla2xxx/qla_mr.c
 
   3001return;
   3002}
   3003
   3004/* Set transfer direction */
   3005if (cmd-sc_data_direction == DMA_TO_DEVICE) {
   3006lcmd_pkt-cntrl_flags =
  3007__constant_cpu_to_le16(TMF_WRITE_DATA);
   3008vha-qla_stats.output_bytes += 
 scsi_bufflen(cmd);
   3009} else if (cmd-sc_data_direction == DMA_FROM_DEVICE) {
   3010lcmd_pkt-cntrl_flags =
  3011__constant_cpu_to_le16(TMF_READ_DATA);
   3012vha-qla_stats.input_bytes += scsi_bufflen(cmd);
   3013}
   3014

This is because of this definition in qla_mr.h:

struct cmd_type_7_fx00 {
...
uint8_t cntrl_flags;

Which means that the assignment produces zero on a BE platform.  That
doesn't look right.  Please fix.

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


[GIT PULL] SCSI fixes for 3.9-rc6

2013-04-12 Thread James Bottomley
This is a set of ten bug fixes (and two consisting of copyright year
update and version number change) pretty much all of which involve
either a crash or a hang except the removal of the random sleep from the
qla2xxx driver (which is a coding error so bad, we want it gone before
anyone has a chance to copy it).

The patch is available here:

git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes

The short changelog is:

Arun Easi (1):
  qla2xxx: Fix crash during firmware dump procedure.

Brian King (1):
  ibmvscsi: Fix slave_configure deadlock

Joe Carnuccio (1):
  Revert qla2xxx: Add setting of driver version string for vendor 
application.

Joe Lawrence (1):
  st: Take additional queue ref in st_probe

John Gong (1):
  libsas: use right function to alloc smp response

Kleber Sacilotto de Souza (1):
  ipr: fix addition of abort command to HRRQ free queue

Lukasz Dorau (1):
  libsas: fix handling vacant phy in sas_set_ex_phy()

Saurav Kashyap (3):
  qla2xxx: Update the driver version to 8.04.00.13-k.
  qla2xxx: Remove debug code that msleeps for random duration.
  qla2xxx: Update copyright dates information in LICENSE.qla2xxx file.

Wei Yongjun (1):
  lpfc: fix potential NULL pointer dereference in lpfc_sli4_rq_put()

wenxi...@linux.vnet.ibm.com (2):
  ipr: dlpar failed when adding an adapter back
  ipr: ipr_test_msi() fails when running with msi-x enabled adapter

and the diffstat

 Documentation/scsi/LICENSE.qla2xxx |  2 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c   |  2 +-
 drivers/scsi/ipr.c | 13 +++--
 drivers/scsi/libsas/sas_expander.c | 14 -
 drivers/scsi/lpfc/lpfc_sli.c   |  3 +-
 drivers/scsi/qla2xxx/qla_attr.c|  5 
 drivers/scsi/qla2xxx/qla_dbg.c |  3 +-
 drivers/scsi/qla2xxx/qla_def.h |  1 -
 drivers/scsi/qla2xxx/qla_gbl.h |  3 --
 drivers/scsi/qla2xxx/qla_init.c|  4 +--
 drivers/scsi/qla2xxx/qla_mbx.c | 58 --
 drivers/scsi/qla2xxx/qla_version.h |  2 +-
 drivers/scsi/st.c  |  8 +-
 13 files changed, 38 insertions(+), 80 deletions(-)

Full diff is attached below.

James

---
diff --git a/Documentation/scsi/LICENSE.qla2xxx 
b/Documentation/scsi/LICENSE.qla2xxx
index 27a91cf..5020b7b 100644
--- a/Documentation/scsi/LICENSE.qla2xxx
+++ b/Documentation/scsi/LICENSE.qla2xxx
@@ -1,4 +1,4 @@
-Copyright (c) 2003-2012 QLogic Corporation
+Copyright (c) 2003-2013 QLogic Corporation
 QLogic Linux FC-FCoE Driver
 
 This program includes a device driver for Linux 3.x.
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index a044f59..d0fa4b6 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1899,8 +1899,8 @@ static int ibmvscsi_slave_configure(struct scsi_device 
*sdev)
sdev-allow_restart = 1;
blk_queue_rq_timeout(sdev-request_queue, 120 * HZ);
}
-   scsi_adjust_queue_depth(sdev, 0, shost-cmd_per_lun);
spin_unlock_irqrestore(shost-host_lock, lock_flags);
+   scsi_adjust_queue_depth(sdev, 0, shost-cmd_per_lun);
return 0;
 }
 
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index f328089..2197b57 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -5148,7 +5148,7 @@ static int ipr_cancel_op(struct scsi_cmnd *scsi_cmd)
ipr_trace;
}
 
-   list_add_tail(ipr_cmd-queue, hrrq-hrrq_free_q);
+   list_add_tail(ipr_cmd-queue, ipr_cmd-hrrq-hrrq_free_q);
if (!ipr_is_naca_model(res))
res-needs_sync_complete = 1;
 
@@ -9349,7 +9349,10 @@ static int ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, 
struct pci_dev *pdev)
int_reg = readl(ioa_cfg-regs.sense_interrupt_mask_reg);
spin_unlock_irqrestore(ioa_cfg-host-host_lock, lock_flags);
 
-   rc = request_irq(pdev-irq, ipr_test_intr, 0, IPR_NAME, ioa_cfg);
+   if (ioa_cfg-intr_flag == IPR_USE_MSIX)
+   rc = request_irq(ioa_cfg-vectors_info[0].vec, ipr_test_intr, 
0, IPR_NAME, ioa_cfg);
+   else
+   rc = request_irq(pdev-irq, ipr_test_intr, 0, IPR_NAME, 
ioa_cfg);
if (rc) {
dev_err(pdev-dev, Can not assign irq %d\n, pdev-irq);
return rc;
@@ -9371,7 +9374,10 @@ static int ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, 
struct pci_dev *pdev)
 
spin_unlock_irqrestore(ioa_cfg-host-host_lock, lock_flags);
 
-   free_irq(pdev-irq, ioa_cfg);
+   if (ioa_cfg-intr_flag == IPR_USE_MSIX)
+   free_irq(ioa_cfg-vectors_info[0].vec, ioa_cfg);
+   else
+   free_irq(pdev-irq, ioa_cfg);
 
LEAVE;
 
@@ -9722,6 +9728,7 @@ static void __ipr_remove(struct pci_dev *pdev)
spin_unlock_irqrestore(ioa_cfg-host-host_lock, host_lock_flags);
wait_event(ioa_cfg-reset_wait_q, !ioa_cfg-in_reset_reload);
flush_work(ioa_cfg-work_q);
+   INIT_LIST_HEAD(ioa_cfg-used_res_q);

Re: error handler scheduling

2013-04-12 Thread Baruch Even
On Fri, Apr 12, 2013 at 12:42 PM, Ren Mingxin re...@cn.fujitsu.com wrote:

 Please let me summarize what this thread has talked about the scsi
 eh latency:

 1) some scsi cmds' timemout values are inappropriate, we can avoid
timeout by:
a) sg_format sets the IMMED bit and use TEST UNIT READY or REQUEST
   SENSE polling to monitor - by Douglas
b) cut big cmd into some reasonable-sized ones - by Douglas
c) improve timeout values according to device types - by Elliott
 2) call -done() on the command after lun reset - by Hannes

 And, my question is:
 - could we wake up eh thread ASAP instead of waiting for all cmds
   complete to fast scheduling?

 BTW: my original question is here:
 http://www.spinics.net/lists/linux-scsi/msg65107.html

I don't think you can just do this simple change of not waiting for all commands
to timeout. The problem will start when your abort will fail and
you'll be forced
to do the higher level actions such as target reset, since it will
take out all active
requests you'll want to wait for all active requests to either return
or timeout and
for that time you want to also not send any new commands down the pipe.

Ofcourse, there are situations where you don't care enough about the other
commands and can handle their cancellation with an immediate target reset
or you may even just prefer to not even abort that single command. I've seen and
implemented changes (internal to my employer) to do just that but the changes
to the code are non-trivial.

Baruch
--
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: [scsi:misc 46/59] drivers/scsi/qla2xxx/qla_mr.c:3007:7: warning: large integer implicitly truncated to unsigned type

2013-04-12 Thread Chad Dupuis



On Fri, 12 Apr 2013, James Bottomley wrote:


[linux-scsi cc added]
On Fri, 2013-04-12 at 09:34 +0800, kbuild test robot wrote:

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git misc
head:   9e45dd73234af9a59613dc2989dcc2df2dab847f
commit: 8ae6d9c7eb1004bc134813287010d57a863ba13b [46/59] [SCSI] qla2xxx: 
Enhancements to support ISPFx00.
config: make ARCH=powerpc allmodconfig

All warnings:

   drivers/scsi/qla2xxx/qla_mr.c: In function 'qlafx00_build_scsi_iocbs':

drivers/scsi/qla2xxx/qla_mr.c:3007:7: warning: large integer implicitly 
truncated to unsigned type [-Woverflow]
drivers/scsi/qla2xxx/qla_mr.c:3011:7: warning: large integer implicitly 
truncated to unsigned type [-Woverflow]


vim +3007 drivers/scsi/qla2xxx/qla_mr.c

  3001   return;
  3002   }
  3003
  3004   /* Set transfer direction */
  3005   if (cmd-sc_data_direction == DMA_TO_DEVICE) {
  3006   lcmd_pkt-cntrl_flags =

3007__constant_cpu_to_le16(TMF_WRITE_DATA);

  3008   vha-qla_stats.output_bytes += scsi_bufflen(cmd);
  3009   } else if (cmd-sc_data_direction == DMA_FROM_DEVICE) {
  3010   lcmd_pkt-cntrl_flags =

3011__constant_cpu_to_le16(TMF_READ_DATA);

  3012   vha-qla_stats.input_bytes += scsi_bufflen(cmd);
  3013   }
  3014


This is because of this definition in qla_mr.h:

struct cmd_type_7_fx00 {
...
  uint8_t cntrl_flags;

Which means that the assignment produces zero on a BE platform.  That
doesn't look right.  Please fix.

James



Thanks for the head up James. Will send a fix soon.


--
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






This message and any attached documents contain information from QLogic 
Corporation or its wholly-owned subsidiaries that may be confidential. If you 
are not the intended recipient, you may not read, copy, distribute, or use this 
information. If you have received this transmission in error, please notify the 
sender immediately by reply e-mail and then delete this message.

--
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 15/18] be2iscsi: Fix the session cleanup when reboot/shutdown happens

2013-04-12 Thread Kallickal, Jayamohan


-Original Message-
From: Mike Christie [mailto:micha...@cs.wisc.edu] 
Sent: Wednesday, April 10, 2013 4:42 PM
To: Jayamohan Kallickal
Cc: jbottom...@parallels.com; linux-scsi@vger.kernel.org; Kallickal, Jayamohan; 
John, Sony
Subject: Re: [PATCH V2 15/18] be2iscsi: Fix the session cleanup when 
reboot/shutdown happens

On 4/5/13 10:38 PM, Jayamohan Kallickal wrote:
   During reboot/shutdown cycle, the active sessions were not updated.
   In iSCSI Boot case, the boot session was alive and this fix informs
   that the machine is going down, so no more ops happens on that session.

 Signed-off-by: John Soni Jose sony.joh...@emulex.com
 Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
 ---
   drivers/scsi/be2iscsi/be_cmds.c |2 +-
   drivers/scsi/be2iscsi/be_cmds.h |3 +++
   drivers/scsi/be2iscsi/be_main.c |1 +
   3 files changed, 5 insertions(+), 1 deletion(-)

 diff --git a/drivers/scsi/be2iscsi/be_cmds.c 
 b/drivers/scsi/be2iscsi/be_cmds.c index e66aa7c..a3bfc1d 100644
 --- a/drivers/scsi/be2iscsi/be_cmds.c
 +++ b/drivers/scsi/be2iscsi/be_cmds.c
 @@ -340,7 +340,7 @@ static struct be_mcc_compl *be_mcc_compl_get(struct 
 beiscsi_hba *phba)
   return NULL;
   }

 -static void be2iscsi_fail_session(struct iscsi_cls_session 
 *cls_session)
 +void be2iscsi_fail_session(struct iscsi_cls_session *cls_session)
   {
   iscsi_session_failure(cls_session-dd_data, ISCSI_ERR_CONN_FAILED);

I am not sure how this is working or what it fixes. During shutdown/reboot when 
the pci_driver shutdown callback is called, without the patch what is 
happening? Does the host shutdown cause iscsid to try and recover the session 
and that causes a shutdown/reboot hang?

I think you want to use ISCSI_ERR_INVALID_HOST. That would cause a clean 
shutdown of the sessions if iscsid is still up at that time. This would cause 
ep_disconnect to get called and a logout pdu to get sent.

ISCSI_ERR_CONN_FAILED just causes recovery to start (ep_disconnect will run if 
the ep is up and we will try to reconnect).

James,

I am looking into this issue raised by MikeC and would send a patch later to 
resolve this.

 So, I would like to withdraw this patch (15/18) now.

Thanks
Jay

--
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


[RFC-v4 0/9] Add support for iSCSI Extensions for RDMA (ISER) target mode

2013-04-12 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

Hi folks,

This series is the forth RFC for iSCSI Extensions for RDMA (ISER) target
mode support planned for an upcoming v3.10 merge.  This series refactors
existing traditional iscsi-target mode logic in order for external
ib_isert.ko module code to function with areas common to traditional
TCP socket based iSCSI and RDMA verbs based ISER operation.

This includes a basic iscsit_transport API that allows different transports
to reside under the existing iscsi-target configfs control plane, using an
pre-defined network portal attribute to enable a rdma_cm listener on top
of existing ipoib portals.

At this point the code is functional and pushing sustained RDMA_WRITE +
RDMA_READ traffic using open-iscsi on top of multiple iser network portals +
multiple IB HCA ports + multiple LUNs.  Thus far we're using Mellanox IB HCAs
for initial development, and will be verfiying with RoCE capable NICs as well
in the near future.

This RFC-v4 code is available in git against v3.9-rc3 here:

  git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git 
iser_target-rfc-v4

Changes since RFC-v3 include:

- Mark isert_cq_rx_work as static (Or)
- Drop unnecessary ib_dma_sync_single_for_cpu + 
ib_dma_sync_single_for_device
  calls for isert_cmd-sense_buf_dma from isert_put_response (Or)
- Use 12288 for ISER_RX_PAD_SIZE base to save extra page per
  struct iser_rx_desc (Or + nab)
- Drop now unnecessary isert_rx_desc usage, and convert RX users to
  iser_rx_desc (Or + nab)
- Move isert_[alloc,free]_rx_descriptors() ahead of
  isert_create_device_ib_res() usage (nab)
- Mark isert_cq_[rx,tx]_callback() + prototypes as static
- Fix 'warning: 'ret' may be used uninitialized' warning for
  isert_create_device_ib_res on powerpc allmodconfig (fengguang + nab)
- Fix 'warning: 'ret' may be used uninitialized' warning for
  isert_connect_request on i386 allyesconfig (fengguang + nab)
- Fix pr_debug conversion specification in isert_rx_completion()
  (fengguang + nab)
- Drop unnecessary isert_conn-conn_cm_id != NULL check in
  isert_connect_release causing the build warning:
  variable dereferenced before check 'isert_conn-conn_cm_id'
- Fix isert_lid + isert_np leak in isert_setup_np failure path
- Add isert_conn-conn_wait_comp_err usage in isert_free_conn()
  for isert_cq_comp_err completion path
- Add isert_conn-logout_posted bit to determine decrement of
  isert_conn-post_send_buf_count from logout response completion
- Always set ISER_CONN_DOWN from isert_disconnect_work() callback
- Add request_module for ib_isert to lio_target_np_store_iser()
- Add missing iscsit_put_transport() call in 
iscsi_target_setup_login_socket()
  failure case

RFC-v4 has been rebased this afternoon into target-pending 
for-next/for-next-merge
to be picked up by monday's -next build.

Please review.

--nab

Nicholas Bellinger (9):
  target: Add export of target_get_sess_cmd symbol
  iscsi-target: Add iscsit_transport API template
  iscsi-target: Initial traditional TCP conversion to iscsit_transport
  iscsi-target: Add iser-target parameter keys + setup during login
  iscsi-target: Add per transport iscsi_cmd alloc/free
  iscsi-target: Refactor RX PDU logic + export request PDU handling
  iscsi-target: Refactor TX queue logic + export response PDU creation
  iscsi-target: Add iser network portal attribute
  iser-target: Add iSCSI Extensions for RDMA (iSER) target driver

 drivers/infiniband/Kconfig |1 +
 drivers/infiniband/Makefile|1 +
 drivers/infiniband/ulp/isert/Kconfig   |6 +
 drivers/infiniband/ulp/isert/Makefile  |2 +
 drivers/infiniband/ulp/isert/ib_isert.c| 2264 
 drivers/infiniband/ulp/isert/ib_isert.h|  138 ++
 drivers/infiniband/ulp/isert/isert_proto.h |   47 +
 drivers/target/iscsi/Makefile  |3 +-
 drivers/target/iscsi/iscsi_target.c| 1169 -
 drivers/target/iscsi/iscsi_target.h|3 +-
 drivers/target/iscsi/iscsi_target_configfs.c   |   98 +-
 drivers/target/iscsi/iscsi_target_core.h   |   26 +-
 drivers/target/iscsi/iscsi_target_device.c |7 +-
 drivers/target/iscsi/iscsi_target_erl1.c   |   13 +-
 drivers/target/iscsi/iscsi_target_login.c  |  472 --
 drivers/target/iscsi/iscsi_target_login.h  |6 +
 drivers/target/iscsi/iscsi_target_nego.c   |  182 +--
 drivers/target/iscsi/iscsi_target_nego.h   |   11 +-
 drivers/target/iscsi/iscsi_target_parameters.c |   87 +-
 drivers/target/iscsi/iscsi_target_parameters.h |   16 +-
 drivers/target/iscsi/iscsi_target_tmr.c|4 +-
 drivers/target/iscsi/iscsi_target_tpg.c|6 +-
 drivers/target/iscsi/iscsi_target_transport.c  |   55 +
 drivers/target/iscsi/iscsi_target_util.c   |   53 +-
 

[RFC-v4 8/9] iscsi-target: Add iser network portal attribute

2013-04-12 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch adds a new network portal attribute for iser, that lives
under existing iscsi-target configfs layout at:

   /sys/kernel/config/target/iscsi/$TARGETNAME/$TPGT/np/$PORTAL/iser

When lio_target_np_store_iser() is enabled, iscsit_tpg_add_network_portal()
will attempt to start an rdma_cma network portal for iser-target, only if
the external ib_isert module transport has been loaded.

When disabled, iscsit_tpg_del_network_portal() will cease iser login service
on the network portal, and release any external ib_isert module reference.

v4 changes:

- Add request_module for ib_isert to lio_target_np_store_iser()

Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/iscsi_target_configfs.c |   79 ++
 1 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_configfs.c 
b/drivers/target/iscsi/iscsi_target_configfs.c
index 2704daf..13e9e71 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -125,8 +125,87 @@ out:
 
 TF_NP_BASE_ATTR(lio_target, sctp, S_IRUGO | S_IWUSR);
 
+static ssize_t lio_target_np_show_iser(
+   struct se_tpg_np *se_tpg_np,
+   char *page)
+{
+   struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
+   struct iscsi_tpg_np, se_tpg_np);
+   struct iscsi_tpg_np *tpg_np_iser;
+   ssize_t rb;
+
+   tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND);
+   if (tpg_np_iser)
+   rb = sprintf(page, 1\n);
+   else
+   rb = sprintf(page, 0\n);
+
+   return rb;
+}
+
+static ssize_t lio_target_np_store_iser(
+   struct se_tpg_np *se_tpg_np,
+   const char *page,
+   size_t count)
+{
+   struct iscsi_np *np;
+   struct iscsi_portal_group *tpg;
+   struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
+   struct iscsi_tpg_np, se_tpg_np);
+   struct iscsi_tpg_np *tpg_np_iser = NULL;
+   char *endptr;
+   u32 op;
+   int rc;
+
+   op = simple_strtoul(page, endptr, 0);
+   if ((op != 1)  (op != 0)) {
+   pr_err(Illegal value for tpg_enable: %u\n, op);
+   return -EINVAL;
+   }
+   np = tpg_np-tpg_np;
+   if (!np) {
+   pr_err(Unable to locate struct iscsi_np from
+struct iscsi_tpg_np\n);
+   return -EINVAL;
+   }
+
+   tpg = tpg_np-tpg;
+   if (iscsit_get_tpg(tpg)  0)
+   return -EINVAL;
+
+   if (op) {
+   int rc = request_module(ib_isert);
+   if (rc != 0)
+   pr_warn(Unable to request_module for ib_isert\n);
+
+   tpg_np_iser = iscsit_tpg_add_network_portal(tpg, 
np-np_sockaddr,
+   np-np_ip, tpg_np, ISCSI_INFINIBAND);
+   if (!tpg_np_iser || IS_ERR(tpg_np_iser))
+   goto out;
+   } else {
+   tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, 
ISCSI_INFINIBAND);
+   if (!tpg_np_iser)
+   goto out;
+
+   rc = iscsit_tpg_del_network_portal(tpg, tpg_np_iser);
+   if (rc  0)
+   goto out;
+   }
+
+   printk(lio_target_np_store_iser() done, op: %d\n, op);
+
+   iscsit_put_tpg(tpg);
+   return count;
+out:
+   iscsit_put_tpg(tpg);
+   return -EINVAL;
+}
+
+TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR);
+
 static struct configfs_attribute *lio_target_portal_attrs[] = {
lio_target_np_sctp.attr,
+   lio_target_np_iser.attr,
NULL,
 };
 
-- 
1.7.2.5

--
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


[RFC-v4 5/9] iscsi-target: Add per transport iscsi_cmd alloc/free

2013-04-12 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch converts struct iscsi_cmd memory allocation + free to use
-iscsit_alloc_cmd() iscsit_transport API caller, and export
iscsit_allocate_cmd() symbols

Also add iscsi_cmd-release_cmd() to be used seperately from
iscsit_transport for connection/session shutdown.

v2 changes:

- Remove unnecessary checks in iscsit_alloc_cmd (asias)
- Drop iscsit_transport-iscsit_free_cmd() usage
- Drop iscsit_transport-iscsit_unmap_cmd() usage
- Add iscsi_cmd-release_cmd()
- Convert lio_release_cmd() to use iscsi_cmd-release_cmd()

Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/iscsi_target.c  |1 +
 drivers/target/iscsi/iscsi_target_configfs.c |3 ++-
 drivers/target/iscsi/iscsi_target_core.h |1 +
 drivers/target/iscsi/iscsi_target_util.c |   25 +
 drivers/target/iscsi/iscsi_target_util.h |1 +
 5 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index 8203bf3..b01a10e 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -489,6 +489,7 @@ static struct iscsit_transport iscsi_target_transport = {
.iscsit_setup_np= iscsit_setup_np,
.iscsit_accept_np   = iscsit_accept_np,
.iscsit_free_np = iscsit_free_np,
+   .iscsit_alloc_cmd   = iscsit_alloc_cmd,
.iscsit_get_login_rx= iscsit_get_login_rx,
.iscsit_put_login_tx= iscsit_put_login_tx,
 };
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c 
b/drivers/target/iscsi/iscsi_target_configfs.c
index 78d75c8..c78b824 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -1700,7 +1700,8 @@ static void lio_release_cmd(struct se_cmd *se_cmd)
 {
struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
 
-   iscsit_release_cmd(cmd);
+   pr_debug(Entering lio_release_cmd for se_cmd: %p\n, se_cmd);
+   cmd-release_cmd(cmd);
 }
 
 /* End functions for target_core_fabric_ops */
diff --git a/drivers/target/iscsi/iscsi_target_core.h 
b/drivers/target/iscsi/iscsi_target_core.h
index 53400b0..60ec4b9 100644
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -485,6 +485,7 @@ struct iscsi_cmd {
u32 first_data_sg_off;
u32 kmapped_nents;
sense_reason_t  sense_reason;
+   void (*release_cmd)(struct iscsi_cmd *);
 }  cacheline_aligned;
 
 struct iscsi_tmr_req {
diff --git a/drivers/target/iscsi/iscsi_target_util.c 
b/drivers/target/iscsi/iscsi_target_util.c
index 4cf1e7f..0b73f90 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -149,6 +149,18 @@ void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd)
spin_unlock_bh(cmd-r2t_lock);
 }
 
+struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp_mask)
+{
+   struct iscsi_cmd *cmd;
+
+   cmd = kmem_cache_zalloc(lio_cmd_cache, gfp_mask);
+   if (!cmd)
+   return NULL;
+
+   cmd-release_cmd = iscsit_release_cmd;
+   return cmd;
+}
+
 /*
  * May be called from software interrupt (timer) context for allocating
  * iSCSI NopINs.
@@ -157,13 +169,12 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn 
*conn, gfp_t gfp_mask)
 {
struct iscsi_cmd *cmd;
 
-   cmd = kmem_cache_zalloc(lio_cmd_cache, gfp_mask);
+   cmd = conn-conn_transport-iscsit_alloc_cmd(conn, gfp_mask);
if (!cmd) {
pr_err(Unable to allocate memory for struct iscsi_cmd.\n);
return NULL;
}
-
-   cmd-conn   = conn;
+   cmd-conn = conn;
INIT_LIST_HEAD(cmd-i_conn_node);
INIT_LIST_HEAD(cmd-datain_list);
INIT_LIST_HEAD(cmd-cmd_r2t_list);
@@ -176,6 +187,7 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn 
*conn, gfp_t gfp_mask)
 
return cmd;
 }
+EXPORT_SYMBOL(iscsit_allocate_cmd);
 
 struct iscsi_seq *iscsit_get_seq_holder_for_datain(
struct iscsi_cmd *cmd,
@@ -690,6 +702,11 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd)
 */
switch (cmd-iscsi_opcode) {
case ISCSI_OP_SCSI_CMD:
+   if (cmd-data_direction == DMA_TO_DEVICE)
+   iscsit_stop_dataout_timer(cmd);
+   /*
+* Fallthrough
+*/
case ISCSI_OP_SCSI_TMFUNC:
transport_generic_free_cmd(cmd-se_cmd, 1);
break;
@@ -705,7 +722,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd)
}
/* Fall-through */
default:
-   iscsit_release_cmd(cmd);
+   cmd-release_cmd(cmd);
break;
}
 }
diff --git a/drivers/target/iscsi/iscsi_target_util.h 

[RFC-v4 3/9] iscsi-target: Initial traditional TCP conversion to iscsit_transport

2013-04-12 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch performs the initial conversion of existing traditional iscsi
to use iscsit_transport API callers.  This includes:

- iscsi-np cleanups for iscsit_transport_type
- Add iscsi-np transport calls w/ -iscsit_setup_up() and -iscsit_free_np()
- Convert login thread process context to use -iscsit_accept_np() for
  connections with pre-allocated struct iscsi_conn
- Convert existing socket accept code to iscsit_accept_np()
- Convert login RX/TX callers to use -iscsit_get_login_rx() and
  -iscsit_put_login_tx() to exchange request/response PDUs
- Convert existing socket login RX/TX calls into iscsit_get_login_rx()
  and iscsit_put_login_tx()
- Change iscsit_close_connection() to invoke -iscsit_free_conn() +
  iscsit_put_transport() calls.
- Add iscsit_register_transport() + iscsit_unregister_transport() calls
  to module init/exit

v4 changes:

- Add missing iscsit_put_transport() call in iscsi_target_setup_login_socket()
  failure case

v2 changes:

- Update module init/exit to use register_transport() + unregister_transport()

Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/iscsi_target.c|   35 ++-
 drivers/target/iscsi/iscsi_target_core.h   |   15 +-
 drivers/target/iscsi/iscsi_target_login.c  |  416 ---
 drivers/target/iscsi/iscsi_target_login.h  |6 +
 drivers/target/iscsi/iscsi_target_nego.c   |  167 +-
 drivers/target/iscsi/iscsi_target_nego.h   |   11 +-
 drivers/target/iscsi/iscsi_target_parameters.c |   12 +-
 drivers/target/iscsi/iscsi_target_tpg.c|6 +-
 drivers/target/iscsi/iscsi_target_util.c   |   27 +--
 9 files changed, 380 insertions(+), 315 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index 7ea246a..8203bf3 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -49,6 +49,8 @@
 #include iscsi_target_device.h
 #include iscsi_target_stat.h
 
+#include target/iscsi/iscsi_transport.h
+
 static LIST_HEAD(g_tiqn_list);
 static LIST_HEAD(g_np_list);
 static DEFINE_SPINLOCK(tiqn_lock);
@@ -401,8 +403,7 @@ struct iscsi_np *iscsit_add_np(
spin_unlock_bh(np_lock);
 
pr_debug(CORE[0] - Added Network Portal: %s:%hu on %s\n,
-   np-np_ip, np-np_port, (np-np_network_transport == ISCSI_TCP) 
?
-   TCP : SCTP);
+   np-np_ip, np-np_port, np-np_transport-name);
 
return np;
 }
@@ -441,11 +442,10 @@ int iscsit_reset_np_thread(
return 0;
 }
 
-static int iscsit_del_np_comm(struct iscsi_np *np)
+static void iscsit_free_np(struct iscsi_np *np)
 {
if (np-np_socket)
sock_release(np-np_socket);
-   return 0;
 }
 
 int iscsit_del_np(struct iscsi_np *np)
@@ -467,20 +467,32 @@ int iscsit_del_np(struct iscsi_np *np)
send_sig(SIGINT, np-np_thread, 1);
kthread_stop(np-np_thread);
}
-   iscsit_del_np_comm(np);
+
+   np-np_transport-iscsit_free_np(np);
 
spin_lock_bh(np_lock);
list_del(np-np_list);
spin_unlock_bh(np_lock);
 
pr_debug(CORE[0] - Removed Network Portal: %s:%hu on %s\n,
-   np-np_ip, np-np_port, (np-np_network_transport == ISCSI_TCP) 
?
-   TCP : SCTP);
+   np-np_ip, np-np_port, np-np_transport-name);
 
+   iscsit_put_transport(np-np_transport);
kfree(np);
return 0;
 }
 
+static struct iscsit_transport iscsi_target_transport = {
+   .name   = iSCSI/TCP,
+   .transport_type = ISCSI_TCP,
+   .owner  = NULL,
+   .iscsit_setup_np= iscsit_setup_np,
+   .iscsit_accept_np   = iscsit_accept_np,
+   .iscsit_free_np = iscsit_free_np,
+   .iscsit_get_login_rx= iscsit_get_login_rx,
+   .iscsit_put_login_tx= iscsit_put_login_tx,
+};
+
 static int __init iscsi_target_init_module(void)
 {
int ret = 0;
@@ -557,6 +569,8 @@ static int __init iscsi_target_init_module(void)
goto ooo_out;
}
 
+   iscsit_register_transport(iscsi_target_transport);
+
if (iscsit_load_discovery_tpg()  0)
goto r2t_out;
 
@@ -587,6 +601,7 @@ static void __exit iscsi_target_cleanup_module(void)
iscsi_deallocate_thread_sets();
iscsi_thread_set_free();
iscsit_release_discovery_tpg();
+   iscsit_unregister_transport(iscsi_target_transport);
kmem_cache_destroy(lio_cmd_cache);
kmem_cache_destroy(lio_qr_cache);
kmem_cache_destroy(lio_dr_cache);
@@ -4053,6 +4068,12 @@ int iscsit_close_connection(
 
if (conn-sock)
sock_release(conn-sock);
+
+   if (conn-conn_transport-iscsit_free_conn)
+   conn-conn_transport-iscsit_free_conn(conn);
+
+   iscsit_put_transport(conn-conn_transport);
+
conn-thread_set = NULL;
 

[RFC-v4 7/9] iscsi-target: Refactor TX queue logic + export response PDU creation

2013-04-12 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch refactors TX immediate + response queue handling to use
the new iscsit_transport API callers, and exports the necessary
traditional iscsi PDU response creation functions for iser-target
to utilize.

This includes:

- Add iscsit_build_datain_pdu() for DATAIN PDU init + convert
  iscsit_build_datain_pdu()
- Add iscsit_build_logout_rsp() for LOGOUT_RSP PDU init + convert
  iscsit_send_logout()
- Add iscsit_build_nopin_rsp() for NOPIN_RSP PDU init + convert
  iscsit_send_nopin()
- Add iscsit_build_rsp_pdu() for SCSI_RSP PDU init + convert
  iscsit_send_response()
- Add iscsit_build_task_mgt_rsp for TM_RSP PDU init + convert
  iscsit_send_task_mgt_rsp()
- Refactor immediate queue state switch into iscsit_immediate_queue()
- Convert handle_immediate_queue() to use iscsit_transport caller
- Refactor response queue state switch into iscsit_response_queue()
- Convert handle_response_queue to use iscsit_transport caller
- Export iscsit_logout_post_handler(), iscsit_increment_maxcmdsn()
  and iscsit_tmr_post_handler() for external transport module usage

v3 changes:
- Add iscsit_build_reject for REJECT PDU init + convert
  iscsit_send_reject()

v2 changes:

- Add iscsit_queue_rsp() for iscsit_transport-iscsit_queue_data_in()
  and iscsit_transport-iscsit_queue_status()
- Update lio_queue_data_in() to use -iscsit_queue_data_in()
- Update lio_queue_status() to use -iscsit_queue_status()
- Use mutex_trylock() in iscsit_increment_maxcmdsn()

Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/iscsi_target.c  |  661 ++
 drivers/target/iscsi/iscsi_target_configfs.c |7 +-
 drivers/target/iscsi/iscsi_target_device.c   |7 +-
 drivers/target/iscsi/iscsi_target_tmr.c  |1 +
 4 files changed, 374 insertions(+), 302 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index 19d4e08..3948aa1 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -70,8 +70,7 @@ struct kmem_cache *lio_ooo_cache;
 struct kmem_cache *lio_r2t_cache;
 
 static int iscsit_handle_immediate_data(struct iscsi_cmd *,
-   unsigned char *buf, u32);
-static int iscsit_logout_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
+   struct iscsi_scsi_req *, u32);
 
 struct iscsi_tiqn *iscsit_get_tiqn_for_login(unsigned char *buf)
 {
@@ -482,6 +481,15 @@ int iscsit_del_np(struct iscsi_np *np)
return 0;
 }
 
+static int iscsit_immediate_queue(struct iscsi_conn *, struct iscsi_cmd *, 
int);
+static int iscsit_response_queue(struct iscsi_conn *, struct iscsi_cmd *, int);
+
+static int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
+{
+   iscsit_add_cmd_to_response_queue(cmd, cmd-conn, cmd-i_state);
+   return 0;
+}
+
 static struct iscsit_transport iscsi_target_transport = {
.name   = iSCSI/TCP,
.transport_type = ISCSI_TCP,
@@ -493,6 +501,10 @@ static struct iscsit_transport iscsi_target_transport = {
.iscsit_get_login_rx= iscsit_get_login_rx,
.iscsit_put_login_tx= iscsit_put_login_tx,
.iscsit_get_dataout = iscsit_build_r2ts_for_cmd,
+   .iscsit_immediate_queue = iscsit_immediate_queue,
+   .iscsit_response_queue  = iscsit_response_queue,
+   .iscsit_queue_data_in   = iscsit_queue_rsp,
+   .iscsit_queue_status= iscsit_queue_rsp,
 };
 
 static int __init iscsi_target_init_module(void)
@@ -651,14 +663,6 @@ static int iscsit_add_reject(
iscsit_add_cmd_to_response_queue(cmd, conn, cmd-i_state);
 
ret = wait_for_completion_interruptible(cmd-reject_comp);
-   /*
-* Perform the kref_put now if se_cmd has been setup by
-* iscsit_setup_scsi_cmd()
-*/
-   if (cmd-se_cmd.se_tfo != NULL) {
-   pr_debug(iscsi reject: calling target_put_sess_cmd \n);
-   target_put_sess_cmd(conn-sess-se_sess, cmd-se_cmd);
-   }
if (ret != 0)
return -1;
 
@@ -2536,18 +2540,60 @@ static void iscsit_tx_thread_wait_for_tcp(struct 
iscsi_conn *conn)
}
 }
 
-static int iscsit_send_data_in(
-   struct iscsi_cmd *cmd,
-   struct iscsi_conn *conn)
+static void
+iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
+   struct iscsi_datain *datain, struct iscsi_data_rsp *hdr,
+   bool set_statsn)
 {
-   int iov_ret = 0, set_statsn = 0;
-   u32 iov_count = 0, tx_size = 0;
+   hdr-opcode = ISCSI_OP_SCSI_DATA_IN;
+   hdr-flags  = datain-flags;
+   if (hdr-flags  ISCSI_FLAG_DATA_STATUS) {
+   if (cmd-se_cmd.se_cmd_flags  SCF_OVERFLOW_BIT) {
+   hdr-flags |= ISCSI_FLAG_DATA_OVERFLOW;
+   hdr-residual_count = 
cpu_to_be32(cmd-se_cmd.residual_count);
+

[RFC-v4 6/9] iscsi-target: Refactor RX PDU logic + export request PDU handling

2013-04-12 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch refactors existing traditional iscsi RX side PDU handling
to use iscsit_transport, and exports the necessary logic for external
transport modules.

This includes:

- Refactor iscsit_handle_scsi_cmd() into PDU setup / processing
- Add updated iscsit_handle_scsi_cmd() for tradtional iscsi code
- Add iscsit_set_unsoliticed_dataout() wrapper
- Refactor iscsit_handle_data_out() into PDU check / processing
- Add updated iscsit_handle_data_out() for tradtional iscsi code
- Add iscsit_handle_nop_out() + iscsit_handle_task_mgt_cmd() to
  accept pre-allocated struct iscsi_cmd
- Add iscsit_build_r2ts_for_cmd() caller for iscsi_target_transport
  to handle ISTATE_SEND_R2T for TX immediate queue
- Refactor main traditional iscsi iscsi_target_rx_thread() PDU switch
  into iscsi_target_rx_opcode() using iscsit_allocate_cmd()
- Turn iscsi_target_rx_thread() process context into NOP for
  ib_isert side work-queue.

v3 changes:
- Add extra target_put_sess_cmd call in iscsit_add_reject_from_cmd
  after completion

v2 changes:

- Disable iscsit_ack_from_expstatsn() usage for RDMAExtentions=Yes
- Disable iscsit_allocate_datain_req() usage for RDMAExtentions=Yes
- Add target_get_sess_cmd() reference counting to
  iscsit_setup_scsi_cmd()
- Add TFO-lio_check_stop_free() fabric API caller
- Add export of iscsit_stop_dataout_timer() symbol
- Add iscsit_build_r2ts_for_cmd() for iscsit_transport-iscsit_get_dataout()
- Convert existing usage of iscsit_build_r2ts_for_cmd() to
  -iscsit_get_dataout()
- Drop RDMAExtentions=Yes specific check in iscsit_build_r2ts_for_cmd()
- Fix RDMAExtentions - RDMAExtensions typo (andy)
- Pass correct dump_payload value into iscsit_get_immediate_data()
  for iscsit_handle_scsi_cmd()

Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/iscsi_target.c  |  486 --
 drivers/target/iscsi/iscsi_target.h  |3 +-
 drivers/target/iscsi/iscsi_target_configfs.c |9 +-
 drivers/target/iscsi/iscsi_target_erl1.c |   13 +-
 drivers/target/iscsi/iscsi_target_login.c|3 +-
 drivers/target/iscsi/iscsi_target_nego.c |   15 -
 drivers/target/iscsi/iscsi_target_tmr.c  |3 +-
 drivers/target/iscsi/iscsi_target_util.c |1 +
 8 files changed, 331 insertions(+), 202 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index b01a10e..19d4e08 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -492,6 +492,7 @@ static struct iscsit_transport iscsi_target_transport = {
.iscsit_alloc_cmd   = iscsit_alloc_cmd,
.iscsit_get_login_rx= iscsit_get_login_rx,
.iscsit_put_login_tx= iscsit_put_login_tx,
+   .iscsit_get_dataout = iscsit_build_r2ts_for_cmd,
 };
 
 static int __init iscsi_target_init_module(void)
@@ -650,6 +651,14 @@ static int iscsit_add_reject(
iscsit_add_cmd_to_response_queue(cmd, conn, cmd-i_state);
 
ret = wait_for_completion_interruptible(cmd-reject_comp);
+   /*
+* Perform the kref_put now if se_cmd has been setup by
+* iscsit_setup_scsi_cmd()
+*/
+   if (cmd-se_cmd.se_tfo != NULL) {
+   pr_debug(iscsi reject: calling target_put_sess_cmd \n);
+   target_put_sess_cmd(conn-sess-se_sess, cmd-se_cmd);
+   }
if (ret != 0)
return -1;
 
@@ -698,11 +707,20 @@ int iscsit_add_reject_from_cmd(
iscsit_add_cmd_to_response_queue(cmd, conn, cmd-i_state);
 
ret = wait_for_completion_interruptible(cmd-reject_comp);
+   /*
+* Perform the kref_put now if se_cmd has already been setup by
+* scsit_setup_scsi_cmd()
+*/
+   if (cmd-se_cmd.se_tfo != NULL) {
+   pr_debug(iscsi reject: calling target_put_sess_cmd \n);
+   target_put_sess_cmd(conn-sess-se_sess, cmd-se_cmd);
+   }
if (ret != 0)
return -1;
 
return (!fail_conn) ? 0 : -1;
 }
+EXPORT_SYMBOL(iscsit_add_reject_from_cmd);
 
 /*
  * Map some portion of the allocated scatterlist to an iovec, suitable for
@@ -761,6 +779,9 @@ static void iscsit_ack_from_expstatsn(struct iscsi_conn 
*conn, u32 exp_statsn)
 
conn-exp_statsn = exp_statsn;
 
+   if (conn-sess-sess_ops-RDMAExtensions)
+   return;
+
spin_lock_bh(conn-cmd_lock);
list_for_each_entry(cmd, conn-conn_cmd_list, i_conn_node) {
spin_lock(cmd-istate_lock);
@@ -793,12 +814,10 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd)
return 0;
 }
 
-static int iscsit_handle_scsi_cmd(
-   struct iscsi_conn *conn,
-   unsigned char *buf)
+int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
+ unsigned char *buf)
 {
-   int data_direction, payload_length, cmdsn_ret = 0, immed_ret;
-   struct iscsi_cmd *cmd = NULL;
+   int 

[RFC-v4 4/9] iscsi-target: Add iser-target parameter keys + setup during login

2013-04-12 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch adds RDMAExtensions, InitiatorRecvDataSegmentLength and
TargetRecvDataSegmentLength parameters keys necessary for iser-target
login to occur.

This includes setting the necessary parameters during login path
code within iscsi_login_zero_tsih_s2(), and currently PAGE_SIZE
aligning the target's advertised MRDSL for immediate data and
unsolicited data-out incoming payloads.

v3 changes:
- Add iscsi_post_login_start_timers FIXME for ISER

v2 changes:

- Fix RDMAExtentions - RDMAExtensions typo (andy)
- Drop unnecessary '== true' conditional checks for type bool

Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/iscsi_target_core.h   |   10 +++
 drivers/target/iscsi/iscsi_target_login.c  |   77 
 drivers/target/iscsi/iscsi_target_parameters.c |   75 +--
 drivers/target/iscsi/iscsi_target_parameters.h |   16 +-
 4 files changed, 161 insertions(+), 17 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_core.h 
b/drivers/target/iscsi/iscsi_target_core.h
index 2587677..53400b0 100644
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -244,6 +244,11 @@ struct iscsi_conn_ops {
u8  IFMarker;   /* [0,1] == [No,Yes] */
u32 OFMarkInt;  /* [1..65535] */
u32 IFMarkInt;  /* [1..65535] */
+   /*
+* iSER specific connection parameters
+*/
+   u32 InitiatorRecvDataSegmentLength; /* [512..2**24-1] */
+   u32 TargetRecvDataSegmentLength;/* [512..2**24-1] */
 };
 
 struct iscsi_sess_ops {
@@ -265,6 +270,10 @@ struct iscsi_sess_ops {
u8  DataSequenceInOrder;/* [0,1] == [No,Yes] */
u8  ErrorRecoveryLevel; /* [0..2] */
u8  SessionType;/* [0,1] == [Normal,Discovery]*/
+   /*
+* iSER specific session parameters
+*/
+   u8  RDMAExtensions; /* [0,1] == [No,Yes] */
 };
 
 struct iscsi_queue_req {
@@ -284,6 +293,7 @@ struct iscsi_data_count {
 };
 
 struct iscsi_param_list {
+   booliser;
struct list_headparam_list;
struct list_headextra_response_list;
 };
diff --git a/drivers/target/iscsi/iscsi_target_login.c 
b/drivers/target/iscsi/iscsi_target_login.c
index 0de5c47..e6a8269 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -340,6 +340,7 @@ static int iscsi_login_zero_tsih_s2(
struct iscsi_node_attrib *na;
struct iscsi_session *sess = conn-sess;
unsigned char buf[32];
+   bool iser = false;
 
sess-tpg = conn-tpg;
 
@@ -361,7 +362,10 @@ static int iscsi_login_zero_tsih_s2(
return -1;
}
 
-   iscsi_set_keys_to_negotiate(0, conn-param_list);
+   if (conn-conn_transport-transport_type == ISCSI_INFINIBAND)
+   iser = true;
+
+   iscsi_set_keys_to_negotiate(conn-param_list, iser);
 
if (sess-sess_ops-SessionType)
return iscsi_set_keys_irrelevant_for_discovery(
@@ -399,6 +403,56 @@ static int iscsi_login_zero_tsih_s2(
 
if (iscsi_login_disable_FIM_keys(conn-param_list, conn)  0)
return -1;
+   /*
+* Set RDMAExtensions=Yes by default for iSER enabled network portals
+*/
+   if (iser) {
+   struct iscsi_param *param;
+   unsigned long mrdsl, off;
+   int rc;
+
+   sprintf(buf, RDMAExtensions=Yes);
+   if (iscsi_change_param_value(buf, conn-param_list, 0)  0) {
+   iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
+   ISCSI_LOGIN_STATUS_NO_RESOURCES);
+   return -1;
+   }
+   /*
+* Make MaxRecvDataSegmentLength PAGE_SIZE aligned for
+* Immediate Data + Unsolicitied Data-OUT if necessary..
+*/
+   param = iscsi_find_param_from_key(MaxRecvDataSegmentLength,
+ conn-param_list);
+   if (!param) {
+   iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
+   ISCSI_LOGIN_STATUS_NO_RESOURCES);
+   return -1;
+   }
+   rc = strict_strtoul(param-value, 0, mrdsl);
+   if (rc  0) {
+   iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
+   ISCSI_LOGIN_STATUS_NO_RESOURCES);
+   return -1;
+   }
+   off = mrdsl % PAGE_SIZE;
+   if (!off)
+   return 0;
+
+   if (mrdsl  PAGE_SIZE)
+   mrdsl = PAGE_SIZE;
+   

[RFC-v4 2/9] iscsi-target: Add iscsit_transport API template

2013-04-12 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

Add basic struct iscsit_transport API template to allow iscsi-target for
running with external transport modules using existing iscsi_target_core.h
code.

For all external modules, this calls try_module_get() and module_put()
to obtain + release an external iscsit_transport module reference count.

Also include the iscsi-target symbols necessary in iscsi_transport.h to
allow external transport modules to function.

v3 changes:
- Add iscsit_build_reject export for ISTATE_SEND_REJECT usage

v2 changes:

- Drop unnecessary export of iscsit_get_transport + iscsit_put_transport 
(roland)
- Add -iscsit_queue_data_in() to remove extra context switch on RDMA_WRITE
- Add -iscsit_queue_status() to remove extra context switch on IB_SEND status
- Add -iscsit_get_dataout() to remove extra context switch on RDMA_READ
- Drop -iscsit_free_cmd()
- Drop -iscsit_unmap_cmd()
- Rename iscsit_create_transport() - iscsit_register_transport() (andy)
- Rename iscsit_destroy_transport() - iscsit_unregister_transport() (andy)

Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/Makefile |3 +-
 drivers/target/iscsi/iscsi_target_transport.c |   55 
 include/target/iscsi/iscsi_transport.h|   83 +
 3 files changed, 140 insertions(+), 1 deletions(-)
 create mode 100644 drivers/target/iscsi/iscsi_target_transport.c
 create mode 100644 include/target/iscsi/iscsi_transport.h

diff --git a/drivers/target/iscsi/Makefile b/drivers/target/iscsi/Makefile
index 5b9a2cf..13a9240 100644
--- a/drivers/target/iscsi/Makefile
+++ b/drivers/target/iscsi/Makefile
@@ -15,6 +15,7 @@ iscsi_target_mod-y += iscsi_target_parameters.o \
iscsi_target_util.o \
iscsi_target.o \
iscsi_target_configfs.o \
-   iscsi_target_stat.o
+   iscsi_target_stat.o \
+   iscsi_target_transport.o
 
 obj-$(CONFIG_ISCSI_TARGET) += iscsi_target_mod.o
diff --git a/drivers/target/iscsi/iscsi_target_transport.c 
b/drivers/target/iscsi/iscsi_target_transport.c
new file mode 100644
index 000..882728f
--- /dev/null
+++ b/drivers/target/iscsi/iscsi_target_transport.c
@@ -0,0 +1,55 @@
+#include linux/spinlock.h
+#include linux/list.h
+#include target/iscsi/iscsi_transport.h
+
+static LIST_HEAD(g_transport_list);
+static DEFINE_MUTEX(transport_mutex);
+
+struct iscsit_transport *iscsit_get_transport(int type)
+{
+   struct iscsit_transport *t;
+
+   mutex_lock(transport_mutex);
+   list_for_each_entry(t, g_transport_list, t_node) {
+   if (t-transport_type == type) {
+   if (t-owner  !try_module_get(t-owner)) {
+   t = NULL;
+   }
+   mutex_unlock(transport_mutex);
+   return t;
+   }
+   }
+   mutex_unlock(transport_mutex);
+
+   return NULL;
+}
+
+void iscsit_put_transport(struct iscsit_transport *t)
+{
+   if (t-owner)
+   module_put(t-owner);
+}
+
+int iscsit_register_transport(struct iscsit_transport *t)
+{
+   INIT_LIST_HEAD(t-t_node);
+
+   mutex_lock(transport_mutex);
+   list_add_tail(t-t_node, g_transport_list);
+   mutex_unlock(transport_mutex);
+
+   pr_debug(Registered iSCSI transport: %s\n, t-name);
+
+   return 0;
+}
+EXPORT_SYMBOL(iscsit_register_transport);
+
+void iscsit_unregister_transport(struct iscsit_transport *t)
+{
+   mutex_lock(transport_mutex);
+   list_del(t-t_node);
+   mutex_unlock(transport_mutex);
+
+   pr_debug(Unregistered iSCSI transport: %s\n, t-name);
+}
+EXPORT_SYMBOL(iscsit_unregister_transport);
diff --git a/include/target/iscsi/iscsi_transport.h 
b/include/target/iscsi/iscsi_transport.h
new file mode 100644
index 000..23a87d0
--- /dev/null
+++ b/include/target/iscsi/iscsi_transport.h
@@ -0,0 +1,83 @@
+#include linux/module.h
+#include linux/list.h
+#include ../../../drivers/target/iscsi/iscsi_target_core.h
+
+struct iscsit_transport {
+#define ISCSIT_TRANSPORT_NAME  16
+   char name[ISCSIT_TRANSPORT_NAME];
+   int transport_type;
+   struct module *owner;
+   struct list_head t_node;
+   int (*iscsit_setup_np)(struct iscsi_np *, struct 
__kernel_sockaddr_storage *);
+   int (*iscsit_accept_np)(struct iscsi_np *, struct iscsi_conn *);
+   void (*iscsit_free_np)(struct iscsi_np *);
+   void (*iscsit_free_conn)(struct iscsi_conn *);
+   struct iscsi_cmd *(*iscsit_alloc_cmd)(struct iscsi_conn *, gfp_t);
+   int (*iscsit_get_login_rx)(struct iscsi_conn *, struct iscsi_login *);
+   int (*iscsit_put_login_tx)(struct iscsi_conn *, struct iscsi_login *, 
u32);
+   int (*iscsit_immediate_queue)(struct iscsi_conn *, struct iscsi_cmd *, 
int);
+   int 

Re: be2iscsi: Patchset for be2iscsi

2013-04-12 Thread Mike Christie
On 04/05/2013 10:38 PM, Jayamohan Kallickal wrote:
   - Fix the session cleanup when reboot or shutdown happens

All patches but that one looked ok. Since Jay dropped it for now, then
the patchset looks ok to me.

Reviewed-by: Mike Christie micha...@cs.wisc.edu

--
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


[GIT PULL] target fixes for v3.9-rc7

2013-04-12 Thread Nicholas A. Bellinger
Hello Linus,

Here are remaining target-pending items for v3.9-rc7 code.

Please go ahead and pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master

The tcm_vhost patches are more than I'd usually include in a -rc7 PULL,
but are changes required for v3.9 to work correctly with the pending
vhost-scsi-pci QEMU upstream series merge.  (Paolo CC'ed)

Plus Asias's conversion to use vhost_virtqueue-private_data + RCU for
managing vhost-scsi endpoints has gotten alot of review + testing over
the past weeks, and MST has ACKed the full series.

Also, there is a target patch to fix a long-standing bug within control
CDB handling with Standby/Offline/Transition ALUA port access states,
that had been incorrectly rejecting the control CDBs required for LUN
scan to work during these port group states.  CC'ing to stable.

Thank you,

--nab

Asias He (7):
  tcm_vhost: Use ACCESS_ONCE for vs-vs_tpg[target] access
  tcm_vhost: Use vq-private_data to indicate if the endpoint is setup
  tcm_vhost: Initialize vq-last_used_idx when set endpoint
  tcm_vhost: Remove double check of response
  tcm_vhost: Fix tv_cmd leak in vhost_scsi_handle_vq
  tcm_vhost: Add vhost_scsi_send_bad_target() helper
  tcm_vhost: Send bad target to guest when cmd fails

Nicholas Bellinger (1):
  target: Fix incorrect fallthrough of ALUA Standby/Offline/Transition
CDBs

 drivers/target/target_core_alua.c |3 +
 drivers/vhost/tcm_vhost.c |  198 -
 2 files changed, 133 insertions(+), 68 deletions(-)

-- 
1.7.2.5

--
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, resend] sd: fix infinite kernel/udev loop on non-removable Medium Not Present

2013-04-12 Thread Steve Magnani
Commit eface65c336eff420d70beb0fb6787a732e05ffb (2.6.38) altered
set_media_not_present() in a way that prevents the sd driver from
remembering that a non-removable device has reported Medium Not Present.
This condition can occur on hotplug of a (i.e.) USB Mass Storage device
whose medium is offline due to an unrecoverable controller error,
but which is otherwise capable of SCSI communication (to download new 
microcode, etc.).

Under these conditions, the changed code results in an infinite loop
between the kernel and udevd. When udevd attempts to open the device
in response to a change notification, a SCSI Medium Not Present error
occurs which causes the kernel to signal another change. The cycle
repeats until the device is unplugged, resulting in udevd consuming ever-
increasing amounts of CPU and virtual memory.

Resolve this by remembering media not present whether the device has
declared itself removable or not.

Signed-off-by: Steven J. Magnani st...@digidescorp.com
---
--- a/drivers/scsi/sd.c 2013-04-12 14:16:12.252531097 -0500
+++ b/drivers/scsi/sd.c 2013-04-12 14:21:55.197216521 -0500
@@ -1298,10 +1298,8 @@ out:
 
 static void set_media_not_present(struct scsi_disk *sdkp)
 {
-   if (sdkp-media_present)
+   if (sdkp-media_present) {
sdkp-device-changed = 1;
-
-   if (sdkp-device-removable) {
sdkp-media_present = 0;
sdkp-capacity = 0;
}

--
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] qla2xxx: Fix for locking issue between driver ISR and mailbox routines

2013-04-12 Thread gurinder . shergill
The qla2xxx driver uses ha-mbx_cmd_flags variable to pass information between
its ISR and mailbox routines, however, it does so without the protection of
any locks.  Under certain conditions, this can lead to multiple mailbox
command completions being signaled, which, in turn, leads to a false mailbox
timeout error for the subsequently issued mailbox command.

The issue occurs frequently but intermittenly with the Qlogic 8GFC mezz
card during initialization, resulting in initialization failure.

Signed-off-by: Gurinder (Sunny) Shergill gurinder.sherg...@hp.com
---
 drivers/scsi/qla2xxx/qla_isr.c | 25 +
 drivers/scsi/qla2xxx/qla_mbx.c |  2 --
 drivers/scsi/qla2xxx/qla_mr.c  |  9 ++---
 drivers/scsi/qla2xxx/qla_nx.c  | 28 ++--
 4 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 259d920..b757ee3 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -104,14 +104,18 @@ qla2100_intr_handler(int irq, void *dev_id)
RD_REG_WORD(reg-hccr);
}
}
-   spin_unlock_irqrestore(ha-hardware_lock, flags);
 
if (test_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags) 
(status  MBX_INTERRUPT)  ha-flags.mbox_int) {
set_bit(MBX_INTERRUPT, ha-mbx_cmd_flags);
+   clear_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags);
+   spin_unlock_irqrestore(ha-hardware_lock, flags);
+
complete(ha-mbx_intr_comp);
+   return IRQ_HANDLED;
}
 
+   spin_unlock_irqrestore(ha-hardware_lock, flags);
return (IRQ_HANDLED);
 }
 
@@ -221,14 +225,18 @@ qla2300_intr_handler(int irq, void *dev_id)
WRT_REG_WORD(reg-hccr, HCCR_CLR_RISC_INT);
RD_REG_WORD_RELAXED(reg-hccr);
}
-   spin_unlock_irqrestore(ha-hardware_lock, flags);
 
if (test_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags) 
(status  MBX_INTERRUPT)  ha-flags.mbox_int) {
set_bit(MBX_INTERRUPT, ha-mbx_cmd_flags);
+   clear_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags);
+   spin_unlock_irqrestore(ha-hardware_lock, flags);
+
complete(ha-mbx_intr_comp);
+   return IRQ_HANDLED;
}
 
+   spin_unlock_irqrestore(ha-hardware_lock, flags);
return (IRQ_HANDLED);
 }
 
@@ -2613,14 +2621,18 @@ qla24xx_intr_handler(int irq, void *dev_id)
if (unlikely(IS_QLA83XX(ha)  (ha-pdev-revision == 1)))
ndelay(3500);
}
-   spin_unlock_irqrestore(ha-hardware_lock, flags);
 
if (test_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags) 
(status  MBX_INTERRUPT)  ha-flags.mbox_int) {
set_bit(MBX_INTERRUPT, ha-mbx_cmd_flags);
+   clear_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags);
+   spin_unlock_irqrestore(ha-hardware_lock, flags);
+
complete(ha-mbx_intr_comp);
+   return IRQ_HANDLED;
}
 
+   spin_unlock_irqrestore(ha-hardware_lock, flags);
return IRQ_HANDLED;
 }
 
@@ -2763,13 +2775,18 @@ qla24xx_msix_default(int irq, void *dev_id)
}
WRT_REG_DWORD(reg-hccr, HCCRX_CLR_RISC_INT);
} while (0);
-   spin_unlock_irqrestore(ha-hardware_lock, flags);
 
if (test_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags) 
(status  MBX_INTERRUPT)  ha-flags.mbox_int) {
set_bit(MBX_INTERRUPT, ha-mbx_cmd_flags);
+   clear_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags);
+   spin_unlock_irqrestore(ha-hardware_lock, flags);
+
complete(ha-mbx_intr_comp);
+   return IRQ_HANDLED;
}
+
+   spin_unlock_irqrestore(ha-hardware_lock, flags);
return IRQ_HANDLED;
 }
 
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 9e5d89d..3587ec2 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -179,8 +179,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t 
*mcp)
 
wait_for_completion_timeout(ha-mbx_intr_comp, mcp-tov * HZ);
 
-   clear_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags);
-
} else {
ql_dbg(ql_dbg_mbx, vha, 0x1011,
Cmd=%x Polling Mode.\n, command);
diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
index 729b743..0ab020c 100644
--- a/drivers/scsi/qla2xxx/qla_mr.c
+++ b/drivers/scsi/qla2xxx/qla_mr.c
@@ -149,8 +149,6 @@ qlafx00_mailbox_command(scsi_qla_host_t *vha, struct 
mbx_cmd_32 *mcp)
 
wait_for_completion_timeout(ha-mbx_intr_comp, mcp-tov * HZ);
 
-   clear_bit(MBX_INTR_WAIT, ha-mbx_cmd_flags);
-
} else {
ql_dbg(ql_dbg_mbx, vha, 0x112c,
Cmd=%x Polling Mode.\n, command);
@@ -2934,13 +2932,18 @@ qlafx00_intr_handler(int irq, void *dev_id)