Re: [PATCH 07/20] qla2xxx: Wait for all conflicts before ack'ing PLOGI

2015-12-08 Thread Hannes Reinecke
On 12/08/2015 01:48 AM, Himanshu Madhani wrote:
> From: Alexei Potashnik 
> 
> Until now ack'ing of a new PLOGI has only been delayed if there
> was an existing session for the same WWN. Ack was released when
> the session deletion completed.
> 
> If there was another WWN session with the same fc_id/loop_id pair
> (aka "conflicting session"), PLOGI was still ack'ed immediately.
> This potentially caused a problem when old session deletion logged
> fc_id/loop_id out of FW after new session has been established.
> 
> Two work-arounds were attempted before:
> 1. Dropping PLOGIs until conflicting session goes away.
> 2. Detecting initiator being logged out of FW and issuing LOGO
> to force re-login.
> 
> This patch introduces proper solution to the problem where PLOGI
> is held until either existing session with same WWN or any
> conflicting session goes away. Mechanism supports one session holding
> two PLOGI acks as well as one PLOGI ack being held by many sessions.
> 
> Signed-off-by: Alexei Potashnik 
> Acked-by: Quinn Tran 
> Signed-off-by: Himanshu Madhani 
> ---
Reviewed-by: Hannes Reinecke 

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


[PATCH 07/20] qla2xxx: Wait for all conflicts before ack'ing PLOGI

2015-12-07 Thread Himanshu Madhani
From: Alexei Potashnik 

Until now ack'ing of a new PLOGI has only been delayed if there
was an existing session for the same WWN. Ack was released when
the session deletion completed.

If there was another WWN session with the same fc_id/loop_id pair
(aka "conflicting session"), PLOGI was still ack'ed immediately.
This potentially caused a problem when old session deletion logged
fc_id/loop_id out of FW after new session has been established.

Two work-arounds were attempted before:
1. Dropping PLOGIs until conflicting session goes away.
2. Detecting initiator being logged out of FW and issuing LOGO
to force re-login.

This patch introduces proper solution to the problem where PLOGI
is held until either existing session with same WWN or any
conflicting session goes away. Mechanism supports one session holding
two PLOGI acks as well as one PLOGI ack being held by many sessions.

Signed-off-by: Alexei Potashnik 
Acked-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_dbg.c|4 +-
 drivers/scsi/qla2xxx/qla_def.h|2 +
 drivers/scsi/qla2xxx/qla_os.c |1 +
 drivers/scsi/qla2xxx/qla_target.c |  202 +
 drivers/scsi/qla2xxx/qla_target.h |   18 +++-
 5 files changed, 177 insertions(+), 50 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 02f01be..b303027 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -26,7 +26,7 @@
  * |  || 0x3036,0x3038  |
  * |  || 0x303a
|
  * | DPC Thread   |   0x4023   | 0x4002,0x4013  |
- * | Async Events |   0x508a   | 0x502b-0x502f  |
+ * | Async Events |   0x5089   | 0x502b-0x502f  |
  * |  || 0x5084,0x5075 |
  * |  || 0x503d,0x5044  |
  * |  || 0x507b,0x505f |
@@ -63,7 +63,7 @@
  * |  || 0xd101-0xd1fe |
  * |  || 0xd214-0xd2fe |
  * | Target Mode |   0xe080   ||
- * | Target Mode Management  |   0xf096   | 0xf002 |
+ * | Target Mode Management  |   0xf09b   | 0xf002 |
  * |  || 0xf046-0xf049  |
  * | Target Mode Task Management  |  0x1000d  ||
  * --
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 1050fc2..46abba8 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3654,6 +3654,8 @@ typedef struct scsi_qla_host {
int total_fcport_update_gen;
/* List of pending LOGOs, protected by tgt_mutex */
struct list_headlogo_list;
+   /* List of pending PLOGI acks, protected by hw lock */
+   struct list_headplogi_ack_list;
 
uint32_tvp_abort_cnt;
 
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index c02cbc6..eb47272 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3919,6 +3919,7 @@ struct scsi_qla_host *qla2x00_create_host(struct 
scsi_host_template *sht,
INIT_LIST_HEAD(&vha->qla_cmd_list);
INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list);
INIT_LIST_HEAD(&vha->logo_list);
+   INIT_LIST_HEAD(&vha->plogi_ack_list);
 
spin_lock_init(&vha->work_lock);
spin_lock_init(&vha->cmd_list_lock);
diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 5ef9d4c..57b4294 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -118,10 +118,13 @@ static void qlt_send_notify_ack(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *ntfy,
uint32_t add_flags, uint16_t resp_code, int resp_code_valid,
uint16_t srr_flags, uint16_t srr_reject_code, uint8_t srr_explan);
+static void qlt_send_term_imm_notif(struct scsi_qla_host *vha,
+   struct imm_ntfy_from_isp *imm, int ha_locked);
 /*
  * Global Variables
  */
 static struct kmem_cache *qla_tgt_mgmt_cmd_cachep;
+static struct kmem_cache *qla_tgt_plogi_cachep;
 static mempool_t *qla_tgt_mgmt_cmd_mempool;
 static struct workqueue_struct *qla_tgt_wq;
 static DEFINE_MUTEX(qla_tgt_mutex);
@@ -389,6 +392,85 @@ void qlt_response_pkt_all_vps(struct scsi_qla_host *vha, 
response_t *pkt)
 
 }
 
+/*
+ * All qlt_plogi_ack_t operations are protected by hardware_lock
+ */
+
+/*
+ * This is a zero-base ref-counting solution, since hardware_lock
+ * guarantees that ref_count is not modified concurrently.
+ * Upon successful return content of iocb is