Re: [PATCH V2 3/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2012-07-16 Thread Namjae Jeon
Hi Vinayak.
 + * ufshcd_pltfrm_remove - remove platform driver routine
 + * @pdev: pointer to platform device handle
 + *
 + * Returns 0 on success, non-zero value on failure
 + */
 +static int __devexit ufshcd_pltfrm_remove(struct platform_device *pdev)
 +{
 + struct resource *mem_res;
 + struct resource *irq_res;
 + resource_size_t mem_size;
 + struct ufs_hba *hba =  platform_get_drvdata(pdev);
 +
 + ufshcd_remove(hba);
 + irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 + if (!irq_res)
 + dev_err(pdev-dev, ufshcd: IRQ resource not available\n);
 + free_irq(irq_res-start, hba);
Is there no possibility of null pointer dereferencing error ?(irq_res-start)
I think that free_irq should be not called if irq_res is NULL.
 + mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Looks mem_res is also same with upper case.
Thanks.
 + mem_size = resource_size(mem_res);
 + release_mem_region(mem_res-start, mem_size);
 + platform_set_drvdata(pdev, NULL);
 + return 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


Re: [PATCH V2 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2012-07-16 Thread James Bottomley
On Fri, 2012-07-13 at 15:45 +, Arnd Bergmann wrote:
 On Friday 13 July 2012, Vinayak Holikatti wrote:
  This patch set adds following features
   - Seprates PCI specific code from ufshcd.c to make it as core
   - Adds PCI glue driver ufshcd-pci.c
   - Adds Platform glue driver ufshcd-pltfrm.c
   - Update correct transfer size in Command UPIU
 
 Acked-by: Arnd Bergmann a...@arndb.de

I need a maintainer ack for this to go upstream.

Also, looking at this, I think this patch series isn't bisectable:
Patch 1 removes PCI support and patch 2 adds it back in a different
form.  However, any PCI based UFS system would stop working if the
bisect landed at patch 1.  I think you can fix this just by combining
patches 1 and 2.

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


[PATCH 0/2] virtio-scsi event changes for 3.6

2012-07-16 Thread Paolo Bonzini
Hi James,

here are two more small patches for virtio-scsi.  The first fixes a
problem with the recently introduced hotplug/hot-unplug support
(happens with LUNs whose number is greater than 255).  The second
introduces support for online resizing of disks.

The host here will also send the sense code via unit attention.
This will be discarded by the high-level driver for non-removable
units.  I sent a separate patch to deal with it for removable
units.

Paolo

Paolo Bonzini (2):
  virtio-scsi: fix parsing of hotplug/hot-unplug LUN number
  virtio-scsi: support online resizing of disks

 drivers/scsi/virtio_scsi.c  |   39 -
 include/linux/virtio_scsi.h |2 +
 2 files changed, 38 insertions(+), 2 deletions(-)

--
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/2] virtio-scsi: support online resizing of disks

2012-07-16 Thread Paolo Bonzini
Support the LUN parameter change event.  Currently, the host fires this event
when the capacity of a disk is changed from the virtual machine monitor.
The resize then appears in the kernel log like this:

  sd 0:0:0:0: [sda] 46137344 512-byte logical blocks: (23.6 GB/22.0 GIb)
  sda: detected capacity change from 22548578304 to 23622320128

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 drivers/scsi/virtio_scsi.c  |   31 ++-
 include/linux/virtio_scsi.h |2 ++
 2 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index c937232..d8c6a57 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -285,6 +285,31 @@ static void virtscsi_handle_transport_reset(struct 
virtio_scsi *vscsi,
}
 }
 
+static void virtscsi_handle_param_change(struct virtio_scsi *vscsi,
+struct virtio_scsi_event *event)
+{
+   struct scsi_device *sdev;
+   struct Scsi_Host *shost = virtio_scsi_host(vscsi-vdev);
+   unsigned int target = event-lun[1];
+   unsigned int lun = virtscsi_get_lun(event-lun);
+   u8 asc = event-reason  255;
+   u8 ascq = event-reason  8;
+
+   sdev = scsi_device_lookup(shost, 0, target, lun);
+   if (!sdev) {
+   pr_err(SCSI device %d 0 %d %d not found\n,
+   shost-host_no, target, lun);
+   return;
+   }
+
+   /* Handle Parameters changed, Mode parameters changed, and
+  Capacity data has changed.  */
+   if (asc == 0x2a  (ascq == 0x00 || ascq == 0x01 || ascq == 0x09))
+   scsi_rescan_device(sdev-sdev_gendev);
+
+   scsi_device_put(sdev);
+}
+
 static void virtscsi_handle_event(struct work_struct *work)
 {
struct virtio_scsi_event_node *event_node =
@@ -303,6 +328,9 @@ static void virtscsi_handle_event(struct work_struct *work)
case VIRTIO_SCSI_T_TRANSPORT_RESET:
virtscsi_handle_transport_reset(vscsi, event);
break;
+   case VIRTIO_SCSI_T_PARAM_CHANGE:
+   virtscsi_handle_param_change(vscsi, event);
+   break;
default:
pr_err(Unsupport virtio scsi event %x\n, event-event);
}
@@ -739,7 +767,8 @@ static struct virtio_device_id id_table[] = {
 };
 
 static unsigned int features[] = {
-   VIRTIO_SCSI_F_HOTPLUG
+   VIRTIO_SCSI_F_HOTPLUG,
+   VIRTIO_SCSI_F_CHANGE,
 };
 
 static struct virtio_driver virtio_scsi_driver = {
diff --git a/include/linux/virtio_scsi.h b/include/linux/virtio_scsi.h
index dc8d305..d6b4440 100644
--- a/include/linux/virtio_scsi.h
+++ b/include/linux/virtio_scsi.h
@@ -72,6 +72,7 @@ struct virtio_scsi_config {
 /* Feature Bits */
 #define VIRTIO_SCSI_F_INOUT0
 #define VIRTIO_SCSI_F_HOTPLUG  1
+#define VIRTIO_SCSI_F_CHANGE   2
 
 /* Response codes */
 #define VIRTIO_SCSI_S_OK   0
@@ -108,6 +109,7 @@ struct virtio_scsi_config {
 #define VIRTIO_SCSI_T_NO_EVENT 0
 #define VIRTIO_SCSI_T_TRANSPORT_RESET  1
 #define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
+#define VIRTIO_SCSI_T_PARAM_CHANGE 3
 
 /* Reasons of transport reset event */
 #define VIRTIO_SCSI_EVT_RESET_HARD 0
-- 
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] sd: do not set changed flag on all unit attention conditions

2012-07-16 Thread Paolo Bonzini
Right now, I/O will fail as soon as a unit attention condition is
detected on a unit with removable media.  However, this is not
always necessary.  There are some cases (such as Capacity data
has changed) where no particular action is needed.  On the
other hand, all problematic cases have to report at least one
of No medium and/or a Medium may have changed, so restrict
our attention to those.

This patch fixes resizing a removable medium with virtio-scsi.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 drivers/scsi/scsi_lib.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index b583277..6d8ca08 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -843,8 +843,11 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned 
int good_bytes)
} else if (sense_valid  !sense_deferred) {
switch (sshdr.sense_key) {
case UNIT_ATTENTION:
-   if (cmd-device-removable) {
-   /* Detected disc change.  Set a bit
+   if (cmd-device-removable 
+   (sshdr.asc == 0x3a ||
+(sshdr.asc == 0x28  sshdr.ascq == 0x00))) {
+   /* No medium or Medium may have changed.
+* This means a disc change.  Set a bit
 * and quietly refuse further access.
 */
cmd-device-changed = 1;
-- 
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


Re: [PATCH] sd: do not set changed flag on all unit attention conditions

2012-07-16 Thread James Bottomley
On Mon, 2012-07-16 at 18:06 +0200, Paolo Bonzini wrote:
 Right now, I/O will fail as soon as a unit attention condition is
 detected on a unit with removable media.  However, this is not
 always necessary.  There are some cases (such as Capacity data
 has changed) where no particular action is needed.  On the
 other hand, all problematic cases have to report at least one
 of No medium and/or a Medium may have changed, so restrict
 our attention to those.
 
 This patch fixes resizing a removable medium with virtio-scsi.
 
 Signed-off-by: Paolo Bonzini pbonz...@redhat.com
 ---
  drivers/scsi/scsi_lib.c |7 +--
  1 files changed, 5 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
 index b583277..6d8ca08 100644
 --- a/drivers/scsi/scsi_lib.c
 +++ b/drivers/scsi/scsi_lib.c
 @@ -843,8 +843,11 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned 
 int good_bytes)
   } else if (sense_valid  !sense_deferred) {
   switch (sshdr.sense_key) {
   case UNIT_ATTENTION:
 - if (cmd-device-removable) {
 - /* Detected disc change.  Set a bit
 + if (cmd-device-removable 
 + (sshdr.asc == 0x3a ||
 +  (sshdr.asc == 0x28  sshdr.ascq == 0x00))) {
 + /* No medium or Medium may have changed.
 +  * This means a disc change.  Set a bit

This type of change would likely cause a huge cascade of errors in real
removable media devices.  Under the MMC standards, which a lot of the
older removable discs seem to follow, UNIT ATTENTION indicates either
medium change or device reset (which we check for and eat lower down);
we can't rely on them giving proper SBC-2 sense codes.  If you want to
pretend to be removable media, you have to conform to its standards.

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


[PATCH 0/7] series to fix qla2xxx use-after-free

2012-07-16 Thread Roland Dreier
From: Roland Dreier rol...@purestorage.com

Hi Nic,

Here's a series that's fundamentally about fixing a use-after-free in
qla_target code.  It ends up being seven patches because I wanted to
make each step easy to review, and several of these are just cleanups
that stand on their own.

We have a few more qla2xxx-related fixes that I need to clean up and
merge with the latest.  I'll send them soon.

Roland Dreier (7):
  qla2xxx: Get rid of redundant qla_tgt_sess.tearing_down
  target: Un-export target_get_sess_cmd()
  sbp-target: Consolidate duplicated error path code in
sbp_handle_command()
  target: Allow for target_submit_cmd() returning errors
  target: Check sess_tearing_down in target_get_sess_cmd()
  qla2xxx: Remove racy, now-redundant check of sess_tearing_down
  target: Remove se_session.sess_wait_list

 drivers/scsi/qla2xxx/qla_target.c  |   16 ++
 drivers/scsi/qla2xxx/qla_target.h  |1 -
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |   10 +++---
 drivers/target/sbp/sbp_target.c|   36 ++---
 drivers/target/target_core_transport.c |   55 
 drivers/target/tcm_fc/tfc_cmd.c|8 +++--
 drivers/usb/gadget/tcm_usb_gadget.c|   20 +---
 include/target/target_core_base.h  |1 -
 include/target/target_core_fabric.h|5 ++-
 9 files changed, 73 insertions(+), 79 deletions(-)

-- 
1.7.10.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/7] qla2xxx: Get rid of redundant qla_tgt_sess.tearing_down

2012-07-16 Thread Roland Dreier
From: Roland Dreier rol...@purestorage.com

The only place that sets qla_tgt_sess.tearing_down calls
target_splice_sess_cmd_list() immediately afterwards, without dropping
the lock it holds.  That function sets se_session.sess_tearing_down,
so we can get rid of the qla_target-specific flag, and in the one
place that looks at the qla_tgt_sess.tearing_down flag just test
se_session.sess_tearing_down instead.

Cc: Chad Dupuis chad.dup...@qlogic.com
Cc: Arun Easi arun.e...@qlogic.com
Signed-off-by: Roland Dreier rol...@purestorage.com
---
 drivers/scsi/qla2xxx/qla_target.c  |2 +-
 drivers/scsi/qla2xxx/qla_target.h  |1 -
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |1 -
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 77759c7..87b5a330 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -2644,7 +2644,7 @@ static void qlt_do_work(struct work_struct *work)
sess = ha-tgt.tgt_ops-find_sess_by_s_id(vha,
atio-u.isp24.fcp_hdr.s_id);
if (sess) {
-   if (unlikely(sess-tearing_down)) {
+   if (unlikely(sess-se_sess-sess_tearing_down)) {
sess = NULL;
spin_unlock_irqrestore(ha-hardware_lock, flags);
goto out_term;
diff --git a/drivers/scsi/qla2xxx/qla_target.h 
b/drivers/scsi/qla2xxx/qla_target.h
index 9f9ef16..07aa265 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -813,7 +813,6 @@ struct qla_tgt_sess {
unsigned int conf_compl_supported:1;
unsigned int deleted:1;
unsigned int local:1;
-   unsigned int tearing_down:1;
 
struct se_session *se_sess;
struct scsi_qla_host *vha;
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 6e64314..3cb2b97 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -466,7 +466,6 @@ static int tcm_qla2xxx_shutdown_session(struct se_session 
*se_sess)
vha = sess-vha;
 
spin_lock_irqsave(vha-hw-hardware_lock, flags);
-   sess-tearing_down = 1;
target_splice_sess_cmd_list(se_sess);
spin_unlock_irqrestore(vha-hw-hardware_lock, flags);
 
-- 
1.7.10.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/7] target: Un-export target_get_sess_cmd()

2012-07-16 Thread Roland Dreier
From: Roland Dreier rol...@purestorage.com

There are no in-tree users of target_get_sess_cmd() outside of
target_core_transport.c.  Any new code should use the higher-level
target_submit_cmd() interface.  So let's un-export target_get_sess_cmd()
and make it static to the one file where it's actually used.

Signed-off-by: Roland Dreier rol...@purestorage.com
---
 drivers/target/target_core_transport.c |6 +++---
 include/target/target_core_fabric.h|1 -
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index 634d0f3..82e40e1 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -73,6 +73,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd);
 static void transport_handle_queue_full(struct se_cmd *cmd,
struct se_device *dev);
 static int transport_generic_get_mem(struct se_cmd *cmd);
+static void target_get_sess_cmd(struct se_session *, struct se_cmd *, bool);
 static void transport_put_cmd(struct se_cmd *cmd);
 static void transport_remove_cmd_from_queue(struct se_cmd *cmd);
 static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq);
@@ -3648,8 +3649,8 @@ EXPORT_SYMBOL(transport_generic_free_cmd);
  * @se_cmd:command descriptor to add
  * @ack_kref:  Signal that fabric will perform an ack target_put_sess_cmd()
  */
-void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd,
-   bool ack_kref)
+static void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd 
*se_cmd,
+   bool ack_kref)
 {
unsigned long flags;
 
@@ -3669,7 +3670,6 @@ void target_get_sess_cmd(struct se_session *se_sess, 
struct se_cmd *se_cmd,
se_cmd-check_release = 1;
spin_unlock_irqrestore(se_sess-sess_cmd_lock, flags);
 }
-EXPORT_SYMBOL(target_get_sess_cmd);
 
 static void target_release_cmd_kref(struct kref *kref)
 {
diff --git a/include/target/target_core_fabric.h 
b/include/target/target_core_fabric.h
index c78a233..1e68882 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -129,7 +129,6 @@ booltransport_wait_for_tasks(struct se_cmd *);
 inttransport_check_aborted_status(struct se_cmd *, int);
 inttransport_send_check_condition_and_sense(struct se_cmd *, u8, int);
 
-void   target_get_sess_cmd(struct se_session *, struct se_cmd *, bool);
 inttarget_put_sess_cmd(struct se_session *, struct se_cmd *);
 void   target_splice_sess_cmd_list(struct se_session *);
 void   target_wait_for_sess_cmds(struct se_session *, int);
-- 
1.7.10.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] sbp-target: Consolidate duplicated error path code in sbp_handle_command()

2012-07-16 Thread Roland Dreier
From: Roland Dreier rol...@purestorage.com

Cc: Chris Boot bo...@bootc.net
Cc: Stefan Richter stef...@s5r6.in-berlin.de
Signed-off-by: Roland Dreier rol...@purestorage.com
---
 drivers/target/sbp/sbp_target.c |   28 
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index 7e6136e..2425ca4 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -1219,28 +1219,14 @@ static void sbp_handle_command(struct 
sbp_target_request *req)
ret = sbp_fetch_command(req);
if (ret) {
pr_debug(sbp_handle_command: fetch command failed: %d\n, ret);
-   req-status.status |= cpu_to_be32(
-   STATUS_BLOCK_RESP(STATUS_RESP_TRANSPORT_FAILURE) |
-   STATUS_BLOCK_DEAD(0) |
-   STATUS_BLOCK_LEN(1) |
-   STATUS_BLOCK_SBP_STATUS(SBP_STATUS_UNSPECIFIED_ERROR));
-   sbp_send_status(req);
-   sbp_free_request(req);
-   return;
+   goto err;
}
 
ret = sbp_fetch_page_table(req);
if (ret) {
pr_debug(sbp_handle_command: fetch page table failed: %d\n,
ret);
-   req-status.status |= cpu_to_be32(
-   STATUS_BLOCK_RESP(STATUS_RESP_TRANSPORT_FAILURE) |
-   STATUS_BLOCK_DEAD(0) |
-   STATUS_BLOCK_LEN(1) |
-   STATUS_BLOCK_SBP_STATUS(SBP_STATUS_UNSPECIFIED_ERROR));
-   sbp_send_status(req);
-   sbp_free_request(req);
-   return;
+   goto err;
}
 
unpacked_lun = req-login-lun-unpacked_lun;
@@ -1252,6 +1238,16 @@ static void sbp_handle_command(struct sbp_target_request 
*req)
target_submit_cmd(req-se_cmd, sess-se_sess, req-cmd_buf,
req-sense_buf, unpacked_lun, data_length,
MSG_SIMPLE_TAG, data_dir, 0);
+   return;
+
+err:
+   req-status.status |= cpu_to_be32(
+   STATUS_BLOCK_RESP(STATUS_RESP_TRANSPORT_FAILURE) |
+   STATUS_BLOCK_DEAD(0) |
+   STATUS_BLOCK_LEN(1) |
+   STATUS_BLOCK_SBP_STATUS(SBP_STATUS_UNSPECIFIED_ERROR));
+   sbp_send_status(req);
+   sbp_free_request(req);
 }
 
 /*
-- 
1.7.10.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] qla2xxx: Remove racy, now-redundant check of sess_tearing_down

2012-07-16 Thread Roland Dreier
From: Roland Dreier rol...@purestorage.com

Now that target_submit_cmd() / target_get_sess_cmd() check
sess_tearing_down before adding commands to the list, we no longer
need the check in qlt_do_work().  In fact this check is racy anyway
(and that race is what inspired the change to add the check of
sess_tearing_down to the target core).

Cc: Chad Dupuis chad.dup...@qlogic.com
Cc: Arun Easi arun.e...@qlogic.com
Signed-off-by: Roland Dreier rol...@purestorage.com
---
 drivers/scsi/qla2xxx/qla_target.c |   16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 87b5a330..5b30132 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -2643,19 +2643,9 @@ static void qlt_do_work(struct work_struct *work)
spin_lock_irqsave(ha-hardware_lock, flags);
sess = ha-tgt.tgt_ops-find_sess_by_s_id(vha,
atio-u.isp24.fcp_hdr.s_id);
-   if (sess) {
-   if (unlikely(sess-se_sess-sess_tearing_down)) {
-   sess = NULL;
-   spin_unlock_irqrestore(ha-hardware_lock, flags);
-   goto out_term;
-   } else {
-   /*
-* Do the extra kref_get() before dropping
-* qla_hw_data-hardware_lock.
-*/
-   kref_get(sess-se_sess-sess_kref);
-   }
-   }
+   /* Do kref_get() before dropping qla_hw_data-hardware_lock. */
+   if (sess)
+   kref_get(sess-se_sess-sess_kref);
spin_unlock_irqrestore(ha-hardware_lock, flags);
 
if (unlikely(!sess)) {
-- 
1.7.10.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/7] target: Allow for target_submit_cmd() returning errors

2012-07-16 Thread Roland Dreier
From: Roland Dreier rol...@purestorage.com

We want it to be possible for target_submit_cmd() to return errors up
to its fabric module callers.  For now just update the prototype to
return an int, and update all callers to handle non-zero return values
as an error.

Cc: Chad Dupuis chad.dup...@qlogic.com
Cc: Arun Easi arun.e...@qlogic.com
Cc: Chris Boot bo...@bootc.net
Cc: Stefan Richter stef...@s5r6.in-berlin.de
Cc: Mark Rustad mark.d.rus...@intel.com
Cc: Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
Cc: Felipe Balbi ba...@ti.com
Signed-off-by: Roland Dreier rol...@purestorage.com
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |7 +++
 drivers/target/sbp/sbp_target.c|8 +---
 drivers/target/target_core_transport.c |9 +
 drivers/target/tcm_fc/tfc_cmd.c|8 +---
 drivers/usb/gadget/tcm_usb_gadget.c|   20 
 include/target/target_core_fabric.h|2 +-
 6 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 3cb2b97..7db7ca7 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -599,10 +599,9 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, 
struct qla_tgt_cmd *cmd,
return -EINVAL;
}
 
-   target_submit_cmd(se_cmd, se_sess, cdb, cmd-sense_buffer[0],
-   cmd-unpacked_lun, data_length, fcp_task_attr,
-   data_dir, flags);
-   return 0;
+   return target_submit_cmd(se_cmd, se_sess, cdb, cmd-sense_buffer[0],
+cmd-unpacked_lun, data_length, fcp_task_attr,
+data_dir, flags);
 }
 
 static void tcm_qla2xxx_do_rsp(struct work_struct *work)
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index 2425ca4..fb75d05 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -1235,9 +1235,11 @@ static void sbp_handle_command(struct sbp_target_request 
*req)
pr_debug(sbp_handle_command ORB:0x%llx unpacked_lun:%d data_len:%d 
data_dir:%d\n,
req-orb_pointer, unpacked_lun, data_length, data_dir);
 
-   target_submit_cmd(req-se_cmd, sess-se_sess, req-cmd_buf,
-   req-sense_buf, unpacked_lun, data_length,
-   MSG_SIMPLE_TAG, data_dir, 0);
+   if (target_submit_cmd(req-se_cmd, sess-se_sess, req-cmd_buf,
+ req-sense_buf, unpacked_lun, data_length,
+ MSG_SIMPLE_TAG, data_dir, 0))
+   goto err;
+
return;
 
 err:
diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index 82e40e1..34ca821 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1544,7 +1544,7 @@ EXPORT_SYMBOL(transport_handle_cdb_direct);
  * This may only be called from process context, and also currently
  * assumes internal allocation of fabric payload buffer by target-core.
  **/
-void target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
+int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
unsigned char *cdb, unsigned char *sense, u32 unpacked_lun,
u32 data_length, int task_attr, int data_dir, int flags)
 {
@@ -1583,7 +1583,7 @@ void target_submit_cmd(struct se_cmd *se_cmd, struct 
se_session *se_sess,
transport_send_check_condition_and_sense(se_cmd,
se_cmd-scsi_sense_reason, 0);
target_put_sess_cmd(se_sess, se_cmd);
-   return;
+   return 0;
}
/*
 * Sanitize CDBs via transport_generic_cmd_sequencer() and
@@ -1592,7 +1592,7 @@ void target_submit_cmd(struct se_cmd *se_cmd, struct 
se_session *se_sess,
rc = target_setup_cmd_from_cdb(se_cmd, cdb);
if (rc != 0) {
transport_generic_request_failure(se_cmd);
-   return;
+   return 0;
}
 
/*
@@ -1608,7 +1608,8 @@ void target_submit_cmd(struct se_cmd *se_cmd, struct 
se_session *se_sess,
 * when fabric has filled the incoming buffer.
 */
transport_handle_cdb_direct(se_cmd);
-   return;
+
+   return 0;
 }
 EXPORT_SYMBOL(target_submit_cmd);
 
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index f03fb97..c7c90aa 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -541,9 +541,11 @@ static void ft_send_work(struct work_struct *work)
 * Use a single se_cmd-cmd_kref as we expect to release se_cmd
 * directly from ft_check_stop_free callback in response path.
 */
-   target_submit_cmd(cmd-se_cmd, cmd-sess-se_sess, fcp-fc_cdb,
-   cmd-ft_sense_buffer[0], 

Re: [PATCH V2 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2012-07-16 Thread Arnd Bergmann
On Monday 16 July 2012, James Bottomley wrote:
 On Fri, 2012-07-13 at 15:45 +, Arnd Bergmann wrote:
  On Friday 13 July 2012, Vinayak Holikatti wrote:
   This patch set adds following features
- Seprates PCI specific code from ufshcd.c to make it as core
- Adds PCI glue driver ufshcd-pci.c
- Adds Platform glue driver ufshcd-pltfrm.c
- Update correct transfer size in Command UPIU
  
  Acked-by: Arnd Bergmann a...@arndb.de
 
 I need a maintainer ack for this to go upstream.
 
 Also, looking at this, I think this patch series isn't bisectable:
 Patch 1 removes PCI support and patch 2 adds it back in a different
 form.  However, any PCI based UFS system would stop working if the
 bisect landed at patch 1.  I think you can fix this just by combining
 patches 1 and 2.

I suggested to split the patch in two in a private review that we
did on the linaro mailing list. I gave my Ack because the split
was done, but I failed to notice that it was done differently
from what I suggested in 

On Monday 02 July 2012, Arnd Bergmann wrote:
 I would recommend that you split this patch into two separate
 changesets, where you do all the changes to existing code in the
 first patch, and only move but don't change code in the second one
 that creates the new file.

I agree that breaking bisectibility by ripping out the PCI code
first is not good. The version 2 is not actually easier to review
at all than the first version, it just splits the changes by
file, which is pointless.

Arnd

--
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/3] ipr: Driver version 2.5.4

2012-07-16 Thread Brian King

Bump driver version.

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

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

diff -puN drivers/scsi/ipr.h~ipr_version_2_5_4 drivers/scsi/ipr.h
--- linux-2.6/drivers/scsi/ipr.h~ipr_version_2_5_4  2012-07-11 
16:40:34.0 -0500
+++ linux-2.6-bjking1/drivers/scsi/ipr.h2012-07-11 16:40:34.0 
-0500
@@ -38,8 +38,8 @@
 /*
  * Literals
  */
-#define IPR_DRIVER_VERSION 2.5.3
-#define IPR_DRIVER_DATE (March 10, 2012)
+#define IPR_DRIVER_VERSION 2.5.4
+#define IPR_DRIVER_DATE (July 11, 2012)
 
 /*
  * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
_

--
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/3] ipr: Reduce interrupt lock time

2012-07-16 Thread Brian King

Reduce the amount of time the host lock is held in the interrupt handler
for improved performance.

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

 drivers/scsi/ipr.c |   60 -
 drivers/scsi/ipr.h |1 
 2 files changed, 47 insertions(+), 14 deletions(-)

diff -puN drivers/scsi/ipr.h~ipr_reduce_isr_lock2 drivers/scsi/ipr.h
--- linux-2.6/drivers/scsi/ipr.h~ipr_reduce_isr_lock2   2012-07-13 
16:06:16.0 -0500
+++ linux-2.6-bjking1/drivers/scsi/ipr.h2012-07-13 16:06:16.0 
-0500
@@ -1525,6 +1525,7 @@ struct ipr_cmnd {
struct ata_queued_cmd *qc;
struct completion completion;
struct timer_list timer;
+   void (*fast_done) (struct ipr_cmnd *);
void (*done) (struct ipr_cmnd *);
int (*job_step) (struct ipr_cmnd *);
int (*job_step_failed) (struct ipr_cmnd *);
diff -puN drivers/scsi/ipr.c~ipr_reduce_isr_lock2 drivers/scsi/ipr.c
--- linux-2.6/drivers/scsi/ipr.c~ipr_reduce_isr_lock2   2012-07-13 
16:06:16.0 -0500
+++ linux-2.6-bjking1/drivers/scsi/ipr.c2012-07-13 16:06:16.0 
-0500
@@ -566,6 +566,23 @@ static void ipr_trc_hook(struct ipr_cmnd
 #endif
 
 /**
+ * ipr_lock_and_done - Acquire lock and complete command
+ * @ipr_cmd:   ipr command struct
+ *
+ * Return value:
+ * none
+ **/
+static void ipr_lock_and_done(struct ipr_cmnd *ipr_cmd)
+{
+   unsigned long lock_flags = 0;
+   struct ipr_ioa_cfg *ioa_cfg = ipr_cmd-ioa_cfg;
+
+   spin_lock_irqsave(ioa_cfg-host-host_lock, lock_flags);
+   ipr_cmd-done(ipr_cmd);
+   spin_unlock_irqrestore(ioa_cfg-host-host_lock, lock_flags);
+}
+
+/**
  * ipr_reinit_ipr_cmnd - Re-initialize an IPR Cmnd block for reuse
  * @ipr_cmd:   ipr command struct
  *
@@ -611,11 +628,13 @@ static void ipr_reinit_ipr_cmnd(struct i
  * Return value:
  * none
  **/
-static void ipr_init_ipr_cmnd(struct ipr_cmnd *ipr_cmd)
+static void ipr_init_ipr_cmnd(struct ipr_cmnd *ipr_cmd,
+ void (*fast_done) (struct ipr_cmnd *))
 {
ipr_reinit_ipr_cmnd(ipr_cmd);
ipr_cmd-u.scratch = 0;
ipr_cmd-sibling = NULL;
+   ipr_cmd-fast_done = fast_done;
init_timer(ipr_cmd-timer);
 }
 
@@ -648,7 +667,7 @@ static
 struct ipr_cmnd *ipr_get_free_ipr_cmnd(struct ipr_ioa_cfg *ioa_cfg)
 {
struct ipr_cmnd *ipr_cmd = __ipr_get_free_ipr_cmnd(ioa_cfg);
-   ipr_init_ipr_cmnd(ipr_cmd);
+   ipr_init_ipr_cmnd(ipr_cmd, ipr_lock_and_done);
return ipr_cmd;
 }
 
@@ -5130,8 +5149,9 @@ static irqreturn_t ipr_isr(int irq, void
u16 cmd_index;
int num_hrrq = 0;
int irq_none = 0;
-   struct ipr_cmnd *ipr_cmd;
+   struct ipr_cmnd *ipr_cmd, *temp;
irqreturn_t rc = IRQ_NONE;
+   LIST_HEAD(doneq);
 
spin_lock_irqsave(ioa_cfg-host-host_lock, lock_flags);
 
@@ -5152,8 +5172,8 @@ static irqreturn_t ipr_isr(int irq, void
 
if (unlikely(cmd_index = IPR_NUM_CMD_BLKS)) {
ipr_isr_eh(ioa_cfg, Invalid response handle 
from IOA);
-   
spin_unlock_irqrestore(ioa_cfg-host-host_lock, lock_flags);
-   return IRQ_HANDLED;
+   rc = IRQ_HANDLED;
+   goto unlock_out;
}
 
ipr_cmd = ioa_cfg-ipr_cmnd_list[cmd_index];
@@ -5162,9 +5182,7 @@ static irqreturn_t ipr_isr(int irq, void
 
ipr_trc_hook(ipr_cmd, IPR_TRACE_FINISH, ioasc);
 
-   list_del(ipr_cmd-queue);
-   del_timer(ipr_cmd-timer);
-   ipr_cmd-done(ipr_cmd);
+   list_move_tail(ipr_cmd-queue, doneq);
 
rc = IRQ_HANDLED;
 
@@ -5194,8 +5212,8 @@ static irqreturn_t ipr_isr(int irq, void
} else if (num_hrrq == IPR_MAX_HRRQ_RETRIES 
   int_reg  IPR_PCII_HRRQ_UPDATED) {
ipr_isr_eh(ioa_cfg, Error clearing HRRQ);
-   spin_unlock_irqrestore(ioa_cfg-host-host_lock, 
lock_flags);
-   return IRQ_HANDLED;
+   rc = IRQ_HANDLED;
+   goto unlock_out;
} else
break;
}
@@ -5203,7 +5221,14 @@ static irqreturn_t ipr_isr(int irq, void
if (unlikely(rc == IRQ_NONE))
rc = ipr_handle_other_interrupt(ioa_cfg, int_reg);
 
+unlock_out:
spin_unlock_irqrestore(ioa_cfg-host-host_lock, lock_flags);
+   list_for_each_entry_safe(ipr_cmd, temp, doneq, queue) {
+   list_del(ipr_cmd-queue);
+   del_timer(ipr_cmd-timer);
+   ipr_cmd-fast_done(ipr_cmd);
+   }
+
return rc;
 }
 
@@ -5784,15 +5809,22 @@ static void ipr_scsi_done(struct ipr_cmn
struct ipr_ioa_cfg *ioa_cfg = ipr_cmd-ioa_cfg;
struct scsi_cmnd 

Re: [PATCH 17/18] srp_transport: Add transport layer recovery support

2012-07-16 Thread Mike Christie
On 01/14/2012 05:56 AM, Bart Van Assche wrote:
 Add the necessary functions in the SRP transport module to allow
 an SRP initiator driver to implement transport layer recovery.
 This includes:
 - A ping mechanism to check whether the transport layer is still
   operational.
 - Support for implementing fast_io_fail_tmo, the time that should
   elapse after having detected a transport layer problem and
   before failing I/O.
 - Support for implementing dev_loss_tmo, the time that should
   elapse after having detected a transport layer problem and
   before removing a remote port.
 

I was updating my iscsi dev loss patch when I saw this is still not merged.

Not sure about the ping code, but I think the dev loss tmo and fast io
fail related stuff should go to scsi_transport_template. We can then add
some common code to start the timers/delayed_work_queues, stop them,
set/get the value from sysfs, etc that all the transport classes can
then call.

For the srp code to use this patch, it was not clear to me what happens
if dev_loss_tmo fires, but then the port comes back online. It looks
like the target and its devices get deleted like with FC when the
dev_loss_tmo fires. Is there something to automatically re-add the
path/port/target when the issue is resolved? Was it on the patches that
did not make the list (I only saw 6 patches out of 18 on linux-scsi) or
do we have some userspace daemon that figures out when
paths/ports/targets come back?

Also I think the patch that has ib_srp call srp_start_tl_fail_timers and
srp_block_rport did not make the list.

For the ping code, does it use TUR because there is not a transport way
to test the path/port/transport/interconnect?
--
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 17/18] srp_transport: Add transport layer recovery support

2012-07-16 Thread Mike Christie
On 07/16/2012 04:07 PM, Mike Christie wrote:
 For the ping code, does it use TUR because there is not a transport way
 to test the path/port/transport/interconnect?

Maybe not transport as in SCSI transport method, but what about
something similar to using a ICMP ping for testing the network with iscsi.
--
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 17/18] srp_transport: Add transport layer recovery support

2012-07-16 Thread David Dillow
On Mon, 2012-07-16 at 18:07 -0400, Mike Christie wrote:
 On 01/14/2012 05:56 AM, Bart Van Assche wrote:
  Add the necessary functions in the SRP transport module to allow
  an SRP initiator driver to implement transport layer recovery.

 I was updating my iscsi dev loss patch when I saw this is still not merged.

Yes, I got part way into doing a rework of Bart's code before I got
sidetracked on another project. Cognizant of the looming merge window,
I'm desperately trying to get back to it. 

 Not sure about the ping code, but I think the dev loss tmo and fast io
 fail related stuff should go to scsi_transport_template. We can then add
 some common code to start the timers/delayed_work_queues, stop them,
 set/get the value from sysfs, etc that all the transport classes can
 then call.

Good idea, I'll look into doing this as part of it.

 For the srp code to use this patch, it was not clear to me what happens
 if dev_loss_tmo fires, but then the port comes back online. It looks
 like the target and its devices get deleted like with FC when the
 dev_loss_tmo fires. Is there something to automatically re-add the
 path/port/target when the issue is resolved? Was it on the patches that
 did not make the list (I only saw 6 patches out of 18 on linux-scsi) or
 do we have some userspace daemon that figures out when
 paths/ports/targets come back?

There is srp_daemon, which performs this task.

 For the ping code, does it use TUR because there is not a transport way
 to test the path/port/transport/interconnect?

Yes, SRP does not have a way to test connectivity on a transport level
ala iSCSI NOPs. I'm not at all inclined to add the ping functionality to
the SRP initiator, as I see it as duplicative of the existing multipathd
functionality in userspace, and it can kill the entire nexus even if
only one LUN is having issues.

-- 
Dave Dillow
National Center for Computational Science
Oak Ridge National Laboratory
(865) 241-6602 office


--
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 17/18] srp_transport: Add transport layer recovery support

2012-07-16 Thread David Dillow
On Mon, 2012-07-16 at 18:38 -0400, Mike Christie wrote:
 On 07/16/2012 04:28 PM, David Dillow wrote:
  On Mon, 2012-07-16 at 18:07 -0400, Mike Christie wrote:
  For the ping code, does it use TUR because there is not a transport way
  to test the path/port/transport/interconnect?
  
  Yes, SRP does not have a way to test connectivity on a transport level
  ala iSCSI NOPs. I'm not at all inclined to add the ping functionality to
  the SRP initiator, as I see it as duplicative of the existing multipathd
  functionality in userspace, and it can kill the entire nexus even if
  only one LUN is having issues.
  
 
 I am not in favor of a tur in the transport class too.
 
 What about when multipath is not used or are you saying we should use it
 for srp even when there is only one path (for iscsi we have told people
 to do something like this if they want mpaths queue_if_no_path behavior).

If they want to quickly detect and fail idle paths, then perhaps.
Otherwise, the loss of the connection will only be noticed on the next
command.

We can also get notifications from the fabric when a device leaves, so
we can use that to start the dev_loss_tmo and prune the stale
connections.

-- 
Dave Dillow
National Center for Computational Science
Oak Ridge National Laboratory
(865) 241-6602 office


--
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 1/7] qla2xxx: Get rid of redundant qla_tgt_sess.tearing_down

2012-07-16 Thread Nicholas A. Bellinger
On Mon, 2012-07-16 at 11:04 -0700, Roland Dreier wrote:
 From: Roland Dreier rol...@purestorage.com
 
 The only place that sets qla_tgt_sess.tearing_down calls
 target_splice_sess_cmd_list() immediately afterwards, without dropping
 the lock it holds.  That function sets se_session.sess_tearing_down,
 so we can get rid of the qla_target-specific flag, and in the one
 place that looks at the qla_tgt_sess.tearing_down flag just test
 se_session.sess_tearing_down instead.
 

Looks fine.  Applied to for-next.

Thanks Roland!

 Cc: Chad Dupuis chad.dup...@qlogic.com
 Cc: Arun Easi arun.e...@qlogic.com
 Signed-off-by: Roland Dreier rol...@purestorage.com
 ---
  drivers/scsi/qla2xxx/qla_target.c  |2 +-
  drivers/scsi/qla2xxx/qla_target.h  |1 -
  drivers/scsi/qla2xxx/tcm_qla2xxx.c |1 -
  3 files changed, 1 insertion(+), 3 deletions(-)
 
 diff --git a/drivers/scsi/qla2xxx/qla_target.c 
 b/drivers/scsi/qla2xxx/qla_target.c
 index 77759c7..87b5a330 100644
 --- a/drivers/scsi/qla2xxx/qla_target.c
 +++ b/drivers/scsi/qla2xxx/qla_target.c
 @@ -2644,7 +2644,7 @@ static void qlt_do_work(struct work_struct *work)
   sess = ha-tgt.tgt_ops-find_sess_by_s_id(vha,
   atio-u.isp24.fcp_hdr.s_id);
   if (sess) {
 - if (unlikely(sess-tearing_down)) {
 + if (unlikely(sess-se_sess-sess_tearing_down)) {
   sess = NULL;
   spin_unlock_irqrestore(ha-hardware_lock, flags);
   goto out_term;
 diff --git a/drivers/scsi/qla2xxx/qla_target.h 
 b/drivers/scsi/qla2xxx/qla_target.h
 index 9f9ef16..07aa265 100644
 --- a/drivers/scsi/qla2xxx/qla_target.h
 +++ b/drivers/scsi/qla2xxx/qla_target.h
 @@ -813,7 +813,6 @@ struct qla_tgt_sess {
   unsigned int conf_compl_supported:1;
   unsigned int deleted:1;
   unsigned int local:1;
 - unsigned int tearing_down:1;
  
   struct se_session *se_sess;
   struct scsi_qla_host *vha;
 diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
 b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 index 6e64314..3cb2b97 100644
 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 @@ -466,7 +466,6 @@ static int tcm_qla2xxx_shutdown_session(struct se_session 
 *se_sess)
   vha = sess-vha;
  
   spin_lock_irqsave(vha-hw-hardware_lock, flags);
 - sess-tearing_down = 1;
   target_splice_sess_cmd_list(se_sess);
   spin_unlock_irqrestore(vha-hw-hardware_lock, flags);
  


--
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 3/7] sbp-target: Consolidate duplicated error path code in sbp_handle_command()

2012-07-16 Thread Nicholas A. Bellinger
On Mon, 2012-07-16 at 11:04 -0700, Roland Dreier wrote:
 From: Roland Dreier rol...@purestorage.com
 
 Cc: Chris Boot bo...@bootc.net
 Cc: Stefan Richter stef...@s5r6.in-berlin.de
 Signed-off-by: Roland Dreier rol...@purestorage.com
 ---
  drivers/target/sbp/sbp_target.c |   28 
  1 file changed, 12 insertions(+), 16 deletions(-)
 

Looks like a reasonable 'de-dupe'.  Applied to for-next.

 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
 index 7e6136e..2425ca4 100644
 --- a/drivers/target/sbp/sbp_target.c
 +++ b/drivers/target/sbp/sbp_target.c
 @@ -1219,28 +1219,14 @@ static void sbp_handle_command(struct 
 sbp_target_request *req)
   ret = sbp_fetch_command(req);
   if (ret) {
   pr_debug(sbp_handle_command: fetch command failed: %d\n, ret);
 - req-status.status |= cpu_to_be32(
 - STATUS_BLOCK_RESP(STATUS_RESP_TRANSPORT_FAILURE) |
 - STATUS_BLOCK_DEAD(0) |
 - STATUS_BLOCK_LEN(1) |
 - STATUS_BLOCK_SBP_STATUS(SBP_STATUS_UNSPECIFIED_ERROR));
 - sbp_send_status(req);
 - sbp_free_request(req);
 - return;
 + goto err;
   }
  
   ret = sbp_fetch_page_table(req);
   if (ret) {
   pr_debug(sbp_handle_command: fetch page table failed: %d\n,
   ret);
 - req-status.status |= cpu_to_be32(
 - STATUS_BLOCK_RESP(STATUS_RESP_TRANSPORT_FAILURE) |
 - STATUS_BLOCK_DEAD(0) |
 - STATUS_BLOCK_LEN(1) |
 - STATUS_BLOCK_SBP_STATUS(SBP_STATUS_UNSPECIFIED_ERROR));
 - sbp_send_status(req);
 - sbp_free_request(req);
 - return;
 + goto err;
   }
  
   unpacked_lun = req-login-lun-unpacked_lun;
 @@ -1252,6 +1238,16 @@ static void sbp_handle_command(struct 
 sbp_target_request *req)
   target_submit_cmd(req-se_cmd, sess-se_sess, req-cmd_buf,
   req-sense_buf, unpacked_lun, data_length,
   MSG_SIMPLE_TAG, data_dir, 0);
 + return;
 +
 +err:
 + req-status.status |= cpu_to_be32(
 + STATUS_BLOCK_RESP(STATUS_RESP_TRANSPORT_FAILURE) |
 + STATUS_BLOCK_DEAD(0) |
 + STATUS_BLOCK_LEN(1) |
 + STATUS_BLOCK_SBP_STATUS(SBP_STATUS_UNSPECIFIED_ERROR));
 + sbp_send_status(req);
 + sbp_free_request(req);
  }
  
  /*


--
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/7] target: Allow for target_submit_cmd() returning errors

2012-07-16 Thread Nicholas A. Bellinger
On Mon, 2012-07-16 at 11:04 -0700, Roland Dreier wrote:
 From: Roland Dreier rol...@purestorage.com
 
 We want it to be possible for target_submit_cmd() to return errors up
 to its fabric module callers.  For now just update the prototype to
 return an int, and update all callers to handle non-zero return values
 as an error.
 

Mmmm.  The original target_submit_cmd() code had been propagating up a
return value, but then we decided (via Agrover's patch) that it made
more sense for target_submit_cmd() to always handle exceptions via
normal TFO callbacks, and not have the fabric worry about the return
here..

Also, I'm not sure if the error paths that this patch now accesses after
target_submit_cmd() failure are going to deal with different types of
target_submit_cmd() failures correctly.

So NACK for the moment, as I don't really see why this is necessary in
the first place..?

 Cc: Chad Dupuis chad.dup...@qlogic.com
 Cc: Arun Easi arun.e...@qlogic.com
 Cc: Chris Boot bo...@bootc.net
 Cc: Stefan Richter stef...@s5r6.in-berlin.de
 Cc: Mark Rustad mark.d.rus...@intel.com
 Cc: Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
 Cc: Felipe Balbi ba...@ti.com
 Signed-off-by: Roland Dreier rol...@purestorage.com
 ---
  drivers/scsi/qla2xxx/tcm_qla2xxx.c |7 +++
  drivers/target/sbp/sbp_target.c|8 +---
  drivers/target/target_core_transport.c |9 +
  drivers/target/tcm_fc/tfc_cmd.c|8 +---
  drivers/usb/gadget/tcm_usb_gadget.c|   20 
  include/target/target_core_fabric.h|2 +-
  6 files changed, 27 insertions(+), 27 deletions(-)
 
 diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
 b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 index 3cb2b97..7db7ca7 100644
 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 @@ -599,10 +599,9 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, 
 struct qla_tgt_cmd *cmd,
   return -EINVAL;
   }
  
 - target_submit_cmd(se_cmd, se_sess, cdb, cmd-sense_buffer[0],
 - cmd-unpacked_lun, data_length, fcp_task_attr,
 - data_dir, flags);
 - return 0;
 + return target_submit_cmd(se_cmd, se_sess, cdb, cmd-sense_buffer[0],
 +  cmd-unpacked_lun, data_length, fcp_task_attr,
 +  data_dir, flags);
  }
  
  static void tcm_qla2xxx_do_rsp(struct work_struct *work)
 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
 index 2425ca4..fb75d05 100644
 --- a/drivers/target/sbp/sbp_target.c
 +++ b/drivers/target/sbp/sbp_target.c
 @@ -1235,9 +1235,11 @@ static void sbp_handle_command(struct 
 sbp_target_request *req)
   pr_debug(sbp_handle_command ORB:0x%llx unpacked_lun:%d data_len:%d 
 data_dir:%d\n,
   req-orb_pointer, unpacked_lun, data_length, data_dir);
  
 - target_submit_cmd(req-se_cmd, sess-se_sess, req-cmd_buf,
 - req-sense_buf, unpacked_lun, data_length,
 - MSG_SIMPLE_TAG, data_dir, 0);
 + if (target_submit_cmd(req-se_cmd, sess-se_sess, req-cmd_buf,
 +   req-sense_buf, unpacked_lun, data_length,
 +   MSG_SIMPLE_TAG, data_dir, 0))
 + goto err;
 +
   return;
  
  err:
 diff --git a/drivers/target/target_core_transport.c 
 b/drivers/target/target_core_transport.c
 index 82e40e1..34ca821 100644
 --- a/drivers/target/target_core_transport.c
 +++ b/drivers/target/target_core_transport.c
 @@ -1544,7 +1544,7 @@ EXPORT_SYMBOL(transport_handle_cdb_direct);
   * This may only be called from process context, and also currently
   * assumes internal allocation of fabric payload buffer by target-core.
   **/
 -void target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
 +int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,
   unsigned char *cdb, unsigned char *sense, u32 unpacked_lun,
   u32 data_length, int task_attr, int data_dir, int flags)
  {
 @@ -1583,7 +1583,7 @@ void target_submit_cmd(struct se_cmd *se_cmd, struct 
 se_session *se_sess,
   transport_send_check_condition_and_sense(se_cmd,
   se_cmd-scsi_sense_reason, 0);
   target_put_sess_cmd(se_sess, se_cmd);
 - return;
 + return 0;
   }
   /*
* Sanitize CDBs via transport_generic_cmd_sequencer() and
 @@ -1592,7 +1592,7 @@ void target_submit_cmd(struct se_cmd *se_cmd, struct 
 se_session *se_sess,
   rc = target_setup_cmd_from_cdb(se_cmd, cdb);
   if (rc != 0) {
   transport_generic_request_failure(se_cmd);
 - return;
 + return 0;
   }
  
   /*
 @@ -1608,7 +1608,8 @@ void target_submit_cmd(struct se_cmd *se_cmd, struct 
 se_session *se_sess,
* when fabric has filled the incoming buffer.
*/
   

Re: [PATCH 4/7] target: Allow for target_submit_cmd() returning errors

2012-07-16 Thread Roland Dreier
On Mon, Jul 16, 2012 at 4:00 PM, Nicholas A. Bellinger
n...@linux-iscsi.org wrote:
 Mmmm.  The original target_submit_cmd() code had been propagating up a
 return value, but then we decided (via Agrover's patch) that it made
 more sense for target_submit_cmd() to always handle exceptions via
 normal TFO callbacks, and not have the fabric worry about the return
 here..

 Also, I'm not sure if the error paths that this patch now accesses after
 target_submit_cmd() failure are going to deal with different types of
 target_submit_cmd() failures correctly.

 So NACK for the moment, as I don't really see why this is necessary in
 the first place..?

Read on in the series to see why this is needed; in short, for qla2xxx
at least, we need a race-free way to check for sess_tearing_down
atomically with actually adding the command to sess_cmd_list.

I'm OK with returning failure via callback, but

 a) I'm not sure we can use the normal TFO callbacks in case
we can't add the command to sess_cmd_list (seems like it
opens the door to other use-after-frees in qla2xxx at least)
 b) Maybe it's OK if we say that failure to add the command to
the sess_cmd_list is the only time submit cmd fails?

The qla2xxx race/use-after-free is definitely real, we hit it in testing
here with active IO across ACL changes.

 - R.
--
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 5/7] target: Check sess_tearing_down in target_get_sess_cmd()

2012-07-16 Thread Nicholas A. Bellinger
On Mon, 2012-07-16 at 11:04 -0700, Roland Dreier wrote:
 From: Roland Dreier rol...@purestorage.com
 
 Target core code assumes that target_splice_sess_cmd_list() has set
 sess_tearing_down and moved the list of pending commands to
 sess_wait_list, no more commands will be added to the session; if any
 are added, nothing keeps the se_session from being freed while the
 command is still in flight, which e.g. leads to use-after-free of
 se_cmd-se_sess in target_release_cmd_kref().
 
 To enforce this invariant, put a check of sess_tearing_down inside of
 sess_cmd_lock in target_get_sess_cmd(); any checks before this are
 racy and can lead to the use-after-free described above.  For example,
 the qla_target check in qlt_do_work() checks sess_tearing_down from
 work thread context but then drops all locks before calling
 target_submit_cmd() (as it must, since that is a sleeping function).
 
 However, since no locks are held, anything can happen with respect to
 the session it has looked up -- although it does correctly get
 sess_kref within its lock, so the memory won't be freed while
 target_submit_cmd() is actually running, nothing stops eg an ACL from
 being dropped and calling -shutdown_session() (which calls into
 target_splice_sess_cmd_list()) before we get to target_get_sess_cmd().
 Once this happens, the se_session memory can be freed as soon as
 target_submit_cmd() returns and qlt_do_work() drops its reference,
 even though we've just added a command to sess_cmd_list.
 
 To prevent this use-after-free, check sess_tearing_down inside of
 sess_cmd_lock right before target_get_sess_cmd() adds a command to
 sess_cmd_list; this is synchronized with target_splice_sess_cmd_list()
 so that every command is either waited for or not added to the queue.
 
 Signed-off-by: Roland Dreier rol...@purestorage.com
 ---
  drivers/target/target_core_transport.c |   24 +++-
  1 file changed, 19 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/target/target_core_transport.c 
 b/drivers/target/target_core_transport.c
 index 34ca821..23e6e2d 100644
 --- a/drivers/target/target_core_transport.c
 +++ b/drivers/target/target_core_transport.c
 @@ -73,7 +73,7 @@ static void transport_complete_task_attr(struct se_cmd 
 *cmd);
  static void transport_handle_queue_full(struct se_cmd *cmd,
   struct se_device *dev);
  static int transport_generic_get_mem(struct se_cmd *cmd);
 -static void target_get_sess_cmd(struct se_session *, struct se_cmd *, bool);
 +static int target_get_sess_cmd(struct se_session *, struct se_cmd *, bool);
  static void transport_put_cmd(struct se_cmd *cmd);
  static void transport_remove_cmd_from_queue(struct se_cmd *cmd);
  static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq);
 @@ -1570,7 +1570,9 @@ int target_submit_cmd(struct se_cmd *se_cmd, struct 
 se_session *se_sess,
* for fabrics using TARGET_SCF_ACK_KREF that expect a second
* kref_put() to happen during fabric packet acknowledgement.
*/
 - target_get_sess_cmd(se_sess, se_cmd, (flags  TARGET_SCF_ACK_KREF));
 + rc = target_get_sess_cmd(se_sess, se_cmd, (flags  
 TARGET_SCF_ACK_KREF));
 + if (rc)
 + return rc;

OK, I see where you where going with the target_submit_cmd() failure
here now..

However, I'm still leaning towards a way to do this for tcm_qla2xxx that
does not require all fabric callers to handle target_submit_cmd()
exceptions directly..

How about a special target_get_sess_cmd() failure callback to free
se_cmd when target_get_sess_cmd() fails, but not actually send a SCSI
response back out to the fabric here during session shutdown..?

That said, I'm going to commit this patch (slightly changed to keep
target_submit_cmd() returning void for now) but I'd still like a better
way of handling this particular failure without propagating up the
return value.

   /*
* Signal bidirectional data payloads to target-core
*/
 @@ -1664,7 +1666,11 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct 
 se_session *se_sess,
   se_cmd-se_tmr_req-ref_task_tag = tag;
  
   /* See target_submit_cmd for commentary */
 - target_get_sess_cmd(se_sess, se_cmd, (flags  TARGET_SCF_ACK_KREF));
 + ret = target_get_sess_cmd(se_sess, se_cmd, (flags  
 TARGET_SCF_ACK_KREF));
 + if (ret) {
 + core_tmr_release_req(se_cmd-se_tmr_req);
 + return ret;
 + }
  
   ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun);
   if (ret) {
 @@ -3650,10 +3656,11 @@ EXPORT_SYMBOL(transport_generic_free_cmd);
   * @se_cmd:  command descriptor to add
   * @ack_kref:Signal that fabric will perform an ack 
 target_put_sess_cmd()
   */
 -static void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd 
 *se_cmd,
 - bool ack_kref)
 +static int target_get_sess_cmd(struct se_session *se_sess, struct se_cmd 
 *se_cmd,
 +bool ack_kref)
  {
 

Re: [PATCH 6/7] qla2xxx: Remove racy, now-redundant check of sess_tearing_down

2012-07-16 Thread Nicholas A. Bellinger
On Mon, 2012-07-16 at 11:04 -0700, Roland Dreier wrote:
 From: Roland Dreier rol...@purestorage.com
 
 Now that target_submit_cmd() / target_get_sess_cmd() check
 sess_tearing_down before adding commands to the list, we no longer
 need the check in qlt_do_work().  In fact this check is racy anyway
 (and that race is what inspired the change to add the check of
 sess_tearing_down to the target core).
 
 Cc: Chad Dupuis chad.dup...@qlogic.com
 Cc: Arun Easi arun.e...@qlogic.com
 Signed-off-by: Roland Dreier rol...@purestorage.com
 ---
  drivers/scsi/qla2xxx/qla_target.c |   16 +++-
  1 file changed, 3 insertions(+), 13 deletions(-)
 

Glad to see this one finally go.  ;)

Applied to for-next

 diff --git a/drivers/scsi/qla2xxx/qla_target.c 
 b/drivers/scsi/qla2xxx/qla_target.c
 index 87b5a330..5b30132 100644
 --- a/drivers/scsi/qla2xxx/qla_target.c
 +++ b/drivers/scsi/qla2xxx/qla_target.c
 @@ -2643,19 +2643,9 @@ static void qlt_do_work(struct work_struct *work)
   spin_lock_irqsave(ha-hardware_lock, flags);
   sess = ha-tgt.tgt_ops-find_sess_by_s_id(vha,
   atio-u.isp24.fcp_hdr.s_id);
 - if (sess) {
 - if (unlikely(sess-se_sess-sess_tearing_down)) {
 - sess = NULL;
 - spin_unlock_irqrestore(ha-hardware_lock, flags);
 - goto out_term;
 - } else {
 - /*
 -  * Do the extra kref_get() before dropping
 -  * qla_hw_data-hardware_lock.
 -  */
 - kref_get(sess-se_sess-sess_kref);
 - }
 - }
 + /* Do kref_get() before dropping qla_hw_data-hardware_lock. */
 + if (sess)
 + kref_get(sess-se_sess-sess_kref);
   spin_unlock_irqrestore(ha-hardware_lock, flags);
  
   if (unlikely(!sess)) {


--
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 7/7] target: Remove se_session.sess_wait_list

2012-07-16 Thread Nicholas A. Bellinger
On Mon, 2012-07-16 at 11:04 -0700, Roland Dreier wrote:
 From: Roland Dreier rol...@purestorage.com
 
 Since we set se_session.sess_tearing_down and stop new commands from
 being added to se_session.sess_cmd_list before we wait for commands to
 finish when freeing a session, there's no need for a separate
 sess_wait_list -- if we let new commands be added to sess_cmd_list
 after setting sess_tearing_down, that would be a bug that breaks the
 logic of waiting in-flight commands.
 
 Also rename target_splice_sess_cmd_list() to
 target_sess_cmd_list_set_waiting(), since we are no longer splicing
 onto a separate list.
 

So it looks reasonable to drop this cruft now, aside from the
target_get_sess_cmd() failure bit that still needs to be worked out
for-3.6 code.

Nice work Roland  Pure folks!

 
 
 Signed-off-by: Roland Dreier rol...@purestorage.com
 ---
  drivers/scsi/qla2xxx/tcm_qla2xxx.c |2 +-
  drivers/target/target_core_transport.c |   22 ++
  include/target/target_core_base.h  |1 -
  include/target/target_core_fabric.h|2 +-
  4 files changed, 12 insertions(+), 15 deletions(-)
 
 diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
 b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 index 7db7ca7..72f3557 100644
 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
 @@ -466,7 +466,7 @@ static int tcm_qla2xxx_shutdown_session(struct se_session 
 *se_sess)
   vha = sess-vha;
  
   spin_lock_irqsave(vha-hw-hardware_lock, flags);
 - target_splice_sess_cmd_list(se_sess);
 + target_sess_cmd_list_set_waiting(se_sess);
   spin_unlock_irqrestore(vha-hw-hardware_lock, flags);
  
   return 1;
 diff --git a/drivers/target/target_core_transport.c 
 b/drivers/target/target_core_transport.c
 index 23e6e2d..7b3359e 100644
 --- a/drivers/target/target_core_transport.c
 +++ b/drivers/target/target_core_transport.c
 @@ -244,7 +244,6 @@ struct se_session *transport_init_session(void)
   INIT_LIST_HEAD(se_sess-sess_list);
   INIT_LIST_HEAD(se_sess-sess_acl_list);
   INIT_LIST_HEAD(se_sess-sess_cmd_list);
 - INIT_LIST_HEAD(se_sess-sess_wait_list);
   spin_lock_init(se_sess-sess_cmd_lock);
   kref_init(se_sess-sess_kref);
  
 @@ -3719,28 +3718,27 @@ int target_put_sess_cmd(struct se_session *se_sess, 
 struct se_cmd *se_cmd)
  }
  EXPORT_SYMBOL(target_put_sess_cmd);
  
 -/* target_splice_sess_cmd_list - Split active cmds into sess_wait_list
 - * @se_sess: session to split
 +/* target_sess_cmd_list_set_waiting - Flag all commands in
 + * sess_cmd_list to complete cmd_wait_comp.  Set
 + * sess_tearing_down so no more commands are queued.
 + * @se_sess: session to flag
   */
 -void target_splice_sess_cmd_list(struct se_session *se_sess)
 +void target_sess_cmd_list_set_waiting(struct se_session *se_sess)
  {
   struct se_cmd *se_cmd;
   unsigned long flags;
  
 - WARN_ON(!list_empty(se_sess-sess_wait_list));
 - INIT_LIST_HEAD(se_sess-sess_wait_list);
 -
   spin_lock_irqsave(se_sess-sess_cmd_lock, flags);
 - se_sess-sess_tearing_down = 1;
  
 - list_splice_init(se_sess-sess_cmd_list, se_sess-sess_wait_list);
 + WARN_ON(se_sess-sess_tearing_down);
 + se_sess-sess_tearing_down = 1;
  
 - list_for_each_entry(se_cmd, se_sess-sess_wait_list, se_cmd_list)
 + list_for_each_entry(se_cmd, se_sess-sess_cmd_list, se_cmd_list)
   se_cmd-cmd_wait_set = 1;
  
   spin_unlock_irqrestore(se_sess-sess_cmd_lock, flags);
  }
 -EXPORT_SYMBOL(target_splice_sess_cmd_list);
 +EXPORT_SYMBOL(target_sess_cmd_list_set_waiting);
  
  /* target_wait_for_sess_cmds - Wait for outstanding descriptors
   * @se_sess:session to wait for active I/O
 @@ -3754,7 +3752,7 @@ void target_wait_for_sess_cmds(
   bool rc = false;
  
   list_for_each_entry_safe(se_cmd, tmp_cmd,
 - se_sess-sess_wait_list, se_cmd_list) {
 + se_sess-sess_cmd_list, se_cmd_list) {
   list_del(se_cmd-se_cmd_list);
  
   pr_debug(Waiting for se_cmd: %p t_state: %d, fabric state:
 diff --git a/include/target/target_core_base.h 
 b/include/target/target_core_base.h
 index dc35d86..5d8907e 100644
 --- a/include/target/target_core_base.h
 +++ b/include/target/target_core_base.h
 @@ -633,7 +633,6 @@ struct se_session {
   struct list_headsess_list;
   struct list_headsess_acl_list;
   struct list_headsess_cmd_list;
 - struct list_headsess_wait_list;
   spinlock_t  sess_cmd_lock;
   struct kref sess_kref;
  };
 diff --git a/include/target/target_core_fabric.h 
 b/include/target/target_core_fabric.h
 index 4f8e515..86d8a4a 100644
 --- a/include/target/target_core_fabric.h
 +++ b/include/target/target_core_fabric.h
 @@ -130,7 +130,7 @@ int   transport_check_aborted_status(struct se_cmd *, 
 int);
  int  transport_send_check_condition_and_sense(struct se_cmd 

Re: [PATCH 5/7] target: Check sess_tearing_down in target_get_sess_cmd()

2012-07-16 Thread Roland Dreier
On Mon, Jul 16, 2012 at 4:08 PM, Nicholas A. Bellinger
n...@linux-iscsi.org wrote:
 However, I'm still leaning towards a way to do this for tcm_qla2xxx that
 does not require all fabric callers to handle target_submit_cmd()
 exceptions directly..

 How about a special target_get_sess_cmd() failure callback to free
 se_cmd when target_get_sess_cmd() fails, but not actually send a SCSI
 response back out to the fabric here during session shutdown..?

I guess that's OK, although I'm not sure it ends up being cleaner.  If
you look at my 4/7 patch, you see that all target_submit_cmd callers
have an error path where they handle terminating commands that
fail processing just before calling submit_cmd anyway.

eg for qla2xxx we'll need a callback to call qlt_send_term_exchange()
in addition to the error path call that qlt_do_work() has anyway.
Similarly tcm_fc ends up with a second call to ft_send_resp_code_and_free().
etc.

But I don't really have a strong feeling about this, if the view is that
submit_cmd() should never return failure directly then I'm OK with that.

 That said, I'm going to commit this patch (slightly changed to keep
 target_submit_cmd() returning void for now) but I'd still like a better
 way of handling this particular failure without propagating up the
 return value.

OK, I'll take a look at how you handle this...

 - R.
--
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 5/7] target: Check sess_tearing_down in target_get_sess_cmd()

2012-07-16 Thread Roland Dreier
 OK, I'll take a look at how you handle this...

So looking at commit bc187ea6c3b3 in the tree you just pushed out
(target: Check sess_tearing_down in target_get_sess_cmd()) it looks
like you just return from target_submit_cmd() if we fail to add the
command to sess_cmd_list -- doesn't this mean we just leak those
commands and possibly leave the HW sitting there with open exchanges?

Do you have a plan for how to handle this?  Do we really want to plumb
through another callback to tell the fabric driver to free the command
in this case?

 - R.
--
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 5/7] target: Check sess_tearing_down in target_get_sess_cmd()

2012-07-16 Thread Nicholas A. Bellinger
On Mon, 2012-07-16 at 18:40 -0700, Roland Dreier wrote:
  OK, I'll take a look at how you handle this...
 
 So looking at commit bc187ea6c3b3 in the tree you just pushed out
 (target: Check sess_tearing_down in target_get_sess_cmd()) it looks
 like you just return from target_submit_cmd() if we fail to add the
 command to sess_cmd_list -- doesn't this mean we just leak those
 commands and possibly leave the HW sitting there with open exchanges?
 

With dropping patch #5 for now, I assume that would be the case..

 Do you have a plan for how to handle this?  Do we really want to plumb
 through another callback to tell the fabric driver to free the command
 in this case?
 

I need to think more about this ahead of changing it back again for-3.6
now that other fabrics have the assumption of target_submit_cmd() would
not fail.

There is a clear case with qla2xxx for just changing it back (we might
end up doing that just yet) but I wanted to get the other important bits
into for-next into place first..




--
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 5/7] target: Check sess_tearing_down in target_get_sess_cmd()

2012-07-16 Thread Nicholas A. Bellinger
On Mon, 2012-07-16 at 18:56 -0700, Nicholas A. Bellinger wrote:
 On Mon, 2012-07-16 at 18:40 -0700, Roland Dreier wrote:
   OK, I'll take a look at how you handle this...
  
  So looking at commit bc187ea6c3b3 in the tree you just pushed out
  (target: Check sess_tearing_down in target_get_sess_cmd()) it looks
  like you just return from target_submit_cmd() if we fail to add the
  command to sess_cmd_list -- doesn't this mean we just leak those
  commands and possibly leave the HW sitting there with open exchanges?
  
 
 With dropping patch #5 for now, I assume that would be the case..
 

Or with patch #4 even..


--
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 1/3] ipr: Reduce queuecommand lock time

2012-07-16 Thread Matthew Wilcox
On Mon, Jul 16, 2012 at 03:48:08PM -0500, Brian King wrote:
 +static int ipr_queuecommand(struct Scsi_Host *shost,
 + struct scsi_cmnd *scsi_cmd)
  {
   struct ipr_ioa_cfg *ioa_cfg;
   struct ipr_resource_entry *res;
   struct ipr_ioarcb *ioarcb;
   struct ipr_cmnd *ipr_cmd;
 + unsigned long lock_flags = 0;

You don't need to initialise lock_flags.

Looking at the rest of the code, you drop the lock in the middle,
then re-acquire it.  That'll help with hold time, but I'm not convinced
it'll help with performance.  Have you done performance testing with
these changes?  I seem to remember we used an eight-socket box to show
host_lock problems in the past.

-- 
Matthew Wilcox  Intel Open Source Technology Centre
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
--
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