iscsi update for 2.6.27
Subsystems (5)
These patches were made over scsi-rc-fixes but are for 2.6.27. There are features and cleanups so this should not go into 2.6.26. I could not make them over scsi-misc because scsi-rc-fixes (and linus's tree) has some bug fixes that went into 2.6.26-rc3 and scsi-misc is based on a older 2.6.26.rc.
These patches do a lot of cleanup in prepartion for braodcom, but this batch of patches are good for iscsi_tcp and iser so I sending them now. They include patches to do the following:
- fix the dma_mask for iser (bnx2i would have had a similar problem)
- modify libiscsi so you do not have to use a workqueue to send IO (offload cards can send from queuecommand context),
- merges a lot of duplicated code and structs.
This also includes from cleanup patches from Harvey Harrison. It does include the patch from Boaz since I goofed and forgot that we were going to cleanup the iscsi_ecdb_ahdr 260 hardcoding usage and Boaz and James are discussing where to define that. That can go in later when Boaz is ready and those issues are resolved.
PATCH 1/25 iscsi class, iscsi_tcp/iser: add host arg to session creation
From: Mike Christie <[email protected]>
iscsi offload (bnx2i and qla4xx) allocate a scsi host per hba, so the session creation path needs a shost/host_no argument. Software iscsi/iser will follow the same behabior as before where it allcoates a host per session, but in the future iser will probably look more like bnx2i where the host's parent is the hardware (rnic for iser and for bnx2i it is the nic), because it does not use a socket layer like how iscsi_tcp does.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 1 + drivers/scsi/iscsi_tcp.c | 5 ++- drivers/scsi/scsi_transport_iscsi.c | 46 ++++++++++++++++++++++++------ include/scsi/iscsi_if.h | 7 ++++ include/scsi/libiscsi.h | 1 + include/scsi/scsi_transport_iscsi.h | 4 +- 6 files changed, 51 insertions(+), 13 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +1 -0
@@ -368,6 +368,7 @@ static struct iscsi_transport iscsi_iser_transport;static struct iscsi_cls_session *iscsi_iser_session_create (struct iscsi_transport *iscsit,struct scsi_transport_template *scsit, +struct Scsi_Host *shost,uint16_t cmds_max,uint16_t qdepth,uint32_t initial_cmdsn,uint32_t *hostno) {
drivers/scsi/iscsi_tcp.c +3 -2
@@ -1871,8 +1871,9 @@ iscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats)static struct iscsi_cls_session *iscsi_tcp_session_create (struct iscsi_transport *iscsit,struct scsi_transport_template *scsit, -uint16_t cmds_max,uint16_t qdepth, -uint32_t initial_cmdsn,uint32_t *hostno) +struct Scsi_Host *shost,uint16_t cmds_max, +uint16_t qdepth,uint32_t initial_cmdsn, +uint32_t *hostno) {struct iscsi_cls_session *cls_session;struct iscsi_session *session;
drivers/scsi/scsi_transport_iscsi.c +37 -9
71 lines not on this page · raw message
include/scsi/iscsi_if.h +7 -0
@@ -50,6 +50,7 @@ enum iscsi_uevent_e {ISCSI_UEVENT_TGT_DSCVR =UEVENT_BASE +15 ,ISCSI_UEVENT_SET_HOST_PARAM =UEVENT_BASE +16 ,ISCSI_UEVENT_UNBIND_SESSION =UEVENT_BASE +17 , +ISCSI_UEVENT_CREATE_BOUND_SESSION =UEVENT_BASE +18 ,/* up events */ ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
@@ -78,6 +79,12 @@ struct iscsi_uevent {uint16_t cmds_max;uint16_t queue_depth; } c_session; +struct msg_create_bound_session { +uint32_t host_no; +uint32_t initial_cmdsn; +uint16_t cmds_max; +uint16_t queue_depth; + } c_bound_session;struct msg_destroy_session {uint32_t sid; } d_session;
include/scsi/libiscsi.h +1 -0
@@ -24,6 +24,7 @@#define LIBISCSI_H #include <linux/types.h> +#include <linux/wait.h> #include <linux/mutex.h> #include <linux/timer.h> #include <linux/workqueue.h>
include/scsi/scsi_transport_iscsi.h +2 -2
@@ -92,8 +92,8 @@ struct iscsi_transport {unsigned int max_conn;unsigned int max_cmd_len;struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it, -struct scsi_transport_template *t,uint16_t ,uint16_t , -uint32_t sn,uint32_t *hn); +struct scsi_transport_template *t,struct Scsi_Host *shost, +uint16_t cmds_max,uint16_t qdepth,uint32_t sn,uint32_t *hn);void (*destroy_session) (struct iscsi_cls_session *session);struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess,uint32_t cid);
Signature · 1 line
1.5.4.1
PATCH 2/25 iscsi class, iscsi drivers: remove unused iscsi_transport attrs
From: Mike Christie <[email protected]>
max_cmd_len and max_conn are not really used. max_cmd_len is always 16 and can be set by the LLD. max_conn is always one since we do not support MCS.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 1 - drivers/infiniband/ulp/iser/iscsi_iser.h | 1 - drivers/scsi/iscsi_tcp.c | 2 -- drivers/scsi/libiscsi.c | 2 +- drivers/scsi/scsi_transport_iscsi.c | 4 ---- include/scsi/scsi_transport_iscsi.h | 2 -- 6 files changed, 1 insertions(+), 11 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +0 -1
@@ -592,7 +592,6 @@ static struct iscsi_transport iscsi_iser_transport = { .host_template = &iscsi_iser_sht, .conndata_size = sizeof(struct iscsi_conn), .max_lun = ISCSI_ISER_MAX_LUN, - .max_cmd_len = ISCSI_ISER_MAX_CMD_LEN,/* session management */ .create_session = iscsi_iser_session_create, .destroy_session = iscsi_session_teardown,
drivers/infiniband/ulp/iser/iscsi_iser.h +0 -1
@@ -96,7 +96,6 @@/* support upto 512KB in one RDMA */ #define ISCSI_ISER_SG_TABLESIZE (0x80000 >> SHIFT_4K)#define ISCSI_ISER_MAX_LUN 256 -#define ISCSI_ISER_MAX_CMD_LEN 16/* QP settings */ /* Maximal bounds on received asynchronous PDUs */
drivers/scsi/iscsi_tcp.c +0 -2
@@ -1978,8 +1978,6 @@ static struct iscsi_transport iscsi_tcp_transport = { ISCSI_HOST_NETDEV_NAME, .host_template = &iscsi_sht, .conndata_size = sizeof(struct iscsi_conn), - .max_conn = 1, - .max_cmd_len = 16,/* session management */ .create_session = iscsi_tcp_session_create, .destroy_session = iscsi_tcp_session_destroy,
drivers/scsi/libiscsi.c +1 -1
@@ -1830,7 +1830,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, shost->max_id =1 ; shost->max_channel =0 ; shost->max_lun = iscsit->max_lun; - shost->max_cmd_len = iscsit->max_cmd_len; + shost->max_cmd_len =16 ; shost->transportt = scsit; shost->transportt->create_work_queue =1 ; shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
drivers/scsi/scsi_transport_iscsi.c +0 -4
@@ -102,15 +102,11 @@ static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL);show_transport_attr (caps,"0x%x" );show_transport_attr (max_lun,"%d" ); -show_transport_attr (max_conn,"%d" ); -show_transport_attr (max_cmd_len,"%d" );static struct attribute *iscsi_transport_attrs[] = { &dev_attr_handle.attr, &dev_attr_caps.attr, &dev_attr_max_lun.attr, - &dev_attr_max_conn.attr, - &dev_attr_max_cmd_len.attr,NULL , };
include/scsi/scsi_transport_iscsi.h +0 -2
@@ -89,8 +89,6 @@ struct iscsi_transport {/* LLD session data size */ int sessiondata_size;int max_lun; -unsigned int max_conn; -unsigned int max_cmd_len;struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it,struct scsi_transport_template *t,struct Scsi_Host *shost,uint16_t cmds_max,uint16_t qdepth,uint32_t sn,uint32_t *hn);
Signature · 1 line
1.5.4.1
PATCH 3/25 iscsi class: rename iscsi_host to iscsi_cls_host
From: Mike Christie <[email protected]>
This renames the iscsi_host to iscsi_cls_host to match the other structs, because libiscsi wants to use the iscsi_host name in the future.
--- drivers/scsi/scsi_transport_iscsi.c | 24 +++++++++++------------- include/scsi/scsi_transport_iscsi.h | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +11 -13
@@ -114,13 +114,11 @@ static struct attribute_group iscsi_transport_group = { .attrs = iscsi_transport_attrs, }; - -static int iscsi_setup_host (struct transport_container *tc,struct device *dev,struct device *cdev) {struct Scsi_Host *shost =dev_to_shost (dev); -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;memset (ihost,0 ,sizeof (*ihost));INIT_LIST_HEAD (&ihost->sessions);
@@ -140,7 +138,7 @@ static int iscsi_remove_host(struct transport_container *tc, struct device *dev, struct device *cdev) {struct Scsi_Host *shost =dev_to_shost (dev); -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;destroy_workqueue (ihost->scan_workq);return 0 ;
@@ -293,7 +291,7 @@ static int iscsi_is_session_dev(const struct device *dev)*/ int iscsi_scan_finished (struct Scsi_Host *shost,unsigned long time) { -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;/* * qla4xxx will have kicked off some session unblocks before calling * scsi_scan_host, so just wait for them to complete.
@@ -305,7 +303,7 @@ EXPORT_SYMBOL_GPL(iscsi_scan_finished);static int iscsi_user_scan (struct Scsi_Host *shost,uint channel,uint id,uint lun) { -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;struct iscsi_cls_session *session;mutex_lock (&ihost->mutex);
@@ -325,7 +323,7 @@ static void iscsi_scan_session(struct work_struct *work)struct iscsi_cls_session *session = container_of(work, struct iscsi_cls_session, scan_work);struct Scsi_Host *shost =iscsi_session_to_shost (session); -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;unsigned long flags;spin_lock_irqsave (&session->lock, flags);
@@ -377,7 +375,7 @@ static void __iscsi_unblock_session(struct work_struct *work) container_of(work, struct iscsi_cls_session, unblock_work);struct Scsi_Host *shost =iscsi_session_to_shost (session); -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;unsigned long flags;/*
@@ -445,7 +443,7 @@ static void __iscsi_unbind_session(struct work_struct *work) container_of(work, struct iscsi_cls_session, unbind_work);struct Scsi_Host *shost =iscsi_session_to_shost (session); -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;/* Prevent new scans and make sure scanning is not in progress */ mutex_lock (&ihost->mutex);
@@ -463,7 +461,7 @@ static void __iscsi_unbind_session(struct work_struct *work)static int iscsi_unbind_session (struct iscsi_cls_session *session) {struct Scsi_Host *shost =iscsi_session_to_shost (session); -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;return queue_work (ihost->scan_workq, &session->unbind_work); }
@@ -505,7 +503,7 @@ EXPORT_SYMBOL_GPL(iscsi_alloc_session);int iscsi_add_session (struct iscsi_cls_session *session,unsigned int target_id) {struct Scsi_Host *shost =iscsi_session_to_shost (session); -struct iscsi_host *ihost; +struct iscsi_cls_host *ihost;unsigned long flags;int err;
@@ -591,7 +589,7 @@ static int iscsi_iter_destroy_conn_fn(struct device *dev, void *data)void iscsi_remove_session (struct iscsi_cls_session *session) {struct Scsi_Host *shost =iscsi_session_to_shost (session); -struct iscsi_host *ihost = shost->shost_data; +struct iscsi_cls_host *ihost = shost->shost_data;unsigned long flags;int err;
@@ -1619,7 +1617,7 @@ iscsi_register_transport(struct iscsi_transport *tt) priv->t.host_attrs.ac.attrs = &priv->host_attrs[0 ]; priv->t.host_attrs.ac.class = &iscsi_host_class.class; priv->t.host_attrs.ac.match = iscsi_host_match; - priv->t.host_size =sizeof (struct iscsi_host ); + priv->t.host_size =sizeof (struct iscsi_cls_host );transport_container_register (&priv->t.host_attrs);SETUP_HOST_RD_ATTR (netdev,ISCSI_HOST_NETDEV_NAME );
include/scsi/scsi_transport_iscsi.h +1 -1
@@ -201,7 +201,7 @@ struct iscsi_cls_session {#define starget_to_session (_stgt) \ iscsi_dev_to_session(_stgt->dev.parent) -struct iscsi_host { +struct iscsi_cls_host {struct list_head sessions;atomic_t nr_scans;struct mutex mutex;
Signature · 1 line
1.5.4.1
PATCH 4/25 iscsi: remove session and host binding in libiscsi
From: Mike Christie <[email protected]>
bnx2i allocates a host per netdevice but will use libiscsi, so this unbinds the session from the host in that code.
This will also be useful for the iser parent device dma settings fixes.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 74 ++++++++--- drivers/scsi/iscsi_tcp.c | 102 ++++++++------- drivers/scsi/libiscsi.c | 213 +++++++++++++----------------- drivers/scsi/qla4xxx/ql4_os.c | 1 - drivers/scsi/scsi_transport_iscsi.c | 5 +- include/scsi/iscsi_if.h | 7 - include/scsi/libiscsi.h | 31 +++-- include/scsi/scsi_transport_iscsi.h | 8 +- 8 files changed, 225 insertions(+), 216 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +54 -20
@@ -74,6 +74,10 @@#include "iscsi_iser.h" +static struct scsi_host_template iscsi_iser_sht; +static struct iscsi_transport iscsi_iser_transport; +static struct scsi_transport_template *iscsi_iser_scsi_transport; +static unsigned int iscsi_max_lun =512 ;module_param_named (max_lun, iscsi_max_lun, uint,S_IRUGO );
@@ -363,40 +367,64 @@ iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)return iscsi_conn_start (cls_conn); } -static struct iscsi_transport iscsi_iser_transport; +static void iscsi_iser_session_destroy (struct iscsi_cls_session *cls_session) +{ +struct Scsi_Host *shost =iscsi_session_to_shost (cls_session); + +iscsi_session_teardown (cls_session); +scsi_remove_host (shost); +iscsi_host_teardown (shost); +scsi_host_put (shost); +}static struct iscsi_cls_session * -iscsi_iser_session_create (struct iscsi_transport *iscsit, -struct scsi_transport_template *scsit, -struct Scsi_Host *shost, -uint16_t cmds_max,uint16_t qdepth, -uint32_t initial_cmdsn,uint32_t *hostno) +iscsi_iser_session_create (struct Scsi_Host *shost, +uint16_t cmds_max,uint16_t qdepth, +uint32_t initial_cmdsn,uint32_t *hostno) {struct iscsi_cls_session *cls_session;struct iscsi_session *session;int i; -uint32_t hn;struct iscsi_cmd_task *ctask;struct iscsi_mgmt_task *mtask;struct iscsi_iser_cmd_task *iser_ctask;struct iser_desc *desc; +if (shost) { +printk (KERN_ERR "iscsi_tcp: invalid shost %d.\n" , + shost->host_no); +return NULL ; + } + + shost =scsi_host_alloc (&iscsi_iser_sht,0 ); +if (!shost) +return NULL ; + shost->transportt = iscsi_iser_scsi_transport; + shost->max_lun = iscsi_max_lun; + shost->max_id =0 ; + shost->max_channel =0 ; + shost->max_cmd_len =16 ; + +iscsi_host_setup (shost, qdepth); + +if (scsi_add_host (shost,NULL )) + goto free_host; + *hostno = shost->host_no; +/* * we do not support setting can_queue cmd_per_lun from userspace yet * because we preallocate so many resources */ - cls_session =iscsi_session_setup (iscsit, scsit, + cls_session =iscsi_session_setup (&iscsi_iser_transport, shost,ISCSI_DEF_XMIT_CMDS_MAX , -ISCSI_MAX_CMD_PER_LUN ,sizeof (struct iscsi_iser_cmd_task ),sizeof (struct iser_desc ), - initial_cmdsn, &hn); + initial_cmdsn);if (!cls_session) -return NULL ; - - *hostno = hn; - session =class_to_transport_session (cls_session); + goto remove_host; + session = cls_session->dd_data; + shost->can_queue = session->cmds_max;/* libiscsi setup itts, data and pool so just set desc fields */ for (i =0 ; i < session->cmds_max; i++) { ctask = session->cmds[i];
@@ -413,6 +441,13 @@ iscsi_iser_session_create(struct iscsi_transport *iscsit, }return cls_session; + +remove_host: +scsi_remove_host (shost); +free_host: +iscsi_host_teardown (shost); +scsi_host_put (shost); +return NULL ; } static int
@@ -589,12 +624,11 @@ static struct iscsi_transport iscsi_iser_transport = { .host_param_mask = ISCSI_HOST_HWADDRESS |ISCSI_HOST_NETDEV_NAME | ISCSI_HOST_INITIATOR_NAME, - .host_template = &iscsi_iser_sht, .conndata_size = sizeof(struct iscsi_conn), - .max_lun = ISCSI_ISER_MAX_LUN, + .sessiondata_size = sizeof(struct iscsi_session),/* session management */ .create_session = iscsi_iser_session_create, - .destroy_session = iscsi_session_teardown, + .destroy_session = iscsi_iser_session_destroy,/* connection management */ .create_conn = iscsi_iser_conn_create, .bind_conn = iscsi_iser_conn_bind,
@@ -633,8 +667,6 @@ static int __init iser_init(void)return -EINVAL ; } - iscsi_iser_transport.max_lun = iscsi_max_lun; -memset (&ig,0 ,sizeof (struct iser_global )); ig.desc_cache = kmem_cache_create("iser_descriptors",
@@ -650,7 +682,9 @@ static int __init iser_init(void)mutex_init (&ig.connlist_mutex);INIT_LIST_HEAD (&ig.connlist); -if (!iscsi_register_transport (&iscsi_iser_transport)) { + iscsi_iser_scsi_transport =iscsi_register_transport ( + &iscsi_iser_transport); +if (!iscsi_iser_scsi_transport) {iser_err ("iscsi_register_transport failed\n" ); err = -EINVAL ; goto register_transport_failure;
drivers/scsi/iscsi_tcp.c +57 -45
176 lines not on this page · raw message
drivers/scsi/libiscsi.c +94 -119
412 lines not on this page · raw message
drivers/scsi/qla4xxx/ql4_os.c +0 -1
@@ -114,7 +114,6 @@ static struct iscsi_transport qla4xxx_iscsi_transport = {ISCSI_HOST_IPADDRESS | ISCSI_HOST_INITIATOR_NAME, .sessiondata_size = sizeof(struct ddb_entry), - .host_template = &qla4xxx_driver_template, .tgt_dscvr = qla4xxx_tgt_dscvr, .get_conn_param = qla4xxx_conn_get_param,
drivers/scsi/scsi_transport_iscsi.c +1 -4
@@ -101,12 +101,10 @@ show_transport_##name(struct device *dev, \ static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL);show_transport_attr (caps,"0x%x" ); -show_transport_attr (max_lun,"%d" );static struct attribute *iscsi_transport_attrs[] = { &dev_attr_handle.attr, &dev_attr_caps.attr, - &dev_attr_max_lun.attr,NULL , };
@@ -1034,8 +1032,7 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev, } } - session = transport->create_session (transport, &priv->t, shost, - cmds_max, queue_depth, + session = transport->create_session (shost, cmds_max, queue_depth, initial_cmdsn, &host_no);if (shost)scsi_host_put (shost);
include/scsi/iscsi_if.h +0 -7
@@ -310,13 +310,6 @@ enum iscsi_host_param {#define iscsi_ptr (_handle) ((void*)(unsigned long)_handle)#define iscsi_handle (_ptr) ((uint64_t)(unsigned long)_ptr) -#define hostdata_session (_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata)) - -/** -* iscsi_hostdata - get LLD hostdata from scsi_host -* @_hostdata: pointer to scsi host's hostdata -**/ -#define iscsi_hostdata (_hostdata) ((void*)_hostdata + sizeof(unsigned long))/* * These flags presents iSCSI Data-Path capabilities.
include/scsi/libiscsi.h +16 -15
@@ -209,9 +209,6 @@ struct iscsi_conn {/* remote portal currently connected to */ int portal_port;char portal_address[ISCSI_ADDRESS_BUF_LEN ]; -/* local address */ -int local_port; -char local_address[ISCSI_ADDRESS_BUF_LEN ];/* MIB-statistics */ uint64_t txdata_octets;
@@ -247,6 +244,7 @@ enum { };struct iscsi_session { +struct iscsi_cls_session *cls_session;/* * Syncs up the scsi eh thread with the iscsi eh thread when sending * task management functions. This must be taken before the session
@@ -282,10 +280,6 @@ struct iscsi_session {char *password;char *password_in;char *targetname; -char *initiatorname; -/* hw address or netdev iscsi connection is bound to */ -char *hwaddress; -char *netdev;/* control data */ struct iscsi_transport *tt;struct Scsi_Host *host;
@@ -307,6 +301,16 @@ struct iscsi_session {struct iscsi_pool mgmtpool;/* Mgmt PDU's pool */ }; +struct iscsi_host { +char *initiatorname; +/* hw address or netdev iscsi connection is bound to */ +char *hwaddress; +char *netdev; +/* local address */ +int local_port; +char local_address[ISCSI_ADDRESS_BUF_LEN ]; +}; +/* * scsi host template */
@@ -326,27 +330,24 @@ extern int iscsi_host_set_param(struct Scsi_Host *shost, int buflen);extern int iscsi_host_get_param (struct Scsi_Host *shost,enum iscsi_host_param param,char *buf); +extern void iscsi_host_setup (struct Scsi_Host *shost,uint16_t qdepth); +extern void iscsi_host_teardown (struct Scsi_Host *shost);/* * session management */ extern struct iscsi_cls_session * -iscsi_session_setup (struct iscsi_transport *,struct scsi_transport_template *, -uint16_t ,uint16_t ,int ,int ,uint32_t ,uint32_t *); +iscsi_session_setup (struct iscsi_transport *,struct Scsi_Host *shost, +uint16_t ,int ,int ,uint32_t );extern void iscsi_session_teardown (struct iscsi_cls_session *); -extern struct iscsi_session *class_to_transport_session (struct iscsi_cls_session *);extern void iscsi_session_recovery_timedout (struct iscsi_cls_session *);extern int iscsi_set_param (struct iscsi_cls_conn *cls_conn,enum iscsi_param param,char *buf,int buflen);extern int iscsi_session_get_param (struct iscsi_cls_session *cls_session,enum iscsi_param param,char *buf); -#define session_to_cls (_sess) \ - hostdata_session(_sess->host->hostdata) - #define iscsi_session_printk(prefix, _sess, fmt, a...) \ - iscsi_cls_session_printk(prefix, \ - (struct iscsi_cls_session *)session_to_cls(_sess), fmt, ##a) + iscsi_cls_session_printk(prefix, _sess->cls_session, fmt, ##a)/* * connection management
include/scsi/scsi_transport_iscsi.h +3 -5
@@ -83,15 +83,13 @@ struct iscsi_transport {/* LLD sets this to indicate what values it can export to sysfs */ uint64_t param_mask;uint64_t host_param_mask; -struct scsi_host_template *host_template;/* LLD connection data size */ int conndata_size;/* LLD session data size */ int sessiondata_size; -int max_lun; -struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it, -struct scsi_transport_template *t,struct Scsi_Host *shost, -uint16_t cmds_max,uint16_t qdepth,uint32_t sn,uint32_t *hn); +struct iscsi_cls_session *(*create_session) (struct Scsi_Host *shost, +uint16_t cmds_max,uint16_t qdepth, +uint32_t sn,uint32_t *hn);void (*destroy_session) (struct iscsi_cls_session *session);struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess,uint32_t cid);
Signature · 1 line
1.5.4.1
PATCH 5/25 iscsi: add iscsi host helpers
From: Mike Christie <[email protected]>
This finishes the host/session unbinding, by adding some helpers to add and remove hosts and the session they manage.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 17 +++----- drivers/scsi/iscsi_tcp.c | 18 +++----- drivers/scsi/libiscsi.c | 60 ++++++++++++++++++++++++++--- drivers/scsi/scsi_transport_iscsi.c | 20 ++++++++++ include/scsi/libiscsi.h | 11 ++++- include/scsi/scsi_transport_iscsi.h | 4 ++ 6 files changed, 99 insertions(+), 31 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +6 -11
@@ -371,10 +371,8 @@ static void iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session) {struct Scsi_Host *shost =iscsi_session_to_shost (cls_session); -iscsi_session_teardown (cls_session); -scsi_remove_host (shost); -iscsi_host_teardown (shost); -scsi_host_put (shost); +iscsi_host_remove (shost); +iscsi_host_free (shost); } static struct iscsi_cls_session *
@@ -396,7 +394,7 @@ iscsi_iser_session_create(struct Scsi_Host *shost,return NULL ; } - shost =scsi_host_alloc (&iscsi_iser_sht,0 ); + shost =iscsi_host_alloc (&iscsi_iser_sht,0 ,ISCSI_MAX_CMD_PER_LUN );if (!shost)return NULL ; shost->transportt = iscsi_iser_scsi_transport;
@@ -405,9 +403,7 @@ iscsi_iser_session_create(struct Scsi_Host *shost, shost->max_channel =0 ; shost->max_cmd_len =16 ; -iscsi_host_setup (shost, qdepth); - -if (scsi_add_host (shost,NULL )) +if (iscsi_host_add (shost,NULL )) goto free_host; *hostno = shost->host_no;
@@ -443,10 +439,9 @@ iscsi_iser_session_create(struct Scsi_Host *shost,return cls_session; remove_host: -scsi_remove_host (shost); +iscsi_host_remove (shost); free_host: -iscsi_host_teardown (shost); -scsi_host_put (shost); +iscsi_host_free (shost);return NULL ; }
drivers/scsi/iscsi_tcp.c +7 -11
@@ -1866,7 +1866,7 @@ iscsi_tcp_session_create(struct Scsi_Host *shost, uint16_t cmds_max,return NULL ; } - shost =scsi_host_alloc (&iscsi_sht,sizeof (struct iscsi_host )); + shost =iscsi_host_alloc (&iscsi_sht,0 , qdepth);if (!shost)return NULL ; shost->transportt = iscsi_tcp_scsi_transport;
@@ -1874,10 +1874,9 @@ iscsi_tcp_session_create(struct Scsi_Host *shost, uint16_t cmds_max, shost->max_id =0 ; shost->max_channel =0 ; shost->max_cmd_len =16 ; + shost->can_queue = cmds_max; -iscsi_host_setup (shost, qdepth); - -if (scsi_add_host (shost,NULL )) +if (iscsi_host_add (shost,NULL )) goto free_host; *hostno = shost->host_no;
@@ -1912,10 +1911,9 @@ iscsi_tcp_session_create(struct Scsi_Host *shost, uint16_t cmds_max, remove_session:iscsi_session_teardown (cls_session); remove_host: -scsi_remove_host (shost); +iscsi_host_remove (shost); free_host: -iscsi_host_teardown (shost); -scsi_host_put (shost); +iscsi_host_free (shost);return NULL ; }
@@ -1924,11 +1922,9 @@ static void iscsi_tcp_session_destroy(struct iscsi_cls_session *cls_session)struct Scsi_Host *shost =iscsi_session_to_shost (cls_session);iscsi_r2tpool_free (cls_session->dd_data); -iscsi_session_teardown (cls_session); -scsi_remove_host (shost); -iscsi_host_teardown (shost); -scsi_host_put (shost); +iscsi_host_remove (shost); +iscsi_host_free (shost); }static int iscsi_tcp_slave_configure (struct scsi_device *sdev)
drivers/scsi/libiscsi.c +53 -7
83 lines not on this page · raw message
drivers/scsi/scsi_transport_iscsi.c +20 -0
@@ -279,6 +279,24 @@ static int iscsi_is_session_dev(const struct device *dev)return dev->release == iscsi_session_release; } +static int iscsi_iter_session_fn (struct device *dev,void *data) +{ +void (* fn) (struct iscsi_cls_session *) = data; + +if (!iscsi_is_session_dev (dev)) +return 0 ; +fn (iscsi_dev_to_session (dev)); +return 0 ; +} + +void iscsi_host_for_each_session (struct Scsi_Host *shost, +void (*fn)(struct iscsi_cls_session *)) +{ +device_for_each_child (&shost->shost_gendev, fn, + iscsi_iter_session_fn); +} +EXPORT_SYMBOL_GPL (iscsi_host_for_each_session); +/** * iscsi_scan_finished - helper to report when running scans are done * @shost: scsi host
@@ -1599,6 +1617,8 @@ iscsi_register_transport(struct iscsi_transport *tt) priv->daemon_pid =-1 ; priv->iscsi_transport = tt; priv->t.user_scan = iscsi_user_scan; +if (!(tt->caps &CAP_DATA_PATH_OFFLOAD )) + priv->t.create_work_queue =1 ; priv->dev.class = &iscsi_transport_class;snprintf (priv->dev.bus_id,BUS_ID_SIZE ,"%s" , tt->name);
include/scsi/libiscsi.h +9 -2
@@ -32,6 +32,7 @@#include <scsi/iscsi_if.h> struct scsi_transport_template ; +struct scsi_host_template ;struct scsi_device ;struct Scsi_Host ;struct scsi_cmnd ;
@@ -41,6 +42,7 @@ struct iscsi_cls_session;struct iscsi_cls_conn ;struct iscsi_session ;struct iscsi_nopin ; +struct device ;/* #define DEBUG_SCSI */ #ifdef DEBUG_SCSI
@@ -311,6 +313,8 @@ struct iscsi_host {char local_address[ISCSI_ADDRESS_BUF_LEN ]; }; +#define iscsi_host_priv (_shost) \ + (shost_priv(_shost) + sizeof(struct iscsi_host))/* * scsi host template */
@@ -330,8 +334,11 @@ extern int iscsi_host_set_param(struct Scsi_Host *shost, int buflen);extern int iscsi_host_get_param (struct Scsi_Host *shost,enum iscsi_host_param param,char *buf); -extern void iscsi_host_setup (struct Scsi_Host *shost,uint16_t qdepth); -extern void iscsi_host_teardown (struct Scsi_Host *shost); +extern int iscsi_host_add (struct Scsi_Host *shost,struct device *pdev); +extern struct Scsi_Host *iscsi_host_alloc (struct scsi_host_template *sht, +int dd_data_size,uint16_t qdepth); +extern void iscsi_host_remove (struct Scsi_Host *shost); +extern void iscsi_host_free (struct Scsi_Host *shost);/* * session management
include/scsi/scsi_transport_iscsi.h +4 -0
@@ -207,6 +207,10 @@ struct iscsi_cls_host {char scan_workq_name[KOBJ_NAME_LEN ]; }; +extern void iscsi_host_for_each_session (struct Scsi_Host *shost, +void (*fn)(struct iscsi_cls_session *)); + +/* * session and connection functions that can be used by HW iSCSI LLDs */
Signature · 1 line
1.5.4.1
PATCH 6/25 iscsi: remove session/conn_data_size from iscsi_transport
From: Mike Christie <[email protected]>
This removes the session and conn data_size fields from the iscsi_transport. Just pass in the value like with host allocation. This patch also makes it so the LLD iscsi_conn data is allocated with the iscsi_cls_conn.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 16 +++------------- drivers/scsi/iscsi_tcp.c | 19 +++++-------------- drivers/scsi/libiscsi.c | 15 ++++++++++----- drivers/scsi/qla4xxx/ql4_os.c | 7 +++---- drivers/scsi/scsi_transport_iscsi.c | 24 ++++++++++++------------ include/scsi/libiscsi.h | 8 ++++---- include/scsi/scsi_transport_iscsi.h | 9 +++------ 7 files changed, 40 insertions(+), 58 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +3 -13
@@ -279,7 +279,7 @@ iscsi_iser_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)struct iscsi_cls_conn *cls_conn;struct iscsi_iser_conn *iser_conn; - cls_conn =iscsi_conn_setup (cls_session, conn_idx); + cls_conn =iscsi_conn_setup (cls_session,sizeof (*iser_conn), conn_idx);if (!cls_conn)return NULL ; conn = cls_conn->dd_data;
@@ -290,10 +290,7 @@ iscsi_iser_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)*/ conn->max_recv_dlength =128 ; - iser_conn =kzalloc (sizeof (*iser_conn),GFP_KERNEL ); -if (!iser_conn) - goto conn_alloc_fail; - + iser_conn = conn->dd_data;/* currently this is the only field which need to be initiated */ rwlock_init (&iser_conn->lock);
@@ -301,10 +298,6 @@ iscsi_iser_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx) iser_conn->iscsi_conn = conn;return cls_conn; - -conn_alloc_fail: -iscsi_conn_teardown (cls_conn); -return NULL ; } static void
@@ -313,10 +306,9 @@ iscsi_iser_conn_destroy(struct iscsi_cls_conn *cls_conn)struct iscsi_conn *conn = cls_conn->dd_data;struct iscsi_iser_conn *iser_conn = conn->dd_data; -iscsi_conn_teardown (cls_conn);if (iser_conn->ib_conn) iser_conn->ib_conn->iser_conn =NULL ; -kfree (iser_conn); +iscsi_conn_teardown (cls_conn); } static int
@@ -619,8 +611,6 @@ static struct iscsi_transport iscsi_iser_transport = { .host_param_mask = ISCSI_HOST_HWADDRESS |ISCSI_HOST_NETDEV_NAME | ISCSI_HOST_INITIATOR_NAME, - .conndata_size = sizeof(struct iscsi_conn), - .sessiondata_size = sizeof(struct iscsi_session),/* session management */ .create_session = iscsi_iser_session_create, .destroy_session = iscsi_iser_session_destroy,
drivers/scsi/iscsi_tcp.c +5 -14
@@ -1490,7 +1490,7 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)struct iscsi_cls_conn *cls_conn;struct iscsi_tcp_conn *tcp_conn; - cls_conn =iscsi_conn_setup (cls_session, conn_idx); + cls_conn =iscsi_conn_setup (cls_session,sizeof (*tcp_conn), conn_idx);if (!cls_conn)return NULL ; conn = cls_conn->dd_data;
@@ -1500,18 +1500,14 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)*/ conn->max_recv_dlength =ISCSI_DEF_MAX_RECV_SEG_LEN ; - tcp_conn =kzalloc (sizeof (*tcp_conn),GFP_KERNEL ); -if (!tcp_conn) - goto tcp_conn_alloc_fail; - - conn->dd_data = tcp_conn; + tcp_conn = conn->dd_data; tcp_conn->iscsi_conn = conn; tcp_conn->tx_hash.tfm =crypto_alloc_hash ("crc32c" ,0 ,CRYPTO_ALG_ASYNC ); tcp_conn->tx_hash.flags =0 ;if (IS_ERR (tcp_conn->tx_hash.tfm)) - goto free_tcp_conn; + goto free_conn; tcp_conn->rx_hash.tfm =crypto_alloc_hash ("crc32c" ,0 ,CRYPTO_ALG_ASYNC );
@@ -1523,14 +1519,12 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx) free_tx_tfm:crypto_free_hash (tcp_conn->tx_hash.tfm); -free_tcp_conn: +free_conn:iscsi_conn_printk (KERN_ERR , conn,"Could not create connection due to crc32c " "loading error. Make sure the crc32c " "module is built as a module or into the " "kernel\n" ); -kfree (tcp_conn); -tcp_conn_alloc_fail:iscsi_conn_teardown (cls_conn);return NULL ; }
@@ -1563,14 +1557,13 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_conn *cls_conn)struct iscsi_tcp_conn *tcp_conn = conn->dd_data;iscsi_tcp_release_conn (conn); -iscsi_conn_teardown (cls_conn);if (tcp_conn->tx_hash.tfm)crypto_free_hash (tcp_conn->tx_hash.tfm);if (tcp_conn->rx_hash.tfm)crypto_free_hash (tcp_conn->rx_hash.tfm); -kfree (tcp_conn); +iscsi_conn_teardown (cls_conn); } static void
@@ -1983,8 +1976,6 @@ static struct iscsi_transport iscsi_tcp_transport = { .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |ISCSI_HOST_INITIATOR_NAME | ISCSI_HOST_NETDEV_NAME, - .conndata_size = sizeof(struct iscsi_conn), - .sessiondata_size = sizeof(struct iscsi_session),/* session management */ .create_session = iscsi_tcp_session_create, .destroy_session = iscsi_tcp_session_destroy,
drivers/scsi/libiscsi.c +10 -5
@@ -1867,7 +1867,8 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, cmds_max =ISCSI_DEF_XMIT_CMDS_MAX ; } - cls_session =iscsi_alloc_session (shost, iscsit); + cls_session =iscsi_alloc_session (shost, iscsit, +sizeof (struct iscsi_session ));if (!cls_session)return NULL ; session = cls_session->dd_data;
@@ -1968,22 +1969,26 @@ EXPORT_SYMBOL_GPL(iscsi_session_teardown);/** * iscsi_conn_setup - create iscsi_cls_conn and iscsi_conn * @cls_session: iscsi_cls_session +* @dd_size: private driver data size * @conn_idx: cid -**/ +*/ struct iscsi_cls_conn * -iscsi_conn_setup (struct iscsi_cls_session *cls_session,uint32_t conn_idx) +iscsi_conn_setup (struct iscsi_cls_session *cls_session,int dd_size, +uint32_t conn_idx) {struct iscsi_session *session = cls_session->dd_data;struct iscsi_conn *conn;struct iscsi_cls_conn *cls_conn;char *data; - cls_conn =iscsi_create_conn (cls_session, conn_idx); + cls_conn =iscsi_create_conn (cls_session,sizeof (*conn) + dd_size, + conn_idx);if (!cls_conn)return NULL ; conn = cls_conn->dd_data; -memset (conn,0 ,sizeof (*conn)); +memset (conn,0 ,sizeof (*conn) + dd_size); + conn->dd_data = cls_conn->dd_data +sizeof (*conn); conn->session = session; conn->cls_conn = cls_conn; conn->c_stage =ISCSI_CONN_INITIAL_STAGE ;
drivers/scsi/qla4xxx/ql4_os.c +3 -4
@@ -113,8 +113,6 @@ static struct iscsi_transport qla4xxx_iscsi_transport = { .host_param_mask = ISCSI_HOST_HWADDRESS |ISCSI_HOST_IPADDRESS | ISCSI_HOST_INITIATOR_NAME, - .sessiondata_size = sizeof(struct ddb_entry), - .tgt_dscvr = qla4xxx_tgt_dscvr, .get_conn_param = qla4xxx_conn_get_param, .get_session_param = qla4xxx_sess_get_param,
@@ -274,7 +272,7 @@ int qla4xxx_add_sess(struct ddb_entry *ddb_entry)return err; } - ddb_entry->conn =iscsi_create_conn (ddb_entry->sess,0 ); + ddb_entry->conn =iscsi_create_conn (ddb_entry->sess,0 ,0 );if (!ddb_entry->conn) {iscsi_remove_session (ddb_entry->sess);DEBUG2 (printk (KERN_ERR "Could not add connection.\n" ));
@@ -291,7 +289,8 @@ struct ddb_entry *qla4xxx_alloc_sess(struct scsi_qla_host *ha)struct ddb_entry *ddb_entry;struct iscsi_cls_session *sess; - sess =iscsi_alloc_session (ha->host, &qla4xxx_iscsi_transport); + sess =iscsi_alloc_session (ha->host, &qla4xxx_iscsi_transport, +sizeof (struct ddb_entry ));if (!sess)return NULL ;
drivers/scsi/scsi_transport_iscsi.c +12 -12
@@ -483,12 +483,12 @@ static int iscsi_unbind_session(struct iscsi_cls_session *session) }struct iscsi_cls_session * -iscsi_alloc_session (struct Scsi_Host *shost, -struct iscsi_transport *transport) +iscsi_alloc_session (struct Scsi_Host *shost,struct iscsi_transport *transport, +int dd_size) {struct iscsi_cls_session *session; - session =kzalloc (sizeof (*session) + transport->sessiondata_size, + session =kzalloc (sizeof (*session) + dd_size,GFP_KERNEL );if (!session)return NULL ;
@@ -510,7 +510,7 @@ iscsi_alloc_session(struct Scsi_Host *shost, session->dev.parent = &shost->shost_gendev; session->dev.release = iscsi_session_release;device_initialize (&session->dev); -if (transport->sessiondata_size) +if (dd_size) session->dd_data = &session[1 ];return session; }
@@ -558,18 +558,18 @@ EXPORT_SYMBOL_GPL(iscsi_add_session);* iscsi_create_session - create iscsi class session * @shost: scsi host * @transport: iscsi transport +* @dd_size: private driver data size * @target_id: which target * * This can be called from a LLD or iscsi_transport. */ struct iscsi_cls_session * -iscsi_create_session (struct Scsi_Host *shost, -struct iscsi_transport *transport, -unsigned int target_id) +iscsi_create_session (struct Scsi_Host *shost,struct iscsi_transport *transport, +int dd_size,unsigned int target_id) {struct iscsi_cls_session *session; - session =iscsi_alloc_session (shost, transport); + session =iscsi_alloc_session (shost, transport, dd_size);if (!session)return NULL ;
@@ -671,6 +671,7 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_session);/** * iscsi_create_conn - create iscsi class connection * @session: iscsi cls session +* @dd_size: private driver data size * @cid: connection id * * This can be called from a LLD or iscsi_transport. The connection
@@ -683,18 +684,17 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_session);* non-zero. */ struct iscsi_cls_conn * -iscsi_create_conn (struct iscsi_cls_session *session,uint32_t cid) +iscsi_create_conn (struct iscsi_cls_session *session,int dd_size,uint32_t cid) {struct iscsi_transport *transport = session->transport;struct iscsi_cls_conn *conn;unsigned long flags;int err; - conn =kzalloc (sizeof (*conn) + transport->conndata_size,GFP_KERNEL ); + conn =kzalloc (sizeof (*conn) + dd_size,GFP_KERNEL );if (!conn)return NULL ; - -if (transport->conndata_size) +if (dd_size) conn->dd_data = &conn[1 ];INIT_LIST_HEAD (&conn->conn_list);
include/scsi/libiscsi.h +4 -4
@@ -313,8 +313,6 @@ struct iscsi_host {char local_address[ISCSI_ADDRESS_BUF_LEN ]; }; -#define iscsi_host_priv (_shost) \ - (shost_priv(_shost) + sizeof(struct iscsi_host))/* * scsi host template */
@@ -325,10 +323,12 @@ extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);extern int iscsi_queuecommand (struct scsi_cmnd *sc,void (*done)(struct scsi_cmnd *)); -/* * iSCSI host helpers. */ +#define iscsi_host_priv (_shost) \ + (shost_priv(_shost) + sizeof(struct iscsi_host)) +extern int iscsi_host_set_param (struct Scsi_Host *shost,enum iscsi_host_param param,char *buf,int buflen);
@@ -360,7 +360,7 @@ extern int iscsi_session_get_param(struct iscsi_cls_session *cls_session,* connection management */ extern struct iscsi_cls_conn *iscsi_conn_setup (struct iscsi_cls_session *, -uint32_t ); +int ,uint32_t );extern void iscsi_conn_teardown (struct iscsi_cls_conn *);extern int iscsi_conn_start (struct iscsi_cls_conn *);extern void iscsi_conn_stop (struct iscsi_cls_conn *,int );
include/scsi/scsi_transport_iscsi.h +3 -6
@@ -83,10 +83,6 @@ struct iscsi_transport {/* LLD sets this to indicate what values it can export to sysfs */ uint64_t param_mask;uint64_t host_param_mask; -/* LLD connection data size */ -int conndata_size; -/* LLD session data size */ -int sessiondata_size;struct iscsi_cls_session *(*create_session) (struct Scsi_Host *shost,uint16_t cmds_max,uint16_t qdepth,uint32_t sn,uint32_t *hn);
@@ -222,19 +218,20 @@ extern void iscsi_host_for_each_session(struct Scsi_Host *shost,extern int iscsi_session_chkready (struct iscsi_cls_session *session);extern struct iscsi_cls_session *iscsi_alloc_session (struct Scsi_Host *shost, -struct iscsi_transport *transport); +struct iscsi_transport *transport,int dd_size);extern int iscsi_add_session (struct iscsi_cls_session *session,unsigned int target_id);extern int iscsi_session_event (struct iscsi_cls_session *session,enum iscsi_uevent_e event);extern struct iscsi_cls_session *iscsi_create_session (struct Scsi_Host *shost,struct iscsi_transport *t, +int dd_size,unsigned int target_id);extern void iscsi_remove_session (struct iscsi_cls_session *session);extern void iscsi_free_session (struct iscsi_cls_session *session);extern int iscsi_destroy_session (struct iscsi_cls_session *session);extern struct iscsi_cls_conn *iscsi_create_conn (struct iscsi_cls_session *sess, -uint32_t cid); +int dd_size,uint32_t cid);extern int iscsi_destroy_conn (struct iscsi_cls_conn *conn);extern void iscsi_unblock_session (struct iscsi_cls_session *session);extern void iscsi_block_session (struct iscsi_cls_session *session);
Signature · 1 line
1.5.4.1
PATCH 7/25 iscsi: modify iscsi printk so it can take driver data pointers
From: Mike Christie <[email protected]>
Some drivers want to be able to just pass in the driver data pointers to the iscsi objects. To enable this we need the iscsi printk macro to cast the object.
--- include/scsi/libiscsi.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
include/scsi/libiscsi.h +3 -1
@@ -369,9 +369,11 @@ extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,extern void iscsi_conn_failure (struct iscsi_conn *conn,enum iscsi_err err);extern int iscsi_conn_get_param (struct iscsi_cls_conn *cls_conn,enum iscsi_param param,char *buf); +extern void iscsi_suspend_tx (struct iscsi_conn *conn); #define iscsi_conn_printk(prefix, _c, fmt, a...) \ - iscsi_cls_conn_printk(prefix, _c->cls_conn, fmt, ##a) + iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \ + fmt, ##a)/* * pdu and task processing
Signature · 1 line
1.5.4.1
PATCH 8/25 iser: fix handling of scsi cmnds during recovery.
From: Mike Christie <[email protected]>
Quoted 1 line
From Mike Christie:
After the stop_conn callback has returned the LLD should not touch the scsi cmds. iscsi_tcp and libiscsi use the conn->recv_lock and suspend_rx field to halt recv path processing, but iser does not have any protection.
This patch modifies iser so that userspace can just call the ep_disconnect callback, which will halt all recv IO, before calling the stop_conn callback so we do not have to worry about the conn->recv_lock and suspend rx field. iser just needs to stop the send side from accessing the ib conn.
Fixup to handle when the ep poll fails and ep disconnect is called from Erez.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 42 +++++++++++++++++++++++++++-- drivers/infiniband/ulp/iser/iscsi_iser.h | 5 +++ drivers/infiniband/ulp/iser/iser_verbs.c | 14 +++++++++- drivers/scsi/libiscsi.c | 3 +- 4 files changed, 59 insertions(+), 5 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +39 -3
@@ -305,10 +305,18 @@ iscsi_iser_conn_destroy(struct iscsi_cls_conn *cls_conn) {struct iscsi_conn *conn = cls_conn->dd_data;struct iscsi_iser_conn *iser_conn = conn->dd_data; +struct iser_conn *ib_conn = iser_conn->ib_conn; -if (iser_conn->ib_conn) - iser_conn->ib_conn->iser_conn =NULL ;iscsi_conn_teardown (cls_conn); +/* +* Userspace will normally call the stop callback and +* already have freed the ib_conn, but if it goofed up then +* we free it here. +*/ +if (ib_conn) { + ib_conn->iser_conn =NULL ; +iser_conn_put (ib_conn); + } } static int
@@ -340,12 +348,29 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session, iser_conn = conn->dd_data; ib_conn->iser_conn = iser_conn; iser_conn->ib_conn = ib_conn; +iser_conn_get (ib_conn); conn->recv_lock = &iser_conn->lock;return 0 ; } +static void +iscsi_iser_conn_stop (struct iscsi_cls_conn *cls_conn,int flag) +{ +struct iscsi_conn *conn = cls_conn->dd_data; +struct iscsi_iser_conn *iser_conn = conn->dd_data; +struct iser_conn *ib_conn = iser_conn->ib_conn; + +iscsi_conn_stop (cls_conn, flag); +/* +* There is no unbind event so the stop callback +* must release the ref from the bind. +*/ +iser_conn_put (ib_conn); + iser_conn->ib_conn =NULL ; +} +static int iscsi_iser_conn_start (struct iscsi_cls_conn *cls_conn) {
@@ -564,6 +589,17 @@ iscsi_iser_ep_disconnect(__u64 ep_handle)if (!ib_conn)return ; +if (ib_conn->iser_conn) +/* +* Must suspend xmit path if the ep is bound to the +* iscsi_conn, so we know we are not accessing the ib_conn +* when we free it. +* +* This may not be bound if the ep poll failed. +*/ +iscsi_suspend_tx (ib_conn->iser_conn->iscsi_conn); + +iser_err ("ib conn %p state %d\n" ,ib_conn, ib_conn->state);iser_conn_terminate (ib_conn); }
@@ -622,7 +658,7 @@ static struct iscsi_transport iscsi_iser_transport = { .get_conn_param = iscsi_conn_get_param, .get_session_param = iscsi_session_get_param, .start_conn = iscsi_iser_conn_start, - .stop_conn = iscsi_conn_stop, + .stop_conn = iscsi_iser_conn_stop,/* iscsi host params */ .get_host_param = iscsi_host_get_param, .set_host_param = iscsi_host_set_param,
drivers/infiniband/ulp/iser/iscsi_iser.h +5 -0
@@ -242,6 +242,7 @@ struct iser_device {struct iser_conn {struct iscsi_iser_conn *iser_conn;/* iser conn for upcalls */ enum iser_ib_conn_state state;/* rdma connection state */ +atomic_t refcount;spinlock_t lock;/* used for state changes */ struct iser_device *device;/* device context */ struct rdma_cm_id *cma_id;/* CMA ID */
@@ -314,6 +315,10 @@ void iscsi_iser_recv(struct iscsi_conn *conn,int iser_conn_init (struct iser_conn **ib_conn); +void iser_conn_get (struct iser_conn *ib_conn); + +void iser_conn_put (struct iser_conn *ib_conn); +void iser_conn_terminate (struct iser_conn *ib_conn); void iser_rcv_completion(struct iser_desc *desc,
drivers/infiniband/ulp/iser/iser_verbs.c +13 -1
@@ -328,6 +328,17 @@ static void iser_conn_release(struct iser_conn *ib_conn)kfree (ib_conn); } +void iser_conn_get (struct iser_conn *ib_conn) +{ +atomic_inc (&ib_conn->refcount); +} + +void iser_conn_put (struct iser_conn *ib_conn) +{ +if (atomic_dec_and_test (&ib_conn->refcount)) +iser_conn_release (ib_conn); +} +/** * triggers start of the disconnect procedures and wait for them to be done */
@@ -349,7 +360,7 @@ void iser_conn_terminate(struct iser_conn *ib_conn)wait_event_interruptible (ib_conn->wait, ib_conn->state ==ISER_CONN_DOWN ); -iser_conn_release (ib_conn); +iser_conn_put (ib_conn); }static void iser_connect_error (struct rdma_cm_id *cma_id)
@@ -496,6 +507,7 @@ int iser_conn_init(struct iser_conn **ibconn)init_waitqueue_head (&ib_conn->wait);atomic_set (&ib_conn->post_recv_buf_count,0 );atomic_set (&ib_conn->post_send_buf_count,0 ); +atomic_set (&ib_conn->refcount,1 );INIT_LIST_HEAD (&ib_conn->conn_list);spin_lock_init (&ib_conn->lock);
drivers/scsi/libiscsi.c +2 -1
@@ -1383,11 +1383,12 @@ static void fail_all_commands(struct iscsi_conn *conn, unsigned lun, } } -static void iscsi_suspend_tx (struct iscsi_conn *conn) +void iscsi_suspend_tx (struct iscsi_conn *conn) {set_bit (ISCSI_SUSPEND_BIT , &conn->suspend_tx);scsi_flush_work (conn->session->host); } +EXPORT_SYMBOL_GPL (iscsi_suspend_tx);static void iscsi_start_tx (struct iscsi_conn *conn) {
Signature · 1 line
1.5.4.1
PATCH 9/25 libiscsi, iscsi_tcp, iser: add session cmds array accessor
From: Mike Christie <[email protected]>
Currently to get a ctask from the session cmd array, you have to know to use the itt modifier. To make this easier on LLDs and so in the future we can easilly kill the session array and use the host shared map instead, this patch adds a nice wrapper to strip the itt into a session->cmds index and return a ctask.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 8 +--- drivers/infiniband/ulp/iser/iser_initiator.c | 23 ++++------ drivers/scsi/iscsi_tcp.c | 13 ++++-- drivers/scsi/libiscsi.c | 60 ++++++++++++++++++------- include/scsi/libiscsi.h | 4 +- 5 files changed, 65 insertions(+), 43 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +1 -7
@@ -98,7 +98,6 @@ iscsi_iser_recv(struct iscsi_conn *conn, struct iscsi_hdr *hdr, char *rx_data, int rx_data_len) { int rc = 0; -uint32_t ret_itt;int datalen;int ahslen;
@@ -114,12 +113,7 @@ iscsi_iser_recv(struct iscsi_conn *conn,/* read AHS */ ahslen = hdr->hlength *4 ; -/* verify itt (itt encoding: age+cid+itt) */ - rc =iscsi_verify_itt (conn, hdr, &ret_itt); - -if (!rc) - rc =iscsi_complete_pdu (conn, hdr, rx_data, rx_data_len); - + rc =iscsi_complete_pdu (conn, hdr, rx_data, rx_data_len);if (rc && rc !=ISCSI_ERR_NO_SCSI_CMD ) goto error;
drivers/infiniband/ulp/iser/iser_initiator.c +10 -13
@@ -537,13 +537,11 @@ void iser_rcv_completion(struct iser_desc *rx_desc, {struct iser_dto *dto = &rx_desc->dto;struct iscsi_iser_conn *conn = dto->ib_conn->iser_conn; -struct iscsi_session *session = conn->iscsi_conn->session;struct iscsi_cmd_task *ctask;struct iscsi_iser_cmd_task *iser_ctask;struct iscsi_hdr *hdr;char *rx_data =NULL ;int rx_data_len =0 ; -unsigned int itt;unsigned char opcode; hdr = &rx_desc->iscsi_header;
@@ -559,19 +557,18 @@ void iser_rcv_completion(struct iser_desc *rx_desc, opcode = hdr->opcode &ISCSI_OPCODE_MASK ;if (opcode ==ISCSI_OP_SCSI_CMD_RSP ) { - itt =get_itt (hdr->itt);/* mask out cid and age bits */ -if (!(itt < session->cmds_max)) + ctask =iscsi_itt_to_ctask (conn->iscsi_conn, hdr->itt); +if (!ctask)iser_err ("itt can't be matched to task!!! " -"conn %p opcode %d cmds_max %d itt %d\n" , - conn->iscsi_conn,opcode,session->cmds_max,itt); -/* use the mapping given with the cmds array indexed by itt */ - ctask = (struct iscsi_cmd_task *)session->cmds[itt]; - iser_ctask = ctask->dd_data; -iser_dbg ("itt %d ctask %p\n" ,itt,ctask); - iser_ctask->status =ISER_TASK_STATUS_COMPLETED ; -iser_ctask_rdma_finalize (iser_ctask); +"conn %p opcode %d itt %d\n" , + conn->iscsi_conn, opcode, hdr->itt); +else { + iser_ctask = ctask->dd_data; +iser_dbg ("itt %d ctask %p\n" ,hdr->itt, ctask); + iser_ctask->status =ISER_TASK_STATUS_COMPLETED ; +iser_ctask_rdma_finalize (iser_ctask); + } } -iser_dto_buffs_release (dto);iscsi_iser_recv (conn->iscsi_conn, hdr, rx_data, rx_data_len);
drivers/scsi/iscsi_tcp.c +9 -4
@@ -740,7 +740,6 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)struct iscsi_session *session = conn->session;struct iscsi_tcp_conn *tcp_conn = conn->dd_data;struct iscsi_cmd_task *ctask; -uint32_t itt;/* verify PDU length */ tcp_conn->in.datalen =ntoh24 (hdr->dlength);
@@ -758,7 +757,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) opcode = hdr->opcode &ISCSI_OPCODE_MASK ;/* verify itt (itt encoding: age+cid+itt) */ - rc =iscsi_verify_itt (conn, hdr, &itt); + rc =iscsi_verify_itt (conn, hdr->itt);if (rc)return rc;
@@ -767,7 +766,10 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)switch (opcode) {case ISCSI_OP_SCSI_DATA_IN : - ctask = session->cmds[itt]; + ctask =iscsi_itt_to_ctask (conn, hdr->itt); +if (!ctask) +return ISCSI_ERR_BAD_ITT ; +spin_lock (&conn->session->lock); rc =iscsi_data_rsp (conn, ctask);spin_unlock (&conn->session->lock);
@@ -810,7 +812,10 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) rc =iscsi_complete_pdu (conn, hdr,NULL ,0 );break ;case ISCSI_OP_R2T : - ctask = session->cmds[itt]; + ctask =iscsi_itt_to_ctask (conn, hdr->itt); +if (!ctask) +return ISCSI_ERR_BAD_ITT ; +if (ahslen) rc =ISCSI_ERR_AHSLEN ;else if (ctask->sc->sc_data_direction ==DMA_TO_DEVICE ) {
drivers/scsi/libiscsi.c +43 -17
87 lines not on this page · raw message
include/scsi/libiscsi.h +2 -2
@@ -385,8 +385,8 @@ extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *, char *, uint32_t);extern int iscsi_complete_pdu (struct iscsi_conn *,struct iscsi_hdr *,char *,int ); -extern int iscsi_verify_itt (struct iscsi_conn *,struct iscsi_hdr *, -uint32_t *); +extern int iscsi_verify_itt (struct iscsi_conn *,itt_t ); +extern struct iscsi_cmd_task *iscsi_itt_to_ctask (struct iscsi_conn *,itt_t );extern void iscsi_requeue_ctask (struct iscsi_cmd_task *ctask);extern void iscsi_free_mgmt_task (struct iscsi_conn *conn,struct iscsi_mgmt_task *mtask);
Signature · 1 line
1.5.4.1
PATCH 10/25 libiscsi: modify libiscsi so it supports offloaded data paths
From: Mike Christie <[email protected]>
This patch modifies libiscsi, so drivers like bnx2i and iser can execute a command from queuecommand/send_pdu instead of having to be queued to be run in a workq.
--- drivers/scsi/libiscsi.c | 179 +++++++++++++++++++++++++++-------------------- 1 files changed, 104 insertions(+), 75 deletions(-)
drivers/scsi/libiscsi.c +104 -75
@@ -79,9 +79,11 @@ iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr)* xmit thread */ if (!list_empty (&session->leadconn->xmitqueue) || - !list_empty (&session->leadconn->mgmtqueue)) -scsi_queue_work (session->host, - &session->leadconn->xmitwork); + !list_empty (&session->leadconn->mgmtqueue)) { +if (!(session->tt->caps &CAP_DATA_PATH_OFFLOAD )) +scsi_queue_work (session->host, + &session->leadconn->xmitwork); + } } }EXPORT_SYMBOL_GPL (iscsi_update_cmdsn);
@@ -298,8 +300,12 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)WARN_ON (hdrlength >=256 ); hdr->hlength = hdrlength &0xFF ; -if (conn->session->tt->init_cmd_task (conn->ctask)) -return EIO ; +if (conn->session->tt->init_cmd_task && + conn->session->tt->init_cmd_task (ctask)) +return -EIO ; + + ctask->state =ISCSI_TASK_RUNNING ; +list_move_tail (&ctask->running, &conn->run_list); conn->scsicmd_pdus_cnt++; debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x "
@@ -334,7 +340,9 @@ static void iscsi_complete_command(struct iscsi_cmd_task *ctask) conn->ctask =NULL ;list_del_init (&ctask->running);__kfifo_put (session->cmdpool.queue, (void *)&ctask,sizeof (void *)); - sc->scsi_done (sc); + +if (sc->scsi_done) + sc->scsi_done (sc); }static void __iscsi_get_ctask (struct iscsi_cmd_task *ctask)
@@ -403,6 +411,50 @@ void iscsi_free_mgmt_task(struct iscsi_conn *conn, }EXPORT_SYMBOL_GPL (iscsi_free_mgmt_task); +static int iscsi_prep_mtask (struct iscsi_conn *conn, +struct iscsi_mgmt_task *mtask) +{ +struct iscsi_session *session = conn->session; +struct iscsi_hdr *hdr = mtask->hdr; +struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr; + +if (conn->session->state ==ISCSI_STATE_LOGGING_OUT ) +return -ENOTCONN ; + +if (hdr->opcode != (ISCSI_OP_LOGIN |ISCSI_OP_IMMEDIATE ) && + hdr->opcode != (ISCSI_OP_TEXT |ISCSI_OP_IMMEDIATE )) + nop->exp_statsn =cpu_to_be32 (conn->exp_statsn); +/* +* pre-format CmdSN for outgoing PDU. +*/ + nop->cmdsn =cpu_to_be32 (session->cmdsn); +if (hdr->itt !=RESERVED_ITT ) { + hdr->itt =build_itt (mtask->itt, session->age); +/* +* TODO: We always use immediate, so we never hit this. +* If we start to send tmfs or nops as non-immediate then +* we should start checking the cmdsn numbers for mgmt tasks. +*/ +if (conn->c_stage ==ISCSI_CONN_STARTED && + !(hdr->opcode &ISCSI_OP_IMMEDIATE )) { + session->queued_cmdsn++; + session->cmdsn++; + } + } + +if (session->tt->init_mgmt_task) + session->tt->init_mgmt_task (conn, mtask); + +if ((hdr->opcode &ISCSI_OPCODE_MASK ) ==ISCSI_OP_LOGOUT ) + session->state =ISCSI_STATE_LOGGING_OUT ; + +list_move_tail (&mtask->running, &conn->mgmt_run_list); +debug_scsi ("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n" , + hdr->opcode &ISCSI_OPCODE_MASK , hdr->itt, + mtask->data_count); +return 0 ; +} +static struct iscsi_mgmt_task *__iscsi_conn_send_pdu (struct iscsi_conn *conn,struct iscsi_hdr *hdr,char *data,uint32_t data_size)
@@ -429,6 +481,12 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,if (!__kfifo_get (session->mgmtpool.queue, (void *)&mtask,sizeof (void *)))return NULL ; + +if ((hdr->opcode == (ISCSI_OP_NOOP_OUT |ISCSI_OP_IMMEDIATE )) && + hdr->ttt ==RESERVED_ITT ) { + conn->ping_mtask = mtask; + conn->last_ping = jiffies; + } }if (data_size) {
@@ -440,6 +498,19 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,memcpy (mtask->hdr, hdr,sizeof (struct iscsi_hdr ));INIT_LIST_HEAD (&mtask->running);list_add_tail (&mtask->running, &conn->mgmtqueue); + +if (session->tt->caps &CAP_DATA_PATH_OFFLOAD ) { +if (iscsi_prep_mtask (conn, mtask)) { +iscsi_free_mgmt_task (conn, mtask); +return NULL ; + } + +if (session->tt->xmit_mgmt_task (conn, mtask)) + mtask =NULL ; + + }else +scsi_queue_work (conn->session->host, &conn->xmitwork); +return mtask; }
@@ -454,7 +525,6 @@ int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,if (!__iscsi_conn_send_pdu (conn, hdr, data, data_size)) err = -EPERM ;spin_unlock_bh (&session->lock); -scsi_queue_work (session->host, &conn->xmitwork);return err; }EXPORT_SYMBOL_GPL (iscsi_conn_send_pdu);
@@ -581,17 +651,8 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) hdr.ttt =RESERVED_ITT ; mtask =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)&hdr,NULL ,0 ); -if (!mtask) { +if (!mtask)iscsi_conn_printk (KERN_ERR , conn,"Could not send nopout\n" ); -return ; - } - -/* only track our nops */ -if (!rhdr) { - conn->ping_mtask = mtask; - conn->last_ping = jiffies; - } -scsi_queue_work (conn->session->host, &conn->xmitwork); } static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
@@ -868,56 +929,15 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) }EXPORT_SYMBOL_GPL (iscsi_conn_failure); -static void iscsi_prep_mtask (struct iscsi_conn *conn, -struct iscsi_mgmt_task *mtask) -{ -struct iscsi_session *session = conn->session; -struct iscsi_hdr *hdr = mtask->hdr; -struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr; - -if (hdr->opcode != (ISCSI_OP_LOGIN |ISCSI_OP_IMMEDIATE ) && - hdr->opcode != (ISCSI_OP_TEXT |ISCSI_OP_IMMEDIATE )) - nop->exp_statsn =cpu_to_be32 (conn->exp_statsn); -/* -* pre-format CmdSN for outgoing PDU. -*/ - nop->cmdsn =cpu_to_be32 (session->cmdsn); -if (hdr->itt !=RESERVED_ITT ) { - hdr->itt =build_itt (mtask->itt, session->age); -/* -* TODO: We always use immediate, so we never hit this. -* If we start to send tmfs or nops as non-immediate then -* we should start checking the cmdsn numbers for mgmt tasks. -*/ -if (conn->c_stage ==ISCSI_CONN_STARTED && - !(hdr->opcode &ISCSI_OP_IMMEDIATE )) { - session->queued_cmdsn++; - session->cmdsn++; - } - } - -if (session->tt->init_mgmt_task) - session->tt->init_mgmt_task (conn, mtask); - -debug_scsi ("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n" , - hdr->opcode &ISCSI_OPCODE_MASK , hdr->itt, - mtask->data_count); -} -static int iscsi_xmit_mtask (struct iscsi_conn *conn) { -struct iscsi_hdr *hdr = conn->mtask->hdr;int rc; -if ((hdr->opcode &ISCSI_OPCODE_MASK ) ==ISCSI_OP_LOGOUT ) - conn->session->state =ISCSI_STATE_LOGGING_OUT ;spin_unlock_bh (&conn->session->lock); - rc = conn->session->tt->xmit_mgmt_task (conn, conn->mtask);spin_lock_bh (&conn->session->lock);if (rc)return rc; -/* done with this in-progress mtask */ conn->mtask =NULL ;return 0 ;
@@ -961,7 +981,8 @@ static int iscsi_xmit_ctask(struct iscsi_conn *conn)* @ctask: ctask to requeue * * LLDs that need to run a ctask from the session workqueue should call -* this. The session lock must be held. +* this. The session lock must be held. This should only be called +* by software drivers. */ void iscsi_requeue_ctask (struct iscsi_cmd_task *ctask) {
@@ -1013,14 +1034,11 @@ check_mgmt:while (!list_empty (&conn->mgmtqueue)) { conn->mtask =list_entry (conn->mgmtqueue.next, struct iscsi_mgmt_task, running); -if (conn->session->state ==ISCSI_STATE_LOGGING_OUT ) { +if (iscsi_prep_mtask (conn, conn->mtask)) {iscsi_free_mgmt_task (conn, conn->mtask); conn->mtask =NULL ;continue ; } - -iscsi_prep_mtask (conn, conn->mtask); -list_move_tail (conn->mgmtqueue.next, &conn->mgmt_run_list); rc =iscsi_xmit_mtask (conn);if (rc) goto again;
@@ -1041,9 +1059,6 @@ check_mgmt:fail_command (conn, conn->ctask,DID_ABORT <<16 );continue ; } - - conn->ctask->state =ISCSI_TASK_RUNNING ; -list_move_tail (conn->xmitqueue.next, &conn->run_list); rc =iscsi_xmit_ctask (conn);if (rc) goto again;
@@ -1192,8 +1207,6 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) reason =FAILURE_OOM ; goto reject; } - session->queued_cmdsn++; - sc->SCp.phase = session->age; sc->SCp.ptr = (char *)ctask;
@@ -1202,11 +1215,26 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) ctask->conn = conn; ctask->sc = sc;INIT_LIST_HEAD (&ctask->running); -list_add_tail (&ctask->running, &conn->xmitqueue); -spin_unlock (&session->lock); -scsi_queue_work (host, &conn->xmitwork); +if (session->tt->caps &CAP_DATA_PATH_OFFLOAD ) { +if (iscsi_prep_scsi_cmd_pdu (ctask)) { + sc->result =DID_ABORT <<16 ; + sc->scsi_done =NULL ; +iscsi_complete_command (ctask); + goto fault; + } +if (session->tt->xmit_cmd_task (conn, ctask)) { + sc->scsi_done =NULL ; +iscsi_complete_command (ctask); + reason =FAILURE_SESSION_NOT_READY ; + goto reject; + } + }else +scsi_queue_work (session->host, &conn->xmitwork); + + session->queued_cmdsn++; +spin_unlock (&session->lock);spin_lock (host->host_lock);return 0 ;
@@ -1225,7 +1253,7 @@ fault:scsi_out (sc)->resid =scsi_out (sc)->length;scsi_in (sc)->resid =scsi_in (sc)->length; } - sc->scsi_done (sc); +done (sc);spin_lock (host->host_lock);return 0 ; }
@@ -1344,7 +1372,6 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,spin_unlock_bh (&session->lock);mutex_unlock (&session->eh_mutex); -scsi_queue_work (session->host, &conn->xmitwork);/* * block eh thread until:
@@ -1412,14 +1439,16 @@ static void fail_all_commands(struct iscsi_conn *conn, unsigned lun,void iscsi_suspend_tx (struct iscsi_conn *conn) {set_bit (ISCSI_SUSPEND_BIT , &conn->suspend_tx); -scsi_flush_work (conn->session->host); +if (!(conn->session->tt->caps &CAP_DATA_PATH_OFFLOAD )) +scsi_flush_work (conn->session->host); }EXPORT_SYMBOL_GPL (iscsi_suspend_tx);static void iscsi_start_tx (struct iscsi_conn *conn) {clear_bit (ISCSI_SUSPEND_BIT , &conn->suspend_tx); -scsi_queue_work (conn->session->host, &conn->xmitwork); +if (!(conn->session->tt->caps &CAP_DATA_PATH_OFFLOAD )) +scsi_queue_work (conn->session->host, &conn->xmitwork); }static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out (struct scsi_cmnd *scmd)
Signature · 1 line
1.5.4.1
PATCH 11/25 libiscsi: merge iscsi_mgmt_task and iscsi_cmd_task
From: Mike Christie <[email protected]>
There is no need to have the mgmt and cmd tasks separate structs. It used to save a lot of memory when we overprealocated memory for tasks, but the next patches will set up the driver so in the future they can use a mempool or some other common scsi command allocator and common tagging.
--- drivers/scsi/libiscsi.c | 518 +++++++++++++++++------------------ include/scsi/libiscsi.h | 29 +-- include/scsi/scsi_transport_iscsi.h | 41 ++-- 3 files changed, 272 insertions(+), 316 deletions(-)
drivers/scsi/libiscsi.c +246 -272
@@ -197,7 +197,7 @@ static int iscsi_prep_bidi_ahs(struct iscsi_cmd_task *ctask)/** * iscsi_prep_scsi_cmd_pdu - prep iscsi scsi cmd pdu -* @ctask: iscsi cmd task +* @ctask: iscsi task * * Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set * fields like dlength or final based on how much data it sends
@@ -300,31 +300,31 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)WARN_ON (hdrlength >=256 ); hdr->hlength = hdrlength &0xFF ; -if (conn->session->tt->init_cmd_task && - conn->session->tt->init_cmd_task (ctask)) +if (conn->session->tt->init_task && + conn->session->tt->init_task (ctask))return -EIO ; ctask->state =ISCSI_TASK_RUNNING ;list_move_tail (&ctask->running, &conn->run_list); conn->scsicmd_pdus_cnt++; -debug_scsi ("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x " -"len %d bidi_len %d cmdsn %d win %d]\n" , -scsi_bidi_cmnd (sc) ?"bidirectional" : - sc->sc_data_direction ==DMA_TO_DEVICE ?"write" :"read" , - conn->id, sc, sc->cmnd[0 ], ctask->itt, -scsi_bufflen (sc),scsi_bidi_cmnd (sc) ?scsi_in (sc)->length :0 , - session->cmdsn, session->max_cmdsn - session->exp_cmdsn +1 ); +debug_scsi ("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d " +"bidi_len %d cmdsn %d win %d]\n" ,scsi_bidi_cmnd (sc) ? +"bidirectional" : sc->sc_data_direction ==DMA_TO_DEVICE ? +"write" :"read" , conn->id, sc, sc->cmnd[0 ], ctask->itt, +scsi_bufflen (sc), +scsi_bidi_cmnd (sc) ?scsi_in (sc)->length :0 , + session->cmdsn, session->max_cmdsn - session->exp_cmdsn +1 );return 0 ; }/** -* iscsi_complete_command - return command back to scsi-ml +* iscsi_complete_command - finish a task * @ctask: iscsi cmd task * * Must be called with session lock. -* This function returns the scsi command to scsi-ml and returns -* the cmd task to the pool of available cmd tasks. +* This function returns the scsi command to scsi-ml or cleans +* up mgmt tasks then returns the task to the pool. */ static void iscsi_complete_command (struct iscsi_cmd_task *ctask) {
@@ -332,17 +332,34 @@ static void iscsi_complete_command(struct iscsi_cmd_task *ctask)struct iscsi_session *session = conn->session;struct scsi_cmnd *sc = ctask->sc; +list_del_init (&ctask->running); ctask->state =ISCSI_TASK_COMPLETED ; ctask->sc =NULL ; -/* SCSI eh reuses commands to verify us */ - sc->SCp.ptr =NULL ; +if (conn->ctask == ctask) conn->ctask =NULL ; -list_del_init (&ctask->running); +/* +* login ctask is preallocated so do not free +*/ +if (conn->login_ctask == ctask) +return ; +__kfifo_put (session->cmdpool.queue, (void *)&ctask,sizeof (void *)); -if (sc->scsi_done) - sc->scsi_done (sc); +if (conn->ping_ctask == ctask) + conn->ping_ctask =NULL ; + +if (sc) { + ctask->sc =NULL ; +/* SCSI eh reuses commands to verify us */ + sc->SCp.ptr =NULL ; +/* +* queue command may call this to free the task, but +* not have setup the sc callback +*/ +if (sc->scsi_done) + sc->scsi_done (sc); + } }static void __iscsi_get_ctask (struct iscsi_cmd_task *ctask)
@@ -356,6 +373,16 @@ static void __iscsi_put_ctask(struct iscsi_cmd_task *ctask)iscsi_complete_command (ctask); } +void iscsi_put_ctask (struct iscsi_cmd_task *ctask) +{ +struct iscsi_session *session = ctask->conn->session; + +spin_lock_bh (&session->lock); +__iscsi_put_ctask (ctask); +spin_unlock_bh (&session->lock); +} +EXPORT_SYMBOL_GPL (iscsi_put_ctask); +/* * session lock must be held */
@@ -375,47 +402,28 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,*/ conn->session->queued_cmdsn--; else - conn->session->tt->cleanup_cmd_task(conn, ctask); + conn->session->tt->cleanup_task(conn, ctask); sc->result = err; +if (!scsi_bidi_cmnd (sc))scsi_set_resid (sc,scsi_bufflen (sc));else {scsi_out (sc)->resid =scsi_out (sc)->length;scsi_in (sc)->resid =scsi_in (sc)->length; } +if (conn->ctask == ctask) conn->ctask =NULL ;/* release ref from queuecommand */ __iscsi_put_ctask (ctask); } -/** -* iscsi_free_mgmt_task - return mgmt task back to pool -* @conn: iscsi connection -* @mtask: mtask -* -* Must be called with session lock. -*/ -void iscsi_free_mgmt_task (struct iscsi_conn *conn, -struct iscsi_mgmt_task *mtask) -{ -list_del_init (&mtask->running); -if (conn->login_mtask == mtask) -return ; - -if (conn->ping_mtask == mtask) - conn->ping_mtask =NULL ; -__kfifo_put (conn->session->mgmtpool.queue, - (void *)&mtask,sizeof (void *)); -} -EXPORT_SYMBOL_GPL (iscsi_free_mgmt_task); - -static int iscsi_prep_mtask (struct iscsi_conn *conn, -struct iscsi_mgmt_task *mtask) +static int iscsi_prep_mgmt_task (struct iscsi_conn *conn, +struct iscsi_cmd_task *ctask) {struct iscsi_session *session = conn->session; -struct iscsi_hdr *hdr = mtask->hdr; +struct iscsi_hdr *hdr = (struct iscsi_hdr *)ctask->hdr;struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr;if (conn->session->state ==ISCSI_STATE_LOGGING_OUT )
@@ -429,7 +437,7 @@ static int iscsi_prep_mtask(struct iscsi_conn *conn,*/ nop->cmdsn =cpu_to_be32 (session->cmdsn);if (hdr->itt !=RESERVED_ITT ) { - hdr->itt =build_itt (mtask->itt, session->age); + hdr->itt =build_itt (ctask->itt, session->age);/* * TODO: We always use immediate, so we never hit this. * If we start to send tmfs or nops as non-immediate then
@@ -442,25 +450,25 @@ static int iscsi_prep_mtask(struct iscsi_conn *conn, } } -if (session->tt->init_mgmt_task) - session->tt->init_mgmt_task (conn, mtask); +if (session->tt->init_task) + session->tt->init_task (ctask);if ((hdr->opcode &ISCSI_OPCODE_MASK ) ==ISCSI_OP_LOGOUT ) session->state =ISCSI_STATE_LOGGING_OUT ; -list_move_tail (&mtask->running, &conn->mgmt_run_list); +list_move_tail (&ctask->running, &conn->mgmt_run_list);debug_scsi ("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n" , hdr->opcode &ISCSI_OPCODE_MASK , hdr->itt, - mtask->data_count); + ctask->data_count);return 0 ; } -static struct iscsi_mgmt_task * +static struct iscsi_cmd_task *__iscsi_conn_send_pdu (struct iscsi_conn *conn,struct iscsi_hdr *hdr,char *data,uint32_t data_size) {struct iscsi_session *session = conn->session; -struct iscsi_mgmt_task *mtask; +struct iscsi_cmd_task *ctask;if (session->state ==ISCSI_STATE_TERMINATE )return NULL ;
@@ -470,48 +478,56 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,/* * Login and Text are sent serially, in * request-followed-by-response sequence. -* Same mtask can be used. Same ITT must be used. -* Note that login_mtask is preallocated at conn_create(). +* Same task can be used. Same ITT must be used. +* Note that login_task is preallocated at conn_create(). */ - mtask = conn->login_mtask; + ctask = conn->login_ctask; else {BUG_ON (conn->c_stage ==ISCSI_CONN_INITIAL_STAGE );BUG_ON (conn->c_stage ==ISCSI_CONN_STOPPED ); -if (!__kfifo_get (session->mgmtpool.queue, - (void *)&mtask,sizeof (void *))) +if (!__kfifo_get (session->cmdpool.queue, + (void *)&ctask,sizeof (void *)))return NULL ;if ((hdr->opcode == (ISCSI_OP_NOOP_OUT |ISCSI_OP_IMMEDIATE )) && hdr->ttt ==RESERVED_ITT ) { - conn->ping_mtask = mtask; + conn->ping_ctask = ctask; conn->last_ping = jiffies; } } +/* +* released in complete pdu for task we expect a response for, and +* released by the lld when it has transmitted the task for +* pdus we do not expect a response for. +*/ +atomic_set (&ctask->refcount,1 ); + ctask->conn = conn; + ctask->sc =NULL ;if (data_size) { -memcpy (mtask->data, data, data_size); - mtask->data_count = data_size; +memcpy (ctask->data, data, data_size); + ctask->data_count = data_size; }else - mtask->data_count =0 ; + ctask->data_count =0 ; -memcpy (mtask->hdr, hdr,sizeof (struct iscsi_hdr )); -INIT_LIST_HEAD (&mtask->running); -list_add_tail (&mtask->running, &conn->mgmtqueue); +memcpy (ctask->hdr, hdr,sizeof (struct iscsi_hdr )); +INIT_LIST_HEAD (&ctask->running); +list_add_tail (&ctask->running, &conn->mgmtqueue);if (session->tt->caps &CAP_DATA_PATH_OFFLOAD ) { -if (iscsi_prep_mtask (conn, mtask)) { -iscsi_free_mgmt_task (conn, mtask); +if (iscsi_prep_mgmt_task (conn, ctask)) { +__iscsi_put_ctask (ctask);return NULL ; } -if (session->tt->xmit_mgmt_task (conn, mtask)) - mtask =NULL ; +if (session->tt->xmit_task (ctask)) + ctask =NULL ; }else scsi_queue_work (conn->session->host, &conn->xmitwork); -return mtask; +return ctask; } int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
@@ -538,7 +554,7 @@ EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);* @datalen: len of buffer * * iscsi_cmd_rsp sets up the scsi_cmnd fields based on the PDU and -* then completes the command and task. +* then completes the command and ctask. **/ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, struct iscsi_cmd_task *ctask, char *data,
@@ -634,9 +650,9 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)static void iscsi_send_nopout (struct iscsi_conn *conn,struct iscsi_nopin *rhdr) {struct iscsi_nopout hdr; -struct iscsi_mgmt_task *mtask; +struct iscsi_cmd_task *ctask; -if (!rhdr && conn->ping_mtask) +if (!rhdr && conn->ping_ctask)return ;memset (&hdr,0 ,sizeof (struct iscsi_nopout ));
@@ -650,8 +666,8 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) }else hdr.ttt =RESERVED_ITT ; - mtask =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)&hdr,NULL ,0 ); -if (!mtask) + ctask =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)&hdr,NULL ,0 ); +if (!ctask)iscsi_conn_printk (KERN_ERR , conn,"Could not send nopout\n" ); }
@@ -697,7 +713,6 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,struct iscsi_session *session = conn->session;int opcode = hdr->opcode &ISCSI_OPCODE_MASK , rc =0 ;struct iscsi_cmd_task *ctask; -struct iscsi_mgmt_task *mtask;uint32_t itt; conn->last_recv = jiffies;
@@ -710,93 +725,10 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,else itt = ~0U ; -if (itt < session->cmds_max) { - ctask = session->cmds[itt]; - -debug_scsi ("cmdrsp [op 0x%x cid %d itt 0x%x len %d]\n" , - opcode, conn->id, ctask->itt, datalen); - -switch (opcode) { -case ISCSI_OP_SCSI_CMD_RSP : -BUG_ON ((void *)ctask != ctask->sc->SCp.ptr); -iscsi_scsi_cmd_rsp (conn, hdr, ctask, data, - datalen); -break ; -case ISCSI_OP_SCSI_DATA_IN : -BUG_ON ((void *)ctask != ctask->sc->SCp.ptr); -if (hdr->flags &ISCSI_FLAG_DATA_STATUS ) { - conn->scsirsp_pdus_cnt++; -__iscsi_put_ctask (ctask); - } -break ; -case ISCSI_OP_R2T : -/* LLD handles this for now */ -break ; -default : - rc =ISCSI_ERR_BAD_OPCODE ; -break ; - } - }else if (itt >=ISCSI_MGMT_ITT_OFFSET && - itt <ISCSI_MGMT_ITT_OFFSET + session->mgmtpool_max) { - mtask = session->mgmt_cmds[itt -ISCSI_MGMT_ITT_OFFSET ]; - -debug_scsi ("immrsp [op 0x%x cid %d itt 0x%x len %d]\n" , - opcode, conn->id, mtask->itt, datalen); +debug_scsi ("[op 0x%x cid %d itt 0x%x len %d]\n" , + opcode, conn->id, itt, datalen); -iscsi_update_cmdsn (session, (struct iscsi_nopin *)hdr); -switch (opcode) { -case ISCSI_OP_LOGOUT_RSP : -if (datalen) { - rc =ISCSI_ERR_PROTO ; -break ; - } - conn->exp_statsn =be32_to_cpu (hdr->statsn) +1 ; -/* fall through */ -case ISCSI_OP_LOGIN_RSP : -case ISCSI_OP_TEXT_RSP : -/* -* login related PDU's exp_statsn is handled in -* userspace -*/ -if (iscsi_recv_pdu (conn->cls_conn, hdr, data, datalen)) - rc =ISCSI_ERR_CONN_FAILED ; -iscsi_free_mgmt_task (conn, mtask); -break ; -case ISCSI_OP_SCSI_TMFUNC_RSP : -if (datalen) { - rc =ISCSI_ERR_PROTO ; -break ; - } - -iscsi_tmf_rsp (conn, hdr); -iscsi_free_mgmt_task (conn, mtask); -break ; -case ISCSI_OP_NOOP_IN : -if (hdr->ttt !=cpu_to_be32 (ISCSI_RESERVED_TAG ) || - datalen) { - rc =ISCSI_ERR_PROTO ; -break ; - } - conn->exp_statsn =be32_to_cpu (hdr->statsn) +1 ; - -if (conn->ping_mtask != mtask) { -/* -* If this is not in response to one of our -* nops then it must be from userspace. -*/ -if (iscsi_recv_pdu (conn->cls_conn, hdr, data, - datalen)) - rc =ISCSI_ERR_CONN_FAILED ; - }else -mod_timer (&conn->transport_timer, - jiffies + conn->recv_timeout); -iscsi_free_mgmt_task (conn, mtask); -break ; -default : - rc =ISCSI_ERR_BAD_OPCODE ; -break ; - } - }else if (itt == ~0U ) { +if (itt == ~0U ) {iscsi_update_cmdsn (session, (struct iscsi_nopin *)hdr);switch (opcode) {
@@ -823,9 +755,88 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, rc =ISCSI_ERR_BAD_OPCODE ;break ; } - }else - rc =ISCSI_ERR_BAD_ITT ; + goto out; + } + + ctask = session->cmds[itt]; +switch (opcode) { +case ISCSI_OP_SCSI_CMD_RSP : +if (!ctask->sc) { + rc =ISCSI_ERR_NO_SCSI_CMD ; +break ; + } +BUG_ON ((void *)ctask != ctask->sc->SCp.ptr); +iscsi_scsi_cmd_rsp (conn, hdr, ctask, data, datalen); +break ; +case ISCSI_OP_SCSI_DATA_IN : +if (!ctask->sc) { + rc =ISCSI_ERR_NO_SCSI_CMD ; +break ; + } +BUG_ON ((void *)ctask != ctask->sc->SCp.ptr); +if (hdr->flags &ISCSI_FLAG_DATA_STATUS ) { + conn->scsirsp_pdus_cnt++; +iscsi_update_cmdsn (session, + (struct iscsi_nopin *) hdr); +__iscsi_put_ctask (ctask); + } +break ; +case ISCSI_OP_R2T : +/* LLD handles this for now */ +break ; +case ISCSI_OP_LOGOUT_RSP : +iscsi_update_cmdsn (session, (struct iscsi_nopin *)hdr); +if (datalen) { + rc =ISCSI_ERR_PROTO ; +break ; + } + conn->exp_statsn =be32_to_cpu (hdr->statsn) +1 ; + goto recv_pdu; +case ISCSI_OP_LOGIN_RSP : +case ISCSI_OP_TEXT_RSP : +iscsi_update_cmdsn (session, (struct iscsi_nopin *)hdr); +/* +* login related PDU's exp_statsn is handled in +* userspace +*/ + goto recv_pdu; +case ISCSI_OP_SCSI_TMFUNC_RSP : +iscsi_update_cmdsn (session, (struct iscsi_nopin *)hdr); +if (datalen) { + rc =ISCSI_ERR_PROTO ; +break ; + } + +iscsi_tmf_rsp (conn, hdr); +__iscsi_put_ctask (ctask); +break ; +case ISCSI_OP_NOOP_IN : +iscsi_update_cmdsn (session, (struct iscsi_nopin *)hdr); +if (hdr->ttt !=cpu_to_be32 (ISCSI_RESERVED_TAG ) || datalen) { + rc =ISCSI_ERR_PROTO ; +break ; + } + conn->exp_statsn =be32_to_cpu (hdr->statsn) +1 ; + +if (conn->ping_ctask != ctask) +/* +* If this is not in response to one of our +* nops then it must be from userspace. +*/ + goto recv_pdu; +__iscsi_put_ctask (ctask); +break ; +default : + rc =ISCSI_ERR_BAD_OPCODE ; +break ; + } +out: +return rc; +recv_pdu: +if (iscsi_recv_pdu (conn->cls_conn, hdr, data, datalen)) + rc =ISCSI_ERR_CONN_FAILED ; +__iscsi_put_ctask (ctask);return rc; }
@@ -845,6 +856,7 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) {struct iscsi_session *session = conn->session;struct iscsi_cmd_task *ctask; +uint32_t i;if (itt ==RESERVED_ITT )return 0 ;
@@ -858,25 +870,22 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)return ISCSI_ERR_BAD_ITT ; } -if (itt < session->cmds_max) { - ctask = session->cmds[itt]; - -if (!ctask->sc) { -iscsi_conn_printk (KERN_INFO , conn,"dropping ctask " -"with itt 0x%x\n" , ctask->itt); -/* force drop */ -return ISCSI_ERR_NO_SCSI_CMD ; - } - -if (ctask->sc->SCp.phase != session->age) { -iscsi_conn_printk (KERN_ERR , conn, -"iscsi: ctask's session age %d, " -"expected %d\n" , ctask->sc->SCp.phase, - session->age); -return ISCSI_ERR_SESSION_FAILED ; - } + i =get_itt (itt); +if (i >= session->cmds_max) { +iscsi_conn_printk (KERN_ERR , conn, +"received invalid itt index %u (max cmds " +"%u.\n" , i, session->cmds_max); +return ISCSI_ERR_BAD_ITT ; } + ctask = session->cmds[i]; +if (ctask->sc && ctask->sc->SCp.phase != session->age) { +iscsi_conn_printk (KERN_ERR , conn, +"iscsi: ctask's session age %d, " +"expected %d\n" , ctask->sc->SCp.phase, + session->age); +return ISCSI_ERR_SESSION_FAILED ; + }return 0 ; }EXPORT_SYMBOL_GPL (iscsi_verify_itt);
@@ -929,20 +938,6 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) }EXPORT_SYMBOL_GPL (iscsi_conn_failure); -static int iscsi_xmit_mtask (struct iscsi_conn *conn) -{ -int rc; - -spin_unlock_bh (&conn->session->lock); - rc = conn->session->tt->xmit_mgmt_task (conn, conn->mtask); -spin_lock_bh (&conn->session->lock); -if (rc) -return rc; -/* done with this in-progress mtask */ - conn->mtask =NULL ; -return 0 ; -} -static int iscsi_check_cmdsn_window_closed (struct iscsi_conn *conn) {struct iscsi_session *session = conn->session;
@@ -967,7 +962,7 @@ static int iscsi_xmit_ctask(struct iscsi_conn *conn)__iscsi_get_ctask (ctask);spin_unlock_bh (&conn->session->lock); - rc = conn->session->tt->xmit_cmd_task (conn, ctask); + rc = conn->session->tt->xmit_task (ctask);spin_lock_bh (&conn->session->lock);__iscsi_put_ctask (ctask);if (!rc)
@@ -1015,12 +1010,6 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)if (conn->ctask) { rc =iscsi_xmit_ctask (conn); -if (rc) - goto again; - } - -if (conn->mtask) { - rc =iscsi_xmit_mtask (conn);if (rc) goto again; }
@@ -1032,14 +1021,14 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)*/ check_mgmt:while (!list_empty (&conn->mgmtqueue)) { - conn->mtask =list_entry (conn->mgmtqueue.next, - struct iscsi_mgmt_task, running); -if (iscsi_prep_mtask (conn, conn->mtask)) { -iscsi_free_mgmt_task (conn, conn->mtask); - conn->mtask =NULL ; + conn->ctask =list_entry (conn->mgmtqueue.next, + struct iscsi_cmd_task, running); +if (iscsi_prep_mgmt_task (conn, conn->ctask)) { +__iscsi_put_ctask (conn->ctask); + conn->ctask =NULL ;continue ; } - rc =iscsi_xmit_mtask (conn); + rc =iscsi_xmit_ctask (conn);if (rc) goto again; }
@@ -1224,7 +1213,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))iscsi_complete_command (ctask); goto fault; } -if (session->tt->xmit_cmd_task (conn, ctask)) { +if (session->tt->xmit_task (ctask)) { sc->scsi_done =NULL ;iscsi_complete_command (ctask); reason =FAILURE_SESSION_NOT_READY ;
@@ -1347,16 +1336,16 @@ static void iscsi_tmf_timedout(unsigned long data)spin_unlock (&session->lock); } -static int iscsi_exec_task_mgmt_fn (struct iscsi_conn *conn, +static int iscsi_exec_ctask_mgmt_fn (struct iscsi_conn *conn,struct iscsi_tm *hdr,int age,int timeout) {struct iscsi_session *session = conn->session; -struct iscsi_mgmt_task *mtask; +struct iscsi_cmd_task *ctask; - mtask =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)hdr, + ctask =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)hdr,NULL ,0 ); -if (!mtask) { +if (!ctask) {spin_unlock_bh (&session->lock);iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED );spin_lock_bh (&session->lock);
@@ -1390,7 +1379,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,mutex_lock (&session->eh_mutex);spin_lock_bh (&session->lock); -/* if the session drops it will clean up the mtask */ +/* if the session drops it will clean up the ctask */ if (age != session->age || session->state !=ISCSI_STATE_LOGGED_IN )return -ENOTCONN ;
@@ -1497,7 +1486,7 @@ static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) jiffies)) rc =EH_RESET_TIMER ;/* if in the middle of checking the transport then give us more time */ -if (conn->ping_mtask) +if (conn->ping_ctask) rc =EH_RESET_TIMER ; done:spin_unlock (&session->lock);
@@ -1521,7 +1510,7 @@ static void iscsi_check_transport_timeouts(unsigned long data) recv_timeout *=HZ ; last_recv = conn->last_recv; -if (conn->ping_mtask && +if (conn->ping_ctask &&time_before_eq (conn->last_ping + (conn->ping_timeout *HZ ), jiffies)) { iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs "
@@ -1547,7 +1536,7 @@ done:spin_unlock (&session->lock); } -static void iscsi_prep_abort_task_pdu (struct iscsi_cmd_task *ctask, +static void iscsi_prep_abort_ctask_pdu (struct iscsi_cmd_task *ctask,struct iscsi_tm *hdr) {memset (hdr,0 ,sizeof (*hdr));
@@ -1619,9 +1608,9 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) conn->tmf_state =TMF_QUEUED ; hdr = &conn->tmhdr; -iscsi_prep_abort_task_pdu (ctask, hdr); +iscsi_prep_abort_ctask_pdu (ctask, hdr); -if (iscsi_exec_task_mgmt_fn (conn, hdr, age, session->abort_timeout)) { +if (iscsi_exec_ctask_mgmt_fn (conn, hdr, age, session->abort_timeout)) { rc =FAILED ; goto failed; }
@@ -1631,7 +1620,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)spin_unlock_bh (&session->lock);iscsi_suspend_tx (conn);/* -* clean up task if aborted. grab the recv lock as a writer +* clean up ctask if aborted. grab the recv lock as a writer */ write_lock_bh (conn->recv_lock);spin_lock (&session->lock);
@@ -1716,7 +1705,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) hdr = &conn->tmhdr;iscsi_prep_lun_reset_pdu (sc, hdr); -if (iscsi_exec_task_mgmt_fn (conn, hdr, session->age, +if (iscsi_exec_ctask_mgmt_fn (conn, hdr, session->age, session->lu_reset_timeout)) { rc =FAILED ; goto unlock;
@@ -1897,8 +1886,7 @@ EXPORT_SYMBOL_GPL(iscsi_host_free);* @iscsit: iscsi transport template * @shost: scsi host * @cmds_max: session can queue -* @cmd_task_size: LLD ctask private data size -* @mgmt_task_size: LLD mtask private data size +* @cmd_ctask_size: LLD ctask private data size * @initial_cmdsn: initial CmdSN * * This can be used by software iscsi_transports that allocate
@@ -1906,22 +1894,26 @@ EXPORT_SYMBOL_GPL(iscsi_host_free);*/ struct iscsi_cls_session *iscsi_session_setup (struct iscsi_transport *iscsit,struct Scsi_Host *shost, -uint16_t cmds_max,int cmd_task_size,int mgmt_task_size, +uint16_t scsi_cmds_max,int cmd_ctask_size,uint32_t initial_cmdsn) {struct iscsi_session *session;struct iscsi_cls_session *cls_session; -int cmd_i; +int cmd_i, cmds_max; -if (!is_power_of_2 (cmds_max) || cmds_max >=ISCSI_MGMT_ITT_OFFSET || - cmds_max <2 ) { -if (cmds_max !=0 ) -printk (KERN_ERR "iscsi: invalid can_queue of %d. " -"can_queue must be a power of 2 and between " -"2 and %d - setting to %d.\n" , cmds_max, -ISCSI_MGMT_ITT_OFFSET ,ISCSI_DEF_XMIT_CMDS_MAX ); - cmds_max =ISCSI_DEF_XMIT_CMDS_MAX ; +/* +* The iscsi layer needs some ctasks for nop handling and tmfs. +*/ +if (scsi_cmds_max <1 ) + scsi_cmds_max =ISCSI_MGMT_CMDS_MAX ; +if ((scsi_cmds_max +ISCSI_MGMT_CMDS_MAX ) >=ISCSI_MGMT_ITT_OFFSET ) { +printk (KERN_ERR "iscsi: invalid can_queue of %d. " +"can_queue must be less than %d.\n" , + scsi_cmds_max, +ISCSI_MGMT_ITT_OFFSET -ISCSI_MGMT_CMDS_MAX ); + scsi_cmds_max =ISCSI_DEF_XMIT_CMDS_MAX ; } + cmds_max =roundup_pow_of_two (scsi_cmds_max +ISCSI_MGMT_CMDS_MAX ); cls_session =iscsi_alloc_session (shost, iscsit,sizeof (struct iscsi_session ));
@@ -1934,7 +1926,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, session->fast_abort =1 ; session->lu_reset_timeout =15 ; session->abort_timeout =10 ; - session->mgmtpool_max =ISCSI_MGMT_CMDS_MAX ; + session->scsi_cmds_max = scsi_cmds_max; session->cmds_max = cmds_max; session->queued_cmdsn = session->cmdsn = initial_cmdsn; session->exp_cmdsn = initial_cmdsn +1 ;
@@ -1947,36 +1939,19 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,/* initialize SCSI PDU commands pool */ if (iscsi_pool_init (&session->cmdpool, session->cmds_max, (void ***)&session->cmds, - cmd_task_size +sizeof (struct iscsi_cmd_task ))) + cmd_ctask_size +sizeof (struct iscsi_cmd_task ))) goto cmdpool_alloc_fail;/* pre-format cmds pool with ITT */ for (cmd_i =0 ; cmd_i < session->cmds_max; cmd_i++) {struct iscsi_cmd_task *ctask = session->cmds[cmd_i]; -if (cmd_task_size) +if (cmd_ctask_size) ctask->dd_data = &ctask[1 ]; ctask->itt = cmd_i;INIT_LIST_HEAD (&ctask->running); } -/* initialize immediate command pool */ -if (iscsi_pool_init (&session->mgmtpool, session->mgmtpool_max, - (void ***)&session->mgmt_cmds, - mgmt_task_size +sizeof (struct iscsi_mgmt_task ))) - goto mgmtpool_alloc_fail; - - -/* pre-format immediate cmds pool with ITT */ -for (cmd_i =0 ; cmd_i < session->mgmtpool_max; cmd_i++) { -struct iscsi_mgmt_task *mtask = session->mgmt_cmds[cmd_i]; - -if (mgmt_task_size) - mtask->dd_data = &mtask[1 ]; - mtask->itt =ISCSI_MGMT_ITT_OFFSET + cmd_i; -INIT_LIST_HEAD (&mtask->running); - } -if (!try_module_get (iscsit->owner)) goto module_get_fail;
@@ -1987,8 +1962,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, cls_session_fail:module_put (iscsit->owner); module_get_fail: -iscsi_pool_free (&session->mgmtpool); -mgmtpool_alloc_fail:iscsi_pool_free (&session->cmdpool); cmdpool_alloc_fail:iscsi_free_session (cls_session);
@@ -2008,7 +1981,6 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)struct iscsi_session *session = cls_session->dd_data;struct module *owner = cls_session->transport->owner; -iscsi_pool_free (&session->mgmtpool);iscsi_pool_free (&session->cmdpool);kfree (session->password);
@@ -2063,30 +2035,30 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,INIT_LIST_HEAD (&conn->requeue);INIT_WORK (&conn->xmitwork, iscsi_xmitworker); -/* allocate login_mtask used for the login/text sequences */ +/* allocate login_ctask used for the login/text sequences */ spin_lock_bh (&session->lock); -if (!__kfifo_get (session->mgmtpool.queue, - (void *)&conn->login_mtask, +if (!__kfifo_get (session->cmdpool.queue, + (void *)&conn->login_ctask,sizeof (void *))) {spin_unlock_bh (&session->lock); - goto login_mtask_alloc_fail; + goto login_ctask_alloc_fail; }spin_unlock_bh (&session->lock); data =kmalloc (ISCSI_DEF_MAX_RECV_SEG_LEN ,GFP_KERNEL );if (!data) - goto login_mtask_data_alloc_fail; - conn->login_mtask->data = conn->data = data; + goto login_ctask_data_alloc_fail; + conn->login_ctask->data = conn->data = data;init_timer (&conn->tmf_timer);init_waitqueue_head (&conn->ehwait);return cls_conn; -login_mtask_data_alloc_fail: -__kfifo_put (session->mgmtpool.queue, (void *)&conn->login_mtask, +login_ctask_data_alloc_fail: +__kfifo_put (session->cmdpool.queue, (void *)&conn->login_ctask,sizeof (void *)); -login_mtask_alloc_fail: +login_ctask_alloc_fail:iscsi_destroy_conn (cls_conn);return NULL ; }
@@ -2146,7 +2118,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)spin_lock_bh (&session->lock);kfree (conn->data);kfree (conn->persistent_address); -__kfifo_put (session->mgmtpool.queue, (void *)&conn->login_mtask, +__kfifo_put (session->cmdpool.queue, (void *)&conn->login_ctask,sizeof (void *));if (session->leadconn == conn) session->leadconn =NULL ;
@@ -2227,21 +2199,23 @@ EXPORT_SYMBOL_GPL(iscsi_conn_start);static void flush_control_queues (struct iscsi_session *session,struct iscsi_conn *conn) { -struct iscsi_mgmt_task *mtask, *tmp; +struct iscsi_cmd_task *ctask, *tmp;/* handle pending */ -list_for_each_entry_safe (mtask, tmp, &conn->mgmtqueue, running) { -debug_scsi ("flushing pending mgmt task itt 0x%x\n" , mtask->itt); -iscsi_free_mgmt_task (conn, mtask); +list_for_each_entry_safe (ctask, tmp, &conn->mgmtqueue, running) { +debug_scsi ("flushing pending mgmt ctask itt 0x%x\n" , ctask->itt); +/* release ref from prep ctask */ +__iscsi_put_ctask (ctask); }/* handle running */ -list_for_each_entry_safe (mtask, tmp, &conn->mgmt_run_list, running) { -debug_scsi ("flushing running mgmt task itt 0x%x\n" , mtask->itt); -iscsi_free_mgmt_task (conn, mtask); +list_for_each_entry_safe (ctask, tmp, &conn->mgmt_run_list, running) { +debug_scsi ("flushing running mgmt ctask itt 0x%x\n" , ctask->itt); +/* release ref from prep ctask */ +__iscsi_put_ctask (ctask); } - conn->mtask =NULL ; + conn->ctask =NULL ; } static void iscsi_start_session_recovery(struct iscsi_session *session,
@@ -2272,7 +2246,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,/* * When this is called for the in_login state, we only want to clean -* up the login task and connection. We do not need to block and set +* up the login ctask and connection. We do not need to block and set * the recovery state again */ if (flag ==STOP_CONN_TERM )
include/scsi/libiscsi.h +7 -22
@@ -85,18 +85,6 @@ enum { ISCSI_DIGEST_SIZE = sizeof(__u32), }; -struct iscsi_mgmt_task { -/* -* Becuae LLDs allocate their hdr differently, this is a pointer to -* that storage. It must be setup at session creation time. -*/ -struct iscsi_hdr *hdr; -char *data;/* mgmt payload */ -unsigned data_count;/* counts data to be sent */ -uint32_t itt;/* this ITT */ -void *dd_data;/* driver/transport data */ -struct list_head running; -};enum {ISCSI_TASK_COMPLETED ,
@@ -121,6 +109,7 @@ struct iscsi_cmd_task {/* offset in unsolicited stream (bytes); */ unsigned unsol_offset;unsigned data_count;/* remaining Data-Out */ +char *data;/* mgmt payload */ struct scsi_cmnd *sc;/* associated SCSI cmd*/ struct iscsi_conn *conn;/* used connection */
@@ -162,7 +151,7 @@ struct iscsi_conn {unsigned long last_ping;int ping_timeout;int recv_timeout; -struct iscsi_mgmt_task *ping_mtask; +struct iscsi_cmd_task *ping_ctask;/* iSCSI connection-wide sequencing */ uint32_t exp_statsn;
@@ -178,9 +167,8 @@ struct iscsi_conn {* should always fit in this buffer */ char *data; -struct iscsi_mgmt_task *login_mtask;/* mtask used for login/text */ -struct iscsi_mgmt_task *mtask;/* xmit mtask in progress */ -struct iscsi_cmd_task *ctask;/* xmit ctask in progress */ +struct iscsi_cmd_task *login_ctask;/* mtask used for login/text */ +struct iscsi_cmd_task *ctask;/* xmit task in progress */ /* xmit */ struct list_head mgmtqueue;/* mgmt (control) xmit queue */
@@ -295,12 +283,10 @@ struct iscsi_session {int state;/* session state */ int age;/* counts session re-opens */ +int scsi_cmds_max;/* max scsi commands */ int cmds_max;/* size of cmds array */ struct iscsi_cmd_task **cmds;/* Original Cmds arr */ struct iscsi_pool cmdpool;/* PDU's pool */ -int mgmtpool_max;/* size of mgmt array */ -struct iscsi_mgmt_task **mgmt_cmds;/* Original mgmt arr */ -struct iscsi_pool mgmtpool;/* Mgmt PDU's pool */ };struct iscsi_host {
@@ -345,7 +331,7 @@ extern void iscsi_host_free(struct Scsi_Host *shost);*/ extern struct iscsi_cls_session *iscsi_session_setup (struct iscsi_transport *,struct Scsi_Host *shost, -uint16_t ,int ,int ,uint32_t ); +uint16_t ,int ,uint32_t );extern void iscsi_session_teardown (struct iscsi_cls_session *);extern void iscsi_session_recovery_timedout (struct iscsi_cls_session *); extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
@@ -388,8 +374,7 @@ extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,extern int iscsi_verify_itt (struct iscsi_conn *,itt_t );extern struct iscsi_cmd_task *iscsi_itt_to_ctask (struct iscsi_conn *,itt_t );extern void iscsi_requeue_ctask (struct iscsi_cmd_task *ctask); -extern void iscsi_free_mgmt_task (struct iscsi_conn *conn, -struct iscsi_mgmt_task *mtask); +extern void iscsi_put_ctask (struct iscsi_cmd_task *ctask);/* * generic helpers
include/scsi/scsi_transport_iscsi.h +19 -22
60 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 12/25 iscsi_tcp: convert iscsi_tcp to support merged tasks
From: Mike Christie <[email protected]>
Convert iscsi_tcp to support merged tasks.
--- drivers/scsi/iscsi_tcp.c | 130 +++++++++++++++++++--------------------------- drivers/scsi/iscsi_tcp.h | 5 -- 2 files changed, 54 insertions(+), 81 deletions(-)
drivers/scsi/iscsi_tcp.c +54 -76
@@ -498,11 +498,15 @@ iscsi_tcp_data_recv_prep(struct iscsi_tcp_conn *tcp_conn)* must be called with session lock */ static void -iscsi_tcp_cleanup_ctask (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) +iscsi_tcp_cleanup_task (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) {struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;struct iscsi_r2t_info *r2t; +/* nothing to do for mgmt ctasks */ +if (!ctask->sc) +return ; +/* flush ctask's r2t queues */ while (__kfifo_get (tcp_ctask->r2tqueue, (void *)&r2t,sizeof (void *))) { __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
@@ -521,7 +525,7 @@ iscsi_tcp_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)/** * iscsi_data_rsp - SCSI Data-In Response processing * @conn: iscsi connection -* @ctask: scsi command task +* @ctask: scsi command ctask **/ static int iscsi_data_rsp (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask)
@@ -578,7 +582,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)/** * iscsi_solicit_data_init - initialize first Data-Out * @conn: iscsi connection -* @ctask: scsi command task +* @ctask: scsi command ctask * @r2t: R2T info * * Notes:
@@ -620,7 +624,7 @@ iscsi_solicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,/** * iscsi_r2t_rsp - iSCSI R2T Response processing * @conn: iscsi connection -* @ctask: scsi command task +* @ctask: scsi command ctask **/ static int iscsi_r2t_rsp (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask)
@@ -646,7 +650,7 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)return ISCSI_ERR_R2TSN ; } -/* fill-in new R2T associated with the task */ +/* fill-in new R2T associated with the ctask */ iscsi_update_cmdsn (session, (struct iscsi_nopin *)rhdr);if (!ctask->sc || session->state !=ISCSI_STATE_LOGGED_IN ) {
@@ -769,6 +773,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) ctask =iscsi_itt_to_ctask (conn, hdr->itt);if (!ctask)return ISCSI_ERR_BAD_ITT ; +if (!ctask->sc) +return ISCSI_ERR_NO_SCSI_CMD ;spin_lock (&conn->session->lock); rc =iscsi_data_rsp (conn, ctask);
@@ -815,6 +821,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) ctask =iscsi_itt_to_ctask (conn, hdr->itt);if (!ctask)return ISCSI_ERR_BAD_ITT ; +if (!ctask->sc) +return ISCSI_ERR_NO_SCSI_CMD ;if (ahslen) rc =ISCSI_ERR_AHSLEN ;
@@ -1194,7 +1202,7 @@ iscsi_tcp_send_hdr_prep(struct iscsi_conn *conn, void *hdr, size_t hdrlen)/* If header digest is enabled, compute the CRC and * place the digest into the same buffer. We make -* sure that both iscsi_tcp_ctask and mtask have +* sure that both iscsi_tcp_cmd_task and mctask have * sufficient room. */ if (conn->hdrdgst_en) {
@@ -1269,7 +1277,7 @@ iscsi_tcp_send_linear_data_prepare(struct iscsi_conn *conn, void *data,/** * iscsi_solicit_data_cont - initialize next Data-Out * @conn: iscsi connection -* @ctask: scsi command task +* @ctask: scsi command ctask * @r2t: R2T info * @left: bytes left to transfer *
@@ -1316,19 +1324,37 @@ iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, }/** -* iscsi_tcp_ctask - Initialize iSCSI SCSI_READ or SCSI_WRITE commands +* iscsi_tcp_task - Initialize iSCSI SCSI_READ or SCSI_WRITE commands * @conn: iscsi connection -* @ctask: scsi command task +* @ctask: scsi command ctask * @sc: scsi command **/ static int -iscsi_tcp_ctask_init (struct iscsi_cmd_task *ctask) +iscsi_tcp_task_init (struct iscsi_cmd_task *ctask) {struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;struct iscsi_conn *conn = ctask->conn;struct scsi_cmnd *sc = ctask->sc;int err; +if (!sc) { +/* +* mgmt ctasks do not have a scatterlist since they come +* in from the iscsi interface. +*/ +debug_scsi ("mctask deq [cid %d itt 0x%x]\n" , conn->id, + ctask->itt); + +/* Prepare PDU, optionally w/ immediate data */ +iscsi_tcp_send_hdr_prep (conn, ctask->hdr,sizeof (*ctask->hdr)); + +/* If we have immediate data, attach a payload */ +if (ctask->data_count) +iscsi_tcp_send_linear_data_prepare (conn, ctask->data, + ctask->data_count); +return 0 ; + } +BUG_ON (__kfifo_len (tcp_ctask->r2tqueue)); tcp_ctask->sent =0 ; tcp_ctask->exp_datasn =0 ;
@@ -1353,52 +1379,21 @@ iscsi_tcp_ctask_init(struct iscsi_cmd_task *ctask)return 0 ; } -/** -* iscsi_tcp_mtask_xmit - xmit management(immediate) task -* @conn: iscsi connection -* @mtask: task management task -* -* Notes: -* The function can return -EAGAIN in which case caller must -* call it again later, or recover. '0' return code means successful -* xmit. -**/ -static int -iscsi_tcp_mtask_xmit (struct iscsi_conn *conn,struct iscsi_mgmt_task *mtask) -{ -int rc; - -/* Flush any pending data first. */ - rc =iscsi_tcp_flush (conn); -if (rc <0 ) -return rc; - -if (mtask->hdr->itt ==RESERVED_ITT ) { -struct iscsi_session *session = conn->session; - -spin_lock_bh (&session->lock); -iscsi_free_mgmt_task (conn, mtask); -spin_unlock_bh (&session->lock); - } - -return 0 ; -} -/* -* iscsi_tcp_ctask_xmit - xmit normal PDU task -* @conn: iscsi connection -* @ctask: iscsi command task +* iscsi_tcp_task_xmit - xmit normal PDU ctask +* @ctask: iscsi command ctask * * We're expected to return 0 when everything was transmitted succesfully, * -EAGAIN if there's still data in the queue, or != 0 for any other kind * of error. */ static int -iscsi_tcp_ctask_xmit (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) +iscsi_tcp_task_xmit (struct iscsi_cmd_task *ctask) { +struct iscsi_conn *conn = ctask->conn;struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;struct scsi_cmnd *sc = ctask->sc; -struct scsi_data_buffer *sdb =scsi_out (sc); +struct scsi_data_buffer *sdb;int rc =0 ; flush:
@@ -1407,10 +1402,18 @@ flush:if (rc <0 )return rc; +/* mgmt command */ +if (!sc) { +if (ctask->hdr->itt ==RESERVED_ITT ) +iscsi_put_ctask (ctask); +return 0 ; + } +/* Are we done already? */ if (sc->sc_data_direction !=DMA_TO_DEVICE )return 0 ; + sdb =scsi_out (sc);if (ctask->unsol_count !=0 ) {struct iscsi_data *hdr = &tcp_ctask->unsol_dtask.hdr;
@@ -1688,21 +1691,6 @@ free_socket:return err; } -/* called with host lock */ -static void -iscsi_tcp_mtask_init (struct iscsi_conn *conn,struct iscsi_mgmt_task *mtask) -{ -debug_scsi ("mtask deq [cid %d itt 0x%x]\n" , conn->id, mtask->itt); - -/* Prepare PDU, optionally w/ immediate data */ -iscsi_tcp_send_hdr_prep (conn, mtask->hdr,sizeof (*mtask->hdr)); - -/* If we have immediate data, attach a payload */ -if (mtask->data_count) -iscsi_tcp_send_linear_data_prepare (conn, mtask->data, - mtask->data_count); -} -static int iscsi_r2tpool_alloc (struct iscsi_session *session) {
@@ -1710,7 +1698,7 @@ iscsi_r2tpool_alloc(struct iscsi_session *session)int cmd_i;/* -* initialize per-task: R2T pool and xmit queue +* initialize per-ctask: R2T pool and xmit queue */ for (cmd_i =0 ; cmd_i < session->cmds_max; cmd_i++) {struct iscsi_cmd_task *ctask = session->cmds[cmd_i];
@@ -1880,13 +1868,12 @@ iscsi_tcp_session_create(struct Scsi_Host *shost, uint16_t cmds_max, cls_session =iscsi_session_setup (&iscsi_tcp_transport, shost, cmds_max,sizeof (struct iscsi_tcp_cmd_task ), -sizeof (struct iscsi_tcp_mgmt_task ), initial_cmdsn);if (!cls_session) goto remove_host; session = cls_session->dd_data; - shost->can_queue = session->cmds_max; + shost->can_queue = session->scsi_cmds_max;for (cmd_i =0 ; cmd_i < session->cmds_max; cmd_i++) {struct iscsi_cmd_task *ctask = session->cmds[cmd_i];struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
@@ -1895,13 +1882,6 @@ iscsi_tcp_session_create(struct Scsi_Host *shost, uint16_t cmds_max, ctask->hdr_max =sizeof (tcp_ctask->hdr) -ISCSI_DIGEST_SIZE ; } -for (cmd_i =0 ; cmd_i < session->mgmtpool_max; cmd_i++) { -struct iscsi_mgmt_task *mtask = session->mgmt_cmds[cmd_i]; -struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data; - - mtask->hdr = (struct iscsi_hdr *) &tcp_mtask->hdr; - } -if (iscsi_r2tpool_alloc (session)) goto remove_session;return cls_session;
@@ -1999,11 +1979,9 @@ static struct iscsi_transport iscsi_tcp_transport = {/* IO */ .send_pdu = iscsi_conn_send_pdu, .get_stats = iscsi_conn_get_stats, - .init_cmd_task = iscsi_tcp_ctask_init, - .init_mgmt_task = iscsi_tcp_mtask_init, - .xmit_cmd_task = iscsi_tcp_ctask_xmit, - .xmit_mgmt_task = iscsi_tcp_mtask_xmit, - .cleanup_cmd_task = iscsi_tcp_cleanup_ctask, + .init_task = iscsi_tcp_task_init, + .xmit_task = iscsi_tcp_task_xmit, + .cleanup_task = iscsi_tcp_cleanup_task, /* recovery */ .session_recovery_timedout = iscsi_session_recovery_timedout, };
drivers/scsi/iscsi_tcp.h +0 -5
@@ -103,11 +103,6 @@ struct iscsi_data_task {char hdrext[ISCSI_DIGEST_SIZE ];/* Header-Digest */ }; -struct iscsi_tcp_mgmt_task { -struct iscsi_hdr hdr; -char hdrext[ISCSI_DIGEST_SIZE ];/* Header-Digest */ -}; -struct iscsi_r2t_info {__be32 ttt;/* copied from R2T */ __be32 exp_statsn;/* copied from R2T */
Signature · 1 line
1.5.4.1
PATCH 13/25 iser: convert ib_iser to support merged tasks
From: Mike Christie <[email protected]>
Convert ib_iser to support merged tasks.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 82 +++++++++++++------------- drivers/infiniband/ulp/iser/iscsi_iser.h | 14 ++-- drivers/infiniband/ulp/iser/iser_initiator.c | 42 ++++++------- 3 files changed, 68 insertions(+), 70 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +42 -40
@@ -124,15 +124,23 @@ error:/** -* iscsi_iser_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands +* iscsi_iser_task_init - Initialize ctask +* @ctask: iscsi ctask * -**/ +* Initialize the ctask for the scsi command or mgmt command. +*/ static int -iscsi_iser_cmd_init (struct iscsi_cmd_task *ctask) +iscsi_iser_task_init (struct iscsi_cmd_task *ctask) { -struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data; +struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data;struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; +/* mgmt ctask */ +if (!ctask->sc) { + iser_ctask->desc.data = ctask->data; +return 0 ; + } + iser_ctask->command_sent =0 ; iser_ctask->iser_conn = iser_conn;iser_ctask_rdma_init (iser_ctask);
@@ -140,9 +148,9 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask) }/** -* iscsi_mtask_xmit - xmit management(immediate) task +* iscsi_iser_mtask_xmit - xmit management(immediate) ctask * @conn: iscsi connection -* @mtask: task management task +* @ctask: ctask management ctask * * Notes: * The function can return -EAGAIN in which case caller must
@@ -151,20 +159,19 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask)* **/ static int -iscsi_iser_mtask_xmit (struct iscsi_conn *conn, -struct iscsi_mgmt_task *mtask) +iscsi_iser_mtask_xmit (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) {int error =0 ; -debug_scsi ("mtask deq [cid %d itt 0x%x]\n" , conn->id, mtask->itt); +debug_scsi ("ctask deq [cid %d itt 0x%x]\n" , conn->id, ctask->itt); - error =iser_send_control (conn, mtask); + error =iser_send_control (conn, ctask); -/* since iser xmits control with zero copy, mtasks can not be recycled +/* since iser xmits control with zero copy, ctasks can not be recycled * right after sending them. * The recycling scheme is based on whether a response is expected -* - if yes, the mtask is recycled at iscsi_complete_pdu -* - if no, the mtask is recycled at iser_snd_completion +* - if yes, the ctask is recycled at iscsi_complete_pdu +* - if no, the ctask is recycled at iser_snd_completion */ if (error && error != -ENOBUFS )iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED );
@@ -173,7 +180,7 @@ iscsi_iser_mtask_xmit(struct iscsi_conn *conn, }static int -iscsi_iser_ctask_xmit_unsol_data (struct iscsi_conn *conn, +iscsi_iser_task_xmit_unsol_data (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) {struct iscsi_data hdr;
@@ -190,24 +197,27 @@ iscsi_iser_ctask_xmit_unsol_data(struct iscsi_conn *conn, error =iser_send_data_out (conn, ctask, &hdr);if (error) { ctask->unsol_datasn--; - goto iscsi_iser_ctask_xmit_unsol_data_exit; + goto iscsi_iser_task_xmit_unsol_data_exit; } ctask->unsol_count -= ctask->data_count;debug_scsi ("Need to send %d more as data-out PDUs\n" , ctask->unsol_count); } -iscsi_iser_ctask_xmit_unsol_data_exit: +iscsi_iser_task_xmit_unsol_data_exit:return error; }static int -iscsi_iser_ctask_xmit (struct iscsi_conn *conn, -struct iscsi_cmd_task *ctask) +iscsi_iser_task_xmit (struct iscsi_cmd_task *ctask) { +struct iscsi_conn *conn = ctask->conn;struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;int error =0 ; +if (!ctask->sc) +return iscsi_iser_mtask_xmit (conn, ctask); +if (ctask->sc->sc_data_direction ==DMA_TO_DEVICE ) {BUG_ON (scsi_bufflen (ctask->sc) ==0 );
@@ -223,25 +233,29 @@ iscsi_iser_ctask_xmit(struct iscsi_conn *conn,if (!iser_ctask->command_sent) { error =iser_send_command (conn, ctask);if (error) - goto iscsi_iser_ctask_xmit_exit; + goto iscsi_iser_task_xmit_exit; iser_ctask->command_sent =1 ; }/* Send unsolicited data-out PDU(s) if necessary */ if (ctask->unsol_count) - error =iscsi_iser_ctask_xmit_unsol_data (conn, ctask); + error =iscsi_iser_task_xmit_unsol_data (conn, ctask); - iscsi_iser_ctask_xmit_exit: + iscsi_iser_task_xmit_exit:if (error && error != -ENOBUFS )iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED );return error; }static void -iscsi_iser_cleanup_ctask (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) +iscsi_iser_cleanup_task (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) {struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; +/* mgmt tasks do not need special cleanup */ +if (!ctask->sc) +return ; +if (iser_ctask->status ==ISER_TASK_STATUS_STARTED ) { iser_ctask->status =ISER_TASK_STATUS_COMPLETED ;iser_ctask_rdma_finalize (iser_ctask);
@@ -394,10 +408,8 @@ iscsi_iser_session_create(struct Scsi_Host *shost,struct iscsi_cls_session *cls_session;struct iscsi_session *session;int i; -struct iscsi_cmd_task *ctask; -struct iscsi_mgmt_task *mtask; +struct iscsi_cmd_task *ctask;struct iscsi_iser_cmd_task *iser_ctask; -struct iser_desc *desc;if (shost) { printk(KERN_ERR "iscsi_tcp: invalid shost %d.\n",
@@ -425,28 +437,19 @@ iscsi_iser_session_create(struct Scsi_Host *shost, cls_session =iscsi_session_setup (&iscsi_iser_transport, shost,ISCSI_DEF_XMIT_CMDS_MAX ,sizeof (struct iscsi_iser_cmd_task ), -sizeof (struct iser_desc ), initial_cmdsn);if (!cls_session) goto remove_host; session = cls_session->dd_data; - shost->can_queue = session->cmds_max; + shost->can_queue = session->scsi_cmds_max;/* libiscsi setup itts, data and pool so just set desc fields */ for (i =0 ; i < session->cmds_max; i++) { - ctask = session->cmds[i]; + ctask = session->cmds[i]; iser_ctask = ctask->dd_data; ctask->hdr = (struct iscsi_cmd *)&iser_ctask->desc.iscsi_header; ctask->hdr_max =sizeof (iser_ctask->desc.iscsi_header); } - -for (i =0 ; i < session->mgmtpool_max; i++) { - mtask = session->mgmt_cmds[i]; - desc = mtask->dd_data; - mtask->hdr = &desc->iscsi_header; - desc->data = mtask->data; - } -return cls_session; remove_host:
@@ -659,10 +662,9 @@ static struct iscsi_transport iscsi_iser_transport = {/* IO */ .send_pdu = iscsi_conn_send_pdu, .get_stats = iscsi_iser_conn_get_stats, - .init_cmd_task = iscsi_iser_cmd_init, - .xmit_cmd_task = iscsi_iser_ctask_xmit, - .xmit_mgmt_task = iscsi_iser_mtask_xmit, - .cleanup_cmd_task = iscsi_iser_cleanup_ctask, + .init_task = iscsi_iser_task_init, + .xmit_task = iscsi_iser_task_xmit, + .cleanup_task = iscsi_iser_cleanup_task,/* recovery */ .session_recovery_timedout = iscsi_session_recovery_timedout,
drivers/infiniband/ulp/iser/iscsi_iser.h +7 -7
@@ -298,15 +298,15 @@ extern int iser_debug_level;/* allocate connection resources needed for rdma functionality */ int iser_conn_set_full_featured_mode (struct iscsi_conn *conn); -int iser_send_control (struct iscsi_conn *conn, -struct iscsi_mgmt_task *mtask); +int iser_send_control (struct iscsi_conn *conn, +struct iscsi_cmd_task *ctask); -int iser_send_command (struct iscsi_conn *conn, -struct iscsi_cmd_task *ctask); +int iser_send_command (struct iscsi_conn *conn, +struct iscsi_cmd_task *ctask); -int iser_send_data_out (struct iscsi_conn *conn, +int iser_send_data_out (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask, -struct iscsi_data *hdr); +struct iscsi_data *hdr); void iscsi_iser_recv(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
@@ -326,7 +326,7 @@ void iser_rcv_completion(struct iser_desc *desc,void iser_snd_completion (struct iser_desc *desc); -void iser_ctask_rdma_init (struct iscsi_iser_cmd_task *ctask); +void iser_ctask_rdma_init (struct iscsi_iser_cmd_task *ctask);void iser_ctask_rdma_finalize (struct iscsi_iser_cmd_task *ctask);
drivers/infiniband/ulp/iser/iser_initiator.c +19 -23
120 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 14/25 libiscsi: rename iscsi_cmd_task to iscsi_task
From: Mike Christie <[email protected]>
This is the second part of the iscsi task merging, and all it does it rename iscsi_cmd_task to iscsi_task and mtask/ctask to just task.
--- drivers/scsi/libiscsi.c | 514 ++++++++++++++++++----------------- include/scsi/libiscsi.h | 22 +- include/scsi/scsi_transport_iscsi.h | 8 +- 3 files changed, 273 insertions(+), 271 deletions(-)
drivers/scsi/libiscsi.c +258 -256
@@ -88,61 +88,61 @@ iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr) }EXPORT_SYMBOL_GPL (iscsi_update_cmdsn); -void iscsi_prep_unsolicit_data_pdu (struct iscsi_cmd_task *ctask, +void iscsi_prep_unsolicit_data_pdu (struct iscsi_task *task,struct iscsi_data *hdr) { -struct iscsi_conn *conn = ctask->conn; +struct iscsi_conn *conn = task->conn;memset (hdr,0 ,sizeof (struct iscsi_data )); hdr->ttt =cpu_to_be32 (ISCSI_RESERVED_TAG ); - hdr->datasn =cpu_to_be32 (ctask->unsol_datasn); - ctask->unsol_datasn++; + hdr->datasn =cpu_to_be32 (task->unsol_datasn); + task->unsol_datasn++; hdr->opcode =ISCSI_OP_SCSI_DATA_OUT ; -memcpy (hdr->lun, ctask->hdr->lun,sizeof (hdr->lun)); +memcpy (hdr->lun, task->hdr->lun,sizeof (hdr->lun)); - hdr->itt = ctask->hdr->itt; + hdr->itt = task->hdr->itt; hdr->exp_statsn =cpu_to_be32 (conn->exp_statsn); - hdr->offset =cpu_to_be32 (ctask->unsol_offset); + hdr->offset =cpu_to_be32 (task->unsol_offset); -if (ctask->unsol_count > conn->max_xmit_dlength) { +if (task->unsol_count > conn->max_xmit_dlength) {hton24 (hdr->dlength, conn->max_xmit_dlength); - ctask->data_count = conn->max_xmit_dlength; - ctask->unsol_offset += ctask->data_count; + task->data_count = conn->max_xmit_dlength; + task->unsol_offset += task->data_count; hdr->flags =0 ; }else { -hton24 (hdr->dlength, ctask->unsol_count); - ctask->data_count = ctask->unsol_count; +hton24 (hdr->dlength, task->unsol_count); + task->data_count = task->unsol_count; hdr->flags =ISCSI_FLAG_CMD_FINAL ; } }EXPORT_SYMBOL_GPL (iscsi_prep_unsolicit_data_pdu); -static int iscsi_add_hdr (struct iscsi_cmd_task *ctask,unsigned len) +static int iscsi_add_hdr (struct iscsi_task *task,unsigned len) { -unsigned exp_len = ctask->hdr_len + len; +unsigned exp_len = task->hdr_len + len; -if (exp_len > ctask->hdr_max) { +if (exp_len > task->hdr_max) {WARN_ON (1 );return -EINVAL ; }WARN_ON (len & (ISCSI_PAD_LEN -1 ));/* caller must pad the AHS */ - ctask->hdr_len = exp_len; + task->hdr_len = exp_len;return 0 ; }/* * make an extended cdb AHS */ -static int iscsi_prep_ecdb_ahs (struct iscsi_cmd_task *ctask) +static int iscsi_prep_ecdb_ahs (struct iscsi_task *task) { -struct scsi_cmnd *cmd = ctask->sc; +struct scsi_cmnd *cmd = task->sc;unsigned rlen, pad_len;unsigned short ahslength;struct iscsi_ecdb_ahdr *ecdb_ahdr;int rc; - ecdb_ahdr =iscsi_next_hdr (ctask); + ecdb_ahdr =iscsi_next_hdr (task); rlen = cmd->cmd_len -ISCSI_CDB_SIZE ;BUG_ON (rlen >sizeof (ecdb_ahdr->ecdb));
@@ -150,7 +150,7 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_cmd_task *ctask) pad_len =iscsi_padding (rlen); - rc =iscsi_add_hdr (ctask,sizeof (ecdb_ahdr->ahslength) + + rc =iscsi_add_hdr (task,sizeof (ecdb_ahdr->ahslength) +sizeof (ecdb_ahdr->ahstype) + ahslength + pad_len);if (rc)return rc;
@@ -165,19 +165,19 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_cmd_task *ctask)debug_scsi ("iscsi_prep_ecdb_ahs: varlen_cdb_len %d " "rlen %d pad_len %d ahs_length %d iscsi_headers_size %u\n" , - cmd->cmd_len, rlen, pad_len, ahslength, ctask->hdr_len); + cmd->cmd_len, rlen, pad_len, ahslength, task->hdr_len);return 0 ; } -static int iscsi_prep_bidi_ahs (struct iscsi_cmd_task *ctask) +static int iscsi_prep_bidi_ahs (struct iscsi_task *task) { -struct scsi_cmnd *sc = ctask->sc; +struct scsi_cmnd *sc = task->sc;struct iscsi_rlength_ahdr *rlen_ahdr;int rc; - rlen_ahdr =iscsi_next_hdr (ctask); - rc =iscsi_add_hdr (ctask,sizeof (*rlen_ahdr)); + rlen_ahdr =iscsi_next_hdr (task); + rc =iscsi_add_hdr (task,sizeof (*rlen_ahdr));if (rc)return rc;
@@ -197,28 +197,28 @@ static int iscsi_prep_bidi_ahs(struct iscsi_cmd_task *ctask)/** * iscsi_prep_scsi_cmd_pdu - prep iscsi scsi cmd pdu -* @ctask: iscsi task +* @task: iscsi task * * Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set * fields like dlength or final based on how much data it sends */ -static int iscsi_prep_scsi_cmd_pdu (struct iscsi_cmd_task *ctask) +static int iscsi_prep_scsi_cmd_pdu (struct iscsi_task *task) { -struct iscsi_conn *conn = ctask->conn; +struct iscsi_conn *conn = task->conn;struct iscsi_session *session = conn->session; -struct iscsi_cmd *hdr = ctask->hdr; -struct scsi_cmnd *sc = ctask->sc; +struct iscsi_cmd *hdr = task->hdr; +struct scsi_cmnd *sc = task->sc;unsigned hdrlength, cmd_len;int rc; - ctask->hdr_len =0 ; - rc =iscsi_add_hdr (ctask,sizeof (*hdr)); + task->hdr_len =0 ; + rc =iscsi_add_hdr (task,sizeof (*hdr));if (rc)return rc; hdr->opcode =ISCSI_OP_SCSI_CMD ; hdr->flags =ISCSI_ATTR_SIMPLE ;int_to_scsilun (sc->device->lun, (struct scsi_lun *)hdr->lun); - hdr->itt =build_itt (ctask->itt, session->age); + hdr->itt =build_itt (task->itt, session->age); hdr->cmdsn =cpu_to_be32 (session->cmdsn); session->cmdsn++; hdr->exp_statsn =cpu_to_be32 (conn->exp_statsn);
@@ -226,17 +226,17 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)if (cmd_len <ISCSI_CDB_SIZE )memset (&hdr->cdb[cmd_len],0 ,ISCSI_CDB_SIZE - cmd_len);else if (cmd_len >ISCSI_CDB_SIZE ) { - rc =iscsi_prep_ecdb_ahs (ctask); + rc =iscsi_prep_ecdb_ahs (task);if (rc)return rc; cmd_len =ISCSI_CDB_SIZE ; }memcpy (hdr->cdb, sc->cmnd, cmd_len); - ctask->imm_count =0 ; + task->imm_count =0 ;if (scsi_bidi_cmnd (sc)) { hdr->flags |=ISCSI_FLAG_CMD_READ ; - rc =iscsi_prep_bidi_ahs (ctask); + rc =iscsi_prep_bidi_ahs (task);if (rc)return rc; }
@@ -258,28 +258,28 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)* * pad_count bytes to be sent as zero-padding */ - ctask->unsol_count =0 ; - ctask->unsol_offset =0 ; - ctask->unsol_datasn =0 ; + task->unsol_count =0 ; + task->unsol_offset =0 ; + task->unsol_datasn =0 ;if (session->imm_data_en) {if (out_len >= session->first_burst) - ctask->imm_count =min (session->first_burst, + task->imm_count =min (session->first_burst, conn->max_xmit_dlength);else - ctask->imm_count =min (out_len, + task->imm_count =min (out_len, conn->max_xmit_dlength); -hton24 (hdr->dlength, ctask->imm_count); +hton24 (hdr->dlength, task->imm_count); }else zero_data (hdr->dlength);if (!session->initial_r2t_en) { - ctask->unsol_count =min (session->first_burst, out_len) - - ctask->imm_count; - ctask->unsol_offset = ctask->imm_count; + task->unsol_count =min (session->first_burst, out_len) + - task->imm_count; + task->unsol_offset = task->imm_count; } -if (!ctask->unsol_count) +if (!task->unsol_count)/* No unsolicit Data-Out's */ hdr->flags |=ISCSI_FLAG_CMD_FINAL ; }else {
@@ -292,7 +292,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) }/* calculate size of additional header segments (AHSs) */ - hdrlength = ctask->hdr_len -sizeof (*hdr); + hdrlength = task->hdr_len -sizeof (*hdr);WARN_ON (hdrlength & (ISCSI_PAD_LEN -1 )); hdrlength /=ISCSI_PAD_LEN ;
@@ -301,17 +301,17 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) hdr->hlength = hdrlength &0xFF ;if (conn->session->tt->init_task && - conn->session->tt->init_task (ctask)) + conn->session->tt->init_task (task))return -EIO ; - ctask->state =ISCSI_TASK_RUNNING ; -list_move_tail (&ctask->running, &conn->run_list); + task->state =ISCSI_TASK_RUNNING ; +list_move_tail (&task->running, &conn->run_list); conn->scsicmd_pdus_cnt++;debug_scsi ("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d " "bidi_len %d cmdsn %d win %d]\n" ,scsi_bidi_cmnd (sc) ?"bidirectional" : sc->sc_data_direction ==DMA_TO_DEVICE ? -"write" :"read" , conn->id, sc, sc->cmnd[0 ], ctask->itt, +"write" :"read" , conn->id, sc, sc->cmnd[0 ], task->itt,scsi_bufflen (sc),scsi_bidi_cmnd (sc) ?scsi_in (sc)->length :0 , session->cmdsn, session->max_cmdsn - session->exp_cmdsn +1 );
@@ -320,37 +320,37 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)/** * iscsi_complete_command - finish a task -* @ctask: iscsi cmd task +* @task: iscsi cmd task * * Must be called with session lock. * This function returns the scsi command to scsi-ml or cleans * up mgmt tasks then returns the task to the pool. */ -static void iscsi_complete_command (struct iscsi_cmd_task *ctask) +static void iscsi_complete_command (struct iscsi_task *task) { -struct iscsi_conn *conn = ctask->conn; +struct iscsi_conn *conn = task->conn;struct iscsi_session *session = conn->session; -struct scsi_cmnd *sc = ctask->sc; +struct scsi_cmnd *sc = task->sc; -list_del_init (&ctask->running); - ctask->state =ISCSI_TASK_COMPLETED ; - ctask->sc =NULL ; +list_del_init (&task->running); + task->state =ISCSI_TASK_COMPLETED ; + task->sc =NULL ; -if (conn->ctask == ctask) - conn->ctask =NULL ; +if (conn->task == task) + conn->task =NULL ;/* -* login ctask is preallocated so do not free +* login task is preallocated so do not free */ -if (conn->login_ctask == ctask) +if (conn->login_task == task)return ; -__kfifo_put (session->cmdpool.queue, (void *)&ctask,sizeof (void *)); +__kfifo_put (session->cmdpool.queue, (void *)&task,sizeof (void *)); -if (conn->ping_ctask == ctask) - conn->ping_ctask =NULL ; +if (conn->ping_task == task) + conn->ping_task =NULL ;if (sc) { - ctask->sc =NULL ; + task->sc =NULL ;/* SCSI eh reuses commands to verify us */ sc->SCp.ptr =NULL ;/*
@@ -362,47 +362,47 @@ static void iscsi_complete_command(struct iscsi_cmd_task *ctask) } } -static void __iscsi_get_ctask (struct iscsi_cmd_task *ctask) +static void __iscsi_get_task (struct iscsi_task *task) { -atomic_inc (&ctask->refcount); +atomic_inc (&task->refcount); } -static void __iscsi_put_ctask (struct iscsi_cmd_task *ctask) +static void __iscsi_put_task (struct iscsi_task *task) { -if (atomic_dec_and_test (&ctask->refcount)) -iscsi_complete_command (ctask); +if (atomic_dec_and_test (&task->refcount)) +iscsi_complete_command (task); } -void iscsi_put_ctask (struct iscsi_cmd_task *ctask) +void iscsi_put_task (struct iscsi_task *task) { -struct iscsi_session *session = ctask->conn->session; +struct iscsi_session *session = task->conn->session;spin_lock_bh (&session->lock); -__iscsi_put_ctask (ctask); +__iscsi_put_task (task);spin_unlock_bh (&session->lock); } -EXPORT_SYMBOL_GPL (iscsi_put_ctask); +EXPORT_SYMBOL_GPL (iscsi_put_task);/* * session lock must be held */ -static void fail_command (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask, +static void fail_command (struct iscsi_conn *conn,struct iscsi_task *task,int err) {struct scsi_cmnd *sc; - sc = ctask->sc; + sc = task->sc;if (!sc)return ; -if (ctask->state ==ISCSI_TASK_PENDING ) +if (task->state ==ISCSI_TASK_PENDING )/* * cmd never made it to the xmit thread, so we should not count * the cmd in the sequencing */ conn->session->queued_cmdsn--;else - conn->session->tt->cleanup_task (conn, ctask); + conn->session->tt->cleanup_task (conn, task); sc->result = err;
@@ -413,17 +413,17 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,scsi_in (sc)->resid =scsi_in (sc)->length; } -if (conn->ctask == ctask) - conn->ctask =NULL ; +if (conn->task == task) + conn->task =NULL ;/* release ref from queuecommand */ -__iscsi_put_ctask (ctask); +__iscsi_put_task (task); }static int iscsi_prep_mgmt_task (struct iscsi_conn *conn, -struct iscsi_cmd_task *ctask) +struct iscsi_task *task) {struct iscsi_session *session = conn->session; -struct iscsi_hdr *hdr = (struct iscsi_hdr *)ctask->hdr; +struct iscsi_hdr *hdr = (struct iscsi_hdr *)task->hdr;struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr;if (conn->session->state ==ISCSI_STATE_LOGGING_OUT )
@@ -437,7 +437,7 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,*/ nop->cmdsn =cpu_to_be32 (session->cmdsn);if (hdr->itt !=RESERVED_ITT ) { - hdr->itt =build_itt (ctask->itt, session->age); + hdr->itt =build_itt (task->itt, session->age);/* * TODO: We always use immediate, so we never hit this. * If we start to send tmfs or nops as non-immediate then
@@ -451,24 +451,24 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, }if (session->tt->init_task) - session->tt->init_task (ctask); + session->tt->init_task (task);if ((hdr->opcode &ISCSI_OPCODE_MASK ) ==ISCSI_OP_LOGOUT ) session->state =ISCSI_STATE_LOGGING_OUT ; -list_move_tail (&ctask->running, &conn->mgmt_run_list); +list_move_tail (&task->running, &conn->mgmt_run_list);debug_scsi ("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n" , hdr->opcode &ISCSI_OPCODE_MASK , hdr->itt, - ctask->data_count); + task->data_count);return 0 ; } -static struct iscsi_cmd_task * +static struct iscsi_task *__iscsi_conn_send_pdu (struct iscsi_conn *conn,struct iscsi_hdr *hdr,char *data,uint32_t data_size) {struct iscsi_session *session = conn->session; -struct iscsi_cmd_task *ctask; +struct iscsi_task *task;if (session->state ==ISCSI_STATE_TERMINATE )return NULL ;
@@ -481,18 +481,18 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,* Same task can be used. Same ITT must be used. * Note that login_task is preallocated at conn_create(). */ - ctask = conn->login_ctask; + task = conn->login_task; else {BUG_ON (conn->c_stage ==ISCSI_CONN_INITIAL_STAGE );BUG_ON (conn->c_stage ==ISCSI_CONN_STOPPED );if (!__kfifo_get (session->cmdpool.queue, - (void *)&ctask,sizeof (void *))) + (void *)&task,sizeof (void *)))return NULL ;if ((hdr->opcode == (ISCSI_OP_NOOP_OUT |ISCSI_OP_IMMEDIATE )) && hdr->ttt ==RESERVED_ITT ) { - conn->ping_ctask = ctask; + conn->ping_task = task; conn->last_ping = jiffies; } }
@@ -501,33 +501,33 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,* released by the lld when it has transmitted the task for * pdus we do not expect a response for. */ -atomic_set (&ctask->refcount,1 ); - ctask->conn = conn; - ctask->sc =NULL ; +atomic_set (&task->refcount,1 ); + task->conn = conn; + task->sc =NULL ;if (data_size) { -memcpy (ctask->data, data, data_size); - ctask->data_count = data_size; +memcpy (task->data, data, data_size); + task->data_count = data_size; }else - ctask->data_count =0 ; + task->data_count =0 ; -memcpy (ctask->hdr, hdr,sizeof (struct iscsi_hdr )); -INIT_LIST_HEAD (&ctask->running); -list_add_tail (&ctask->running, &conn->mgmtqueue); +memcpy (task->hdr, hdr,sizeof (struct iscsi_hdr )); +INIT_LIST_HEAD (&task->running); +list_add_tail (&task->running, &conn->mgmtqueue);if (session->tt->caps &CAP_DATA_PATH_OFFLOAD ) { -if (iscsi_prep_mgmt_task (conn, ctask)) { -__iscsi_put_ctask (ctask); +if (iscsi_prep_mgmt_task (conn, task)) { +__iscsi_put_task (task);return NULL ; } -if (session->tt->xmit_task (ctask)) - ctask =NULL ; +if (session->tt->xmit_task (task)) + task =NULL ; }else scsi_queue_work (conn->session->host, &conn->xmitwork); -return ctask; +return task; } int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
@@ -549,20 +549,20 @@ EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);* iscsi_cmd_rsp - SCSI Command Response processing * @conn: iscsi connection * @hdr: iscsi header -* @ctask: scsi command task +* @task: scsi command task * @data: cmd data buffer * @datalen: len of buffer * * iscsi_cmd_rsp sets up the scsi_cmnd fields based on the PDU and -* then completes the command and ctask. +* then completes the command and task. **/ static void iscsi_scsi_cmd_rsp (struct iscsi_conn *conn,struct iscsi_hdr *hdr, -struct iscsi_cmd_task *ctask,char *data, +struct iscsi_task *task,char *data,int datalen) {struct iscsi_cmd_rsp *rhdr = (struct iscsi_cmd_rsp *)hdr;struct iscsi_session *session = conn->session; -struct scsi_cmnd *sc = ctask->sc; +struct scsi_cmnd *sc = task->sc;iscsi_update_cmdsn (session, (struct iscsi_nopin *)rhdr); conn->exp_statsn =be32_to_cpu (rhdr->statsn) +1 ;
@@ -622,10 +622,10 @@ invalid_datalen: } out:debug_scsi ("done [sc %lx res %d itt 0x%x]\n" , - (long )sc, sc->result, ctask->itt); + (long )sc, sc->result, task->itt); conn->scsirsp_pdus_cnt++; -__iscsi_put_ctask (ctask); +__iscsi_put_task (task); }static void iscsi_tmf_rsp (struct iscsi_conn *conn,struct iscsi_hdr *hdr)
@@ -650,9 +650,9 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)static void iscsi_send_nopout (struct iscsi_conn *conn,struct iscsi_nopin *rhdr) {struct iscsi_nopout hdr; -struct iscsi_cmd_task *ctask; +struct iscsi_task *task; -if (!rhdr && conn->ping_ctask) +if (!rhdr && conn->ping_task)return ;memset (&hdr,0 ,sizeof (struct iscsi_nopout ));
@@ -666,8 +666,8 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) }else hdr.ttt =RESERVED_ITT ; - ctask =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)&hdr,NULL ,0 ); -if (!ctask) + task =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)&hdr,NULL ,0 ); +if (!task)iscsi_conn_printk (KERN_ERR , conn,"Could not send nopout\n" ); }
@@ -712,7 +712,7 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, {struct iscsi_session *session = conn->session;int opcode = hdr->opcode &ISCSI_OPCODE_MASK , rc =0 ; -struct iscsi_cmd_task *ctask; +struct iscsi_task *task;uint32_t itt; conn->last_recv = jiffies;
@@ -758,27 +758,27 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, goto out; } - ctask = session->cmds[itt]; + task = session->cmds[itt];switch (opcode) {case ISCSI_OP_SCSI_CMD_RSP : -if (!ctask->sc) { +if (!task->sc) { rc =ISCSI_ERR_NO_SCSI_CMD ;break ; } -BUG_ON ((void *)ctask != ctask->sc->SCp.ptr); -iscsi_scsi_cmd_rsp (conn, hdr, ctask, data, datalen); +BUG_ON ((void *)task != task->sc->SCp.ptr); +iscsi_scsi_cmd_rsp (conn, hdr, task, data, datalen);break ;case ISCSI_OP_SCSI_DATA_IN : -if (!ctask->sc) { +if (!task->sc) { rc =ISCSI_ERR_NO_SCSI_CMD ;break ; } -BUG_ON ((void *)ctask != ctask->sc->SCp.ptr); +BUG_ON ((void *)task != task->sc->SCp.ptr);if (hdr->flags &ISCSI_FLAG_DATA_STATUS ) { conn->scsirsp_pdus_cnt++;iscsi_update_cmdsn (session, (struct iscsi_nopin *) hdr); -__iscsi_put_ctask (ctask); +__iscsi_put_task (task); }break ;case ISCSI_OP_R2T :
@@ -808,7 +808,7 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, }iscsi_tmf_rsp (conn, hdr); -__iscsi_put_ctask (ctask); +__iscsi_put_task (task);break ;case ISCSI_OP_NOOP_IN :iscsi_update_cmdsn (session, (struct iscsi_nopin *)hdr);
@@ -818,13 +818,15 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, } conn->exp_statsn =be32_to_cpu (hdr->statsn) +1 ; -if (conn->ping_ctask != ctask) +if (conn->ping_task != task)/* * If this is not in response to one of our * nops then it must be from userspace. */ goto recv_pdu; -__iscsi_put_ctask (ctask); + +mod_timer (&conn->transport_timer, jiffies + conn->recv_timeout); +__iscsi_put_task (task);break ;default : rc =ISCSI_ERR_BAD_OPCODE ;
@@ -836,7 +838,7 @@ out: recv_pdu:if (iscsi_recv_pdu (conn->cls_conn, hdr, data, datalen)) rc =ISCSI_ERR_CONN_FAILED ; -__iscsi_put_ctask (ctask); +__iscsi_put_task (task);return rc; }
@@ -855,7 +857,7 @@ EXPORT_SYMBOL_GPL(iscsi_complete_pdu);int iscsi_verify_itt (struct iscsi_conn *conn,itt_t itt) {struct iscsi_session *session = conn->session; -struct iscsi_cmd_task *ctask; +struct iscsi_task *task;uint32_t i;if (itt ==RESERVED_ITT )
@@ -878,11 +880,11 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)return ISCSI_ERR_BAD_ITT ; } - ctask = session->cmds[i]; -if (ctask->sc && ctask->sc->SCp.phase != session->age) { + task = session->cmds[i]; +if (task->sc && task->sc->SCp.phase != session->age) {iscsi_conn_printk (KERN_ERR , conn, -"iscsi: ctask's session age %d, " -"expected %d\n" , ctask->sc->SCp.phase, +"iscsi: task's session age %d, " +"expected %d\n" , task->sc->SCp.phase, session->age);return ISCSI_ERR_SESSION_FAILED ; }
@@ -890,11 +892,11 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) }EXPORT_SYMBOL_GPL (iscsi_verify_itt); -struct iscsi_cmd_task * +struct iscsi_task *iscsi_itt_to_ctask (struct iscsi_conn *conn,itt_t itt) {struct iscsi_session *session = conn->session; -struct iscsi_cmd_task *ctask; +struct iscsi_task *task;uint32_t i;if (iscsi_verify_itt (conn, itt))
@@ -907,14 +909,14 @@ iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt)if (i >= session->cmds_max)return NULL ; - ctask = session->cmds[i]; -if (!ctask->sc) + task = session->cmds[i]; +if (!task->sc)return NULL ; -if (ctask->sc->SCp.phase != session->age) +if (task->sc->SCp.phase != session->age)return NULL ; -return ctask; +return task; }EXPORT_SYMBOL_GPL (iscsi_itt_to_ctask);
@@ -955,38 +957,38 @@ static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn)return 0 ; } -static int iscsi_xmit_ctask (struct iscsi_conn *conn) +static int iscsi_xmit_task (struct iscsi_conn *conn) { -struct iscsi_cmd_task *ctask = conn->ctask; +struct iscsi_task *task = conn->task;int rc; -__iscsi_get_ctask (ctask); +__iscsi_get_task (task);spin_unlock_bh (&conn->session->lock); - rc = conn->session->tt->xmit_task (ctask); + rc = conn->session->tt->xmit_task (task);spin_lock_bh (&conn->session->lock); -__iscsi_put_ctask (ctask); +__iscsi_put_task (task);if (!rc) -/* done with this ctask */ - conn->ctask =NULL ; +/* done with this task */ + conn->task =NULL ;return rc; }/** -* iscsi_requeue_ctask - requeue ctask to run from session workqueue -* @ctask: ctask to requeue +* iscsi_requeue_task - requeue task to run from session workqueue +* @task: task to requeue * -* LLDs that need to run a ctask from the session workqueue should call +* LLDs that need to run a task from the session workqueue should call * this. The session lock must be held. This should only be called * by software drivers. */ -void iscsi_requeue_ctask (struct iscsi_cmd_task *ctask) +void iscsi_requeue_task (struct iscsi_task *task) { -struct iscsi_conn *conn = ctask->conn; +struct iscsi_conn *conn = task->conn; -list_move_tail (&ctask->running, &conn->requeue); +list_move_tail (&task->running, &conn->requeue);scsi_queue_work (conn->session->host, &conn->xmitwork); } -EXPORT_SYMBOL_GPL (iscsi_requeue_ctask); +EXPORT_SYMBOL_GPL (iscsi_requeue_task);/** * iscsi_data_xmit - xmit any command into the scheduled connection
@@ -1008,8 +1010,8 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)return -ENODATA ; } -if (conn->ctask) { - rc =iscsi_xmit_ctask (conn); +if (conn->task) { + rc =iscsi_xmit_task (conn);if (rc) goto again; }
@@ -1021,14 +1023,14 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)*/ check_mgmt:while (!list_empty (&conn->mgmtqueue)) { - conn->ctask =list_entry (conn->mgmtqueue.next, - struct iscsi_cmd_task, running); -if (iscsi_prep_mgmt_task (conn, conn->ctask)) { -__iscsi_put_ctask (conn->ctask); - conn->ctask =NULL ; + conn->task =list_entry (conn->mgmtqueue.next, + struct iscsi_task, running); +if (iscsi_prep_mgmt_task (conn, conn->task)) { +__iscsi_put_task (conn->task); + conn->task =NULL ;continue ; } - rc =iscsi_xmit_ctask (conn); + rc =iscsi_xmit_task (conn);if (rc) goto again; }
@@ -1038,21 +1040,21 @@ check_mgmt:if (conn->tmf_state ==TMF_QUEUED )break ; - conn->ctask =list_entry (conn->xmitqueue.next, - struct iscsi_cmd_task, running); + conn->task =list_entry (conn->xmitqueue.next, + struct iscsi_task, running);if (conn->session->state ==ISCSI_STATE_LOGGING_OUT ) { -fail_command (conn, conn->ctask,DID_IMM_RETRY <<16 ); +fail_command (conn, conn->task,DID_IMM_RETRY <<16 );continue ; } -if (iscsi_prep_scsi_cmd_pdu (conn->ctask)) { -fail_command (conn, conn->ctask,DID_ABORT <<16 ); +if (iscsi_prep_scsi_cmd_pdu (conn->task)) { +fail_command (conn, conn->task,DID_ABORT <<16 );continue ; } - rc =iscsi_xmit_ctask (conn); + rc =iscsi_xmit_task (conn);if (rc) goto again;/* -* we could continuously get new ctask requests so +* we could continuously get new task requests so * we need to check the mgmt queue for nops that need to * be sent to aviod starvation */
@@ -1070,11 +1072,11 @@ check_mgmt:if (conn->session->state ==ISCSI_STATE_LOGGING_OUT )break ; - conn->ctask =list_entry (conn->requeue.next, - struct iscsi_cmd_task, running); - conn->ctask->state =ISCSI_TASK_RUNNING ; + conn->task =list_entry (conn->requeue.next, + struct iscsi_task, running); + conn->task->state =ISCSI_TASK_RUNNING ;list_move_tail (conn->requeue.next, &conn->run_list); - rc =iscsi_xmit_ctask (conn); + rc =iscsi_xmit_task (conn);if (rc) goto again;if (!list_empty (&conn->mgmtqueue))
@@ -1123,7 +1125,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))int reason =0 ;struct iscsi_session *session;struct iscsi_conn *conn; -struct iscsi_cmd_task *ctask =NULL ; +struct iscsi_task *task =NULL ; sc->scsi_done = done; sc->result =0 ;
@@ -1191,31 +1193,31 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) goto reject; } -if (!__kfifo_get (session->cmdpool.queue, (void *)&ctask, +if (!__kfifo_get (session->cmdpool.queue, (void *)&task,sizeof (void *))) { reason =FAILURE_OOM ; goto reject; } sc->SCp.phase = session->age; - sc->SCp.ptr = (char *)ctask; + sc->SCp.ptr = (char *)task; -atomic_set (&ctask->refcount,1 ); - ctask->state =ISCSI_TASK_PENDING ; - ctask->conn = conn; - ctask->sc = sc; -INIT_LIST_HEAD (&ctask->running); -list_add_tail (&ctask->running, &conn->xmitqueue); +atomic_set (&task->refcount,1 ); + task->state =ISCSI_TASK_PENDING ; + task->conn = conn; + task->sc = sc; +INIT_LIST_HEAD (&task->running); +list_add_tail (&task->running, &conn->xmitqueue);if (session->tt->caps &CAP_DATA_PATH_OFFLOAD ) { -if (iscsi_prep_scsi_cmd_pdu (ctask)) { +if (iscsi_prep_scsi_cmd_pdu (task)) { sc->result =DID_ABORT <<16 ; sc->scsi_done =NULL ; -iscsi_complete_command (ctask); +iscsi_complete_command (task); goto fault; } -if (session->tt->xmit_task (ctask)) { +if (session->tt->xmit_task (task)) { sc->scsi_done =NULL ; -iscsi_complete_command (ctask); +iscsi_complete_command (task); reason =FAILURE_SESSION_NOT_READY ; goto reject; }
@@ -1336,16 +1338,16 @@ static void iscsi_tmf_timedout(unsigned long data)spin_unlock (&session->lock); } -static int iscsi_exec_ctask_mgmt_fn (struct iscsi_conn *conn, +static int iscsi_exec_task_mgmt_fn (struct iscsi_conn *conn,struct iscsi_tm *hdr,int age,int timeout) {struct iscsi_session *session = conn->session; -struct iscsi_cmd_task *ctask; +struct iscsi_task *task; - ctask =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)hdr, + task =__iscsi_conn_send_pdu (conn, (struct iscsi_hdr *)hdr,NULL ,0 ); -if (!ctask) { +if (!task) {spin_unlock_bh (&session->lock);iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED );spin_lock_bh (&session->lock);
@@ -1379,7 +1381,7 @@ static int iscsi_exec_ctask_mgmt_fn(struct iscsi_conn *conn,mutex_lock (&session->eh_mutex);spin_lock_bh (&session->lock); -/* if the session drops it will clean up the ctask */ +/* if the session drops it will clean up the task */ if (age != session->age || session->state !=ISCSI_STATE_LOGGED_IN )return -ENOTCONN ;
@@ -1393,34 +1395,34 @@ static int iscsi_exec_ctask_mgmt_fn(struct iscsi_conn *conn,static void fail_all_commands (struct iscsi_conn *conn,unsigned lun,int error) { -struct iscsi_cmd_task *ctask, *tmp; +struct iscsi_task *task, *tmp; -if (conn->ctask && (conn->ctask->sc->device->lun == lun || lun ==-1 )) - conn->ctask =NULL ; +if (conn->task && (conn->task->sc->device->lun == lun || lun ==-1 )) + conn->task =NULL ;/* flush pending */ -list_for_each_entry_safe (ctask, tmp, &conn->xmitqueue, running) { -if (lun == ctask->sc->device->lun || lun ==-1 ) { +list_for_each_entry_safe (task, tmp, &conn->xmitqueue, running) { +if (lun == task->sc->device->lun || lun ==-1 ) {debug_scsi ("failing pending sc %p itt 0x%x\n" , - ctask->sc, ctask->itt); -fail_command (conn, ctask, error <<16 ); + task->sc, task->itt); +fail_command (conn, task, error <<16 ); } } -list_for_each_entry_safe (ctask, tmp, &conn->requeue, running) { -if (lun == ctask->sc->device->lun || lun ==-1 ) { +list_for_each_entry_safe (task, tmp, &conn->requeue, running) { +if (lun == task->sc->device->lun || lun ==-1 ) {debug_scsi ("failing requeued sc %p itt 0x%x\n" , - ctask->sc, ctask->itt); -fail_command (conn, ctask, error <<16 ); + task->sc, task->itt); +fail_command (conn, task, error <<16 ); } }/* fail all other running */ -list_for_each_entry_safe (ctask, tmp, &conn->run_list, running) { -if (lun == ctask->sc->device->lun || lun ==-1 ) { +list_for_each_entry_safe (task, tmp, &conn->run_list, running) { +if (lun == task->sc->device->lun || lun ==-1 ) {debug_scsi ("failing in progress sc %p itt 0x%x\n" , - ctask->sc, ctask->itt); -fail_command (conn, ctask,DID_BUS_BUSY <<16 ); + task->sc, task->itt); +fail_command (conn, task,DID_BUS_BUSY <<16 ); } } }
@@ -1486,7 +1488,7 @@ static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) jiffies)) rc =EH_RESET_TIMER ;/* if in the middle of checking the transport then give us more time */ -if (conn->ping_ctask) +if (conn->ping_task) rc =EH_RESET_TIMER ; done:spin_unlock (&session->lock);
@@ -1510,7 +1512,7 @@ static void iscsi_check_transport_timeouts(unsigned long data) recv_timeout *=HZ ; last_recv = conn->last_recv; -if (conn->ping_ctask && +if (conn->ping_task &&time_before_eq (conn->last_ping + (conn->ping_timeout *HZ ), jiffies)) { iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs "
@@ -1536,16 +1538,16 @@ done:spin_unlock (&session->lock); } -static void iscsi_prep_abort_ctask_pdu (struct iscsi_cmd_task *ctask, +static void iscsi_prep_abort_task_pdu (struct iscsi_task *task,struct iscsi_tm *hdr) {memset (hdr,0 ,sizeof (*hdr)); hdr->opcode =ISCSI_OP_SCSI_TMFUNC |ISCSI_OP_IMMEDIATE ; hdr->flags =ISCSI_TM_FUNC_ABORT_TASK &ISCSI_FLAG_TM_FUNC_MASK ; hdr->flags |=ISCSI_FLAG_CMD_FINAL ; -memcpy (hdr->lun, ctask->hdr->lun,sizeof (hdr->lun)); - hdr->rtt = ctask->hdr->itt; - hdr->refcmdsn = ctask->hdr->cmdsn; +memcpy (hdr->lun, task->hdr->lun,sizeof (hdr->lun)); + hdr->rtt = task->hdr->itt; + hdr->refcmdsn = task->hdr->cmdsn; }int iscsi_eh_abort (struct scsi_cmnd *sc)
@@ -1553,7 +1555,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)struct iscsi_cls_session *cls_session;struct iscsi_session *session;struct iscsi_conn *conn; -struct iscsi_cmd_task *ctask; +struct iscsi_task *task;struct iscsi_tm *hdr;int rc, age;
@@ -1588,17 +1590,17 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) conn->eh_abort_cnt++; age = session->age; - ctask = (struct iscsi_cmd_task *)sc->SCp.ptr; -debug_scsi ("aborting [sc %p itt 0x%x]\n" , sc, ctask->itt); + task = (struct iscsi_task *)sc->SCp.ptr; +debug_scsi ("aborting [sc %p itt 0x%x]\n" , sc, task->itt); -/* ctask completed before time out */ -if (!ctask->sc) { +/* task completed before time out */ +if (!task->sc) {debug_scsi ("sc completed while abort in progress\n" ); goto success; } -if (ctask->state ==ISCSI_TASK_PENDING ) { -fail_command (conn, ctask,DID_ABORT <<16 ); +if (task->state ==ISCSI_TASK_PENDING ) { +fail_command (conn, task,DID_ABORT <<16 ); goto success; }
@@ -1608,9 +1610,9 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) conn->tmf_state =TMF_QUEUED ; hdr = &conn->tmhdr; -iscsi_prep_abort_ctask_pdu (ctask, hdr); +iscsi_prep_abort_task_pdu (task, hdr); -if (iscsi_exec_ctask_mgmt_fn (conn, hdr, age, session->abort_timeout)) { +if (iscsi_exec_task_mgmt_fn (conn, hdr, age, session->abort_timeout)) { rc =FAILED ; goto failed; }
@@ -1620,11 +1622,11 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)spin_unlock_bh (&session->lock);iscsi_suspend_tx (conn);/* -* clean up ctask if aborted. grab the recv lock as a writer +* clean up task if aborted. grab the recv lock as a writer */ write_lock_bh (conn->recv_lock);spin_lock (&session->lock); -fail_command (conn, ctask,DID_ABORT <<16 ); +fail_command (conn, task,DID_ABORT <<16 ); conn->tmf_state =TMF_INITIAL ;spin_unlock (&session->lock);write_unlock_bh (conn->recv_lock);
@@ -1637,7 +1639,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)case TMF_NOT_FOUND :if (!sc->SCp.ptr) { conn->tmf_state =TMF_INITIAL ; -/* ctask completed before tmf abort response */ +/* task completed before tmf abort response */ debug_scsi ("sc completed while abort in progress\n" ); goto success; }
@@ -1650,7 +1652,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) success:spin_unlock_bh (&session->lock); success_unlocked: -debug_scsi ("abort success [sc %lx itt 0x%x]\n" , (long )sc, ctask->itt); +debug_scsi ("abort success [sc %lx itt 0x%x]\n" , (long )sc, task->itt);mutex_unlock (&session->eh_mutex);return SUCCESS ;
@@ -1658,7 +1660,7 @@ failed:spin_unlock_bh (&session->lock); failed_unlocked:debug_scsi ("abort failed [sc %p itt 0x%x]\n" , sc, - ctask ? ctask->itt :0 ); + task ? task->itt :0 );mutex_unlock (&session->eh_mutex);return FAILED ; }
@@ -1705,7 +1707,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) hdr = &conn->tmhdr;iscsi_prep_lun_reset_pdu (sc, hdr); -if (iscsi_exec_ctask_mgmt_fn (conn, hdr, session->age, +if (iscsi_exec_task_mgmt_fn (conn, hdr, session->age, session->lu_reset_timeout)) { rc =FAILED ; goto unlock;
@@ -1886,7 +1888,7 @@ EXPORT_SYMBOL_GPL(iscsi_host_free);* @iscsit: iscsi transport template * @shost: scsi host * @cmds_max: session can queue -* @cmd_ctask_size: LLD ctask private data size +* @cmd_task_size: LLD task private data size * @initial_cmdsn: initial CmdSN * * This can be used by software iscsi_transports that allocate
@@ -1894,7 +1896,7 @@ EXPORT_SYMBOL_GPL(iscsi_host_free);*/ struct iscsi_cls_session *iscsi_session_setup (struct iscsi_transport *iscsit,struct Scsi_Host *shost, -uint16_t scsi_cmds_max,int cmd_ctask_size, +uint16_t scsi_cmds_max,int cmd_task_size,uint32_t initial_cmdsn) {struct iscsi_session *session;
@@ -1902,7 +1904,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,int cmd_i, cmds_max;/* -* The iscsi layer needs some ctasks for nop handling and tmfs. +* The iscsi layer needs some tasks for nop handling and tmfs. */ if (scsi_cmds_max <1 ) scsi_cmds_max =ISCSI_MGMT_CMDS_MAX ;
@@ -1939,17 +1941,17 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,/* initialize SCSI PDU commands pool */ if (iscsi_pool_init (&session->cmdpool, session->cmds_max, (void ***)&session->cmds, - cmd_ctask_size +sizeof (struct iscsi_cmd_task ))) + cmd_task_size +sizeof (struct iscsi_task ))) goto cmdpool_alloc_fail;/* pre-format cmds pool with ITT */ for (cmd_i =0 ; cmd_i < session->cmds_max; cmd_i++) { -struct iscsi_cmd_task *ctask = session->cmds[cmd_i]; +struct iscsi_task *task = session->cmds[cmd_i]; -if (cmd_ctask_size) - ctask->dd_data = &ctask[1 ]; - ctask->itt = cmd_i; -INIT_LIST_HEAD (&ctask->running); +if (cmd_task_size) + task->dd_data = &task[1 ]; + task->itt = cmd_i; +INIT_LIST_HEAD (&task->running); }if (!try_module_get (iscsit->owner))
@@ -2035,30 +2037,30 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,INIT_LIST_HEAD (&conn->requeue);INIT_WORK (&conn->xmitwork, iscsi_xmitworker); -/* allocate login_ctask used for the login/text sequences */ +/* allocate login_task used for the login/text sequences */ spin_lock_bh (&session->lock);if (!__kfifo_get (session->cmdpool.queue, - (void *)&conn->login_ctask, + (void *)&conn->login_task,sizeof (void *))) {spin_unlock_bh (&session->lock); - goto login_ctask_alloc_fail; + goto login_task_alloc_fail; }spin_unlock_bh (&session->lock); data =kmalloc (ISCSI_DEF_MAX_RECV_SEG_LEN ,GFP_KERNEL );if (!data) - goto login_ctask_data_alloc_fail; - conn->login_ctask->data = conn->data = data; + goto login_task_data_alloc_fail; + conn->login_task->data = conn->data = data;init_timer (&conn->tmf_timer);init_waitqueue_head (&conn->ehwait);return cls_conn; -login_ctask_data_alloc_fail: -__kfifo_put (session->cmdpool.queue, (void *)&conn->login_ctask, +login_task_data_alloc_fail: +__kfifo_put (session->cmdpool.queue, (void *)&conn->login_task,sizeof (void *)); -login_ctask_alloc_fail: +login_task_alloc_fail:iscsi_destroy_conn (cls_conn);return NULL ; }
@@ -2118,7 +2120,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)spin_lock_bh (&session->lock);kfree (conn->data);kfree (conn->persistent_address); -__kfifo_put (session->cmdpool.queue, (void *)&conn->login_ctask, +__kfifo_put (session->cmdpool.queue, (void *)&conn->login_task,sizeof (void *));if (session->leadconn == conn) session->leadconn =NULL ;
@@ -2199,23 +2201,23 @@ EXPORT_SYMBOL_GPL(iscsi_conn_start);static void flush_control_queues (struct iscsi_session *session,struct iscsi_conn *conn) { -struct iscsi_cmd_task *ctask, *tmp; +struct iscsi_task *task, *tmp;/* handle pending */ -list_for_each_entry_safe (ctask, tmp, &conn->mgmtqueue, running) { -debug_scsi ("flushing pending mgmt ctask itt 0x%x\n" , ctask->itt); -/* release ref from prep ctask */ -__iscsi_put_ctask (ctask); +list_for_each_entry_safe (task, tmp, &conn->mgmtqueue, running) { +debug_scsi ("flushing pending mgmt task itt 0x%x\n" , task->itt); +/* release ref from prep task */ +__iscsi_put_task (task); }/* handle running */ -list_for_each_entry_safe (ctask, tmp, &conn->mgmt_run_list, running) { -debug_scsi ("flushing running mgmt ctask itt 0x%x\n" , ctask->itt); -/* release ref from prep ctask */ -__iscsi_put_ctask (ctask); +list_for_each_entry_safe (task, tmp, &conn->mgmt_run_list, running) { +debug_scsi ("flushing running mgmt task itt 0x%x\n" , task->itt); +/* release ref from prep task */ +__iscsi_put_task (task); } - conn->ctask =NULL ; + conn->task =NULL ; } static void iscsi_start_session_recovery(struct iscsi_session *session,
@@ -2246,7 +2248,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,/* * When this is called for the in_login state, we only want to clean -* up the login ctask and connection. We do not need to block and set +* up the login task and connection. We do not need to block and set * the recovery state again */ if (flag ==STOP_CONN_TERM )
include/scsi/libiscsi.h +11 -11
@@ -92,7 +92,7 @@ enum { ISCSI_TASK_RUNNING, }; -struct iscsi_cmd_task { +struct iscsi_task {/* * Because LLDs allocate their hdr differently, this is a pointer * and length to that storage. It must be setup at session
@@ -120,9 +120,9 @@ struct iscsi_cmd_task {void *dd_data;/* driver/transport data */ }; -static inline void *iscsi_next_hdr (struct iscsi_cmd_task *ctask) +static inline void *iscsi_next_hdr (struct iscsi_task *task) { -return (void *)ctask->hdr + ctask->hdr_len; +return (void *)task->hdr + task->hdr_len; }/* Connection's states */
@@ -151,7 +151,7 @@ struct iscsi_conn {unsigned long last_ping;int ping_timeout;int recv_timeout; -struct iscsi_cmd_task *ping_ctask; +struct iscsi_task *ping_task;/* iSCSI connection-wide sequencing */ uint32_t exp_statsn;
@@ -167,8 +167,8 @@ struct iscsi_conn {* should always fit in this buffer */ char *data; -struct iscsi_cmd_task *login_ctask;/* mtask used for login/text */ -struct iscsi_cmd_task *ctask;/* xmit task in progress */ +struct iscsi_task *login_task;/* mtask used for login/text */ +struct iscsi_task *task;/* xmit task in progress */ /* xmit */ struct list_head mgmtqueue;/* mgmt (control) xmit queue */
@@ -285,7 +285,7 @@ struct iscsi_session {int scsi_cmds_max;/* max scsi commands */ int cmds_max;/* size of cmds array */ -struct iscsi_cmd_task **cmds;/* Original Cmds arr */ +struct iscsi_task **cmds;/* Original Cmds arr */ struct iscsi_pool cmdpool;/* PDU's pool */ };
@@ -365,16 +365,16 @@ extern void iscsi_suspend_tx(struct iscsi_conn *conn);* pdu and task processing */ extern void iscsi_update_cmdsn (struct iscsi_session *,struct iscsi_nopin *); -extern void iscsi_prep_unsolicit_data_pdu (struct iscsi_cmd_task *, +extern void iscsi_prep_unsolicit_data_pdu (struct iscsi_task *,struct iscsi_data *hdr);extern int iscsi_conn_send_pdu (struct iscsi_cls_conn *,struct iscsi_hdr *,char *,uint32_t );extern int iscsi_complete_pdu (struct iscsi_conn *,struct iscsi_hdr *,char *,int );extern int iscsi_verify_itt (struct iscsi_conn *,itt_t ); -extern struct iscsi_cmd_task *iscsi_itt_to_ctask (struct iscsi_conn *,itt_t ); -extern void iscsi_requeue_ctask (struct iscsi_cmd_task *ctask); -extern void iscsi_put_ctask (struct iscsi_cmd_task *ctask); +extern struct iscsi_task *iscsi_itt_to_ctask (struct iscsi_conn *,itt_t ); +extern void iscsi_requeue_task (struct iscsi_task *task); +extern void iscsi_put_task (struct iscsi_task *task);/* * generic helpers
include/scsi/scsi_transport_iscsi.h +4 -4
@@ -33,7 +33,7 @@ struct iscsi_transport;struct Scsi_Host ;struct iscsi_cls_conn ;struct iscsi_conn ; -struct iscsi_cmd_task ; +struct iscsi_task ;struct sockaddr ;/**
@@ -112,10 +112,10 @@ struct iscsi_transport { char *data, uint32_t data_size);void (*get_stats) (struct iscsi_cls_conn *conn,struct iscsi_stats *stats); -int (*init_task) (struct iscsi_cmd_task *task); -int (*xmit_task) (struct iscsi_cmd_task *task); +int (*init_task) (struct iscsi_task *task); +int (*xmit_task) (struct iscsi_task *task);void (*cleanup_task) (struct iscsi_conn *conn, -struct iscsi_cmd_task *task); +struct iscsi_task *task);void (*session_recovery_timedout) (struct iscsi_cls_session *session);int (*ep_connect) (struct sockaddr *dst_addr,int non_blocking,uint64_t *ep_handle);
Signature · 1 line
1.5.4.1
PATCH 15/25 iscsi_tcp: handle iscsi_cmd_task rename
From: Mike Christie <[email protected]>
This converts iscsi_tcp to use the iscsi_task name.
--- drivers/scsi/iscsi_tcp.c | 262 +++++++++++++++++++++++----------------------- drivers/scsi/iscsi_tcp.h | 2 +- 2 files changed, 132 insertions(+), 132 deletions(-)
drivers/scsi/iscsi_tcp.c +131 -131
@@ -498,43 +498,43 @@ iscsi_tcp_data_recv_prep(struct iscsi_tcp_conn *tcp_conn)* must be called with session lock */ static void -iscsi_tcp_cleanup_task (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) +iscsi_tcp_cleanup_task (struct iscsi_conn *conn,struct iscsi_task *task) { -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; +struct iscsi_tcp_task *tcp_task = task->dd_data;struct iscsi_r2t_info *r2t; -/* nothing to do for mgmt ctasks */ -if (!ctask->sc) +/* nothing to do for mgmt tasks */ +if (!task->sc)return ; -/* flush ctask's r2t queues */ -while (__kfifo_get (tcp_ctask->r2tqueue, (void *)&r2t,sizeof (void *))) { -__kfifo_put (tcp_ctask->r2tpool.queue, (void *)&r2t, +/* flush task's r2t queues */ +while (__kfifo_get (tcp_task->r2tqueue, (void *)&r2t,sizeof (void *))) { +__kfifo_put (tcp_task->r2tpool.queue, (void *)&r2t,sizeof (void *)); -debug_scsi ("iscsi_tcp_cleanup_ctask pending r2t dropped\n" ); +debug_scsi ("iscsi_tcp_cleanup_task pending r2t dropped\n" ); } - r2t = tcp_ctask->r2t; + r2t = tcp_task->r2t;if (r2t !=NULL ) { -__kfifo_put (tcp_ctask->r2tpool.queue, (void *)&r2t, +__kfifo_put (tcp_task->r2tpool.queue, (void *)&r2t,sizeof (void *)); - tcp_ctask->r2t =NULL ; + tcp_task->r2t =NULL ; } }/** * iscsi_data_rsp - SCSI Data-In Response processing * @conn: iscsi connection -* @ctask: scsi command ctask +* @task: scsi command task **/ static int -iscsi_data_rsp (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) +iscsi_data_rsp (struct iscsi_conn *conn,struct iscsi_task *task) {struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; +struct iscsi_tcp_task *tcp_task = task->dd_data;struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr;struct iscsi_session *session = conn->session; -struct scsi_cmnd *sc = ctask->sc; +struct scsi_cmnd *sc = task->sc;int datasn =be32_to_cpu (rhdr->datasn);unsigned total_in_length =scsi_in (sc)->length;
@@ -542,18 +542,18 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)if (tcp_conn->in.datalen ==0 )return 0 ; -if (tcp_ctask->exp_datasn != datasn) { -debug_tcp ("%s: ctask->exp_datasn(%d) != rhdr->datasn(%d)\n" , - __FUNCTION__, tcp_ctask->exp_datasn, datasn); +if (tcp_task->exp_datasn != datasn) { +debug_tcp ("%s: task->exp_datasn(%d) != rhdr->datasn(%d)\n" , + __FUNCTION__, tcp_task->exp_datasn, datasn);return ISCSI_ERR_DATASN ; } - tcp_ctask->exp_datasn++; + tcp_task->exp_datasn++; - tcp_ctask->data_offset =be32_to_cpu (rhdr->offset); -if (tcp_ctask->data_offset + tcp_conn->in.datalen > total_in_length) { + tcp_task->data_offset =be32_to_cpu (rhdr->offset); +if (tcp_task->data_offset + tcp_conn->in.datalen > total_in_length) {debug_tcp ("%s: data_offset(%d) + data_len(%d) > total_length_in(%d)\n" , - __FUNCTION__, tcp_ctask->data_offset, + __FUNCTION__, tcp_task->data_offset, tcp_conn->in.datalen, total_in_length);return ISCSI_ERR_DATA_OFFSET ; }
@@ -582,7 +582,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)/** * iscsi_solicit_data_init - initialize first Data-Out * @conn: iscsi connection -* @ctask: scsi command ctask +* @task: scsi command task * @r2t: R2T info * * Notes:
@@ -592,7 +592,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)* This function is called with connection lock taken. **/ static void -iscsi_solicit_data_init (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask, +iscsi_solicit_data_init (struct iscsi_conn *conn,struct iscsi_task *task,struct iscsi_r2t_info *r2t) {struct iscsi_data *hdr;
@@ -603,8 +603,8 @@ iscsi_solicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, hdr->datasn =cpu_to_be32 (r2t->solicit_datasn); r2t->solicit_datasn++; hdr->opcode =ISCSI_OP_SCSI_DATA_OUT ; -memcpy (hdr->lun, ctask->hdr->lun,sizeof (hdr->lun)); - hdr->itt = ctask->hdr->itt; +memcpy (hdr->lun, task->hdr->lun,sizeof (hdr->lun)); + hdr->itt = task->hdr->itt; hdr->exp_statsn = r2t->exp_statsn; hdr->offset =cpu_to_be32 (r2t->data_offset);if (r2t->data_length > conn->max_xmit_dlength) {
@@ -624,14 +624,14 @@ iscsi_solicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,/** * iscsi_r2t_rsp - iSCSI R2T Response processing * @conn: iscsi connection -* @ctask: scsi command ctask +* @task: scsi command task **/ static int -iscsi_r2t_rsp (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) +iscsi_r2t_rsp (struct iscsi_conn *conn,struct iscsi_task *task) {struct iscsi_r2t_info *r2t;struct iscsi_session *session = conn->session; -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; +struct iscsi_tcp_task *tcp_task = task->dd_data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data;struct iscsi_r2t_rsp *rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr;int r2tsn =be32_to_cpu (rhdr->r2tsn);
@@ -644,23 +644,23 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)return ISCSI_ERR_DATALEN ; } -if (tcp_ctask->exp_datasn != r2tsn){ -debug_tcp ("%s: ctask->exp_datasn(%d) != rhdr->r2tsn(%d)\n" , - __FUNCTION__, tcp_ctask->exp_datasn, r2tsn); +if (tcp_task->exp_datasn != r2tsn){ +debug_tcp ("%s: task->exp_datasn(%d) != rhdr->r2tsn(%d)\n" , + __FUNCTION__, tcp_task->exp_datasn, r2tsn);return ISCSI_ERR_R2TSN ; } -/* fill-in new R2T associated with the ctask */ +/* fill-in new R2T associated with the task */ iscsi_update_cmdsn (session, (struct iscsi_nopin *)rhdr); -if (!ctask->sc || session->state !=ISCSI_STATE_LOGGED_IN ) { +if (!task->sc || session->state !=ISCSI_STATE_LOGGED_IN ) {iscsi_conn_printk (KERN_INFO , conn,"dropping R2T itt %d in recovery.\n" , - ctask->itt); + task->itt);return 0 ; } - rc =__kfifo_get (tcp_ctask->r2tpool.queue, (void *)&r2t,sizeof (void *)); + rc =__kfifo_get (tcp_task->r2tpool.queue, (void *)&r2t,sizeof (void *));BUG_ON (!rc); r2t->exp_statsn = rhdr->statsn;
@@ -668,7 +668,7 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)if (r2t->data_length ==0 ) {iscsi_conn_printk (KERN_ERR , conn,"invalid R2T with zero data len\n" ); -__kfifo_put (tcp_ctask->r2tpool.queue, (void *)&r2t, +__kfifo_put (tcp_task->r2tpool.queue, (void *)&r2t,sizeof (void *));return ISCSI_ERR_DATALEN ; }
@@ -679,12 +679,12 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) r2t->data_length, session->max_burst); r2t->data_offset =be32_to_cpu (rhdr->data_offset); -if (r2t->data_offset + r2t->data_length >scsi_out (ctask->sc)->length) { +if (r2t->data_offset + r2t->data_length >scsi_out (task->sc)->length) {iscsi_conn_printk (KERN_ERR , conn,"invalid R2T with data len %u at offset %u " "and total length %d\n" , r2t->data_length, - r2t->data_offset,scsi_out (ctask->sc)->length); -__kfifo_put (tcp_ctask->r2tpool.queue, (void *)&r2t, + r2t->data_offset,scsi_out (task->sc)->length); +__kfifo_put (tcp_task->r2tpool.queue, (void *)&r2t,sizeof (void *));return ISCSI_ERR_DATALEN ; }
@@ -692,13 +692,13 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) r2t->ttt = rhdr->ttt;/* no flip */ r2t->solicit_datasn =0 ; -iscsi_solicit_data_init (conn, ctask, r2t); +iscsi_solicit_data_init (conn, task, r2t); - tcp_ctask->exp_datasn = r2tsn +1 ; -__kfifo_put (tcp_ctask->r2tqueue, (void *)&r2t,sizeof (void *)); + tcp_task->exp_datasn = r2tsn +1 ; +__kfifo_put (tcp_task->r2tqueue, (void *)&r2t,sizeof (void *)); conn->r2t_pdus_cnt++; -iscsi_requeue_ctask (ctask); +iscsi_requeue_task (task);return 0 ; }
@@ -743,7 +743,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)int rc =0 , opcode, ahslen;struct iscsi_session *session = conn->session;struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -struct iscsi_cmd_task *ctask; +struct iscsi_task *task;/* verify PDU length */ tcp_conn->in.datalen =ntoh24 (hdr->dlength);
@@ -770,21 +770,21 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)switch (opcode) {case ISCSI_OP_SCSI_DATA_IN : - ctask =iscsi_itt_to_ctask (conn, hdr->itt); -if (!ctask) + task =iscsi_itt_to_ctask (conn, hdr->itt); +if (!task)return ISCSI_ERR_BAD_ITT ; -if (!ctask->sc) +if (!task->sc)return ISCSI_ERR_NO_SCSI_CMD ;spin_lock (&conn->session->lock); - rc =iscsi_data_rsp (conn, ctask); + rc =iscsi_data_rsp (conn, task);spin_unlock (&conn->session->lock);if (rc)return rc;if (tcp_conn->in.datalen) { -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; +struct iscsi_tcp_task *tcp_task = task->dd_data;struct hash_desc *rx_hash =NULL ; -struct scsi_data_buffer *sdb =scsi_in (ctask->sc); +struct scsi_data_buffer *sdb =scsi_in (task->sc);/* * Setup copy of Data-In into the Scsi_Cmnd
@@ -799,12 +799,12 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)debug_tcp ("iscsi_tcp_begin_data_in(%p, offset=%d, " "datalen=%d)\n" , tcp_conn, - tcp_ctask->data_offset, + tcp_task->data_offset, tcp_conn->in.datalen);return iscsi_segment_seek_sg (&tcp_conn->in.segment, sdb->table.sgl, sdb->table.nents, - tcp_ctask->data_offset, + tcp_task->data_offset, tcp_conn->in.datalen, iscsi_tcp_process_data_in, rx_hash);
@@ -818,17 +818,17 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) rc =iscsi_complete_pdu (conn, hdr,NULL ,0 );break ;case ISCSI_OP_R2T : - ctask =iscsi_itt_to_ctask (conn, hdr->itt); -if (!ctask) + task =iscsi_itt_to_ctask (conn, hdr->itt); +if (!task)return ISCSI_ERR_BAD_ITT ; -if (!ctask->sc) +if (!task->sc)return ISCSI_ERR_NO_SCSI_CMD ;if (ahslen) rc =ISCSI_ERR_AHSLEN ; -else if (ctask->sc->sc_data_direction ==DMA_TO_DEVICE ) { +else if (task->sc->sc_data_direction ==DMA_TO_DEVICE ) {spin_lock (&session->lock); - rc =iscsi_r2t_rsp (conn, ctask); + rc =iscsi_r2t_rsp (conn, task);spin_unlock (&session->lock); }else rc =ISCSI_ERR_PROTO ;
@@ -1202,7 +1202,7 @@ iscsi_tcp_send_hdr_prep(struct iscsi_conn *conn, void *hdr, size_t hdrlen)/* If header digest is enabled, compute the CRC and * place the digest into the same buffer. We make -* sure that both iscsi_tcp_cmd_task and mctask have +* sure that both iscsi_tcp_task and mtask have * sufficient room. */ if (conn->hdrdgst_en) {
@@ -1277,7 +1277,7 @@ iscsi_tcp_send_linear_data_prepare(struct iscsi_conn *conn, void *data,/** * iscsi_solicit_data_cont - initialize next Data-Out * @conn: iscsi connection -* @ctask: scsi command ctask +* @task: scsi command task * @r2t: R2T info * @left: bytes left to transfer *
@@ -1288,7 +1288,7 @@ iscsi_tcp_send_linear_data_prepare(struct iscsi_conn *conn, void *data,* Called under connection lock. **/ static int -iscsi_solicit_data_cont (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask, +iscsi_solicit_data_cont (struct iscsi_conn *conn,struct iscsi_task *task,struct iscsi_r2t_info *r2t) {struct iscsi_data *hdr;
@@ -1305,8 +1305,8 @@ iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, hdr->datasn =cpu_to_be32 (r2t->solicit_datasn); r2t->solicit_datasn++; hdr->opcode =ISCSI_OP_SCSI_DATA_OUT ; -memcpy (hdr->lun, ctask->hdr->lun,sizeof (hdr->lun)); - hdr->itt = ctask->hdr->itt; +memcpy (hdr->lun, task->hdr->lun,sizeof (hdr->lun)); + hdr->itt = task->hdr->itt; hdr->exp_statsn = r2t->exp_statsn; new_offset = r2t->data_offset + r2t->sent; hdr->offset =cpu_to_be32 (new_offset);
@@ -1326,73 +1326,73 @@ iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,/** * iscsi_tcp_task - Initialize iSCSI SCSI_READ or SCSI_WRITE commands * @conn: iscsi connection -* @ctask: scsi command ctask +* @task: scsi command task * @sc: scsi command **/ static int -iscsi_tcp_task_init (struct iscsi_cmd_task *ctask) +iscsi_tcp_task_init (struct iscsi_task *task) { -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; -struct iscsi_conn *conn = ctask->conn; -struct scsi_cmnd *sc = ctask->sc; +struct iscsi_tcp_task *tcp_task = task->dd_data; +struct iscsi_conn *conn = task->conn; +struct scsi_cmnd *sc = task->sc;int err;if (!sc) {/* -* mgmt ctasks do not have a scatterlist since they come +* mgmt tasks do not have a scatterlist since they come * in from the iscsi interface. */ -debug_scsi ("mctask deq [cid %d itt 0x%x]\n" , conn->id, - ctask->itt); +debug_scsi ("mtask deq [cid %d itt 0x%x]\n" , conn->id, + task->itt);/* Prepare PDU, optionally w/ immediate data */ -iscsi_tcp_send_hdr_prep (conn, ctask->hdr,sizeof (*ctask->hdr)); +iscsi_tcp_send_hdr_prep (conn, task->hdr,sizeof (*task->hdr));/* If we have immediate data, attach a payload */ -if (ctask->data_count) -iscsi_tcp_send_linear_data_prepare (conn, ctask->data, - ctask->data_count); +if (task->data_count) +iscsi_tcp_send_linear_data_prepare (conn, task->data, + task->data_count);return 0 ; } -BUG_ON (__kfifo_len (tcp_ctask->r2tqueue)); - tcp_ctask->sent =0 ; - tcp_ctask->exp_datasn =0 ; +BUG_ON (__kfifo_len (tcp_task->r2tqueue)); + tcp_task->sent =0 ; + tcp_task->exp_datasn =0 ;/* Prepare PDU, optionally w/ immediate data */ -debug_scsi ("ctask deq [cid %d itt 0x%x imm %d unsol %d]\n" , - conn->id, ctask->itt, ctask->imm_count, - ctask->unsol_count); -iscsi_tcp_send_hdr_prep (conn, ctask->hdr, ctask->hdr_len); +debug_scsi ("task deq [cid %d itt 0x%x imm %d unsol %d]\n" , + conn->id, task->itt, task->imm_count, + task->unsol_count); +iscsi_tcp_send_hdr_prep (conn, task->hdr, task->hdr_len); -if (!ctask->imm_count) +if (!task->imm_count)return 0 ;/* If we have immediate data, attach a payload */ err =iscsi_tcp_send_data_prep (conn,scsi_out (sc)->table.sgl,scsi_out (sc)->table.nents, -0 , ctask->imm_count); +0 , task->imm_count);if (err)return err; - tcp_ctask->sent += ctask->imm_count; - ctask->imm_count =0 ; + tcp_task->sent += task->imm_count; + task->imm_count =0 ;return 0 ; }/* -* iscsi_tcp_task_xmit - xmit normal PDU ctask -* @ctask: iscsi command ctask +* iscsi_tcp_task_xmit - xmit normal PDU task +* @task: iscsi command task * * We're expected to return 0 when everything was transmitted succesfully, * -EAGAIN if there's still data in the queue, or != 0 for any other kind * of error. */ static int -iscsi_tcp_task_xmit (struct iscsi_cmd_task *ctask) +iscsi_tcp_task_xmit (struct iscsi_task *task) { -struct iscsi_conn *conn = ctask->conn; -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; -struct scsi_cmnd *sc = ctask->sc; +struct iscsi_conn *conn = task->conn; +struct iscsi_tcp_task *tcp_task = task->dd_data; +struct scsi_cmnd *sc = task->sc;struct scsi_data_buffer *sdb;int rc =0 ;
@@ -1404,8 +1404,8 @@ flush:/* mgmt command */ if (!sc) { -if (ctask->hdr->itt ==RESERVED_ITT ) -iscsi_put_ctask (ctask); +if (task->hdr->itt ==RESERVED_ITT ) +iscsi_put_task (task);return 0 ; }
@@ -1414,27 +1414,27 @@ flush:return 0 ; sdb =scsi_out (sc); -if (ctask->unsol_count !=0 ) { -struct iscsi_data *hdr = &tcp_ctask->unsol_dtask.hdr; +if (task->unsol_count !=0 ) { +struct iscsi_data *hdr = &tcp_task->unsol_dtask.hdr;/* Prepare a header for the unsolicited PDU. * The amount of data we want to send will be -* in ctask->data_count. +* in task->data_count. * FIXME: return the data count instead. */ -iscsi_prep_unsolicit_data_pdu (ctask, hdr); +iscsi_prep_unsolicit_data_pdu (task, hdr);debug_tcp ("unsol dout [itt 0x%x doff %d dlen %d]\n" , - ctask->itt, tcp_ctask->sent, ctask->data_count); + task->itt, tcp_task->sent, task->data_count);iscsi_tcp_send_hdr_prep (conn, hdr,sizeof (*hdr)); rc =iscsi_tcp_send_data_prep (conn, sdb->table.sgl, - sdb->table.nents, tcp_ctask->sent, - ctask->data_count); + sdb->table.nents, tcp_task->sent, + task->data_count);if (rc) goto fail; - tcp_ctask->sent += ctask->data_count; - ctask->unsol_count -= ctask->data_count; + tcp_task->sent += task->data_count; + task->unsol_count -= task->data_count; goto flush; }else {struct iscsi_session *session = conn->session;
@@ -1443,22 +1443,22 @@ flush:/* All unsolicited PDUs sent. Check for solicited PDUs. */ spin_lock_bh (&session->lock); - r2t = tcp_ctask->r2t; + r2t = tcp_task->r2t;if (r2t !=NULL ) {/* Continue with this R2T? */ -if (!iscsi_solicit_data_cont (conn, ctask, r2t)) { +if (!iscsi_solicit_data_cont (conn, task, r2t)) {debug_scsi (" done with r2t %p\n" , r2t); -__kfifo_put (tcp_ctask->r2tpool.queue, +__kfifo_put (tcp_task->r2tpool.queue, (void *)&r2t,sizeof (void *)); - tcp_ctask->r2t = r2t =NULL ; + tcp_task->r2t = r2t =NULL ; } }if (r2t ==NULL ) { -__kfifo_get (tcp_ctask->r2tqueue, (void *)&tcp_ctask->r2t, +__kfifo_get (tcp_task->r2tqueue, (void *)&tcp_task->r2t,sizeof (void *)); - r2t = tcp_ctask->r2t; + r2t = tcp_task->r2t; }spin_unlock_bh (&session->lock);
@@ -1469,7 +1469,7 @@ flush: }debug_scsi ("sol dout %p [dsn %d itt 0x%x doff %d dlen %d]\n" , - r2t, r2t->solicit_datasn -1 , ctask->itt, + r2t, r2t->solicit_datasn -1 , task->itt, r2t->data_offset + r2t->sent, r2t->data_count); iscsi_tcp_send_hdr_prep(conn, &r2t->dtask.hdr,
@@ -1481,7 +1481,7 @@ flush: r2t->data_count);if (rc) goto fail; - tcp_ctask->sent += r2t->data_count; + tcp_task->sent += r2t->data_count; r2t->sent += r2t->data_count; goto flush; }
@@ -1698,11 +1698,11 @@ iscsi_r2tpool_alloc(struct iscsi_session *session)int cmd_i;/* -* initialize per-ctask: R2T pool and xmit queue +* initialize per-task: R2T pool and xmit queue */ for (cmd_i =0 ; cmd_i < session->cmds_max; cmd_i++) { -struct iscsi_cmd_task *ctask = session->cmds[cmd_i]; -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; +struct iscsi_task *task = session->cmds[cmd_i]; +struct iscsi_tcp_task *tcp_task = task->dd_data;/* * pre-allocated x4 as much r2ts to handle race when
@@ -1711,16 +1711,16 @@ iscsi_r2tpool_alloc(struct iscsi_session *session)*/ /* R2T pool */ -if (iscsi_pool_init (&tcp_ctask->r2tpool, session->max_r2t *4 ,NULL , +if (iscsi_pool_init (&tcp_task->r2tpool, session->max_r2t *4 ,NULL ,sizeof (struct iscsi_r2t_info ))) { goto r2t_alloc_fail; }/* R2T xmit queue */ - tcp_ctask->r2tqueue =kfifo_alloc ( + tcp_task->r2tqueue =kfifo_alloc ( session->max_r2t *4 *sizeof (void *),GFP_KERNEL ,NULL ); -if (tcp_ctask->r2tqueue ==ERR_PTR (-ENOMEM )) { -iscsi_pool_free (&tcp_ctask->r2tpool); +if (tcp_task->r2tqueue ==ERR_PTR (-ENOMEM )) { +iscsi_pool_free (&tcp_task->r2tpool); goto r2t_alloc_fail; } }
@@ -1729,11 +1729,11 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) r2t_alloc_fail:for (i =0 ; i < cmd_i; i++) { -struct iscsi_cmd_task *ctask = session->cmds[i]; -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; +struct iscsi_task *task = session->cmds[i]; +struct iscsi_tcp_task *tcp_task = task->dd_data; -kfifo_free (tcp_ctask->r2tqueue); -iscsi_pool_free (&tcp_ctask->r2tpool); +kfifo_free (tcp_task->r2tqueue); +iscsi_pool_free (&tcp_task->r2tpool); }return -ENOMEM ; }
@@ -1744,11 +1744,11 @@ iscsi_r2tpool_free(struct iscsi_session *session)int i;for (i =0 ; i < session->cmds_max; i++) { -struct iscsi_cmd_task *ctask = session->cmds[i]; -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; +struct iscsi_task *task = session->cmds[i]; +struct iscsi_tcp_task *tcp_task = task->dd_data; -kfifo_free (tcp_ctask->r2tqueue); -iscsi_pool_free (&tcp_ctask->r2tpool); +kfifo_free (tcp_task->r2tqueue); +iscsi_pool_free (&tcp_task->r2tpool); } }
@@ -1867,7 +1867,7 @@ iscsi_tcp_session_create(struct Scsi_Host *shost, uint16_t cmds_max, *hostno = shost->host_no; cls_session =iscsi_session_setup (&iscsi_tcp_transport, shost, cmds_max, -sizeof (struct iscsi_tcp_cmd_task ), +sizeof (struct iscsi_tcp_task ), initial_cmdsn);if (!cls_session) goto remove_host;
@@ -1875,11 +1875,11 @@ iscsi_tcp_session_create(struct Scsi_Host *shost, uint16_t cmds_max, shost->can_queue = session->scsi_cmds_max;for (cmd_i =0 ; cmd_i < session->cmds_max; cmd_i++) { -struct iscsi_cmd_task *ctask = session->cmds[cmd_i]; -struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; +struct iscsi_task *task = session->cmds[cmd_i]; +struct iscsi_tcp_task *tcp_task = task->dd_data; - ctask->hdr = &tcp_ctask->hdr.cmd_hdr; - ctask->hdr_max =sizeof (tcp_ctask->hdr) -ISCSI_DIGEST_SIZE ; + task->hdr = &tcp_task->hdr.cmd_hdr; + task->hdr_max =sizeof (tcp_task->hdr) -ISCSI_DIGEST_SIZE ; }if (iscsi_r2tpool_alloc (session))
drivers/scsi/iscsi_tcp.h +1 -1
@@ -114,7 +114,7 @@ struct iscsi_r2t_info {struct iscsi_data_task dtask;/* Data-Out header buf */ }; -struct iscsi_tcp_cmd_task { +struct iscsi_tcp_task { struct iscsi_hdr_buff { struct iscsi_cmd cmd_hdr; char hdrextbuf[ISCSI_MAX_AHS_SIZE +
Signature · 1 line
1.5.4.1
PATCH 16/25 iser: handle iscsi_cmd_task rename
From: Mike Christie <[email protected]>
This handles the iscsi_cmd_task rename and renames the iser cmd task to iser task.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 114 ++++++++-------- drivers/infiniband/ulp/iser/iscsi_iser.h | 24 ++-- drivers/infiniband/ulp/iser/iser_initiator.c | 190 +++++++++++++------------- drivers/infiniband/ulp/iser/iser_memory.c | 77 ++++++----- 4 files changed, 203 insertions(+), 202 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +57 -57
@@ -124,33 +124,33 @@ error:/** -* iscsi_iser_task_init - Initialize ctask -* @ctask: iscsi ctask +* iscsi_iser_task_init - Initialize task +* @task: iscsi task * -* Initialize the ctask for the scsi command or mgmt command. +* Initialize the task for the scsi command or mgmt command. */ static int -iscsi_iser_task_init (struct iscsi_cmd_task *ctask) +iscsi_iser_task_init (struct iscsi_task *task) { -struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data; -struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; +struct iscsi_iser_conn *iser_conn = task->conn->dd_data; +struct iscsi_iser_task *iser_task = task->dd_data; -/* mgmt ctask */ -if (!ctask->sc) { - iser_ctask->desc.data = ctask->data; +/* mgmt task */ +if (!task->sc) { + iser_task->desc.data = task->data;return 0 ; } - iser_ctask->command_sent =0 ; - iser_ctask->iser_conn = iser_conn; -iser_ctask_rdma_init (iser_ctask); + iser_task->command_sent =0 ; + iser_task->iser_conn = iser_conn; +iser_task_rdma_init (iser_task);return 0 ; }/** -* iscsi_iser_mtask_xmit - xmit management(immediate) ctask +* iscsi_iser_mtask_xmit - xmit management(immediate) task * @conn: iscsi connection -* @ctask: ctask management ctask +* @task: task management task * * Notes: * The function can return -EAGAIN in which case caller must
@@ -159,19 +159,19 @@ iscsi_iser_task_init(struct iscsi_cmd_task *ctask)* **/ static int -iscsi_iser_mtask_xmit (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) +iscsi_iser_mtask_xmit (struct iscsi_conn *conn,struct iscsi_task *task) {int error =0 ; -debug_scsi ("ctask deq [cid %d itt 0x%x]\n" , conn->id, ctask->itt); +debug_scsi ("task deq [cid %d itt 0x%x]\n" , conn->id, task->itt); - error =iser_send_control (conn, ctask); + error =iser_send_control (conn, task); -/* since iser xmits control with zero copy, ctasks can not be recycled +/* since iser xmits control with zero copy, tasks can not be recycled * right after sending them. * The recycling scheme is based on whether a response is expected -* - if yes, the ctask is recycled at iscsi_complete_pdu -* - if no, the ctask is recycled at iser_snd_completion +* - if yes, the task is recycled at iscsi_complete_pdu +* - if no, the task is recycled at iser_snd_completion */ if (error && error != -ENOBUFS )iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED );
@@ -181,27 +181,27 @@ iscsi_iser_mtask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)static int iscsi_iser_task_xmit_unsol_data (struct iscsi_conn *conn, -struct iscsi_cmd_task *ctask) +struct iscsi_task *task) {struct iscsi_data hdr;int error =0 ;/* Send data-out PDUs while there's still unsolicited data to send */ -while (ctask->unsol_count >0 ) { -iscsi_prep_unsolicit_data_pdu (ctask, &hdr); +while (task->unsol_count >0 ) { +iscsi_prep_unsolicit_data_pdu (task, &hdr);debug_scsi ("Sending data-out: itt 0x%x, data count %d\n" , - hdr.itt, ctask->data_count); + hdr.itt, task->data_count);/* the buffer description has been passed with the command */ /* Send the command */ - error =iser_send_data_out (conn, ctask, &hdr); + error =iser_send_data_out (conn, task, &hdr);if (error) { - ctask->unsol_datasn--; + task->unsol_datasn--; goto iscsi_iser_task_xmit_unsol_data_exit; } - ctask->unsol_count -= ctask->data_count; + task->unsol_count -= task->data_count;debug_scsi ("Need to send %d more as data-out PDUs\n" , - ctask->unsol_count); + task->unsol_count); } iscsi_iser_task_xmit_unsol_data_exit:
@@ -209,37 +209,37 @@ iscsi_iser_task_xmit_unsol_data_exit: }static int -iscsi_iser_task_xmit (struct iscsi_cmd_task *ctask) +iscsi_iser_task_xmit (struct iscsi_task *task) { -struct iscsi_conn *conn = ctask->conn; -struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; +struct iscsi_conn *conn = task->conn; +struct iscsi_iser_task *iser_task = task->dd_data;int error =0 ; -if (!ctask->sc) -return iscsi_iser_mtask_xmit (conn, ctask); +if (!task->sc) +return iscsi_iser_mtask_xmit (conn, task); -if (ctask->sc->sc_data_direction ==DMA_TO_DEVICE ) { -BUG_ON (scsi_bufflen (ctask->sc) ==0 ); +if (task->sc->sc_data_direction ==DMA_TO_DEVICE ) { +BUG_ON (scsi_bufflen (task->sc) ==0 );debug_scsi ("cmd [itt %x total %d imm %d unsol_data %d\n" , - ctask->itt,scsi_bufflen (ctask->sc), - ctask->imm_count, ctask->unsol_count); + task->itt,scsi_bufflen (task->sc), + task->imm_count, task->unsol_count); } -debug_scsi ("ctask deq [cid %d itt 0x%x]\n" , - conn->id, ctask->itt); +debug_scsi ("task deq [cid %d itt 0x%x]\n" , + conn->id, task->itt);/* Send the cmd PDU */ -if (!iser_ctask->command_sent) { - error =iser_send_command (conn, ctask); +if (!iser_task->command_sent) { + error =iser_send_command (conn, task);if (error) goto iscsi_iser_task_xmit_exit; - iser_ctask->command_sent =1 ; + iser_task->command_sent =1 ; }/* Send unsolicited data-out PDU(s) if necessary */ -if (ctask->unsol_count) - error =iscsi_iser_task_xmit_unsol_data (conn, ctask); +if (task->unsol_count) + error =iscsi_iser_task_xmit_unsol_data (conn, task); iscsi_iser_task_xmit_exit:if (error && error != -ENOBUFS )
@@ -248,17 +248,17 @@ iscsi_iser_task_xmit(struct iscsi_cmd_task *ctask) }static void -iscsi_iser_cleanup_task (struct iscsi_conn *conn,struct iscsi_cmd_task *ctask) +iscsi_iser_cleanup_task (struct iscsi_conn *conn,struct iscsi_task *task) { -struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; +struct iscsi_iser_task *iser_task = task->dd_data;/* mgmt tasks do not need special cleanup */ -if (!ctask->sc) +if (!task->sc)return ; -if (iser_ctask->status ==ISER_TASK_STATUS_STARTED ) { - iser_ctask->status =ISER_TASK_STATUS_COMPLETED ; -iser_ctask_rdma_finalize (iser_ctask); +if (iser_task->status ==ISER_TASK_STATUS_STARTED ) { + iser_task->status =ISER_TASK_STATUS_COMPLETED ; +iser_task_rdma_finalize (iser_task); } }
@@ -408,8 +408,8 @@ iscsi_iser_session_create(struct Scsi_Host *shost,struct iscsi_cls_session *cls_session;struct iscsi_session *session;int i; -struct iscsi_cmd_task *ctask; -struct iscsi_iser_cmd_task *iser_ctask; +struct iscsi_task *task; +struct iscsi_iser_task *iser_task;if (shost) { printk(KERN_ERR "iscsi_tcp: invalid shost %d.\n",
@@ -436,7 +436,7 @@ iscsi_iser_session_create(struct Scsi_Host *shost,*/ cls_session =iscsi_session_setup (&iscsi_iser_transport, shost,ISCSI_DEF_XMIT_CMDS_MAX , -sizeof (struct iscsi_iser_cmd_task ), +sizeof (struct iscsi_iser_task ), initial_cmdsn);if (!cls_session) goto remove_host;
@@ -445,10 +445,10 @@ iscsi_iser_session_create(struct Scsi_Host *shost, shost->can_queue = session->scsi_cmds_max;/* libiscsi setup itts, data and pool so just set desc fields */ for (i =0 ; i < session->cmds_max; i++) { - ctask = session->cmds[i]; - iser_ctask = ctask->dd_data; - ctask->hdr = (struct iscsi_cmd *)&iser_ctask->desc.iscsi_header; - ctask->hdr_max =sizeof (iser_ctask->desc.iscsi_header); + task = session->cmds[i]; + iser_task = task->dd_data; + task->hdr = (struct iscsi_cmd *)&iser_task->desc.iscsi_header; + task->hdr_max =sizeof (iser_task->desc.iscsi_header); }return cls_session;
drivers/infiniband/ulp/iser/iscsi_iser.h +12 -12
@@ -173,7 +173,7 @@ struct iser_data_buf {/* fwd declarations */ struct iser_device ;struct iscsi_iser_conn ; -struct iscsi_iser_cmd_task ; +struct iscsi_iser_task ;struct iser_mem_reg {u32 lkey;
@@ -197,7 +197,7 @@ struct iser_regd_buf {#define MAX_REGD_BUF_VECTOR_LEN 2struct iser_dto { -struct iscsi_iser_cmd_task *ctask; +struct iscsi_iser_task *task;struct iser_conn *ib_conn;int notify_enable;
@@ -265,7 +265,7 @@ struct iscsi_iser_conn {rwlock_t lock; }; -struct iscsi_iser_cmd_task { +struct iscsi_iser_task {struct iser_desc desc;struct iscsi_iser_conn *iser_conn;enum iser_task_status status;
@@ -299,13 +299,13 @@ extern int iser_debug_level;int iser_conn_set_full_featured_mode (struct iscsi_conn *conn);int iser_send_control (struct iscsi_conn *conn, -struct iscsi_cmd_task *ctask); +struct iscsi_task *task);int iser_send_command (struct iscsi_conn *conn, -struct iscsi_cmd_task *ctask); +struct iscsi_task *task);int iser_send_data_out (struct iscsi_conn *conn, -struct iscsi_cmd_task *ctask, +struct iscsi_task *task,struct iscsi_data *hdr); void iscsi_iser_recv(struct iscsi_conn *conn,
@@ -326,9 +326,9 @@ void iser_rcv_completion(struct iser_desc *desc,void iser_snd_completion (struct iser_desc *desc); -void iser_ctask_rdma_init (struct iscsi_iser_cmd_task *ctask); +void iser_task_rdma_init (struct iscsi_iser_task *task); -void iser_ctask_rdma_finalize (struct iscsi_iser_cmd_task *ctask); +void iser_task_rdma_finalize (struct iscsi_iser_task *task);void iser_dto_buffs_release (struct iser_dto *dto);
@@ -338,10 +338,10 @@ void iser_reg_single(struct iser_device *device,struct iser_regd_buf *regd_buf, enum dma_data_direction direction); -void iser_finalize_rdma_unaligned_sg (struct iscsi_iser_cmd_task *ctask, +void iser_finalize_rdma_unaligned_sg (struct iscsi_iser_task *task,enum iser_data_dir cmd_dir); -int iser_reg_rdma_mem (struct iscsi_iser_cmd_task *ctask, +int iser_reg_rdma_mem (struct iscsi_iser_task *task,enum iser_data_dir cmd_dir); int iser_connect(struct iser_conn *ib_conn,
@@ -361,10 +361,10 @@ int iser_post_send(struct iser_desc *tx_desc);int iser_conn_state_comp (struct iser_conn *ib_conn,enum iser_ib_conn_state comp); -int iser_dma_map_task_data (struct iscsi_iser_cmd_task *iser_ctask, +int iser_dma_map_task_data (struct iscsi_iser_task *iser_task,struct iser_data_buf *data,enum iser_data_dir iser_dir,enum dma_data_direction dma_dir); -void iser_dma_unmap_task_data (struct iscsi_iser_cmd_task *iser_ctask); +void iser_dma_unmap_task_data (struct iscsi_iser_task *iser_task);#endif
drivers/infiniband/ulp/iser/iser_initiator.c +95 -95
456 lines not on this page · raw message
drivers/infiniband/ulp/iser/iser_memory.c +39 -38
181 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 17/25 iscsi class: user device_for_each_child instead of duplicating session list
From: Mike Christie <[email protected]>
Currently we duplicate the list of sessions, because we were using the test for if a session was on the host list to indicate if the session was bound or unbound. We can instead use the target_id and fix up the class so that drivers like bnx2i do not have to manage the target id space.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 2 +- drivers/scsi/iscsi_tcp.c | 2 +- drivers/scsi/libiscsi.c | 4 +- drivers/scsi/scsi_transport_iscsi.c | 125 +++++++++++++++++++++++------- include/scsi/libiscsi.h | 2 +- include/scsi/scsi_transport_iscsi.h | 6 +- 6 files changed, 104 insertions(+), 37 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +1 -1
@@ -437,7 +437,7 @@ iscsi_iser_session_create(struct Scsi_Host *shost, cls_session =iscsi_session_setup (&iscsi_iser_transport, shost,ISCSI_DEF_XMIT_CMDS_MAX ,sizeof (struct iscsi_iser_task ), - initial_cmdsn); + initial_cmdsn,0 );if (!cls_session) goto remove_host; session = cls_session->dd_data;
drivers/scsi/iscsi_tcp.c +1 -1
@@ -1868,7 +1868,7 @@ iscsi_tcp_session_create(struct Scsi_Host *shost, uint16_t cmds_max, cls_session =iscsi_session_setup (&iscsi_tcp_transport, shost, cmds_max,sizeof (struct iscsi_tcp_task ), - initial_cmdsn); + initial_cmdsn,0 );if (!cls_session) goto remove_host; session = cls_session->dd_data;
drivers/scsi/libiscsi.c +2 -2
@@ -1897,7 +1897,7 @@ EXPORT_SYMBOL_GPL(iscsi_host_free);struct iscsi_cls_session *iscsi_session_setup (struct iscsi_transport *iscsit,struct Scsi_Host *shost,uint16_t scsi_cmds_max,int cmd_task_size, -uint32_t initial_cmdsn) +uint32_t initial_cmdsn,unsigned int id) {struct iscsi_session *session;struct iscsi_cls_session *cls_session;
@@ -1957,7 +1957,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,if (!try_module_get (iscsit->owner)) goto module_get_fail; -if (iscsi_add_session (cls_session,0 )) +if (iscsi_add_session (cls_session, id)) goto cls_session_fail;return cls_session;
drivers/scsi/scsi_transport_iscsi.c +96 -29
194 lines not on this page · raw message
include/scsi/libiscsi.h +1 -1
@@ -331,7 +331,7 @@ extern void iscsi_host_free(struct Scsi_Host *shost);*/ extern struct iscsi_cls_session *iscsi_session_setup (struct iscsi_transport *,struct Scsi_Host *shost, -uint16_t ,int ,uint32_t ); +uint16_t ,int ,uint32_t ,unsigned int );extern void iscsi_session_teardown (struct iscsi_cls_session *);extern void iscsi_session_recovery_timedout (struct iscsi_cls_session *); extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
include/scsi/scsi_transport_iscsi.h +3 -3
@@ -161,9 +161,10 @@ enum { ISCSI_SESSION_FREE, }; +#define ISCSI_MAX_TARGET -1 +struct iscsi_cls_session {struct list_head sess_list;/* item in session_list */ -struct list_head host_list;struct iscsi_transport *transport;spinlock_t lock;struct work_struct block_work;
@@ -175,7 +176,7 @@ struct iscsi_cls_session {int recovery_tmo;struct delayed_work recovery_work; -int target_id; +unsigned int target_id;int state;int sid;/* session id */
@@ -193,7 +194,6 @@ struct iscsi_cls_session { iscsi_dev_to_session(_stgt->dev.parent)struct iscsi_cls_host { -struct list_head sessions;atomic_t nr_scans;struct mutex mutex;struct workqueue_struct *scan_workq;
Signature · 1 line
1.5.4.1
PATCH 18/25 iscsi class: add endpoint class
From: Mike Christie <[email protected]>
Add sysfs representation for the endpoint, so userspace can match the host and session to the endpoint. This will allow us to set the host's parent correctly at host creation time.
The next patches will convert tcp and iser, and fix iser's dma_mask bug.
--- drivers/scsi/scsi_transport_iscsi.c | 190 +++++++++++++++++++++++++++++------ include/scsi/iscsi_if.h | 2 +- include/scsi/scsi_transport_iscsi.h | 19 +++- 3 files changed, 172 insertions(+), 39 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +157 -33
@@ -33,6 +33,7 @@#define ISCSI_SESSION_ATTRS 19#define ISCSI_CONN_ATTRS 13#define ISCSI_HOST_ATTRS 4 +#define ISCSI_TRANSPORT_VERSION "2.0-869"struct iscsi_internal {
@@ -112,6 +113,123 @@ static struct attribute_group iscsi_transport_group = { .attrs = iscsi_transport_attrs, }; +/* +* iSCSI endpoint attrs +*/ +#define iscsi_dev_to_endpoint (_dev) \ + container_of(_dev, struct iscsi_endpoint, dev) + +#define ISCSI_ATTR (_prefix,_name,_mode,_show,_store) \ +struct device_attribute dev_attr_##_prefix##_##_name = \ + __ATTR(_name,_mode,_show,_store) + +static void iscsi_endpoint_release (struct device *dev) +{ +struct iscsi_endpoint *ep =iscsi_dev_to_endpoint (dev); +kfree (ep); +} + +static struct class iscsi_endpoint_class = { + .name ="iscsi_endpoint" , + .dev_release = iscsi_endpoint_release, +}; + +static ssize_t +show_ep_handle (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct iscsi_endpoint *ep =iscsi_dev_to_endpoint (dev); +return sprintf (buf,"%u\n" , ep->id); +} +static ISCSI_ATTR(ep, handle, S_IRUGO, show_ep_handle, NULL); + +static struct attribute *iscsi_endpoint_attrs[] = { + &dev_attr_ep_handle.attr, +NULL , +}; + +static struct attribute_group iscsi_endpoint_group = { + .attrs = iscsi_endpoint_attrs, +}; + +#define ISCSI_MAX_EPID -1 + +static int iscsi_match_epid (struct device *dev,void *data) +{ +struct iscsi_endpoint *ep =iscsi_dev_to_endpoint (dev); +unsigned int *epid = (unsigned int *) data; + +return *epid == ep->id; +} + +struct iscsi_endpoint * +iscsi_create_endpoint (int dd_size) +{ +struct device *dev; +struct iscsi_endpoint *ep; +unsigned int id; +int err; + +for (id =1 ; id <ISCSI_MAX_EPID ; id++) { + dev =class_find_device (&iscsi_endpoint_class, &id, + iscsi_match_epid); +if (!dev) +break ; + } +if (id ==ISCSI_MAX_EPID ) { +printk (KERN_ERR "Too many connections. Max supported %u\n" , +ISCSI_MAX_EPID -1 ); +return NULL ; + } + + ep =kzalloc (sizeof (*ep) + dd_size,GFP_KERNEL ); +if (!ep) +return NULL ; + + ep->id = id; + ep->dev.class = &iscsi_endpoint_class; +snprintf (ep->dev.bus_id,BUS_ID_SIZE ,"ep-%u" , id); + err =device_register (&ep->dev); +if (err) + goto free_ep; + + err =sysfs_create_group (&ep->dev.kobj, &iscsi_endpoint_group); +if (err) + goto unregister_dev; + +if (dd_size) + ep->dd_data = &ep[1 ]; +return ep; + +unregister_dev: +device_unregister (&ep->dev); +return NULL ; + +free_ep: +kfree (ep); +return NULL ; +} +EXPORT_SYMBOL_GPL (iscsi_create_endpoint); + +void iscsi_destroy_endpoint (struct iscsi_endpoint *ep) +{ +sysfs_remove_group (&ep->dev.kobj, &iscsi_endpoint_group); +device_unregister (&ep->dev); +} +EXPORT_SYMBOL_GPL (iscsi_destroy_endpoint); + +struct iscsi_endpoint *iscsi_lookup_endpoint (u64 handle) +{ +struct device *dev; + + dev =class_find_device (&iscsi_endpoint_class, &handle, + iscsi_match_epid); +if (!dev) +return NULL ; + +return iscsi_dev_to_endpoint (dev); +} +EXPORT_SYMBOL_GPL (iscsi_lookup_endpoint); +static int iscsi_setup_host (struct transport_container *tc,struct device *dev,struct device *cdev) {
@@ -1094,33 +1212,16 @@ int iscsi_session_event(struct iscsi_cls_session *session,EXPORT_SYMBOL_GPL (iscsi_session_event);static int -iscsi_if_create_session (struct iscsi_internal *priv,struct iscsi_uevent *ev, -uint32_t host_no,uint32_t initial_cmdsn, +iscsi_if_create_session (struct iscsi_internal *priv,struct iscsi_endpoint *ep, +struct iscsi_uevent *ev,uint32_t initial_cmdsn,uint16_t cmds_max,uint16_t queue_depth) {struct iscsi_transport *transport = priv->iscsi_transport;struct iscsi_cls_session *session; -struct Scsi_Host *shost =NULL ; +uint32_t host_no; -/* -* Software iscsi allocates a host per session, but -* offload drivers (and possibly iser one day) allocate a host per -* hba/nic/rnic. Offload will match a host here, but software will -* return a new hostno after the create_session callback has returned. -*/ -if (host_no !=UINT_MAX ) { - shost =scsi_host_lookup (host_no); -if (IS_ERR (shost)) { -printk (KERN_ERR "Could not find host no %u to " -"create session\n" , host_no); -return -ENODEV ; - } - } - - session = transport->create_session (shost, cmds_max, queue_depth, + session = transport->create_session (ep, cmds_max, queue_depth, initial_cmdsn, &host_no); -if (shost) -scsi_host_put (shost);if (!session)return -ENOMEM ;
@@ -1199,6 +1300,7 @@ static int iscsi_if_transport_ep(struct iscsi_transport *transport, struct iscsi_uevent *ev, int msg_type) { + struct iscsi_endpoint *ep;struct sockaddr *dst_addr;int rc =0 ;
@@ -1208,22 +1310,33 @@ iscsi_if_transport_ep(struct iscsi_transport *transport,return -EINVAL ; dst_addr = (struct sockaddr *)((char *)ev +sizeof (*ev)); - rc = transport->ep_connect (dst_addr, - ev->u.ep_connect.non_blocking, - &ev->r.ep_connect_ret.handle); + ep = transport->ep_connect (dst_addr, + ev->u.ep_connect.non_blocking); +if (IS_ERR (ep)) +return PTR_ERR (ep); + + ev->r.ep_connect_ret.handle = ep->id;break ;case ISCSI_UEVENT_TRANSPORT_EP_POLL :if (!transport->ep_poll)return -EINVAL ; - ev->r.retcode = transport->ep_poll (ev->u.ep_poll.ep_handle, + ep =iscsi_lookup_endpoint (ev->u.ep_poll.ep_handle); +if (!ep) +return -EINVAL ; + + ev->r.retcode = transport->ep_poll (ep, ev->u.ep_poll.timeout_ms);break ;case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT :if (!transport->ep_disconnect)return -EINVAL ; - transport->ep_disconnect (ev->u.ep_disconnect.ep_handle); + ep =iscsi_lookup_endpoint (ev->u.ep_disconnect.ep_handle); +if (!ep) +return -EINVAL ; + + transport->ep_disconnect (ep);break ; }return rc;
@@ -1283,12 +1396,12 @@ static int iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) { int err = 0; -uint32_t host_no =UINT_MAX ;struct iscsi_uevent *ev =NLMSG_DATA (nlh);struct iscsi_transport *transport =NULL ;struct iscsi_internal *priv;struct iscsi_cls_session *session;struct iscsi_cls_conn *conn; +struct iscsi_endpoint *ep =NULL ; priv =iscsi_if_transport_lookup (iscsi_ptr (ev->transport_handle));if (!priv)
@@ -1302,14 +1415,17 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)switch (nlh->nlmsg_type) {case ISCSI_UEVENT_CREATE_SESSION : - err =iscsi_if_create_session (priv, ev, host_no, + err =iscsi_if_create_session (priv, ep, ev, ev->u.c_session.initial_cmdsn, ev->u.c_session.cmds_max, ev->u.c_session.queue_depth);break ;case ISCSI_UEVENT_CREATE_BOUND_SESSION : - err =iscsi_if_create_session (priv, ev, - ev->u.c_bound_session.host_no, + ep =iscsi_lookup_endpoint (ev->u.c_bound_session.ep_handle); +if (!ep) +return -EINVAL ; + + err =iscsi_if_create_session (priv, ep, ev, ev->u.c_bound_session.initial_cmdsn, ev->u.c_bound_session.cmds_max, ev->u.c_bound_session.queue_depth);
@@ -1774,6 +1890,7 @@ iscsi_register_transport(struct iscsi_transport *tt) unregister_dev:device_unregister (&priv->dev); +return NULL ; free_priv:kfree (priv);return NULL ;
@@ -1821,10 +1938,14 @@ static __init int iscsi_transport_init(void)if (err)return err; - err =transport_class_register (&iscsi_host_class); + err =class_register (&iscsi_endpoint_class);if (err) goto unregister_transport_class; + err =transport_class_register (&iscsi_host_class); +if (err) + goto unregister_endpoint_class; + err =transport_class_register (&iscsi_connection_class);if (err) goto unregister_host_class;
@@ -1833,8 +1954,8 @@ static __init int iscsi_transport_init(void)if (err) goto unregister_conn_class; - nls =netlink_kernel_create (&init_net,NETLINK_ISCSI ,1 , iscsi_if_rx,NULL , -THIS_MODULE ); + nls =netlink_kernel_create (&init_net,NETLINK_ISCSI ,1 , iscsi_if_rx, +NULL ,THIS_MODULE );if (!nls) { err = -ENOBUFS ; goto unregister_session_class;
@@ -1854,6 +1975,8 @@ unregister_conn_class:transport_class_unregister (&iscsi_connection_class); unregister_host_class:transport_class_unregister (&iscsi_host_class); +unregister_endpoint_class: +class_unregister (&iscsi_endpoint_class); unregister_transport_class:class_unregister (&iscsi_transport_class);return err;
@@ -1866,6 +1989,7 @@ static void __exit iscsi_transport_exit(void)transport_class_unregister (&iscsi_connection_class);transport_class_unregister (&iscsi_session_class);transport_class_unregister (&iscsi_host_class); +class_unregister (&iscsi_endpoint_class);class_unregister (&iscsi_transport_class); }
include/scsi/iscsi_if.h +1 -1
@@ -80,7 +80,7 @@ struct iscsi_uevent {uint16_t queue_depth; } c_session;struct msg_create_bound_session { -uint32_t host_no; +uint64_t ep_handle;uint32_t initial_cmdsn;uint16_t cmds_max;uint16_t queue_depth;
include/scsi/scsi_transport_iscsi.h +14 -5
@@ -30,6 +30,7 @@struct scsi_transport_template ;struct iscsi_transport ; +struct iscsi_endpoint ;struct Scsi_Host ;struct iscsi_cls_conn ;struct iscsi_conn ;
@@ -85,7 +86,7 @@ struct iscsi_transport {/* LLD sets this to indicate what values it can export to sysfs */ uint64_t param_mask;uint64_t host_param_mask; -struct iscsi_cls_session *(*create_session) (struct Scsi_Host *shost, +struct iscsi_cls_session *(*create_session) (struct iscsi_endpoint *ep,uint16_t cmds_max,uint16_t qdepth,uint32_t sn,uint32_t *hn);void (*destroy_session) (struct iscsi_cls_session *session);
@@ -117,10 +118,10 @@ struct iscsi_transport {void (*cleanup_task) (struct iscsi_conn *conn,struct iscsi_task *task);void (*session_recovery_timedout) (struct iscsi_cls_session *session); -int (*ep_connect) (struct sockaddr *dst_addr,int non_blocking, -uint64_t *ep_handle); -int (*ep_poll) (uint64_t ep_handle,int timeout_ms); -void (*ep_disconnect) (uint64_t ep_handle); +struct iscsi_endpoint *(*ep_connect) (struct sockaddr *dst_addr, +int non_blocking); +int (*ep_poll) (struct iscsi_endpoint *ep,int timeout_ms); +void (*ep_disconnect) (struct iscsi_endpoint *ep);int (*tgt_dscvr) (struct Scsi_Host *shost,enum iscsi_tgt_dscvr type,uint32_t enable,struct sockaddr *dst_addr); };
@@ -203,6 +204,11 @@ struct iscsi_cls_host {extern void iscsi_host_for_each_session (struct Scsi_Host *shost,void (*fn)(struct iscsi_cls_session *)); +struct iscsi_endpoint { +void *dd_data;/* LLD private data */ +struct device dev; +unsigned int id; +};/* * session and connection functions that can be used by HW iSCSI LLDs
@@ -233,5 +239,8 @@ extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);extern void iscsi_unblock_session (struct iscsi_cls_session *session);extern void iscsi_block_session (struct iscsi_cls_session *session);extern int iscsi_scan_finished (struct Scsi_Host *shost,unsigned long time); +extern struct iscsi_endpoint *iscsi_create_endpoint (int dd_size); +extern void iscsi_destroy_endpoint (struct iscsi_endpoint *ep); +extern struct iscsi_endpoint *iscsi_lookup_endpoint (u64 handle);#endif
Signature · 1 line
1.5.4.1
PATCH 19/25 iser: Modify iser to take a iscsi_endpoint struct in ep callouts and session setup
From: Mike Christie <[email protected]>
This hooks iser into the iscsi endpoint code. Previously it handled the lookup and allocation. This has been made generic so bnx2i and iser can share it. It also allows us to pass iser the leading conn's ep, so we know the ib_deivce being used and can set it as the scsi_host's parent. And that allows scsi-ml to set the dma_mask based on those values.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 87 +++++++++++++----------------- drivers/infiniband/ulp/iser/iscsi_iser.h | 4 +- drivers/infiniband/ulp/iser/iser_verbs.c | 14 +---- 3 files changed, 43 insertions(+), 62 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +38 -49
@@ -262,24 +262,6 @@ iscsi_iser_cleanup_task(struct iscsi_conn *conn, struct iscsi_task *task) } } -static struct iser_conn * -iscsi_iser_ib_conn_lookup (__u64 ep_handle) -{ -struct iser_conn *ib_conn; -struct iser_conn *uib_conn = (struct iser_conn *)(unsigned long )ep_handle; - -mutex_lock (&ig.connlist_mutex); -list_for_each_entry (ib_conn, &ig.connlist, conn_list) { -if (ib_conn == uib_conn) { -mutex_unlock (&ig.connlist_mutex); -return ib_conn; - } - } -mutex_unlock (&ig.connlist_mutex); -iser_err ("no conn exists for eph %llx\n" ,(unsigned long long )ep_handle); -return NULL ; -} -static struct iscsi_cls_conn *iscsi_iser_conn_create (struct iscsi_cls_session *cls_session,uint32_t conn_idx) {
@@ -335,6 +317,7 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,struct iscsi_conn *conn = cls_conn->dd_data;struct iscsi_iser_conn *iser_conn;struct iser_conn *ib_conn; +struct iscsi_endpoint *ep;int error; error =iscsi_conn_bind (cls_session, cls_conn, is_leading);
@@ -343,12 +326,14 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,/* the transport ep handle comes from user space so it must be * verified against the global ib connections list */ - ib_conn =iscsi_iser_ib_conn_lookup (transport_eph); -if (!ib_conn) { + ep =iscsi_lookup_endpoint (transport_eph); +if (!ep) {iser_err ("can't bind eph %llx\n" , (unsigned long long )transport_eph);return -EINVAL ; } + ib_conn = ep->dd_data; +/* binds the iSER connection retrieved from the previously * connected ep_handle to the iSCSI layer connection. exchanges * connection pointers */
@@ -401,21 +386,17 @@ static void iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session) }static struct iscsi_cls_session * -iscsi_iser_session_create (struct Scsi_Host *shost, +iscsi_iser_session_create (struct iscsi_endpoint *ep,uint16_t cmds_max,uint16_t qdepth,uint32_t initial_cmdsn,uint32_t *hostno) {struct iscsi_cls_session *cls_session;struct iscsi_session *session; +struct Scsi_Host *shost;int i;struct iscsi_task *task;struct iscsi_iser_task *iser_task; - -if (shost) { -printk (KERN_ERR "iscsi_tcp: invalid shost %d.\n" , - shost->host_no); -return NULL ; - } +struct iser_conn *ib_conn; shost =iscsi_host_alloc (&iscsi_iser_sht,0 ,ISCSI_MAX_CMD_PER_LUN );if (!shost)
@@ -426,7 +407,15 @@ iscsi_iser_session_create(struct Scsi_Host *shost, shost->max_channel =0 ; shost->max_cmd_len =16 ; -if (iscsi_host_add (shost,NULL )) +/* +* older userspace tools (before 2.0-870) did not pass us +* the leading conn's ep so this will be NULL; +*/ +if (ep) + ib_conn = ep->dd_data; + +if (iscsi_host_add (shost, + ep ? ib_conn->device->ib_device->dma_device :NULL )) goto free_host; *hostno = shost->host_no;
@@ -529,34 +518,37 @@ iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *s stats->custom[3 ].value = conn->fmr_unalign_cnt; } -static int -iscsi_iser_ep_connect (struct sockaddr *dst_addr,int non_blocking, -__u64 *ep_handle) +static struct iscsi_endpoint * +iscsi_iser_ep_connect (struct sockaddr *dst_addr,int non_blocking) {int err;struct iser_conn *ib_conn; +struct iscsi_endpoint *ep; - err =iser_conn_init (&ib_conn); -if (err) - goto out; + ep =iscsi_create_endpoint (sizeof (*ib_conn)); +if (!ep) +return ERR_PTR (-ENOMEM ); - err =iser_connect (ib_conn,NULL , (struct sockaddr_in *)dst_addr, non_blocking); -if (!err) - *ep_handle = (__u64 )(unsigned long )ib_conn; + ib_conn = ep->dd_data; + ib_conn->ep = ep; +iser_conn_init (ib_conn); -out: -return err; + err =iser_connect (ib_conn,NULL , (struct sockaddr_in *)dst_addr, + non_blocking); +if (err) { +iscsi_destroy_endpoint (ep); +return ERR_PTR (err); + } +return ep; }static int -iscsi_iser_ep_poll (__u64 ep_handle,int timeout_ms) +iscsi_iser_ep_poll (struct iscsi_endpoint *ep,int timeout_ms) { -struct iser_conn *ib_conn =iscsi_iser_ib_conn_lookup (ep_handle); +struct iser_conn *ib_conn;int rc; -if (!ib_conn) -return -EINVAL ; - + ib_conn = ep->dd_data; rc =wait_event_interruptible_timeout (ib_conn->wait, ib_conn->state ==ISER_CONN_UP ,msecs_to_jiffies (timeout_ms));
@@ -578,14 +570,11 @@ iscsi_iser_ep_poll(__u64 ep_handle, int timeout_ms) }static void -iscsi_iser_ep_disconnect (__u64 ep_handle) +iscsi_iser_ep_disconnect (struct iscsi_endpoint *ep) {struct iser_conn *ib_conn; - ib_conn =iscsi_iser_ib_conn_lookup (ep_handle); -if (!ib_conn) -return ; - + ib_conn = ep->dd_data;if (ib_conn->iser_conn)/* * Must suspend xmit path if the ep is bound to the
drivers/infiniband/ulp/iser/iscsi_iser.h +3 -1
@@ -174,6 +174,7 @@ struct iser_data_buf {struct iser_device ;struct iscsi_iser_conn ;struct iscsi_iser_task ; +struct iscsi_endpoint ;struct iser_mem_reg {u32 lkey;
@@ -241,6 +242,7 @@ struct iser_device {struct iser_conn {struct iscsi_iser_conn *iser_conn;/* iser conn for upcalls */ +struct iscsi_endpoint *ep;enum iser_ib_conn_state state;/* rdma connection state */ atomic_t refcount;spinlock_t lock;/* used for state changes */
@@ -313,7 +315,7 @@ void iscsi_iser_recv(struct iscsi_conn *conn,char *rx_data, int rx_data_len); -int iser_conn_init (struct iser_conn **ib_conn); +void iser_conn_init (struct iser_conn *ib_conn);void iser_conn_get (struct iser_conn *ib_conn);
drivers/infiniband/ulp/iser/iser_verbs.c +2 -12
@@ -325,7 +325,7 @@ static void iser_conn_release(struct iser_conn *ib_conn)iser_device_try_release (device);if (ib_conn->iser_conn) ib_conn->iser_conn->ib_conn =NULL ; -kfree (ib_conn); +iscsi_destroy_endpoint (ib_conn->ep); }void iser_conn_get (struct iser_conn *ib_conn)
@@ -494,15 +494,8 @@ static int iser_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *evereturn ret; } -int iser_conn_init (struct iser_conn **ibconn) +void iser_conn_init (struct iser_conn *ib_conn) { -struct iser_conn *ib_conn; - - ib_conn =kzalloc (sizeof *ib_conn,GFP_KERNEL ); -if (!ib_conn) { -iser_err ("can't alloc memory for struct iser_conn\n" ); -return -ENOMEM ; - } ib_conn->state =ISER_CONN_INIT ;init_waitqueue_head (&ib_conn->wait);atomic_set (&ib_conn->post_recv_buf_count,0 );
@@ -510,9 +503,6 @@ int iser_conn_init(struct iser_conn **ibconn)atomic_set (&ib_conn->refcount,1 );INIT_LIST_HEAD (&ib_conn->conn_list);spin_lock_init (&ib_conn->lock); - - *ibconn = ib_conn; -return 0 ; }/**
Signature · 1 line
1.5.4.1
PATCH 20/25 iscsi_tcp: hook iscsi_tcp into iscsi_endpoint code
From: Mike Christie <[email protected]>
iscsi_tcp creates its ep in userspace using sockets because it is virtual, so we just check if we are sent a ep and fail if we are.
--- drivers/scsi/iscsi_tcp.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/iscsi_tcp.c +4 -4
@@ -1838,17 +1838,17 @@ iscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats) }static struct iscsi_cls_session * -iscsi_tcp_session_create (struct Scsi_Host *shost,uint16_t cmds_max, +iscsi_tcp_session_create (struct iscsi_endpoint *ep,uint16_t cmds_max,uint16_t qdepth,uint32_t initial_cmdsn,uint32_t *hostno) {struct iscsi_cls_session *cls_session;struct iscsi_session *session; +struct Scsi_Host *shost;int cmd_i; -if (shost) { -printk (KERN_ERR "iscsi_tcp: invalid shost %d.\n" , - shost->host_no); +if (ep) { +printk (KERN_ERR "iscsi_tcp: invalid ep %p.\n" , ep);return NULL ; }
Signature · 1 line
1.5.4.1
PATCH 21/25 iscsi class: Add session initiatorname and ifacename sysfs attrs.
From: Mike Christie <[email protected]>
This adds two new attrs used for creating initiator ports and binding sessions to hardware.
The session level initiatorname:
Since bnx2i does a scsi_host per host device, we need to add the iface initiator port settings on the session, so we can create multiple initiator ports (each with different inames) per device/scsi_host.
The current iname reflects that qla4xxx can have one iname per hba, and we are allocating a host per session for software. The iname on the host will remain so we can export and set the hba level qla4xxx setting.
The ifacename attr:
To bind a session to a some peice of hardware in userspace we maintain some mappings, but during boot or iscsid restart (iscsid contains the user space part of the driver) we need to be able to figure out which of those host mappings abstractions maps to certain sessions. This patch adds a ifacename attr, which userspace can set to id the host side of the endpoint across pivot_roots and iscsid restarts.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 3 +- drivers/scsi/iscsi_tcp.c | 3 +- drivers/scsi/libiscsi.c | 20 ++++++++ drivers/scsi/scsi_transport_iscsi.c | 6 ++- include/scsi/iscsi_if.h | 79 ++++++++++++++++-------------- include/scsi/libiscsi.h | 2 + 6 files changed, 74 insertions(+), 39 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +2 -1
@@ -629,7 +629,8 @@ static struct iscsi_transport iscsi_iser_transport = {ISCSI_USERNAME |ISCSI_PASSWORD |ISCSI_USERNAME_IN |ISCSI_PASSWORD_IN |ISCSI_FAST_ABORT |ISCSI_ABORT_TMO | - ISCSI_PING_TMO | ISCSI_RECV_TMO, +ISCSI_PING_TMO |ISCSI_RECV_TMO | + ISCSI_IFACE_NAME | ISCSI_INITIATOR_NAME, .host_param_mask =ISCSI_HOST_HWADDRESS |ISCSI_HOST_NETDEV_NAME | ISCSI_HOST_INITIATOR_NAME,
drivers/scsi/iscsi_tcp.c +2 -1
@@ -1957,7 +1957,8 @@ static struct iscsi_transport iscsi_tcp_transport = {ISCSI_USERNAME_IN |ISCSI_PASSWORD_IN |ISCSI_FAST_ABORT |ISCSI_ABORT_TMO |ISCSI_LU_RESET_TMO | - ISCSI_PING_TMO | ISCSI_RECV_TMO, +ISCSI_PING_TMO |ISCSI_RECV_TMO | + ISCSI_IFACE_NAME | ISCSI_INITIATOR_NAME, .host_param_mask =ISCSI_HOST_HWADDRESS |ISCSI_HOST_IPADDRESS |ISCSI_HOST_INITIATOR_NAME | ISCSI_HOST_NETDEV_NAME,
drivers/scsi/libiscsi.c +20 -0
@@ -1990,6 +1990,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)kfree (session->username);kfree (session->username_in);kfree (session->targetname); +kfree (session->initiatorname); +kfree (session->ifacename);iscsi_destroy_session (cls_session);module_put (owner);
@@ -2453,6 +2455,14 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,if (!conn->persistent_address)return -ENOMEM ;break ; +case ISCSI_PARAM_IFACE_NAME : +if (!session->ifacename) + session->ifacename =kstrdup (buf,GFP_KERNEL ); +break ; +case ISCSI_PARAM_INITIATOR_NAME : +if (!session->initiatorname) + session->initiatorname =kstrdup (buf,GFP_KERNEL ); +break ;default :return -ENOSYS ; }
@@ -2519,6 +2529,15 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session,case ISCSI_PARAM_PASSWORD_IN : len =sprintf (buf,"%s\n" , session->password_in);break ; +case ISCSI_PARAM_IFACE_NAME : + len =sprintf (buf,"%s\n" , session->ifacename); +break ; +case ISCSI_PARAM_INITIATOR_NAME : +if (!session->initiatorname) + len =sprintf (buf,"%s\n" ,"unknown" ); +else + len =sprintf (buf,"%s\n" , session->initiatorname); +break ;default :return -ENOSYS ; }
@@ -2606,6 +2625,7 @@ int iscsi_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param,else len =sprintf (buf,"%s\n" , ihost->local_address); +break ;default :return -ENOSYS ; }
drivers/scsi/scsi_transport_iscsi.c +5 -1
@@ -30,7 +30,7 @@#include <scsi/scsi_transport_iscsi.h> #include <scsi/iscsi_if.h> -#define ISCSI_SESSION_ATTRS 19 +#define ISCSI_SESSION_ATTRS 21#define ISCSI_CONN_ATTRS 13#define ISCSI_HOST_ATTRS 4
@@ -1634,6 +1634,8 @@ iscsi_session_attr(password_in, ISCSI_PARAM_PASSWORD_IN, 1);iscsi_session_attr (fast_abort,ISCSI_PARAM_FAST_ABORT ,0 );iscsi_session_attr (abort_tmo,ISCSI_PARAM_ABORT_TMO ,0 );iscsi_session_attr (lu_reset_tmo,ISCSI_PARAM_LU_RESET_TMO ,0 ); +iscsi_session_attr (ifacename,ISCSI_PARAM_IFACE_NAME ,0 ); +iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0) static ssize_t show_priv_session_state(struct device *dev, struct device_attribute *attr,
@@ -1875,6 +1877,8 @@ iscsi_register_transport(struct iscsi_transport *tt)SETUP_SESSION_RD_ATTR (fast_abort,ISCSI_FAST_ABORT );SETUP_SESSION_RD_ATTR (abort_tmo,ISCSI_ABORT_TMO );SETUP_SESSION_RD_ATTR (lu_reset_tmo,ISCSI_LU_RESET_TMO ); +SETUP_SESSION_RD_ATTR (ifacename,ISCSI_IFACE_NAME ); +SETUP_SESSION_RD_ATTR (initiatorname,ISCSI_INITIATOR_NAME );SETUP_PRIV_SESSION_RD_ATTR (recovery_tmo);SETUP_PRIV_SESSION_RD_ATTR (state);
include/scsi/iscsi_if.h +43 -36
95 lines not on this page · raw message
include/scsi/libiscsi.h +2 -0
@@ -270,6 +270,8 @@ struct iscsi_session {char *password;char *password_in;char *targetname; +char *ifacename; +char *initiatorname;/* control data */ struct iscsi_transport *tt;struct Scsi_Host *host;
Signature · 1 line
1.5.4.1
PATCH 22/25 libiscsi: fix cmds_max setting
From: Mike Christie <[email protected]>
Drivers expect that the cmds_max value they pass to the iscsi layer is the max scsi commands + mgmt tasks. This patch implements that and fixes some checks for nr cmd limits.
--- drivers/scsi/libiscsi.c | 49 ++++++++++++++++++++++++++++++++-------------- include/scsi/libiscsi.h | 9 ++++--- 2 files changed, 39 insertions(+), 19 deletions(-)
drivers/scsi/libiscsi.c +34 -15
@@ -1893,29 +1893,48 @@ EXPORT_SYMBOL_GPL(iscsi_host_free);* * This can be used by software iscsi_transports that allocate * a session per scsi host. +* +* Callers should set cmds_max to the largest total numer (mgmt + scsi) of +* tasks they support. The iscsi layer reserves ISCSI_MGMT_CMDS_MAX tasks +* for nop handling and login/logout requests. */ struct iscsi_cls_session *iscsi_session_setup (struct iscsi_transport *iscsit,struct Scsi_Host *shost, -uint16_t scsi_cmds_max,int cmd_task_size, +uint16_t cmds_max,int cmd_task_size,uint32_t initial_cmdsn,unsigned int id) {struct iscsi_session *session;struct iscsi_cls_session *cls_session; -int cmd_i, cmds_max; - +int cmd_i, scsi_cmds, total_cmds = cmds_max;/* -* The iscsi layer needs some tasks for nop handling and tmfs. +* The iscsi layer needs some tasks for nop handling and tmfs, +* so the cmds_max must at least be greater than ISCSI_MGMT_CMDS_MAX +* + 1 command for scsi IO. */ -if (scsi_cmds_max <1 ) - scsi_cmds_max =ISCSI_MGMT_CMDS_MAX ; -if ((scsi_cmds_max +ISCSI_MGMT_CMDS_MAX ) >=ISCSI_MGMT_ITT_OFFSET ) { -printk (KERN_ERR "iscsi: invalid can_queue of %d. " -"can_queue must be less than %d.\n" , - scsi_cmds_max, -ISCSI_MGMT_ITT_OFFSET -ISCSI_MGMT_CMDS_MAX ); - scsi_cmds_max =ISCSI_DEF_XMIT_CMDS_MAX ; +if (total_cmds <ISCSI_TOTAL_CMDS_MIN ) { +printk (KERN_ERR "iscsi: invalid can_queue of %d. can_queue " +"must be a power of two that is at least %d.\n" , + total_cmds,ISCSI_TOTAL_CMDS_MIN ); +return NULL ; + } + +if (total_cmds >ISCSI_TOTAL_CMDS_MAX ) { +printk (KERN_ERR "iscsi: invalid can_queue of %d. can_queue " +"must be a power of 2 less than or equal to %d.\n" , + cmds_max,ISCSI_TOTAL_CMDS_MAX ); + total_cmds =ISCSI_TOTAL_CMDS_MAX ; + } + +if (!is_power_of_2 (total_cmds)) { +printk (KERN_ERR "iscsi: invalid can_queue of %d. can_queue " +"must be a power of 2.\n" , total_cmds); + total_cmds =rounddown_pow_of_two (total_cmds); +if (total_cmds <ISCSI_TOTAL_CMDS_MIN ) +return NULL ; +printk (KERN_INFO "iscsi: Rounding can_queue to %d.\n" , + total_cmds); } - cmds_max =roundup_pow_of_two (scsi_cmds_max +ISCSI_MGMT_CMDS_MAX ); + scsi_cmds = total_cmds -ISCSI_MGMT_CMDS_MAX ; cls_session =iscsi_alloc_session (shost, iscsit,sizeof (struct iscsi_session ));
@@ -1928,8 +1947,8 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, session->fast_abort =1 ; session->lu_reset_timeout =15 ; session->abort_timeout =10 ; - session->scsi_cmds_max = scsi_cmds_max; - session->cmds_max = cmds_max; + session->scsi_cmds_max = scsi_cmds; + session->cmds_max = total_cmds; session->queued_cmdsn = session->cmdsn = initial_cmdsn; session->exp_cmdsn = initial_cmdsn +1 ; session->max_cmdsn = initial_cmdsn +1 ;
include/scsi/libiscsi.h +5 -4
@@ -52,9 +52,7 @@ struct device;#endif #define ISCSI_DEF_XMIT_CMDS_MAX 128/* must be power of 2 */ -#define ISCSI_MGMT_CMDS_MAX 16/* must be power of 2 */ - -#define ISCSI_MGMT_ITT_OFFSET 0xa00 +#define ISCSI_MGMT_CMDS_MAX 15#define ISCSI_DEF_CMD_PER_LUN 32#define ISCSI_MAX_CMD_PER_LUN 128
@@ -72,7 +70,10 @@ enum {/* Connection suspend "bit" */ #define ISCSI_SUSPEND_BIT 1 -#define ISCSI_ITT_MASK (0xfff) +#define ISCSI_ITT_MASK (0x1fff) +#define ISCSI_TOTAL_CMDS_MAX 4096 +/* this must be a power of two greater than ISCSI_MGMT_CMDS_MAX */ +#define ISCSI_TOTAL_CMDS_MIN 16#define ISCSI_AGE_SHIFT 28#define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT)
Signature · 1 line
1.5.4.1
PATCH 23/25 libiscsi, iser, tcp: remove recv_lock
From: Mike Christie <[email protected]>
The recv lock was defined so the iscsi layer could block the recv path from processing IO during recovery. It turns out iser just set a lock to that pointer which was pointless.
We now disconnect the transport connection before doing recovery so we do not need the recv lock. For iscsi_tcp we still stop the recv path incase older tools are being used.
This patch also has iscsi_itt_to_ctask user grab the session lock and has the caller access the task with the lock or get a ref to it in case the target is broken and sends a tmf success response then sends data or a response for the command that was supposed to be affected bty the tmf.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 20 ++-- drivers/infiniband/ulp/iser/iscsi_iser.h | 2 - drivers/infiniband/ulp/iser/iser_initiator.c | 6 + drivers/scsi/iscsi_tcp.c | 73 +++++++------ drivers/scsi/libiscsi.c | 152 +++++++++++++++----------- include/scsi/libiscsi.h | 8 +- 6 files changed, 144 insertions(+), 117 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +10 -10
@@ -281,9 +281,6 @@ iscsi_iser_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx) conn->max_recv_dlength =128 ; iser_conn = conn->dd_data; -/* currently this is the only field which need to be initiated */ -rwlock_init (&iser_conn->lock); - conn->dd_data = iser_conn; iser_conn->iscsi_conn = conn;
@@ -342,9 +339,6 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session, ib_conn->iser_conn = iser_conn; iser_conn->ib_conn = ib_conn;iser_conn_get (ib_conn); - - conn->recv_lock = &iser_conn->lock; -return 0 ; }
@@ -355,12 +349,18 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)struct iscsi_iser_conn *iser_conn = conn->dd_data;struct iser_conn *ib_conn = iser_conn->ib_conn; -iscsi_conn_stop (cls_conn, flag);/* -* There is no unbind event so the stop callback -* must release the ref from the bind. +* Userspace may have goofed up and not bound the connection or +* might have only partially setup the connection. */ -iser_conn_put (ib_conn); +if (ib_conn) { +iscsi_conn_stop (cls_conn, flag); +/* +* There is no unbind event so the stop callback +* must release the ref from the bind. +*/ +iser_conn_put (ib_conn); + } iser_conn->ib_conn =NULL ; }
drivers/infiniband/ulp/iser/iscsi_iser.h +0 -2
@@ -263,8 +263,6 @@ struct iser_conn {struct iscsi_iser_conn {struct iscsi_conn *iscsi_conn;/* ptr to iscsi conn */ struct iser_conn *ib_conn;/* iSER IB conn */ - -rwlock_t lock; };struct iscsi_iser_task {
drivers/infiniband/ulp/iser/iser_initiator.c +6 -0
@@ -558,7 +558,12 @@ void iser_rcv_completion(struct iser_desc *rx_desc, opcode = hdr->opcode &ISCSI_OPCODE_MASK ;if (opcode ==ISCSI_OP_SCSI_CMD_RSP ) { +spin_lock (&conn->iscsi_conn->session->lock); task =iscsi_itt_to_ctask (conn->iscsi_conn, hdr->itt); +if (task) +__iscsi_get_task (task); +spin_unlock (&conn->iscsi_conn->session->lock); +if (!task) iser_err("itt can't be matched to task!!! " "conn %p opcode %d itt %d\n",
@@ -568,6 +573,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc,iser_dbg ("itt %d task %p\n" ,hdr->itt, task); iser_task->status =ISER_TASK_STATUS_COMPLETED ;iser_task_rdma_finalize (iser_task); +iscsi_put_task (task); } }iser_dto_buffs_release (dto);
drivers/scsi/iscsi_tcp.c +39 -34
124 lines not on this page · raw message
drivers/scsi/libiscsi.c +86 -66
270 lines not on this page · raw message
include/scsi/libiscsi.h +3 -5
@@ -139,11 +139,6 @@ struct iscsi_conn {void *dd_data;/* iscsi_transport data */ struct iscsi_session *session;/* parent session */ /* -* LLDs should set this lock. It protects the transport recv -* code -*/ -rwlock_t *recv_lock; -/* * conn_stop() flag: stop to recover, stop to terminate */ int stop_stage;
@@ -374,10 +369,13 @@ extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *, char *, uint32_t);extern int iscsi_complete_pdu (struct iscsi_conn *,struct iscsi_hdr *,char *,int ); +extern int __iscsi_complete_pdu (struct iscsi_conn *,struct iscsi_hdr *, +char *,int );extern int iscsi_verify_itt (struct iscsi_conn *,itt_t );extern struct iscsi_task *iscsi_itt_to_ctask (struct iscsi_conn *,itt_t );extern void iscsi_requeue_task (struct iscsi_task *task);extern void iscsi_put_task (struct iscsi_task *task); +extern void __iscsi_get_task (struct iscsi_task *task);/* * generic helpers
Signature · 1 line
1.5.4.1
PATCH 24/25 Replace __FUNCTION__ with __func__ in iscsi_tcp.
From: Harvey Harrison <[email protected]>
__FUNCTION__ is gcc-specific, use __func__
(Update diff by Mike Christie)
--- drivers/scsi/iscsi_tcp.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/iscsi_tcp.c +6 -6
@@ -544,7 +544,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task)if (tcp_task->exp_datasn != datasn) {debug_tcp ("%s: task->exp_datasn(%d) != rhdr->datasn(%d)\n" , - __FUNCTION__, tcp_task->exp_datasn, datasn); + __func__, tcp_task->exp_datasn, datasn);return ISCSI_ERR_DATASN ; }
@@ -553,7 +553,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) tcp_task->data_offset =be32_to_cpu (rhdr->offset);if (tcp_task->data_offset + tcp_conn->in.datalen > total_in_length) {debug_tcp ("%s: data_offset(%d) + data_len(%d) > total_length_in(%d)\n" , - __FUNCTION__, tcp_task->data_offset, + __func__, tcp_task->data_offset, tcp_conn->in.datalen, total_in_length);return ISCSI_ERR_DATA_OFFSET ; }
@@ -646,7 +646,7 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)if (tcp_task->exp_datasn != r2tsn){debug_tcp ("%s: task->exp_datasn(%d) != rhdr->r2tsn(%d)\n" , - __FUNCTION__, tcp_task->exp_datasn, r2tsn); + __func__, tcp_task->exp_datasn, r2tsn);return ISCSI_ERR_R2TSN ; }
@@ -1193,7 +1193,7 @@ iscsi_tcp_send_hdr_prep(struct iscsi_conn *conn, void *hdr, size_t hdrlen) {struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -debug_tcp ("%s(%p%s)\n" , __FUNCTION__, tcp_conn, +debug_tcp ("%s(%p%s)\n" , __func__, tcp_conn, conn->hdrdgst_en?", digest enabled" :"" );/* Clear the data segment - needs to be filled in by the
@@ -1234,7 +1234,7 @@ iscsi_tcp_send_data_prep(struct iscsi_conn *conn, struct scatterlist *sg,struct hash_desc *tx_hash =NULL ;unsigned int hdr_spec_len; -debug_tcp ("%s(%p, offset=%d, datalen=%d%s)\n" , __FUNCTION__, +debug_tcp ("%s(%p, offset=%d, datalen=%d%s)\n" , __func__, tcp_conn, offset, len, conn->datadgst_en?", digest enabled" :"" );
@@ -1259,7 +1259,7 @@ iscsi_tcp_send_linear_data_prepare(struct iscsi_conn *conn, void *data,struct hash_desc *tx_hash =NULL ;unsigned int hdr_spec_len; -debug_tcp ("%s(%p, datalen=%d%s)\n" , __FUNCTION__, tcp_conn, len, +debug_tcp ("%s(%p, datalen=%d%s)\n" , __func__, tcp_conn, len, conn->datadgst_en?", digest enabled" :"" );/* Make sure the datalen matches what the caller
Signature · 1 line
1.5.4.1
PATCH 25/25 scsi: use get_unaligned_* helpers
From: Harvey Harrison <[email protected]>
--- drivers/scsi/libiscsi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/libiscsi.c +1 -1
@@ -591,7 +591,7 @@ invalid_datalen: goto out; } - senselen =be16_to_cpu (get_unaligned ((__be16 *) data)); + senselen =get_unaligned_be16 (data);if (datalen < senselen) goto invalid_datalen;
Signature · 1 line
1.5.4.1
James Bottomley
maintainerRe: [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task
In reply to [email protected]Quoted 5 lines · On Wed, 2008-05-21 at 15:54 -0500, [email protected] wrote:
From: Mike Christie <[email protected]>
This is the second part of the iscsi task merging, and all it does it rename
iscsi_cmd_tasktoiscsi_taskand mtask/ctask to just task.
OK, I've rebased the scsi-misc tree up to 2.6.26-rc5 (which includes the rc-fixes tree) and I still can't get this to apply:
patching file drivers/scsi/libiscsi.c
Hunk #4 FAILED at 197.
Hunk #8 FAILED at 301.
Hunk #9 FAILED at 320.
Hunk #10 FAILED at 362.
Hunk #11 FAILED at 413.
Hunk #12 FAILED at 437.
Hunk #13 FAILED at 451.
Hunk #14 FAILED at 481.
Hunk #15 FAILED at 501.
Hunk #16 FAILED at 549.
Hunk #17 succeeded at 606 (offset -16 lines). Hunk #18 FAILED at 634.
Hunk #19 FAILED at 650.
Hunk #20 FAILED at 696.
Hunk #21 FAILED at 742.
Hunk #22 FAILED at 792.
Hunk #23 FAILED at 802.
Hunk #24 FAILED at 822.
Hunk #25 succeeded at 903 with fuzz 1 (offset 46 lines). Hunk #26 FAILED at 926.
Hunk #27 FAILED at 938.
Hunk #28 succeeded at 854 (offset -55 lines). Hunk #29 FAILED at 902.
Hunk #30 FAILED at 955.
Hunk #31 FAILED at 968.
Hunk #32 succeeded at 1106 (offset 66 lines). Hunk #33 succeeded at 1017 (offset -55 lines). Hunk #34 succeeded at 1191 (offset 66 lines). Hunk #35 FAILED at 1259.
Hunk #36 FAILED at 1404.
Hunk #37 FAILED at 1447.
Hunk #38 succeeded at 1340 (offset -55 lines). Hunk #39 FAILED at 1433.
Hunk #40 FAILED at 1457.
Hunk #41 FAILED at 1483.
Hunk #42 succeeded at 1621 (offset 66 lines). Hunk #43 succeeded at 1535 (offset -55 lines). Hunk #44 FAILED at 1555.
Hunk #45 FAILED at 1567.
Hunk #46 succeeded at 1705 (offset 66 lines). Hunk #47 succeeded at 1597 (offset -55 lines). Hunk #48 succeeded at 1726 (offset 66 lines). Hunk #49 FAILED at 1773.
Hunk #50 FAILED at 1954.
Hunk #51 FAILED at 1962.
Hunk #52 FAILED at 1970.
Hunk #53 FAILED at 2007.
Hunk #54 FAILED at 2103.
Hunk #55 FAILED at 2186.
Hunk #56 FAILED at 2267.
Hunk #57 FAILED at 2314.
39 out of 57 hunks FAILED -- saving rejects to file drivers/scsi/libiscsi.c.rej
patching file include/scsi/libiscsi.h
Hunk #1 succeeded at 104 (offset 12 lines). Hunk #2 succeeded at 119 (offset -1 lines). Hunk #3 FAILED at 150.
Hunk #4 FAILED at 166.
Hunk #5 succeeded at 297 with fuzz 2 (offset 12 lines). Hunk #6 FAILED at 377.
3 out of 6 hunks FAILED -- saving rejects to file include/scsi/libiscsi.h.rej
patching file include/scsi/scsi_transport_iscsi.h Hunk #1 FAILED at 33.
Hunk #2 FAILED at 112.
2 out of 2 hunks FAILED -- saving rejects to file include/scsi/scsi_transport_iscsi.h.rej
James
James Bottomley
maintainerRe: [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task
Quoted 9 lines · James Bottomley
Quoted 5 lines · On Wed, 2008-05-21 at 15:54 -0500, [email protected] wrote:
From: Mike Christie <[email protected]>
This is the second part of the iscsi task merging, and all it does it rename
iscsi_cmd_tasktoiscsi_taskand mtask/ctask to just task.OK, I've rebased the scsi-misc tree up to 2.6.26-rc5 (which includes the rc-fixes tree) and I still can't get this to apply:
Actually forget this. A careful recount showed me I'd managed to miss one of the 13 preceding patches. Putting it back into the correct place fixed the rejections.
Sorry for the noise,
James
Quoted 2 lines · [email protected] wrote:
This also includes from cleanup patches from Harvey Harrison. It does include the patch from Boaz since I goofed and forgot that we were
This should say it does _not_ include the patch from boaz.
Quoted 3 lines
going to cleanup the
iscsi_ecdb_ahdr260 hardcoding usage and Boaz and James are discussing where to define that. That can go in later when Boaz is ready and those issues are resolved.
Quoted 6 lines · Mike Christie
Quoted 2 lines · [email protected] wrote:
This also includes from cleanup patches from Harvey Harrison. It does include the patch from Boaz since I goofed and forgot that we were
This should say it does _not_ include the patch from boaz.
Rrr, what a girl got to do to get a one liner in the tree around here.
You are the maintainer. Please you decide. I have sent both versions of the patch, one hard coded 260 everywhere, second use of SCSI_MAX_VARLEN_CDB_SIZE. As it stands now SCSI_MAX_VARLEN_CDB_SIZE definition is already in the kernel, but the use of it is not. I have proved that the scsi standard do defines this limit, and the confusion about it just proves that it should be defined.
[
SCSI_Primary_Commands-3-spc3r23
section 4.3.3 The variable length CDB formats:
"The ADDITIONAL CDB LENGTH field specifies the number of additional CDB bytes. This value in the ADDITIONAL CDB LENGTH field shall be a multiple of 4" ]
The 2 patches are here:
http://www.spinics.net/lists/linux-scsi/msg26579.html
Quoted 4 lines
Quoted 4 lines
going to cleanup the
iscsi_ecdb_ahdr260 hardcoding usage and Boaz and James are discussing where to define that. That can go in later when Boaz is ready and those issues are resolved.
Please include the version you like. It looks like James has no farther response on this issue.
Boaz
Quoted 11 lines · Boaz Harrosh
Quoted 5 lines · Mike Christie
Quoted 2 lines · [email protected] wrote:
This also includes from cleanup patches from Harvey Harrison. It does include the patch from Boaz since I goofed and forgot that we were
This should say it does _not_ include the patch from boaz.
Rrr, what a girl got to do to get a one liner in the tree around here.
You are the maintainer. Please you decide. I have sent both versions of the patch, one hard coded 260 everywhere, second use of
SCSI_MAX_VARLEN_CDB_SIZE.
I missed it. Could you send me a link.
Quoted 8 lines · Mike Christie
Quoted 7 lines · Boaz Harrosh
Quoted 5 lines · Mike Christie
Quoted 2 lines · [email protected] wrote:
This also includes from cleanup patches from Harvey Harrison. It does include the patch from Boaz since I goofed and forgot that we were
This should say it does _not_ include the patch from boaz.
Quoted 7 lines
Quoted 4 lines
Rrr, what a girl got to do to get a one liner in the tree around here.
You are the maintainer. Please you decide. I have sent both versions of the patch, one hard coded 260 everywhere, second use of
SCSI_MAX_VARLEN_CDB_SIZE.I missed it. Could you send me a link.
Ah shoot I see it now. It was in mail with two patches and I only saw the last one in there. Could you resend the one where we use SCSI_MAX_VARLEN_CDB_SIZE. Build it over these patches and add my ack.
PATCH 1/1 iscsi_tcp: Enable any size command
Let through upto the largest command of 260 defined by the scsi standard. iscsi core supports this already. Now that the scsi-ml supports it we can start using large commands.
--- drivers/scsi/iscsi_tcp.c | 2 +- include/scsi/iscsi_proto.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/iscsi_tcp.c +1 -1
@@ -1978,7 +1978,7 @@ static struct iscsi_transport iscsi_tcp_transport = { .host_template = &iscsi_sht, .conndata_size = sizeof(struct iscsi_conn), .max_conn = 1, - .max_cmd_len = 16, + .max_cmd_len = SCSI_MAX_VARLEN_CDB_SIZE,/* session management */ .create_session = iscsi_tcp_session_create, .destroy_session = iscsi_tcp_session_destroy,
include/scsi/iscsi_proto.h +2 -1
@@ -22,6 +22,7 @@#define ISCSI_PROTO_H #include <linux/types.h> +#include <scsi/scsi.h> #define ISCSI_DRAFT20_VERSION 0x00
@@ -156,7 +157,7 @@ struct iscsi_ecdb_ahdr {uint8_t ahstype;uint8_t reserved;/* 4-byte aligned extended CDB spillover */ -uint8_t ecdb[260 -ISCSI_CDB_SIZE ]; +uint8_t ecdb[SCSI_MAX_VARLEN_CDB_SIZE -ISCSI_CDB_SIZE ]; };/* SCSI Response Header */
Signature · 1 line
1.5.3.3
James Bottomley
maintainerRe: [PATCH] iscsi_tcp: Enable any size command
Quoted 6 lines · Boaz Harrosh
Let through upto the largest command of 260 defined by the scsi standard. iscsi core supports this already. Now that the scsi-ml supports it we can start using large commands.
Signed-off-by Boaz Harrosh <[email protected]>Signed-off-by Mike Christie <[email protected]>
This Should Be Acked-by not Signed-off-by. Signed-off-by means you got a patch from this person and the order of patch transmission is the
signed off by order. For Mike to have a signed off by at the bottom, I
have to have got the patch from him, not from you.
Also, this doesn't apply against the latest, but I fixed up the rejections (iscsi has moved from template based to setting variables in the shost-> initialisation).
James