IB/srp patches for kernel v4.2
Subsystems (5)
v2 cover IB/srp patches for kernel v4.2
Hello Doug,
My own testing and code review of the SRP initiator driver during the past months resulted in a series of twelve patches with bug fixes, source code simplifications and other improvements. Patches 1..6 are bug fixes and have been tagged for the stable kernel series. These patches have been tested against kernel v4.1-rc3. Please consider these patches for the v4.2 merge window.
The changes compared to the previous version of this series are as follows:
- Dropped the target->connected state.
- Dropped patch "IB/srp: Make CM timeout dependent on subnet timeout".
- Moved a change from patch "IB/srp: Fix reconnection failure handling" into patch "IB/srp: Remove !ch->target tests from the reconnect code".
The individual patches in this series are:
0001-scsi_transport_srp-Introduce-srp_wait_for_queuecomma.patch 0002-scsi_transport_srp-Fix-a-race-condition.patch 0003-IB-srp-Remove-an-extraneous-scsi_host_put-from-an-er.patch 0004-IB-srp-Fix-a-connection-setup-race.patch 0005-IB-srp-Fix-connection-state-tracking.patch 0006-IB-srp-Fix-reconnection-failure-handling.patch 0007-scsi_transport_srp-Reduce-failover-time.patch 0008-IB-srp-Remove-superfluous-casts.patch 0009-IB-srp-Rearrange-module-description.patch 0010-IB-srp-Remove-a-superfluous-check-from-srp_free_req_.patch 0011-IB-srp-Remove-ch-target-tests-from-the-reconnect-cod.patch 0012-IB-srp-Add-64-bit-LUN-support.patch
Thanks,
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/12 scsi_transport_srp: Introduce srp_wait_for_queuecommand()
Introduce the helper function srp_wait_for_queuecommand(). Move the definition of scsi_request_fn_active(). Add a comment above srp_wait_for_queuecommand() that support for scsi-mq needs to be added.
This patch does not change any functionality. A second call to srp_wait_for_queuecommand() will be introduced in the next patch.
--- drivers/scsi/scsi_transport_srp.c | 54 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 23 deletions(-)
drivers/scsi/scsi_transport_srp.c +31 -23
@@ -396,6 +396,36 @@ static void srp_reconnect_work(struct work_struct *work) } } +/** +* scsi_request_fn_active() - number of kernel threads inside scsi_request_fn() +* @shost: SCSI host for which to count the number of scsi_request_fn() callers. +* +* To do: add support for scsi-mq in this function. +*/ +static int scsi_request_fn_active (struct Scsi_Host *shost) +{ +struct scsi_device *sdev; +struct request_queue *q; +int request_fn_active =0 ; + +shost_for_each_device (sdev, shost) { + q = sdev->request_queue; + +spin_lock_irq (q->queue_lock); + request_fn_active += q->request_fn_active; +spin_unlock_irq (q->queue_lock); + } + +return request_fn_active; +} + +/* Wait until ongoing shost->hostt->queuecommand() calls have finished. */ +static void srp_wait_for_queuecommand (struct Scsi_Host *shost) +{ +while (scsi_request_fn_active (shost)) +msleep (20 ); +} +static void __rport_fail_io_fast (struct srp_rport *rport) {struct Scsi_Host *shost =rport_to_shost (rport);
@@ -504,27 +534,6 @@ void srp_start_tl_fail_timers(struct srp_rport *rport)EXPORT_SYMBOL (srp_start_tl_fail_timers);/** -* scsi_request_fn_active() - number of kernel threads inside scsi_request_fn() -* @shost: SCSI host for which to count the number of scsi_request_fn() callers. -*/ -static int scsi_request_fn_active (struct Scsi_Host *shost) -{ -struct scsi_device *sdev; -struct request_queue *q; -int request_fn_active =0 ; - -shost_for_each_device (sdev, shost) { - q = sdev->request_queue; - -spin_lock_irq (q->queue_lock); - request_fn_active += q->request_fn_active; -spin_unlock_irq (q->queue_lock); - } - -return request_fn_active; -} - -/** * srp_reconnect_rport() - reconnect to an SRP target port * @rport: SRP target port. *
@@ -559,8 +568,7 @@ int srp_reconnect_rport(struct srp_rport *rport)if (res) goto out;scsi_target_block (&shost->shost_gendev); -while (scsi_request_fn_active (shost)) -msleep (20 ); +srp_wait_for_queuecommand (shost); res = rport->state !=SRP_RPORT_LOST ? i->f->reconnect (rport) : -ENODEV ;pr_debug ("%s (state %d): transport.reconnect() returned %d\n" ,dev_name (&shost->shost_gendev), rport->state, res);
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 2/12 scsi_transport_srp: Fix a race condition
Avoid that srp_terminate_io() can get invoked while srp_queuecommand() is in progress. This patch avoids that an I/O timeout can trigger the following kernel warning:
WARNING: at drivers/infiniband/ulp/srp/ib_srp.c:1447 srp_terminate_io+0xef/0x100 [ib_srp]() Call Trace: [<ffffffff814c65a2>] dump_stack+0x4e/0x68 [<ffffffff81051f71>] warn_slowpath_common+0x81/0xa0 [<ffffffff8105204a>] warn_slowpath_null+0x1a/0x20 [<ffffffffa075f51f>] srp_terminate_io+0xef/0x100 [ib_srp] [<ffffffffa07495da>] __rport_fail_io_fast+0xba/0xc0 [scsi_transport_srp] [<ffffffffa0749a90>] rport_fast_io_fail_timedout+0xe0/0xf0 [scsi_transport_srp] [<ffffffff8106e09b>] process_one_work+0x1db/0x780 [<ffffffff8106e75b>] worker_thread+0x11b/0x450 [<ffffffff81073c64>] kthread+0xe4/0x100 [<ffffffff814cf26c>] ret_from_fork+0x7c/0xb0
See also patch "scsi_transport_srp: Add transport layer error handling" (commit ID 29c17324803c).
--- drivers/scsi/scsi_transport_srp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/scsi_transport_srp.c +3 -1
@@ -439,8 +439,10 @@ static void __rport_fail_io_fast(struct srp_rport *rport)/* Involve the LLD if possible to terminate all I/O on the rport. */ i =to_srp_internal (shost->transportt); -if (i->f->terminate_rport_io) +if (i->f->terminate_rport_io) { +srp_wait_for_queuecommand (shost); i->f->terminate_rport_io (rport); + } }/**
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/12 IB/srp: Remove an extraneous scsi_host_put() from an error path
In reply to a message not in the archiveFix a scsi_get_host() / scsi_host_put() imbalance in the error path of srp_create_target(). See also patch "IB/srp: Avoid that I/O hangs due to a cable pull during LUN scanning" (commit ID 34aa654ecb8e).
--- drivers/infiniband/ulp/srp/ib_srp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +5 -8
@@ -3188,11 +3188,11 @@ static ssize_t srp_create_target(struct device *dev, ret =srp_parse_options (buf, target);if (ret) - goto err; + goto out; ret =scsi_init_shared_tag_map (target_host, target_host->can_queue);if (ret) - goto err; + goto out; target->req_ring_size = target->queue_size -SRP_TSK_MGMT_SQ_SIZE ;
@@ -3203,7 +3203,7 @@ static ssize_t srp_create_target(struct device *dev,be64_to_cpu (target->ioc_guid), be64_to_cpu(target->initiator_ext)); ret = -EEXIST ; - goto err; + goto out; } if (!srp_dev->has_fmr && !srp_dev->has_fr && !target->allow_ext_sg &&
@@ -3224,7 +3224,7 @@ static ssize_t srp_create_target(struct device *dev,spin_lock_init (&target->lock); ret =ib_query_gid (ibdev, host->port,0 , &target->sgid);if (ret) - goto err; + goto out; ret = -ENOMEM ; target->ch_count = max_t(unsigned, num_online_nodes(),
@@ -3235,7 +3235,7 @@ static ssize_t srp_create_target(struct device *dev, target->ch =kcalloc (target->ch_count,sizeof (*target->ch),GFP_KERNEL );if (!target->ch) - goto err; + goto out; node_idx =0 ;for_each_online_node (node) {
@@ -3331,9 +3331,6 @@ err_disconnect: }kfree (target->ch); - -err: -scsi_host_put (target_host); goto out; }
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 4/12 IB/srp: Fix a connection setup race
In reply to a message not in the archiveAvoid that receiving a DREQ while RDMA channels are being established causes target->qp_in_error to be reset.
--- drivers/infiniband/ulp/srp/ib_srp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +3 -2
@@ -1009,8 +1009,6 @@ static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich)WARN_ON_ONCE (!multich && target->connected); - target->qp_in_error = false; - ret =srp_lookup_path (ch);if (ret)return ret;
@@ -1259,6 +1257,9 @@ static int srp_rport_reconnect(struct srp_rport *rport)for (j =0 ; j < target->queue_size; ++j)list_add (&ch->tx_ring[j]->list, &ch->free_tx); } + + target->qp_in_error = false; +for (i =0 ; i < target->ch_count; i++) { ch = &target->ch[i];if (ret || !ch->target) {
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 5/12 IB/srp: Fix connection state tracking
In reply to a message not in the archiveReception of a DREQ message only causes the state of a single channel to change. Hence move the 'connected' member variable from the target to the channel data structure. This patch avoids that following false positive warning can be reported by srp_destroy_qp():
WARNING: at drivers/infiniband/ulp/srp/ib_srp.c:617 srp_destroy_qp+0xa6/0x120 [ib_srp]() Call Trace: [<ffffffff8106e10f>] warn_slowpath_common+0x7f/0xc0 [<ffffffff8106e16a>] warn_slowpath_null+0x1a/0x20 [<ffffffffa0440226>] srp_destroy_qp+0xa6/0x120 [ib_srp] [<ffffffffa0440322>] srp_free_ch_ib+0x82/0x1e0 [ib_srp] [<ffffffffa044408b>] srp_create_target+0x7ab/0x998 [ib_srp] [<ffffffff81346f60>] dev_attr_store+0x20/0x30 [<ffffffff811dd90f>] sysfs_write_file+0xef/0x170 [<ffffffff8116d248>] vfs_write+0xc8/0x190 [<ffffffff8116d411>] sys_write+0x51/0x90
--- drivers/infiniband/ulp/srp/ib_srp.c | 60 ++++++++++++++++++------------------- drivers/infiniband/ulp/srp/ib_srp.h | 2 +- 2 files changed, 30 insertions(+), 32 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +29 -31
@@ -465,14 +465,13 @@ static struct srp_fr_pool *srp_alloc_fr_pool(struct srp_target_port *target)*/ static void srp_destroy_qp (struct srp_rdma_ch *ch) { -struct srp_target_port *target = ch->target;static struct ib_qp_attr attr = { .qp_state =IB_QPS_ERR };static struct ib_recv_wr wr = { .wr_id =SRP_LAST_WR_ID };struct ib_recv_wr *bad_wr;int ret;/* Destroying a QP and reusing ch->done is only safe if not connected */ -WARN_ON_ONCE (target->connected); +WARN_ON_ONCE (ch->connected); ret =ib_modify_qp (ch->qp, &attr,IB_QP_STATE );WARN_ONCE (ret,"ib_cm_init_qp_attr() returned %d\n" , ret);
@@ -827,35 +826,19 @@ static bool srp_queue_remove_work(struct srp_target_port *target)return changed; } -static bool srp_change_conn_state (struct srp_target_port *target, -bool connected) -{ -bool changed = false; - -spin_lock_irq (&target->lock); -if (target->connected != connected) { - target->connected = connected; - changed = true; - } -spin_unlock_irq (&target->lock); - -return changed; -} -static void srp_disconnect_target (struct srp_target_port *target) {struct srp_rdma_ch *ch;int i; -if (srp_change_conn_state (target, false)) { -/* XXX should send SRP_I_LOGOUT request */ +/* XXX should send SRP_I_LOGOUT request */ -for (i =0 ; i < target->ch_count; i++) { - ch = &target->ch[i]; -if (ch->cm_id &&ib_send_cm_dreq (ch->cm_id,NULL ,0 )) { -shost_printk (KERN_DEBUG , target->scsi_host, -PFX "Sending CM DREQ failed\n" ); - } +for (i =0 ; i < target->ch_count; i++) { + ch = &target->ch[i]; + ch->connected = false; +if (ch->cm_id &&ib_send_cm_dreq (ch->cm_id,NULL ,0 )) { +shost_printk (KERN_DEBUG , target->scsi_host, +PFX "Sending CM DREQ failed\n" ); } } }
@@ -1002,12 +985,26 @@ static void srp_rport_delete(struct srp_rport *rport)srp_queue_remove_work (target); } +/** +* srp_connected_ch() - number of connected channels +* @target: SRP target port. +*/ +static int srp_connected_ch (struct srp_target_port *target) +{ +int i, c =0 ; + +for (i =0 ; i < target->ch_count; i++) + c += target->ch[i].connected; + +return c; +} +static int srp_connect_ch (struct srp_rdma_ch *ch,bool multich) {struct srp_target_port *target = ch->target;int ret; -WARN_ON_ONCE (!multich && target->connected); +WARN_ON_ONCE (!multich &&srp_connected_ch (target) >0 ); ret =srp_lookup_path (ch);if (ret)
@@ -1030,7 +1027,7 @@ static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich)*/ switch (ch->status) {case 0 : -srp_change_conn_state (target, true); + ch->connected = true;return 0 ;case SRP_PORT_REDIRECT :
@@ -1946,7 +1943,7 @@ static void srp_handle_qp_err(u64 wr_id, enum ib_wc_status wc_status,return ; } -if (target->connected && !target->qp_in_error) { +if (ch->connected && !target->qp_in_error) {if (wr_id &LOCAL_INV_WR_ID_MASK ) { shost_printk(KERN_ERR, target->scsi_host, PFX "LOCAL_INV failed with status %d\n",
@@ -2384,7 +2381,7 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)case IB_CM_DREQ_RECEIVED :shost_printk (KERN_WARNING , target->scsi_host,PFX "DREQ received - connection closed\n" ); -srp_change_conn_state (target, false); + ch->connected = false;if (ib_send_cm_drep (cm_id,NULL ,0 ))shost_printk (KERN_ERR , target->scsi_host,PFX "Sending CM DREP failed\n" );
@@ -2440,7 +2437,7 @@ static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag,struct srp_iu *iu;struct srp_tsk_mgmt *tsk_mgmt; -if (!target->connected || target->qp_in_error) +if (!ch->connected || target->qp_in_error)return -1 ;init_completion (&ch->tsk_mgmt_done);
@@ -2814,7 +2811,8 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)scsi_scan_target (&target->scsi_host->shost_gendev,0 , target->scsi_id,SCAN_WILD_CARD ,0 ); -if (!target->connected || target->qp_in_error) { +if (srp_connected_ch (target) < target->ch_count || + target->qp_in_error) {shost_printk (KERN_INFO , target->scsi_host,PFX "SCSI scan failed - removing SCSI host\n" );srp_queue_remove_work (target);
drivers/infiniband/ulp/srp/ib_srp.h +1 -1
@@ -170,6 +170,7 @@ struct srp_rdma_ch {struct completion tsk_mgmt_done;u8 tsk_mgmt_status; +bool connected; };/**
@@ -214,7 +215,6 @@ struct srp_target_port {__be16 pkey;u32 rq_tmo_jiffies; -bool connected;int zero_req_lim;
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 7/12 scsi_transport_srp: Reduce failover time
In reply to a message not in the archiveUnlike FC, there is no risk that SCSI devices will be offlined by the SCSI error handler if the SCSI error handler is started while a reconnect attempt is ongoing. Hence report timeout errors as soon as possible if a higher software layer (e.g. multipathd) needs to be informed about a timeout. It is assumed that if both fast_io_fail_tmo < 0 and rport->dev_loss_tmo < 0 that this means that there is no need to report timeouts quickly.
--- drivers/scsi/scsi_transport_srp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/scsi_transport_srp.c +8 -1
@@ -61,6 +61,11 @@ static inline struct Scsi_Host *rport_to_shost(struct srp_rport *r)return dev_to_shost (r->dev.parent); } +static inline struct srp_rport *shost_to_rport (struct Scsi_Host *shost) +{ +return transport_class_to_srp_rport (&shost->shost_gendev); +} +/** * srp_tmo_valid() - check timeout combination validity * @reconnect_delay: Reconnect delay in seconds.
@@ -628,9 +633,11 @@ static enum blk_eh_timer_return srp_timed_out(struct scsi_cmnd *scmd)struct scsi_device *sdev = scmd->device;struct Scsi_Host *shost = sdev->host;struct srp_internal *i =to_srp_internal (shost->transportt); +struct srp_rport *rport =shost_to_rport (shost);pr_debug ("timeout for sdev %s\n" ,dev_name (&sdev->sdev_gendev)); -return i->f->reset_timer_if_blocked &&scsi_device_blocked (sdev) ? +return rport->fast_io_fail_tmo <0 && rport->dev_loss_tmo <0 && + i->f->reset_timer_if_blocked &&scsi_device_blocked (sdev) ?BLK_EH_RESET_TIMER :BLK_EH_NOT_HANDLED ; }
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 9/12 IB/srp: Rearrange module description
In reply to a message not in the archiveMove the module version and release date into separate fields. This makes the modinfo output easier to read.
--- drivers/infiniband/ulp/srp/ib_srp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +3 -2
@@ -59,9 +59,10 @@#define DRV_RELDATE "July 1, 2013"MODULE_AUTHOR ("Roland Dreier" ); -MODULE_DESCRIPTION ("InfiniBand SCSI RDMA Protocol initiator " -"v" DRV_VERSION " (" DRV_RELDATE ")" ); +MODULE_DESCRIPTION ("InfiniBand SCSI RDMA Protocol initiator" );MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_VERSION (DRV_VERSION ); +MODULE_INFO (release_date,DRV_RELDATE );static unsigned int srp_sg_tablesize;static unsigned int cmd_sg_entries;
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 10/12 IB/srp: Remove a superfluous check from srp_free_req_data()
In reply to a message not in the archiveThe function srp_free_req_data() does not use ch->target. Hence remove the ch->target != NULL check.
--- drivers/infiniband/ulp/srp/ib_srp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/srp/ib_srp.c +1 -1
@@ -852,7 +852,7 @@ static void srp_free_req_data(struct srp_target_port *target,struct srp_request *req;int i; -if (!ch->target || !ch->req_ring) +if (!ch->req_ring)return ;for (i =0 ; i < target->req_ring_size; ++i) {
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 6/12 IB/srp: Fix reconnection failure handling
In reply to Bart Van AsscheAlthough it is possible to let SRP I/O continue if a reconnect results in a reduction of the number of channels, the current code does not handle this scenario correctly. Instead of making the reconnect code more complex, consider this as a reconnection failure.
--- drivers/infiniband/ulp/srp/ib_srp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +1 -4
@@ -1259,11 +1259,8 @@ static int srp_rport_reconnect(struct srp_rport *rport)for (i =0 ; i < target->ch_count; i++) { ch = &target->ch[i]; -if (ret || !ch->target) { -if (i >1 ) - ret =0 ; +if (ret || !ch->target)break ; - } ret =srp_connect_ch (ch, multich); multich = true; }
Signature · 1 line
2.1.4
PATCH v2 8/12 IB/srp: Remove superfluous casts
In reply to Bart Van AsscheA long time ago the data type int64_t was declared as long long on x86 systems and as long on PPC systems. Today that data type is declared as long long on all Linux architectures. This means that the casts from uint64_t into unsigned long long are superfluous. Remove these superfluous casts.
--- drivers/infiniband/ulp/srp/ib_srp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +5 -8
@@ -796,7 +796,7 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich)shost_printk (KERN_DEBUG , target->scsi_host,PFX "Topspin/Cisco initiator port ID workaround " "activated for target GUID %016llx\n" , - (unsigned long long )be64_to_cpu (target->ioc_guid)); +be64_to_cpu (target->ioc_guid));memset (req->priv.initiator_port_id,0 ,8 );memcpy (req->priv.initiator_port_id +8 , &target->srp_host->srp_dev->dev->node_guid,8 );
@@ -2574,8 +2574,7 @@ static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr, {struct srp_target_port *target =host_to_target (class_to_shost (dev)); -return sprintf (buf,"0x%016llx\n" , - (unsigned long long )be64_to_cpu (target->id_ext)); +return sprintf (buf,"0x%016llx\n" ,be64_to_cpu (target->id_ext)); } static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr,
@@ -2583,8 +2582,7 @@ static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr, {struct srp_target_port *target =host_to_target (class_to_shost (dev)); -return sprintf (buf,"0x%016llx\n" , - (unsigned long long )be64_to_cpu (target->ioc_guid)); +return sprintf (buf,"0x%016llx\n" ,be64_to_cpu (target->ioc_guid)); } static ssize_t show_service_id(struct device *dev,
@@ -2592,8 +2590,7 @@ static ssize_t show_service_id(struct device *dev, {struct srp_target_port *target =host_to_target (class_to_shost (dev)); -return sprintf (buf,"0x%016llx\n" , - (unsigned long long )be64_to_cpu (target->service_id)); +return sprintf (buf,"0x%016llx\n" ,be64_to_cpu (target->service_id)); } static ssize_t show_pkey(struct device *dev, struct device_attribute *attr,
@@ -2784,7 +2781,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) target->state =SRP_TARGET_SCANNING ;sprintf (target->target_name,"SRP.T10:%016llX" , - (unsigned long long )be64_to_cpu (target->id_ext)); +be64_to_cpu (target->id_ext));if (scsi_add_host (target->scsi_host, host->srp_dev->dev->dma_device))return -ENODEV ;
Signature · 1 line
2.1.4
PATCH v2 11/12 IB/srp: Remove !ch->target tests from the reconnect code
In reply to Bart Van AsscheRemove the !ch->target tests from the reconnect code. These tests are not needed: upon entry of srp_rport_reconnect() it is guaranteed that all ch->target pointers are non-NULL. None of the functions srp_new_cm_id(), srp_finish_req(), srp_create_ch_ib() nor srp_connect_ch() modifies this pointer. srp_free_ch_ib() is never called concurrently with srp_rport_reconnect().
--- drivers/infiniband/ulp/srp/ib_srp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +1 -7
@@ -1226,14 +1226,10 @@ static int srp_rport_reconnect(struct srp_rport *rport)*/ for (i =0 ; i < target->ch_count; i++) { ch = &target->ch[i]; -if (!ch->target) -break ; ret +=srp_new_cm_id (ch); }for (i =0 ; i < target->ch_count; i++) { ch = &target->ch[i]; -if (!ch->target) -break ;for (j =0 ; j < target->req_ring_size; ++j) {struct srp_request *req = &ch->req_ring[j];
@@ -1242,8 +1238,6 @@ static int srp_rport_reconnect(struct srp_rport *rport) }for (i =0 ; i < target->ch_count; i++) { ch = &target->ch[i]; -if (!ch->target) -break ;/* * Whether or not creating a new CM ID succeeded, create a new * QP. This guarantees that all completion callback function
@@ -1260,7 +1254,7 @@ static int srp_rport_reconnect(struct srp_rport *rport)for (i =0 ; i < target->ch_count; i++) { ch = &target->ch[i]; -if (ret || !ch->target) +if (ret)break ; ret =srp_connect_ch (ch, multich); multich = true;
Signature · 1 line
2.1.4
PATCH v2 12/12 IB/srp: Add 64-bit LUN support
In reply to Bart Van AsscheThe SCSI standard defines 64-bit values for LUNs. Large arrays employing large or hierarchical LUN numbers become more and more common. So update the SRP initiator to use 64-bit LUN numbers. See also Hannes Reinecke, commit 9cb78c16f5da ("scsi: use 64-bit LUNs"), June 2014.
The largest LUN number that has been tested is 0xd2003fff00000000.
Checked the following structure sizes with gdb:
* sizeof(struct srp_cmd) = 48
* sizeof(struct srp_tsk_mgmt) = 48
* sizeof(struct srp_aer_req) = 36
The ibmvscsi changes have been compile tested only (on a PPC system).
--- drivers/infiniband/ulp/srp/ib_srp.c | 12 ++++++------ drivers/infiniband/ulp/srp/ib_srp.h | 1 - drivers/scsi/ibmvscsi/ibmvscsi.c | 6 +++--- include/scsi/srp.h | 7 ++++--- 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +6 -6
@@ -1848,7 +1848,7 @@ static void srp_process_aer_req(struct srp_rdma_ch *ch,s32 delta =be32_to_cpu (req->req_lim_delta);shost_printk (KERN_ERR , target->scsi_host,PFX -"ignoring AER for LUN %llu\n" ,be64_to_cpu (req->lun)); +"ignoring AER for LUN %llu\n" ,scsilun_to_int (&req->lun));if (srp_response_common (ch, delta, &rsp,sizeof (rsp))) shost_printk(KERN_ERR, target->scsi_host, PFX
@@ -2040,7 +2040,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)memset (cmd,0 ,sizeof *cmd); cmd->opcode =SRP_CMD ; - cmd->lun =cpu_to_be64 ((u64 ) scmnd->device->lun <<48 ); +int_to_scsilun (scmnd->device->lun, &cmd->lun); cmd->tag = tag;memcpy (cmd->cdb, scmnd->cmnd, scmnd->cmd_len);
@@ -2420,8 +2420,8 @@ srp_change_queue_depth(struct scsi_device *sdev, int qdepth)return scsi_change_queue_depth (sdev, qdepth); } -static int srp_send_tsk_mgmt (struct srp_rdma_ch *ch,u64 req_tag, -unsigned int lun,u8 func) +static int srp_send_tsk_mgmt (struct srp_rdma_ch *ch,u64 req_tag,u64 lun, +u8 func) {struct srp_target_port *target = ch->target;struct srp_rport *rport = target->rport;
@@ -2455,7 +2455,7 @@ static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag,memset (tsk_mgmt,0 ,sizeof *tsk_mgmt); tsk_mgmt->opcode =SRP_TSK_MGMT ; - tsk_mgmt->lun =cpu_to_be64 ((u64 ) lun <<48 ); +int_to_scsilun (lun, &tsk_mgmt->lun); tsk_mgmt->tag = req_tag |SRP_TAG_TSK_MGMT ; tsk_mgmt->tsk_mgmt_func = func; tsk_mgmt->task_tag = req_tag;
@@ -3150,7 +3150,7 @@ static ssize_t srp_create_target(struct device *dev, target_host->transportt = ib_srp_transport_template; target_host->max_channel =0 ; target_host->max_id =1 ; - target_host->max_lun =SRP_MAX_LUN ; + target_host->max_lun =-1LL ; target_host->max_cmd_len =sizeof ((struct srp_cmd *) (void *)0L )->cdb; target =host_to_target (target_host);
drivers/infiniband/ulp/srp/ib_srp.h +0 -1
@@ -54,7 +54,6 @@ enum {SRP_DLID_REDIRECT =2 ,SRP_STALE_CONN =3 , -SRP_MAX_LUN =512 ,SRP_DEF_SG_TABLESIZE =12 , SRP_DEFAULT_QUEUE_SIZE = 1 << 6,
drivers/scsi/ibmvscsi/ibmvscsi.c +3 -3
@@ -1053,7 +1053,7 @@ static int ibmvscsi_queuecommand_lck(struct scsi_cmnd *cmnd,memset (srp_cmd,0x00 ,SRP_MAX_IU_LEN ); srp_cmd->opcode =SRP_CMD ;memcpy (srp_cmd->cdb, cmnd->cmnd,sizeof (srp_cmd->cdb)); - srp_cmd->lun =cpu_to_be64 (((u64 )lun) <<48 ); +int_to_scsilun (lun, &srp_cmd->lun);if (!map_data_for_srp_cmd (cmnd, evt_struct, srp_cmd, hostdata->dev)) {if (!firmware_has_feature (FW_FEATURE_CMO ))
@@ -1529,7 +1529,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)/* Set up an abort SRP command */ memset (tsk_mgmt,0x00 ,sizeof (*tsk_mgmt)); tsk_mgmt->opcode =SRP_TSK_MGMT ; - tsk_mgmt->lun =cpu_to_be64 (((u64 ) lun) <<48 ); +int_to_scsilun (lun, &tsk_mgmt->lun); tsk_mgmt->tsk_mgmt_func =SRP_TSK_ABORT_TASK ; tsk_mgmt->task_tag = (u64 ) found_evt;
@@ -1652,7 +1652,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)/* Set up a lun reset SRP command */ memset (tsk_mgmt,0x00 ,sizeof (*tsk_mgmt)); tsk_mgmt->opcode =SRP_TSK_MGMT ; - tsk_mgmt->lun =cpu_to_be64 (((u64 ) lun) <<48 ); +int_to_scsilun (lun, &tsk_mgmt->lun); tsk_mgmt->tsk_mgmt_func =SRP_TSK_LUN_RESET ; evt->sync_srp = &srp_rsp;
include/scsi/srp.h +4 -3
@@ -42,6 +42,7 @@*/ #include <linux/types.h> +#include <scsi/scsi.h> enum {SRP_LOGIN_REQ =0x00 ,
@@ -179,7 +180,7 @@ struct srp_tsk_mgmt {u8 reserved1[6 ];u64 tag;u8 reserved2[4 ]; - __be64 lun __attribute__((packed)); +struct scsi_lun lun;u8 reserved3[2 ];u8 tsk_mgmt_func;u8 reserved4;
@@ -200,7 +201,7 @@ struct srp_cmd {u8 data_in_desc_cnt;u64 tag;u8 reserved2[4 ]; - __be64 lun __attribute__((packed)); +struct scsi_lun lun;u8 reserved3;u8 task_attr;u8 reserved4;
@@ -265,7 +266,7 @@ struct srp_aer_req {__be32 req_lim_delta;u64 tag;u32 reserved2; -__be64 lun; +struct scsi_lun lun;__be32 sense_data_len;u32 reserved3;u8 sense_data[0 ];
Signature · 1 line
2.1.4