* iscsi update for 2.6.27
@ 2008-05-21 20:53 michaelc
2008-05-21 20:53 ` [PATCH 01/25] iscsi class, iscsi_tcp/iser: add host arg to session creation michaelc
2008-05-21 21:06 ` iscsi update for 2.6.27 Mike Christie
0 siblings, 2 replies; 34+ messages in thread
From: michaelc @ 2008-05-21 20:53 UTC (permalink / raw)
To: linux-scsi
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.
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH 01/25] iscsi class, iscsi_tcp/iser: add host arg to session creation
2008-05-21 20:53 iscsi update for 2.6.27 michaelc
@ 2008-05-21 20:53 ` michaelc
2008-05-21 20:53 ` [PATCH 02/25] iscsi class, iscsi drivers: remove unused iscsi_transport attrs michaelc
2008-05-21 21:06 ` iscsi update for 2.6.27 Mike Christie
1 sibling, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:53 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index aeb58ca..efc1219 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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)
{
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 72b9b2a..81c421a 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 65d1737..2a6669d 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1017,21 +1017,38 @@ 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)
+iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev,
+ uint32_t host_no, uint32_t initial_cmdsn,
+ uint16_t cmds_max, uint16_t queue_depth)
{
struct iscsi_transport *transport = priv->iscsi_transport;
struct iscsi_cls_session *session;
- uint32_t hostno;
+ struct Scsi_Host *shost = NULL;
- session = transport->create_session(transport, &priv->t,
- ev->u.c_session.cmds_max,
- ev->u.c_session.queue_depth,
- ev->u.c_session.initial_cmdsn,
- &hostno);
+ /*
+ * 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(transport, &priv->t, shost,
+ cmds_max, queue_depth,
+ initial_cmdsn, &host_no);
+ if (shost)
+ scsi_host_put(shost);
if (!session)
return -ENOMEM;
- ev->r.c_session_ret.host_no = hostno;
+ ev->r.c_session_ret.host_no = host_no;
ev->r.c_session_ret.sid = session->sid;
return 0;
}
@@ -1190,6 +1207,7 @@ 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;
@@ -1208,7 +1226,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);
+ err = iscsi_if_create_session(priv, ev, host_no,
+ 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,
+ ev->u.c_bound_session.initial_cmdsn,
+ ev->u.c_bound_session.cmds_max,
+ ev->u.c_bound_session.queue_depth);
break;
case ISCSI_UEVENT_DESTROY_SESSION:
session = iscsi_session_lookup(ev->u.d_session.sid);
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index e19e584..1883c85 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -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;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index cd3ca63..f24cf02 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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>
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index aab1eae..02a8520 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 02/25] iscsi class, iscsi drivers: remove unused iscsi_transport attrs
2008-05-21 20:53 ` [PATCH 01/25] iscsi class, iscsi_tcp/iser: add host arg to session creation michaelc
@ 2008-05-21 20:53 ` michaelc
2008-05-21 20:53 ` [PATCH 03/25] iscsi class: rename iscsi_host to iscsi_cls_host michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:53 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index efc1219..32f5d5e 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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,
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index a8c1b30..66a2f30 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -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 */
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 81c421a..aecadbd 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index b43bf1d..01a1a4d 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 2a6669d..e6a090e 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -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,
};
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 02a8520..afed70e 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 03/25] iscsi class: rename iscsi_host to iscsi_cls_host
2008-05-21 20:53 ` [PATCH 02/25] iscsi class, iscsi drivers: remove unused iscsi_transport attrs michaelc
@ 2008-05-21 20:53 ` michaelc
2008-05-21 20:53 ` [PATCH 04/25] iscsi: remove session and host binding in libiscsi michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:53 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/scsi_transport_iscsi.c | 24 +++++++++++-------------
include/scsi/scsi_transport_iscsi.h | 2 +-
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index e6a090e..5577a60 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -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);
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index afed70e..7287022 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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;
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 04/25] iscsi: remove session and host binding in libiscsi
2008-05-21 20:53 ` [PATCH 03/25] iscsi class: rename iscsi_host to iscsi_cls_host michaelc
@ 2008-05-21 20:53 ` michaelc
2008-05-21 20:54 ` [PATCH 05/25] iscsi: add iscsi host helpers michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:53 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 32f5d5e..5a75004 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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;
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index aecadbd..8cdcaf3 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -64,6 +64,10 @@ MODULE_LICENSE("GPL");
#define BUG_ON(expr)
#endif
+static struct scsi_transport_template *iscsi_tcp_scsi_transport;
+static struct scsi_host_template iscsi_sht;
+static struct iscsi_transport iscsi_tcp_transport;
+
static unsigned int iscsi_max_lun = 512;
module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
@@ -1623,6 +1627,8 @@ iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session,
struct iscsi_cls_conn *cls_conn, uint64_t transport_eph,
int is_leading)
{
+ struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
+ struct iscsi_host *ihost = shost_priv(shost);
struct iscsi_conn *conn = cls_conn->dd_data;
struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
struct sock *sk;
@@ -1646,8 +1652,8 @@ iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session,
if (err)
goto free_socket;
- err = iscsi_tcp_get_addr(conn, sock, conn->local_address,
- &conn->local_port, kernel_getsockname);
+ err = iscsi_tcp_get_addr(conn, sock, ihost->local_address,
+ &ihost->local_port, kernel_getsockname);
if (err)
goto free_socket;
@@ -1821,29 +1827,6 @@ iscsi_tcp_conn_get_param(struct iscsi_cls_conn *cls_conn,
return len;
}
-static int
-iscsi_tcp_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param,
- char *buf)
-{
- struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
- int len;
-
- switch (param) {
- case ISCSI_HOST_PARAM_IPADDRESS:
- spin_lock_bh(&session->lock);
- if (!session->leadconn)
- len = -ENODEV;
- else
- len = sprintf(buf, "%s\n",
- session->leadconn->local_address);
- spin_unlock_bh(&session->lock);
- break;
- default:
- return iscsi_host_get_param(shost, param, buf);
- }
- return len;
-}
-
static void
iscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats)
{
@@ -1869,26 +1852,44 @@ 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,
- struct Scsi_Host *shost, uint16_t cmds_max,
+iscsi_tcp_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;
- uint32_t hn;
int cmd_i;
- cls_session = iscsi_session_setup(iscsit, scsit, cmds_max, qdepth,
- sizeof(struct iscsi_tcp_cmd_task),
- sizeof(struct iscsi_tcp_mgmt_task),
- initial_cmdsn, &hn);
- if (!cls_session)
+ if (shost) {
+ printk(KERN_ERR "iscsi_tcp: invalid shost %d.\n",
+ shost->host_no);
+ return NULL;
+ }
+
+ shost = scsi_host_alloc(&iscsi_sht, sizeof(struct iscsi_host));
+ if (!shost)
return NULL;
- *hostno = hn;
+ shost->transportt = iscsi_tcp_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;
+
+ 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;
- session = class_to_transport_session(cls_session);
+ shost->can_queue = session->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;
@@ -1904,20 +1905,30 @@ iscsi_tcp_session_create(struct iscsi_transport *iscsit,
mtask->hdr = (struct iscsi_hdr *) &tcp_mtask->hdr;
}
- if (iscsi_r2tpool_alloc(class_to_transport_session(cls_session)))
- goto r2tpool_alloc_fail;
-
+ if (iscsi_r2tpool_alloc(session))
+ goto remove_session;
return cls_session;
-r2tpool_alloc_fail:
+remove_session:
iscsi_session_teardown(cls_session);
+remove_host:
+ scsi_remove_host(shost);
+free_host:
+ iscsi_host_teardown(shost);
+ scsi_host_put(shost);
return NULL;
}
static void iscsi_tcp_session_destroy(struct iscsi_cls_session *cls_session)
{
- iscsi_r2tpool_free(class_to_transport_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);
}
static int iscsi_tcp_slave_configure(struct scsi_device *sdev)
@@ -1976,8 +1987,8 @@ static struct iscsi_transport iscsi_tcp_transport = {
.host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
ISCSI_HOST_INITIATOR_NAME |
ISCSI_HOST_NETDEV_NAME,
- .host_template = &iscsi_sht,
.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,
@@ -1991,7 +2002,7 @@ static struct iscsi_transport iscsi_tcp_transport = {
.start_conn = iscsi_conn_start,
.stop_conn = iscsi_tcp_conn_stop,
/* iscsi host params */
- .get_host_param = iscsi_tcp_host_get_param,
+ .get_host_param = iscsi_host_get_param,
.set_host_param = iscsi_host_set_param,
/* IO */
.send_pdu = iscsi_conn_send_pdu,
@@ -2013,9 +2024,10 @@ iscsi_tcp_init(void)
iscsi_max_lun);
return -EINVAL;
}
- iscsi_tcp_transport.max_lun = iscsi_max_lun;
- if (!iscsi_register_transport(&iscsi_tcp_transport))
+ iscsi_tcp_scsi_transport = iscsi_register_transport(
+ &iscsi_tcp_transport);
+ if (!iscsi_tcp_scsi_transport)
return -ENODEV;
return 0;
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 01a1a4d..64b1dd8 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -38,14 +38,6 @@
#include <scsi/scsi_transport_iscsi.h>
#include <scsi/libiscsi.h>
-struct iscsi_session *
-class_to_transport_session(struct iscsi_cls_session *cls_session)
-{
- struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
- return iscsi_hostdata(shost->hostdata);
-}
-EXPORT_SYMBOL_GPL(class_to_transport_session);
-
/* Serial Number Arithmetic, 32 bits, less than, RFC1982 */
#define SNA32_CHECK 2147483648UL
@@ -1096,6 +1088,7 @@ enum {
int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
{
+ struct iscsi_cls_session *cls_session;
struct Scsi_Host *host;
int reason = 0;
struct iscsi_session *session;
@@ -1109,10 +1102,11 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
host = sc->device->host;
spin_unlock(host->host_lock);
- session = iscsi_hostdata(host->hostdata);
+ cls_session = starget_to_session(scsi_target(sc->device));
+ session = cls_session->dd_data;
spin_lock(&session->lock);
- reason = iscsi_session_chkready(session_to_cls(session));
+ reason = iscsi_session_chkready(cls_session);
if (reason) {
sc->result = reason;
goto fault;
@@ -1222,7 +1216,7 @@ EXPORT_SYMBOL_GPL(iscsi_change_queue_depth);
void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)
{
- struct iscsi_session *session = class_to_transport_session(cls_session);
+ struct iscsi_session *session = cls_session->dd_data;
spin_lock_bh(&session->lock);
if (session->state != ISCSI_STATE_LOGGED_IN) {
@@ -1236,9 +1230,13 @@ EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout);
int iscsi_eh_host_reset(struct scsi_cmnd *sc)
{
- struct Scsi_Host *host = sc->device->host;
- struct iscsi_session *session = iscsi_hostdata(host->hostdata);
- struct iscsi_conn *conn = session->leadconn;
+ struct iscsi_cls_session *cls_session;
+ struct iscsi_session *session;
+ struct iscsi_conn *conn;
+
+ cls_session = starget_to_session(scsi_target(sc->device));
+ session = cls_session->dd_data;
+ conn = session->leadconn;
mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock);
@@ -1405,7 +1403,7 @@ static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd)
enum scsi_eh_timer_return rc = EH_NOT_HANDLED;
cls_session = starget_to_session(scsi_target(scmd->device));
- session = class_to_transport_session(cls_session);
+ session = cls_session->dd_data;
debug_scsi("scsi cmd %p timedout\n", scmd);
@@ -1507,13 +1505,16 @@ static void iscsi_prep_abort_task_pdu(struct iscsi_cmd_task *ctask,
int iscsi_eh_abort(struct scsi_cmnd *sc)
{
- struct Scsi_Host *host = sc->device->host;
- struct iscsi_session *session = iscsi_hostdata(host->hostdata);
+ struct iscsi_cls_session *cls_session;
+ struct iscsi_session *session;
struct iscsi_conn *conn;
struct iscsi_cmd_task *ctask;
struct iscsi_tm *hdr;
int rc, age;
+ cls_session = starget_to_session(scsi_target(sc->device));
+ session = cls_session->dd_data;
+
mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock);
/*
@@ -1630,12 +1631,15 @@ static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
int iscsi_eh_device_reset(struct scsi_cmnd *sc)
{
- struct Scsi_Host *host = sc->device->host;
- struct iscsi_session *session = iscsi_hostdata(host->hostdata);
+ struct iscsi_cls_session *cls_session;
+ struct iscsi_session *session;
struct iscsi_conn *conn;
struct iscsi_tm *hdr;
int rc = FAILED;
+ cls_session = starget_to_session(scsi_target(sc->device));
+ session = cls_session->dd_data;
+
debug_scsi("LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
mutex_lock(&session->eh_mutex);
@@ -1760,55 +1764,53 @@ void iscsi_pool_free(struct iscsi_pool *q)
}
EXPORT_SYMBOL_GPL(iscsi_pool_free);
-/*
- * iSCSI Session's hostdata organization:
- *
- * *------------------* <== hostdata_session(host->hostdata)
- * | ptr to class sess|
- * |------------------| <== iscsi_hostdata(host->hostdata)
- * | iscsi_session |
- * *------------------*
- */
+void iscsi_host_setup(struct Scsi_Host *shost, uint16_t qdepth)
+{
+ if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) {
+ if (qdepth != 0)
+ printk(KERN_ERR "iscsi: invalid queue depth of %d. "
+ "Queue depth must be between 1 and %d.\n",
+ qdepth, ISCSI_MAX_CMD_PER_LUN);
+ qdepth = ISCSI_DEF_CMD_PER_LUN;
+ }
+
+ shost->transportt->create_work_queue = 1;
+ shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
+ shost->cmd_per_lun = qdepth;
+}
+EXPORT_SYMBOL_GPL(iscsi_host_setup);
-#define hostdata_privsize(_sz) (sizeof(unsigned long) + _sz + \
- _sz % sizeof(unsigned long))
+void iscsi_host_teardown(struct Scsi_Host *shost)
+{
+ struct iscsi_host *ihost = shost_priv(shost);
-#define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))
+ kfree(ihost->netdev);
+ kfree(ihost->hwaddress);
+ kfree(ihost->initiatorname);
+}
+EXPORT_SYMBOL_GPL(iscsi_host_teardown);
/**
* iscsi_session_setup - create iscsi cls session and host and session
- * @scsit: scsi transport template
* @iscsit: iscsi transport template
- * @cmds_max: scsi host can queue
- * @qdepth: scsi host cmds per lun
+ * @shost: scsi host
+ * @cmds_max: session can queue
* @cmd_task_size: LLD ctask private data size
* @mgmt_task_size: LLD mtask private data size
* @initial_cmdsn: initial CmdSN
- * @hostno: host no allocated
*
* This can be used by software iscsi_transports that allocate
* a session per scsi host.
- **/
+ */
struct iscsi_cls_session *
-iscsi_session_setup(struct iscsi_transport *iscsit,
- struct scsi_transport_template *scsit,
- uint16_t cmds_max, uint16_t qdepth,
- int cmd_task_size, int mgmt_task_size,
- uint32_t initial_cmdsn, uint32_t *hostno)
+iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
+ uint16_t cmds_max, int cmd_task_size, int mgmt_task_size,
+ uint32_t initial_cmdsn)
{
- struct Scsi_Host *shost;
struct iscsi_session *session;
struct iscsi_cls_session *cls_session;
int cmd_i;
- if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) {
- if (qdepth != 0)
- printk(KERN_ERR "iscsi: invalid queue depth of %d. "
- "Queue depth must be between 1 and %d.\n",
- qdepth, ISCSI_MAX_CMD_PER_LUN);
- qdepth = ISCSI_DEF_CMD_PER_LUN;
- }
-
if (!is_power_of_2(cmds_max) || cmds_max >= ISCSI_MGMT_ITT_OFFSET ||
cmds_max < 2) {
if (cmds_max != 0)
@@ -1819,25 +1821,11 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
cmds_max = ISCSI_DEF_XMIT_CMDS_MAX;
}
- shost = scsi_host_alloc(iscsit->host_template,
- hostdata_privsize(sizeof(*session)));
- if (!shost)
+ cls_session = iscsi_alloc_session(shost, iscsit);
+ if (!cls_session)
return NULL;
-
- /* the iscsi layer takes one task for reserve */
- shost->can_queue = cmds_max - 1;
- shost->cmd_per_lun = qdepth;
- shost->max_id = 1;
- shost->max_channel = 0;
- shost->max_lun = iscsit->max_lun;
- shost->max_cmd_len = 16;
- shost->transportt = scsit;
- shost->transportt->create_work_queue = 1;
- shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
- *hostno = shost->host_no;
-
- session = iscsi_hostdata(shost->hostdata);
- memset(session, 0, sizeof(struct iscsi_session));
+ session = cls_session->dd_data;
+ session->cls_session = cls_session;
session->host = shost;
session->state = ISCSI_STATE_FREE;
session->fast_abort = 1;
@@ -1851,6 +1839,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
session->max_r2t = 1;
session->tt = iscsit;
mutex_init(&session->eh_mutex);
+ spin_lock_init(&session->lock);
/* initialize SCSI PDU commands pool */
if (iscsi_pool_init(&session->cmdpool, session->cmds_max,
@@ -1868,8 +1857,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
INIT_LIST_HEAD(&ctask->running);
}
- spin_lock_init(&session->lock);
-
/* initialize immediate command pool */
if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max,
(void***)&session->mgmt_cmds,
@@ -1887,49 +1874,37 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
INIT_LIST_HEAD(&mtask->running);
}
- if (scsi_add_host(shost, NULL))
- goto add_host_fail;
-
if (!try_module_get(iscsit->owner))
- goto cls_session_fail;
-
- cls_session = iscsi_create_session(shost, iscsit, 0);
- if (!cls_session)
- goto module_put;
- *(unsigned long*)shost->hostdata = (unsigned long)cls_session;
+ goto module_get_fail;
+ if (iscsi_add_session(cls_session, 0))
+ goto cls_session_fail;
return cls_session;
-module_put:
- module_put(iscsit->owner);
cls_session_fail:
- scsi_remove_host(shost);
-add_host_fail:
+ module_put(iscsit->owner);
+module_get_fail:
iscsi_pool_free(&session->mgmtpool);
mgmtpool_alloc_fail:
iscsi_pool_free(&session->cmdpool);
cmdpool_alloc_fail:
- scsi_host_put(shost);
+ iscsi_free_session(cls_session);
return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_session_setup);
/**
* iscsi_session_teardown - destroy session, host, and cls_session
- * shost: scsi host
+ * @cls_session: iscsi session
*
- * This can be used by software iscsi_transports that allocate
- * a session per scsi host.
- **/
+ * The driver must have called iscsi_remove_session before
+ * calling this.
+ */
void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
{
- struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
- struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
+ struct iscsi_session *session = cls_session->dd_data;
struct module *owner = cls_session->transport->owner;
- iscsi_remove_session(cls_session);
- scsi_remove_host(shost);
-
iscsi_pool_free(&session->mgmtpool);
iscsi_pool_free(&session->cmdpool);
@@ -1938,12 +1913,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
kfree(session->username);
kfree(session->username_in);
kfree(session->targetname);
- kfree(session->netdev);
- kfree(session->hwaddress);
- kfree(session->initiatorname);
- iscsi_free_session(cls_session);
- scsi_host_put(shost);
+ iscsi_destroy_session(cls_session);
module_put(owner);
}
EXPORT_SYMBOL_GPL(iscsi_session_teardown);
@@ -1956,7 +1927,7 @@ EXPORT_SYMBOL_GPL(iscsi_session_teardown);
struct iscsi_cls_conn *
iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
{
- struct iscsi_session *session = class_to_transport_session(cls_session);
+ struct iscsi_session *session = cls_session->dd_data;
struct iscsi_conn *conn;
struct iscsi_cls_conn *cls_conn;
char *data;
@@ -2140,7 +2111,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
}
spin_unlock_bh(&session->lock);
- iscsi_unblock_session(session_to_cls(session));
+ iscsi_unblock_session(session->cls_session);
wake_up(&conn->ehwait);
return 0;
}
@@ -2225,7 +2196,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
if (session->state == ISCSI_STATE_IN_RECOVERY &&
old_stop_stage != STOP_CONN_RECOVER) {
debug_scsi("blocking session\n");
- iscsi_block_session(session_to_cls(session));
+ iscsi_block_session(session->cls_session);
}
}
@@ -2260,7 +2231,7 @@ EXPORT_SYMBOL_GPL(iscsi_conn_stop);
int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
struct iscsi_cls_conn *cls_conn, int is_leading)
{
- struct iscsi_session *session = class_to_transport_session(cls_session);
+ struct iscsi_session *session = cls_session->dd_data;
struct iscsi_conn *conn = cls_conn->dd_data;
spin_lock_bh(&session->lock);
@@ -2410,8 +2381,7 @@ EXPORT_SYMBOL_GPL(iscsi_set_param);
int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
enum iscsi_param param, char *buf)
{
- struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
- struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
+ struct iscsi_session *session = cls_session->dd_data;
int len;
switch(param) {
@@ -2525,29 +2495,34 @@ EXPORT_SYMBOL_GPL(iscsi_conn_get_param);
int iscsi_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param,
char *buf)
{
- struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
+ struct iscsi_host *ihost = shost_priv(shost);
int len;
switch (param) {
case ISCSI_HOST_PARAM_NETDEV_NAME:
- if (!session->netdev)
+ if (!ihost->netdev)
len = sprintf(buf, "%s\n", "default");
else
- len = sprintf(buf, "%s\n", session->netdev);
+ len = sprintf(buf, "%s\n", ihost->netdev);
break;
case ISCSI_HOST_PARAM_HWADDRESS:
- if (!session->hwaddress)
+ if (!ihost->hwaddress)
len = sprintf(buf, "%s\n", "default");
else
- len = sprintf(buf, "%s\n", session->hwaddress);
+ len = sprintf(buf, "%s\n", ihost->hwaddress);
break;
case ISCSI_HOST_PARAM_INITIATOR_NAME:
- if (!session->initiatorname)
+ if (!ihost->initiatorname)
len = sprintf(buf, "%s\n", "unknown");
else
- len = sprintf(buf, "%s\n", session->initiatorname);
+ len = sprintf(buf, "%s\n", ihost->initiatorname);
break;
-
+ case ISCSI_HOST_PARAM_IPADDRESS:
+ if (!strlen(ihost->local_address))
+ len = sprintf(buf, "%s\n", "unknown");
+ else
+ len = sprintf(buf, "%s\n",
+ ihost->local_address);
default:
return -ENOSYS;
}
@@ -2559,20 +2534,20 @@ EXPORT_SYMBOL_GPL(iscsi_host_get_param);
int iscsi_host_set_param(struct Scsi_Host *shost, enum iscsi_host_param param,
char *buf, int buflen)
{
- struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
+ struct iscsi_host *ihost = shost_priv(shost);
switch (param) {
case ISCSI_HOST_PARAM_NETDEV_NAME:
- if (!session->netdev)
- session->netdev = kstrdup(buf, GFP_KERNEL);
+ if (!ihost->netdev)
+ ihost->netdev = kstrdup(buf, GFP_KERNEL);
break;
case ISCSI_HOST_PARAM_HWADDRESS:
- if (!session->hwaddress)
- session->hwaddress = kstrdup(buf, GFP_KERNEL);
+ if (!ihost->hwaddress)
+ ihost->hwaddress = kstrdup(buf, GFP_KERNEL);
break;
case ISCSI_HOST_PARAM_INITIATOR_NAME:
- if (!session->initiatorname)
- session->initiatorname = kstrdup(buf, GFP_KERNEL);
+ if (!ihost->initiatorname)
+ ihost->initiatorname = kstrdup(buf, GFP_KERNEL);
break;
default:
return -ENOSYS;
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 0c78694..6c6ee0f 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -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,
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 5577a60..9c00a15 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -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);
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 1883c85..801a677 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -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.
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index f24cf02..8a6271c 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 7287022..702eda2 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 05/25] iscsi: add iscsi host helpers
2008-05-21 20:53 ` [PATCH 04/25] iscsi: remove session and host binding in libiscsi michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 06/25] iscsi: remove session/conn_data_size from iscsi_transport michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
This finishes the host/session unbinding, by adding some helpers
to add and remove hosts and the session they manage.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 5a75004..62e35e5 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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;
}
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 8cdcaf3..e19d92f 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 64b1dd8..73c37c0 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1764,8 +1764,39 @@ void iscsi_pool_free(struct iscsi_pool *q)
}
EXPORT_SYMBOL_GPL(iscsi_pool_free);
-void iscsi_host_setup(struct Scsi_Host *shost, uint16_t qdepth)
+/**
+ * iscsi_host_add - add host to system
+ * @shost: scsi host
+ * @pdev: parent device
+ *
+ * This should be called by partial offload and software iscsi drivers
+ * to add a host to the system.
+ */
+int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev)
+{
+ return scsi_add_host(shost, pdev);
+}
+EXPORT_SYMBOL_GPL(iscsi_host_add);
+
+/**
+ * iscsi_host_alloc - allocate a host and driver data
+ * @sht: scsi host template
+ * @dd_data_size: driver host data size
+ * @qdepth: default device queue depth
+ *
+ * This should be called by partial offload and software iscsi drivers.
+ * To access the driver specific memory use the iscsi_host_priv() macro.
+ */
+struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
+ int dd_data_size, uint16_t qdepth)
{
+ struct Scsi_Host *shost;
+
+ shost = scsi_host_alloc(sht, sizeof(struct iscsi_host) + dd_data_size);
+ if (!shost)
+ return NULL;
+ shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
+
if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) {
if (qdepth != 0)
printk(KERN_ERR "iscsi: invalid queue depth of %d. "
@@ -1773,22 +1804,37 @@ void iscsi_host_setup(struct Scsi_Host *shost, uint16_t qdepth)
qdepth, ISCSI_MAX_CMD_PER_LUN);
qdepth = ISCSI_DEF_CMD_PER_LUN;
}
-
- shost->transportt->create_work_queue = 1;
- shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
shost->cmd_per_lun = qdepth;
+ return shost;
+}
+EXPORT_SYMBOL_GPL(iscsi_host_alloc);
+
+/**
+ * iscsi_host_remove - remove host and sessions
+ * @shost: scsi host
+ *
+ * This will also remove any sessions attached to the host, but if userspace
+ * is managing the session at the same time this will break. TODO: add
+ * refcounting to the netlink iscsi interface so a rmmod or host hot unplug
+ * does not remove the memory from under us.
+ */
+void iscsi_host_remove(struct Scsi_Host *shost)
+{
+ iscsi_host_for_each_session(shost, iscsi_session_teardown);
+ scsi_remove_host(shost);
}
-EXPORT_SYMBOL_GPL(iscsi_host_setup);
+EXPORT_SYMBOL_GPL(iscsi_host_remove);
-void iscsi_host_teardown(struct Scsi_Host *shost)
+void iscsi_host_free(struct Scsi_Host *shost)
{
struct iscsi_host *ihost = shost_priv(shost);
kfree(ihost->netdev);
kfree(ihost->hwaddress);
kfree(ihost->initiatorname);
+ scsi_host_put(shost);
}
-EXPORT_SYMBOL_GPL(iscsi_host_teardown);
+EXPORT_SYMBOL_GPL(iscsi_host_free);
/**
* iscsi_session_setup - create iscsi cls session and host and session
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 9c00a15..6fdaa2e 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -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);
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 8a6271c..9a26d71 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 702eda2..761f62d 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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
*/
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 06/25] iscsi: remove session/conn_data_size from iscsi_transport
2008-05-21 20:54 ` [PATCH 05/25] iscsi: add iscsi host helpers michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 07/25] iscsi: modify iscsi printk so it can take driver data pointers michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 62e35e5..9b34946 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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,
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index e19d92f..dfaf9fa 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 73c37c0..784a935 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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;
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 6c6ee0f..5822dd5 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -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;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 6fdaa2e..6b8516a 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -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);
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 9a26d71..4e1c14f 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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);
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 761f62d..4028f12 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 07/25] iscsi: modify iscsi printk so it can take driver data pointers
2008-05-21 20:54 ` [PATCH 06/25] iscsi: remove session/conn_data_size from iscsi_transport michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 08/25] iser: fix handling of scsi cmnds during recovery michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
include/scsi/libiscsi.h | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 4e1c14f..f54aeb1 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 08/25] iser: fix handling of scsi cmnds during recovery.
2008-05-21 20:54 ` [PATCH 07/25] iscsi: modify iscsi printk so it can take driver data pointers michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 09/25] libiscsi, iscsi_tcp, iser: add session cmds array accessor michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
>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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 9b34946..8a1bfb7 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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,
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index 66a2f30..bd5c1a5 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -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,
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index d19cfe6..5daed2b 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -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);
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 784a935..79bc49f 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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)
{
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 09/25] libiscsi, iscsi_tcp, iser: add session cmds array accessor
2008-05-21 20:54 ` [PATCH 08/25] iser: fix handling of scsi cmnds during recovery michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 10/25] libiscsi: modify libiscsi so it supports offloaded data paths michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 8a1bfb7..7b14688 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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;
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 08dc81c..b82a5f2 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -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);
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index dfaf9fa..f2a08f7 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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) {
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 79bc49f..4bc63c4 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -640,6 +640,10 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
uint32_t itt;
conn->last_recv = jiffies;
+ rc = iscsi_verify_itt(conn, hdr->itt);
+ if (rc)
+ return rc;
+
if (hdr->itt != RESERVED_ITT)
itt = get_itt(hdr->itt);
else
@@ -776,27 +780,22 @@ int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
}
EXPORT_SYMBOL_GPL(iscsi_complete_pdu);
-/* verify itt (itt encoding: age+cid+itt) */
-int iscsi_verify_itt(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
- uint32_t *ret_itt)
+int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)
{
struct iscsi_session *session = conn->session;
struct iscsi_cmd_task *ctask;
- uint32_t itt;
- if (hdr->itt != RESERVED_ITT) {
- if (((__force u32)hdr->itt & ISCSI_AGE_MASK) !=
- (session->age << ISCSI_AGE_SHIFT)) {
- iscsi_conn_printk(KERN_ERR, conn,
- "received itt %x expected session "
- "age (%x)\n", (__force u32)hdr->itt,
- session->age & ISCSI_AGE_MASK);
- return ISCSI_ERR_BAD_ITT;
- }
+ if (itt == RESERVED_ITT)
+ return 0;
- itt = get_itt(hdr->itt);
- } else
- itt = ~0U;
+ if (((__force u32)itt & ISCSI_AGE_MASK) !=
+ (session->age << ISCSI_AGE_SHIFT)) {
+ iscsi_conn_printk(KERN_ERR, conn,
+ "received itt %x expected session age (%x)\n",
+ (__force u32)itt,
+ session->age & ISCSI_AGE_MASK);
+ return ISCSI_ERR_BAD_ITT;
+ }
if (itt < session->cmds_max) {
ctask = session->cmds[itt];
@@ -817,11 +816,38 @@ int iscsi_verify_itt(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
}
}
- *ret_itt = itt;
return 0;
}
EXPORT_SYMBOL_GPL(iscsi_verify_itt);
+struct iscsi_cmd_task *
+iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt)
+{
+ struct iscsi_session *session = conn->session;
+ struct iscsi_cmd_task *ctask;
+ uint32_t i;
+
+ if (iscsi_verify_itt(conn, itt))
+ return NULL;
+
+ if (itt == RESERVED_ITT)
+ return NULL;
+
+ i = get_itt(itt);
+ if (i >= session->cmds_max)
+ return NULL;
+
+ ctask = session->cmds[i];
+ if (!ctask->sc)
+ return NULL;
+
+ if (ctask->sc->SCp.phase != session->age)
+ return NULL;
+
+ return ctask;
+}
+EXPORT_SYMBOL_GPL(iscsi_itt_to_ctask);
+
void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err)
{
struct iscsi_session *session = conn->session;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index f54aeb1..9be6a70 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 10/25] libiscsi: modify libiscsi so it supports offloaded data paths
2008-05-21 20:54 ` [PATCH 09/25] libiscsi, iscsi_tcp, iser: add session cmds array accessor michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 11/25] libiscsi: merge iscsi_mgmt_task and iscsi_cmd_task michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/libiscsi.c | 179 +++++++++++++++++++++++++++--------------------
1 files changed, 104 insertions(+), 75 deletions(-)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 4bc63c4..1e605de 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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)
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 11/25] libiscsi: merge iscsi_mgmt_task and iscsi_cmd_task
2008-05-21 20:54 ` [PATCH 10/25] libiscsi: modify libiscsi so it supports offloaded data paths michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 12/25] iscsi_tcp: convert iscsi_tcp to support merged tasks michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/libiscsi.c | 518 +++++++++++++++++------------------
include/scsi/libiscsi.h | 29 +--
include/scsi/scsi_transport_iscsi.h | 41 ++--
3 files changed, 272 insertions(+), 316 deletions(-)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 1e605de..ef92b1b 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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)
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 9be6a70..d1c3675 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 4028f12..3f24503 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -34,7 +34,6 @@ struct Scsi_Host;
struct iscsi_cls_conn;
struct iscsi_conn;
struct iscsi_cmd_task;
-struct iscsi_mgmt_task;
struct sockaddr;
/**
@@ -58,19 +57,22 @@ struct sockaddr;
* @stop_conn: suspend/recover/terminate connection
* @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text.
* @session_recovery_timedout: notify LLD a block during recovery timed out
- * @init_cmd_task: Initialize a iscsi_cmd_task and any internal structs.
- * Called from queuecommand with session lock held.
- * @init_mgmt_task: Initialize a iscsi_mgmt_task and any internal structs.
- * Called from iscsi_conn_send_generic with xmitmutex.
- * @xmit_cmd_task: Requests LLD to transfer cmd task. Returns 0 or the
+ * @init_task: Initialize a iscsi_task and any internal structs.
+ * When offloading the data path, this is called from
+ * queuecommand with the session lock, or from the
+ * iscsi_conn_send_pdu context with the session lock.
+ * When not offloading the data path, this is called
+ * from the scsi work queue without the session lock.
+ * @xmit_task Requests LLD to transfer cmd task. Returns 0 or the
* the number of bytes transferred on success, and -Exyz
- * value on error.
- * @xmit_mgmt_task: Requests LLD to transfer mgmt task. Returns 0 or the
- * the number of bytes transferred on success, and -Exyz
- * value on error.
- * @cleanup_cmd_task: requests LLD to fail cmd task. Called with xmitmutex
- * and session->lock after the connection has been
- * suspended and terminated during recovery. If called
+ * value on error. When offloading the data path, this
+ * is called from queuecommand with the session lock, or
+ * from the iscsi_conn_send_pdu context with the session
+ * lock. When not offloading the data path, this is called
+ * from the scsi work queue without the session lock.
+ * @cleanup_task: requests LLD to fail task. Called with session lock
+ * and after the connection has been suspended and
+ * terminated during recovery. If called
* from abort task then connection is not suspended
* or terminated but sk_callback_lock is held
*
@@ -110,15 +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_cmd_task) (struct iscsi_cmd_task *ctask);
- void (*init_mgmt_task) (struct iscsi_conn *conn,
- struct iscsi_mgmt_task *mtask);
- int (*xmit_cmd_task) (struct iscsi_conn *conn,
- struct iscsi_cmd_task *ctask);
- void (*cleanup_cmd_task) (struct iscsi_conn *conn,
- struct iscsi_cmd_task *ctask);
- int (*xmit_mgmt_task) (struct iscsi_conn *conn,
- struct iscsi_mgmt_task *mtask);
+ int (*init_task) (struct iscsi_cmd_task *task);
+ int (*xmit_task) (struct iscsi_cmd_task *task);
+ void (*cleanup_task) (struct iscsi_conn *conn,
+ struct iscsi_cmd_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);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 12/25] iscsi_tcp: convert iscsi_tcp to support merged tasks
2008-05-21 20:54 ` [PATCH 11/25] libiscsi: merge iscsi_mgmt_task and iscsi_cmd_task michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 13/25] iser: convert ib_iser " michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
Convert iscsi_tcp to support merged tasks.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/iscsi_tcp.c | 130 +++++++++++++++++++---------------------------
drivers/scsi/iscsi_tcp.h | 5 --
2 files changed, 54 insertions(+), 81 deletions(-)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index f2a08f7..517bad1 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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,
};
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h
index ed0b991..c9c8633 100644
--- a/drivers/scsi/iscsi_tcp.h
+++ b/drivers/scsi/iscsi_tcp.h
@@ -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 */
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 13/25] iser: convert ib_iser to support merged tasks
2008-05-21 20:54 ` [PATCH 12/25] iscsi_tcp: convert iscsi_tcp to support merged tasks michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
Convert ib_iser to support merged tasks.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 7b14688..baecca1 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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,
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index bd5c1a5..96a600f 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -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);
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index b82a5f2..4ea78fb 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -300,13 +300,13 @@ int iser_conn_set_full_featured_mode(struct iscsi_conn *conn)
}
static int
-iser_check_xmit(struct iscsi_conn *conn, void *task)
+iser_check_xmit(struct iscsi_conn *conn, void *ctask)
{
struct iscsi_iser_conn *iser_conn = conn->dd_data;
if (atomic_read(&iser_conn->ib_conn->post_send_buf_count) ==
ISER_QP_MAX_REQ_DTOS) {
- iser_dbg("%ld can't xmit task %p\n",jiffies,task);
+ iser_dbg("%ld can't xmit ctask %p\n",jiffies,ctask);
return -ENOBUFS;
}
return 0;
@@ -316,7 +316,7 @@ iser_check_xmit(struct iscsi_conn *conn, void *task)
/**
* iser_send_command - send command PDU
*/
-int iser_send_command(struct iscsi_conn *conn,
+int iser_send_command(struct iscsi_conn *conn,
struct iscsi_cmd_task *ctask)
{
struct iscsi_iser_conn *iser_conn = conn->dd_data;
@@ -395,7 +395,7 @@ send_command_error:
/**
* iser_send_data_out - send data out PDU
*/
-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)
{
@@ -470,10 +470,11 @@ send_data_out_error:
}
int iser_send_control(struct iscsi_conn *conn,
- struct iscsi_mgmt_task *mtask)
+ struct iscsi_cmd_task *ctask)
{
struct iscsi_iser_conn *iser_conn = conn->dd_data;
- struct iser_desc *mdesc = mtask->dd_data;
+ struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
+ struct iser_desc *mdesc = &iser_ctask->desc;
struct iser_dto *send_dto = NULL;
unsigned long data_seg_len;
int err = 0;
@@ -485,7 +486,7 @@ int iser_send_control(struct iscsi_conn *conn,
return -EPERM;
}
- if (iser_check_xmit(conn,mtask))
+ if (iser_check_xmit(conn, ctask))
return -ENOBUFS;
/* build the tx desc regd header and add it to the tx desc dto */
@@ -498,14 +499,14 @@ int iser_send_control(struct iscsi_conn *conn,
iser_reg_single(device, send_dto->regd[0], DMA_TO_DEVICE);
- data_seg_len = ntoh24(mtask->hdr->dlength);
+ data_seg_len = ntoh24(ctask->hdr->dlength);
if (data_seg_len > 0) {
regd_buf = &mdesc->data_regd_buf;
memset(regd_buf, 0, sizeof(struct iser_regd_buf));
regd_buf->device = device;
- regd_buf->virt_addr = mtask->data;
- regd_buf->data_size = mtask->data_count;
+ regd_buf->virt_addr = ctask->data;
+ regd_buf->data_size = ctask->data_count;
iser_reg_single(device, regd_buf,
DMA_TO_DEVICE);
iser_dto_add_regd_buff(send_dto, regd_buf,
@@ -535,7 +536,7 @@ send_control_error:
void iser_rcv_completion(struct iser_desc *rx_desc,
unsigned long dto_xfer_len)
{
- struct iser_dto *dto = &rx_desc->dto;
+ struct iser_dto *dto = &rx_desc->dto;
struct iscsi_iser_conn *conn = dto->ib_conn->iser_conn;
struct iscsi_cmd_task *ctask;
struct iscsi_iser_cmd_task *iser_ctask;
@@ -559,7 +560,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
if (opcode == ISCSI_OP_SCSI_CMD_RSP) {
ctask = iscsi_itt_to_ctask(conn->iscsi_conn, hdr->itt);
if (!ctask)
- iser_err("itt can't be matched to task!!! "
+ iser_err("itt can't be matched to ctask!!! "
"conn %p opcode %d itt %d\n",
conn->iscsi_conn, opcode, hdr->itt);
else {
@@ -577,7 +578,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
kmem_cache_free(ig.desc_cache, rx_desc);
/* decrementing conn->post_recv_buf_count only --after-- freeing the *
- * task eliminates the need to worry on tasks which are completed in *
+ * ctask eliminates the need to worry on ctasks which are completed in *
* parallel to the execution of iser_conn_term. So the code that waits *
* for the posted rx bufs refcount to become zero handles everything */
atomic_dec(&conn->ib_conn->post_recv_buf_count);
@@ -589,7 +590,7 @@ void iser_snd_completion(struct iser_desc *tx_desc)
struct iser_conn *ib_conn = dto->ib_conn;
struct iscsi_iser_conn *iser_conn = ib_conn->iser_conn;
struct iscsi_conn *conn = iser_conn->iscsi_conn;
- struct iscsi_mgmt_task *mtask;
+ struct iscsi_cmd_task *ctask;
int resume_tx = 0;
iser_dbg("Initiator, Data sent dto=0x%p\n", dto);
@@ -612,15 +613,10 @@ void iser_snd_completion(struct iser_desc *tx_desc)
if (tx_desc->type == ISCSI_TX_CONTROL) {
/* this arithmetic is legal by libiscsi dd_data allocation */
- mtask = (void *) ((long)(void *)tx_desc -
- sizeof(struct iscsi_mgmt_task));
- if (mtask->hdr->itt == RESERVED_ITT) {
- struct iscsi_session *session = conn->session;
-
- spin_lock(&conn->session->lock);
- iscsi_free_mgmt_task(conn, mtask);
- spin_unlock(&session->lock);
- }
+ ctask = (void *) ((long)(void *)tx_desc -
+ sizeof(struct iscsi_cmd_task));
+ if (ctask->hdr->itt == RESERVED_ITT)
+ iscsi_put_ctask(ctask);
}
}
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task
2008-05-21 20:54 ` [PATCH 13/25] iser: convert ib_iser " michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 15/25] iscsi_tcp: handle iscsi_cmd_task rename michaelc
2008-06-05 14:53 ` [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task James Bottomley
0 siblings, 2 replies; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/libiscsi.c | 514 ++++++++++++++++++-----------------
include/scsi/libiscsi.h | 22 +-
include/scsi/scsi_transport_iscsi.h | 8 +-
3 files changed, 273 insertions(+), 271 deletions(-)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index ef92b1b..92ee6d9 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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)
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index d1c3675..176353c 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 3f24503..0553240 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 15/25] iscsi_tcp: handle iscsi_cmd_task rename
2008-05-21 20:54 ` [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 16/25] iser: " michaelc
2008-06-05 14:53 ` [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task James Bottomley
1 sibling, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
This converts iscsi_tcp to use the iscsi_task name.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/iscsi_tcp.c | 262 +++++++++++++++++++++++-----------------------
drivers/scsi/iscsi_tcp.h | 2 +-
2 files changed, 132 insertions(+), 132 deletions(-)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 517bad1..33cd0ca 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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))
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h
index c9c8633..498d8ca 100644
--- a/drivers/scsi/iscsi_tcp.h
+++ b/drivers/scsi/iscsi_tcp.h
@@ -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 +
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 16/25] iser: handle iscsi_cmd_task rename
2008-05-21 20:54 ` [PATCH 15/25] iscsi_tcp: handle iscsi_cmd_task rename michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 17/25] iscsi class: user device_for_each_child instead of duplicating session list michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
This handles the iscsi_cmd_task rename and renames
the iser cmd task to iser task.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index baecca1..86d9c42 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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;
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index 96a600f..05431f2 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -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 2
struct 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
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 4ea78fb..35af60a 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -66,46 +66,46 @@ static void iser_dto_add_regd_buff(struct iser_dto *dto,
/* Register user buffer memory and initialize passive rdma
* dto descriptor. Total data size is stored in
- * iser_ctask->data[ISER_DIR_IN].data_len
+ * iser_task->data[ISER_DIR_IN].data_len
*/
-static int iser_prepare_read_cmd(struct iscsi_cmd_task *ctask,
+static int iser_prepare_read_cmd(struct iscsi_task *task,
unsigned int edtl)
{
- struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
+ struct iscsi_iser_task *iser_task = task->dd_data;
struct iser_regd_buf *regd_buf;
int err;
- struct iser_hdr *hdr = &iser_ctask->desc.iser_header;
- struct iser_data_buf *buf_in = &iser_ctask->data[ISER_DIR_IN];
+ struct iser_hdr *hdr = &iser_task->desc.iser_header;
+ struct iser_data_buf *buf_in = &iser_task->data[ISER_DIR_IN];
- err = iser_dma_map_task_data(iser_ctask,
+ err = iser_dma_map_task_data(iser_task,
buf_in,
ISER_DIR_IN,
DMA_FROM_DEVICE);
if (err)
return err;
- if (edtl > iser_ctask->data[ISER_DIR_IN].data_len) {
+ if (edtl > iser_task->data[ISER_DIR_IN].data_len) {
iser_err("Total data length: %ld, less than EDTL: "
"%d, in READ cmd BHS itt: %d, conn: 0x%p\n",
- iser_ctask->data[ISER_DIR_IN].data_len, edtl,
- ctask->itt, iser_ctask->iser_conn);
+ iser_task->data[ISER_DIR_IN].data_len, edtl,
+ task->itt, iser_task->iser_conn);
return -EINVAL;
}
- err = iser_reg_rdma_mem(iser_ctask,ISER_DIR_IN);
+ err = iser_reg_rdma_mem(iser_task,ISER_DIR_IN);
if (err) {
iser_err("Failed to set up Data-IN RDMA\n");
return err;
}
- regd_buf = &iser_ctask->rdma_regd[ISER_DIR_IN];
+ regd_buf = &iser_task->rdma_regd[ISER_DIR_IN];
hdr->flags |= ISER_RSV;
hdr->read_stag = cpu_to_be32(regd_buf->reg.rkey);
hdr->read_va = cpu_to_be64(regd_buf->reg.va);
iser_dbg("Cmd itt:%d READ tags RKEY:%#.4X VA:%#llX\n",
- ctask->itt, regd_buf->reg.rkey,
+ task->itt, regd_buf->reg.rkey,
(unsigned long long)regd_buf->reg.va);
return 0;
@@ -113,43 +113,43 @@ static int iser_prepare_read_cmd(struct iscsi_cmd_task *ctask,
/* Register user buffer memory and initialize passive rdma
* dto descriptor. Total data size is stored in
- * ctask->data[ISER_DIR_OUT].data_len
+ * task->data[ISER_DIR_OUT].data_len
*/
static int
-iser_prepare_write_cmd(struct iscsi_cmd_task *ctask,
+iser_prepare_write_cmd(struct iscsi_task *task,
unsigned int imm_sz,
unsigned int unsol_sz,
unsigned int edtl)
{
- struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
+ struct iscsi_iser_task *iser_task = task->dd_data;
struct iser_regd_buf *regd_buf;
int err;
- struct iser_dto *send_dto = &iser_ctask->desc.dto;
- struct iser_hdr *hdr = &iser_ctask->desc.iser_header;
- struct iser_data_buf *buf_out = &iser_ctask->data[ISER_DIR_OUT];
+ struct iser_dto *send_dto = &iser_task->desc.dto;
+ struct iser_hdr *hdr = &iser_task->desc.iser_header;
+ struct iser_data_buf *buf_out = &iser_task->data[ISER_DIR_OUT];
- err = iser_dma_map_task_data(iser_ctask,
+ err = iser_dma_map_task_data(iser_task,
buf_out,
ISER_DIR_OUT,
DMA_TO_DEVICE);
if (err)
return err;
- if (edtl > iser_ctask->data[ISER_DIR_OUT].data_len) {
+ if (edtl > iser_task->data[ISER_DIR_OUT].data_len) {
iser_err("Total data length: %ld, less than EDTL: %d, "
"in WRITE cmd BHS itt: %d, conn: 0x%p\n",
- iser_ctask->data[ISER_DIR_OUT].data_len,
- edtl, ctask->itt, ctask->conn);
+ iser_task->data[ISER_DIR_OUT].data_len,
+ edtl, task->itt, task->conn);
return -EINVAL;
}
- err = iser_reg_rdma_mem(iser_ctask,ISER_DIR_OUT);
+ err = iser_reg_rdma_mem(iser_task,ISER_DIR_OUT);
if (err != 0) {
iser_err("Failed to register write cmd RDMA mem\n");
return err;
}
- regd_buf = &iser_ctask->rdma_regd[ISER_DIR_OUT];
+ regd_buf = &iser_task->rdma_regd[ISER_DIR_OUT];
if (unsol_sz < edtl) {
hdr->flags |= ISER_WSV;
@@ -158,13 +158,13 @@ iser_prepare_write_cmd(struct iscsi_cmd_task *ctask,
iser_dbg("Cmd itt:%d, WRITE tags, RKEY:%#.4X "
"VA:%#llX + unsol:%d\n",
- ctask->itt, regd_buf->reg.rkey,
+ task->itt, regd_buf->reg.rkey,
(unsigned long long)regd_buf->reg.va, unsol_sz);
}
if (imm_sz > 0) {
iser_dbg("Cmd itt:%d, WRITE, adding imm.data sz: %d\n",
- ctask->itt, imm_sz);
+ task->itt, imm_sz);
iser_dto_add_regd_buff(send_dto,
regd_buf,
0,
@@ -300,13 +300,13 @@ int iser_conn_set_full_featured_mode(struct iscsi_conn *conn)
}
static int
-iser_check_xmit(struct iscsi_conn *conn, void *ctask)
+iser_check_xmit(struct iscsi_conn *conn, void *task)
{
struct iscsi_iser_conn *iser_conn = conn->dd_data;
if (atomic_read(&iser_conn->ib_conn->post_send_buf_count) ==
ISER_QP_MAX_REQ_DTOS) {
- iser_dbg("%ld can't xmit ctask %p\n",jiffies,ctask);
+ iser_dbg("%ld can't xmit task %p\n",jiffies,task);
return -ENOBUFS;
}
return 0;
@@ -317,37 +317,37 @@ iser_check_xmit(struct iscsi_conn *conn, void *ctask)
* iser_send_command - send command PDU
*/
int iser_send_command(struct iscsi_conn *conn,
- struct iscsi_cmd_task *ctask)
+ struct iscsi_task *task)
{
struct iscsi_iser_conn *iser_conn = conn->dd_data;
- struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
+ struct iscsi_iser_task *iser_task = task->dd_data;
struct iser_dto *send_dto = NULL;
unsigned long edtl;
int err = 0;
struct iser_data_buf *data_buf;
- struct iscsi_cmd *hdr = ctask->hdr;
- struct scsi_cmnd *sc = ctask->sc;
+ struct iscsi_cmd *hdr = task->hdr;
+ struct scsi_cmnd *sc = task->sc;
if (!iser_conn_state_comp(iser_conn->ib_conn, ISER_CONN_UP)) {
iser_err("Failed to send, conn: 0x%p is not up\n", iser_conn->ib_conn);
return -EPERM;
}
- if (iser_check_xmit(conn, ctask))
+ if (iser_check_xmit(conn, task))
return -ENOBUFS;
edtl = ntohl(hdr->data_length);
/* build the tx desc regd header and add it to the tx desc dto */
- iser_ctask->desc.type = ISCSI_TX_SCSI_COMMAND;
- send_dto = &iser_ctask->desc.dto;
- send_dto->ctask = iser_ctask;
- iser_create_send_desc(iser_conn, &iser_ctask->desc);
+ iser_task->desc.type = ISCSI_TX_SCSI_COMMAND;
+ send_dto = &iser_task->desc.dto;
+ send_dto->task = iser_task;
+ iser_create_send_desc(iser_conn, &iser_task->desc);
if (hdr->flags & ISCSI_FLAG_CMD_READ)
- data_buf = &iser_ctask->data[ISER_DIR_IN];
+ data_buf = &iser_task->data[ISER_DIR_IN];
else
- data_buf = &iser_ctask->data[ISER_DIR_OUT];
+ data_buf = &iser_task->data[ISER_DIR_OUT];
if (scsi_sg_count(sc)) { /* using a scatter list */
data_buf->buf = scsi_sglist(sc);
@@ -357,15 +357,15 @@ int iser_send_command(struct iscsi_conn *conn,
data_buf->data_len = scsi_bufflen(sc);
if (hdr->flags & ISCSI_FLAG_CMD_READ) {
- err = iser_prepare_read_cmd(ctask, edtl);
+ err = iser_prepare_read_cmd(task, edtl);
if (err)
goto send_command_error;
}
if (hdr->flags & ISCSI_FLAG_CMD_WRITE) {
- err = iser_prepare_write_cmd(ctask,
- ctask->imm_count,
- ctask->imm_count +
- ctask->unsol_count,
+ err = iser_prepare_write_cmd(task,
+ task->imm_count,
+ task->imm_count +
+ task->unsol_count,
edtl);
if (err)
goto send_command_error;
@@ -380,15 +380,15 @@ int iser_send_command(struct iscsi_conn *conn,
goto send_command_error;
}
- iser_ctask->status = ISER_TASK_STATUS_STARTED;
+ iser_task->status = ISER_TASK_STATUS_STARTED;
- err = iser_post_send(&iser_ctask->desc);
+ err = iser_post_send(&iser_task->desc);
if (!err)
return 0;
send_command_error:
iser_dto_buffs_release(send_dto);
- iser_err("conn %p failed ctask->itt %d err %d\n",conn, ctask->itt, err);
+ iser_err("conn %p failed task->itt %d err %d\n",conn, task->itt, err);
return err;
}
@@ -396,11 +396,11 @@ send_command_error:
* iser_send_data_out - send data out PDU
*/
int iser_send_data_out(struct iscsi_conn *conn,
- struct iscsi_cmd_task *ctask,
+ struct iscsi_task *task,
struct iscsi_data *hdr)
{
struct iscsi_iser_conn *iser_conn = conn->dd_data;
- struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
+ struct iscsi_iser_task *iser_task = task->dd_data;
struct iser_desc *tx_desc = NULL;
struct iser_dto *send_dto = NULL;
unsigned long buf_offset;
@@ -413,7 +413,7 @@ int iser_send_data_out(struct iscsi_conn *conn,
return -EPERM;
}
- if (iser_check_xmit(conn, ctask))
+ if (iser_check_xmit(conn, task))
return -ENOBUFS;
itt = (__force uint32_t)hdr->itt;
@@ -434,7 +434,7 @@ int iser_send_data_out(struct iscsi_conn *conn,
/* build the tx desc regd header and add it to the tx desc dto */
send_dto = &tx_desc->dto;
- send_dto->ctask = iser_ctask;
+ send_dto->task = iser_task;
iser_create_send_desc(iser_conn, tx_desc);
iser_reg_single(iser_conn->ib_conn->device,
@@ -442,15 +442,15 @@ int iser_send_data_out(struct iscsi_conn *conn,
/* all data was registered for RDMA, we can use the lkey */
iser_dto_add_regd_buff(send_dto,
- &iser_ctask->rdma_regd[ISER_DIR_OUT],
+ &iser_task->rdma_regd[ISER_DIR_OUT],
buf_offset,
data_seg_len);
- if (buf_offset + data_seg_len > iser_ctask->data[ISER_DIR_OUT].data_len) {
+ if (buf_offset + data_seg_len > iser_task->data[ISER_DIR_OUT].data_len) {
iser_err("Offset:%ld & DSL:%ld in Data-Out "
"inconsistent with total len:%ld, itt:%d\n",
buf_offset, data_seg_len,
- iser_ctask->data[ISER_DIR_OUT].data_len, itt);
+ iser_task->data[ISER_DIR_OUT].data_len, itt);
err = -EINVAL;
goto send_data_out_error;
}
@@ -470,11 +470,11 @@ send_data_out_error:
}
int iser_send_control(struct iscsi_conn *conn,
- struct iscsi_cmd_task *ctask)
+ struct iscsi_task *task)
{
struct iscsi_iser_conn *iser_conn = conn->dd_data;
- struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data;
- struct iser_desc *mdesc = &iser_ctask->desc;
+ struct iscsi_iser_task *iser_task = task->dd_data;
+ struct iser_desc *mdesc = &iser_task->desc;
struct iser_dto *send_dto = NULL;
unsigned long data_seg_len;
int err = 0;
@@ -486,27 +486,27 @@ int iser_send_control(struct iscsi_conn *conn,
return -EPERM;
}
- if (iser_check_xmit(conn, ctask))
+ if (iser_check_xmit(conn, task))
return -ENOBUFS;
/* build the tx desc regd header and add it to the tx desc dto */
mdesc->type = ISCSI_TX_CONTROL;
send_dto = &mdesc->dto;
- send_dto->ctask = NULL;
+ send_dto->task = NULL;
iser_create_send_desc(iser_conn, mdesc);
device = iser_conn->ib_conn->device;
iser_reg_single(device, send_dto->regd[0], DMA_TO_DEVICE);
- data_seg_len = ntoh24(ctask->hdr->dlength);
+ data_seg_len = ntoh24(task->hdr->dlength);
if (data_seg_len > 0) {
regd_buf = &mdesc->data_regd_buf;
memset(regd_buf, 0, sizeof(struct iser_regd_buf));
regd_buf->device = device;
- regd_buf->virt_addr = ctask->data;
- regd_buf->data_size = ctask->data_count;
+ regd_buf->virt_addr = task->data;
+ regd_buf->data_size = task->data_count;
iser_reg_single(device, regd_buf,
DMA_TO_DEVICE);
iser_dto_add_regd_buff(send_dto, regd_buf,
@@ -538,8 +538,8 @@ 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_cmd_task *ctask;
- struct iscsi_iser_cmd_task *iser_ctask;
+ struct iscsi_task *task;
+ struct iscsi_iser_task *iser_task;
struct iscsi_hdr *hdr;
char *rx_data = NULL;
int rx_data_len = 0;
@@ -558,16 +558,16 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
opcode = hdr->opcode & ISCSI_OPCODE_MASK;
if (opcode == ISCSI_OP_SCSI_CMD_RSP) {
- ctask = iscsi_itt_to_ctask(conn->iscsi_conn, hdr->itt);
- if (!ctask)
- iser_err("itt can't be matched to ctask!!! "
+ task = iscsi_itt_to_ctask(conn->iscsi_conn, hdr->itt);
+ if (!task)
+ iser_err("itt can't be matched to task!!! "
"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_task = task->dd_data;
+ iser_dbg("itt %d task %p\n",hdr->itt, task);
+ iser_task->status = ISER_TASK_STATUS_COMPLETED;
+ iser_task_rdma_finalize(iser_task);
}
}
iser_dto_buffs_release(dto);
@@ -578,7 +578,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
kmem_cache_free(ig.desc_cache, rx_desc);
/* decrementing conn->post_recv_buf_count only --after-- freeing the *
- * ctask eliminates the need to worry on ctasks which are completed in *
+ * task eliminates the need to worry on tasks which are completed in *
* parallel to the execution of iser_conn_term. So the code that waits *
* for the posted rx bufs refcount to become zero handles everything */
atomic_dec(&conn->ib_conn->post_recv_buf_count);
@@ -590,7 +590,7 @@ void iser_snd_completion(struct iser_desc *tx_desc)
struct iser_conn *ib_conn = dto->ib_conn;
struct iscsi_iser_conn *iser_conn = ib_conn->iser_conn;
struct iscsi_conn *conn = iser_conn->iscsi_conn;
- struct iscsi_cmd_task *ctask;
+ struct iscsi_task *task;
int resume_tx = 0;
iser_dbg("Initiator, Data sent dto=0x%p\n", dto);
@@ -613,31 +613,31 @@ void iser_snd_completion(struct iser_desc *tx_desc)
if (tx_desc->type == ISCSI_TX_CONTROL) {
/* this arithmetic is legal by libiscsi dd_data allocation */
- ctask = (void *) ((long)(void *)tx_desc -
- sizeof(struct iscsi_cmd_task));
- if (ctask->hdr->itt == RESERVED_ITT)
- iscsi_put_ctask(ctask);
+ task = (void *) ((long)(void *)tx_desc -
+ sizeof(struct iscsi_task));
+ if (task->hdr->itt == RESERVED_ITT)
+ iscsi_put_task(task);
}
}
-void iser_ctask_rdma_init(struct iscsi_iser_cmd_task *iser_ctask)
+void iser_task_rdma_init(struct iscsi_iser_task *iser_task)
{
- iser_ctask->status = ISER_TASK_STATUS_INIT;
+ iser_task->status = ISER_TASK_STATUS_INIT;
- iser_ctask->dir[ISER_DIR_IN] = 0;
- iser_ctask->dir[ISER_DIR_OUT] = 0;
+ iser_task->dir[ISER_DIR_IN] = 0;
+ iser_task->dir[ISER_DIR_OUT] = 0;
- iser_ctask->data[ISER_DIR_IN].data_len = 0;
- iser_ctask->data[ISER_DIR_OUT].data_len = 0;
+ iser_task->data[ISER_DIR_IN].data_len = 0;
+ iser_task->data[ISER_DIR_OUT].data_len = 0;
- memset(&iser_ctask->rdma_regd[ISER_DIR_IN], 0,
+ memset(&iser_task->rdma_regd[ISER_DIR_IN], 0,
sizeof(struct iser_regd_buf));
- memset(&iser_ctask->rdma_regd[ISER_DIR_OUT], 0,
+ memset(&iser_task->rdma_regd[ISER_DIR_OUT], 0,
sizeof(struct iser_regd_buf));
}
-void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
+void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task)
{
int deferred;
int is_rdma_aligned = 1;
@@ -646,17 +646,17 @@ void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
/* if we were reading, copy back to unaligned sglist,
* anyway dma_unmap and free the copy
*/
- if (iser_ctask->data_copy[ISER_DIR_IN].copy_buf != NULL) {
+ if (iser_task->data_copy[ISER_DIR_IN].copy_buf != NULL) {
is_rdma_aligned = 0;
- iser_finalize_rdma_unaligned_sg(iser_ctask, ISER_DIR_IN);
+ iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_IN);
}
- if (iser_ctask->data_copy[ISER_DIR_OUT].copy_buf != NULL) {
+ if (iser_task->data_copy[ISER_DIR_OUT].copy_buf != NULL) {
is_rdma_aligned = 0;
- iser_finalize_rdma_unaligned_sg(iser_ctask, ISER_DIR_OUT);
+ iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_OUT);
}
- if (iser_ctask->dir[ISER_DIR_IN]) {
- regd = &iser_ctask->rdma_regd[ISER_DIR_IN];
+ if (iser_task->dir[ISER_DIR_IN]) {
+ regd = &iser_task->rdma_regd[ISER_DIR_IN];
deferred = iser_regd_buff_release(regd);
if (deferred) {
iser_err("%d references remain for BUF-IN rdma reg\n",
@@ -664,8 +664,8 @@ void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
}
}
- if (iser_ctask->dir[ISER_DIR_OUT]) {
- regd = &iser_ctask->rdma_regd[ISER_DIR_OUT];
+ if (iser_task->dir[ISER_DIR_OUT]) {
+ regd = &iser_task->rdma_regd[ISER_DIR_OUT];
deferred = iser_regd_buff_release(regd);
if (deferred) {
iser_err("%d references remain for BUF-OUT rdma reg\n",
@@ -675,7 +675,7 @@ void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
/* if the data was unaligned, it was already unmapped and then copied */
if (is_rdma_aligned)
- iser_dma_unmap_task_data(iser_ctask);
+ iser_dma_unmap_task_data(iser_task);
}
void iser_dto_buffs_release(struct iser_dto *dto)
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index cac50c4..48f2a60 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -101,13 +101,13 @@ void iser_reg_single(struct iser_device *device,
/**
* iser_start_rdma_unaligned_sg
*/
-static int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
+static int iser_start_rdma_unaligned_sg(struct iscsi_iser_task *iser_task,
enum iser_data_dir cmd_dir)
{
int dma_nents;
struct ib_device *dev;
char *mem = NULL;
- struct iser_data_buf *data = &iser_ctask->data[cmd_dir];
+ struct iser_data_buf *data = &iser_task->data[cmd_dir];
unsigned long cmd_data_len = data->data_len;
if (cmd_data_len > ISER_KMALLOC_THRESHOLD)
@@ -140,37 +140,37 @@ static int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
}
}
- sg_init_one(&iser_ctask->data_copy[cmd_dir].sg_single, mem, cmd_data_len);
- iser_ctask->data_copy[cmd_dir].buf =
- &iser_ctask->data_copy[cmd_dir].sg_single;
- iser_ctask->data_copy[cmd_dir].size = 1;
+ sg_init_one(&iser_task->data_copy[cmd_dir].sg_single, mem, cmd_data_len);
+ iser_task->data_copy[cmd_dir].buf =
+ &iser_task->data_copy[cmd_dir].sg_single;
+ iser_task->data_copy[cmd_dir].size = 1;
- iser_ctask->data_copy[cmd_dir].copy_buf = mem;
+ iser_task->data_copy[cmd_dir].copy_buf = mem;
- dev = iser_ctask->iser_conn->ib_conn->device->ib_device;
+ dev = iser_task->iser_conn->ib_conn->device->ib_device;
dma_nents = ib_dma_map_sg(dev,
- &iser_ctask->data_copy[cmd_dir].sg_single,
+ &iser_task->data_copy[cmd_dir].sg_single,
1,
(cmd_dir == ISER_DIR_OUT) ?
DMA_TO_DEVICE : DMA_FROM_DEVICE);
BUG_ON(dma_nents == 0);
- iser_ctask->data_copy[cmd_dir].dma_nents = dma_nents;
+ iser_task->data_copy[cmd_dir].dma_nents = dma_nents;
return 0;
}
/**
* iser_finalize_rdma_unaligned_sg
*/
-void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
+void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_task *iser_task,
enum iser_data_dir cmd_dir)
{
struct ib_device *dev;
struct iser_data_buf *mem_copy;
unsigned long cmd_data_len;
- dev = iser_ctask->iser_conn->ib_conn->device->ib_device;
- mem_copy = &iser_ctask->data_copy[cmd_dir];
+ dev = iser_task->iser_conn->ib_conn->device->ib_device;
+ mem_copy = &iser_task->data_copy[cmd_dir];
ib_dma_unmap_sg(dev, &mem_copy->sg_single, 1,
(cmd_dir == ISER_DIR_OUT) ?
@@ -186,8 +186,8 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
/* copy back read RDMA to unaligned sg */
mem = mem_copy->copy_buf;
- sgl = (struct scatterlist *)iser_ctask->data[ISER_DIR_IN].buf;
- sg_size = iser_ctask->data[ISER_DIR_IN].size;
+ sgl = (struct scatterlist *)iser_task->data[ISER_DIR_IN].buf;
+ sg_size = iser_task->data[ISER_DIR_IN].size;
p = mem;
for_each_sg(sgl, sg, sg_size, i) {
@@ -200,7 +200,7 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
}
}
- cmd_data_len = iser_ctask->data[cmd_dir].data_len;
+ cmd_data_len = iser_task->data[cmd_dir].data_len;
if (cmd_data_len > ISER_KMALLOC_THRESHOLD)
free_pages((unsigned long)mem_copy->copy_buf,
@@ -378,15 +378,15 @@ static void iser_page_vec_build(struct iser_data_buf *data,
}
}
-int iser_dma_map_task_data(struct iscsi_iser_cmd_task *iser_ctask,
- struct iser_data_buf *data,
- enum iser_data_dir iser_dir,
- enum dma_data_direction dma_dir)
+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)
{
struct ib_device *dev;
- iser_ctask->dir[iser_dir] = 1;
- dev = iser_ctask->iser_conn->ib_conn->device->ib_device;
+ iser_task->dir[iser_dir] = 1;
+ dev = iser_task->iser_conn->ib_conn->device->ib_device;
data->dma_nents = ib_dma_map_sg(dev, data->buf, data->size, dma_dir);
if (data->dma_nents == 0) {
@@ -396,20 +396,20 @@ int iser_dma_map_task_data(struct iscsi_iser_cmd_task *iser_ctask,
return 0;
}
-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)
{
struct ib_device *dev;
struct iser_data_buf *data;
- dev = iser_ctask->iser_conn->ib_conn->device->ib_device;
+ dev = iser_task->iser_conn->ib_conn->device->ib_device;
- if (iser_ctask->dir[ISER_DIR_IN]) {
- data = &iser_ctask->data[ISER_DIR_IN];
+ if (iser_task->dir[ISER_DIR_IN]) {
+ data = &iser_task->data[ISER_DIR_IN];
ib_dma_unmap_sg(dev, data->buf, data->size, DMA_FROM_DEVICE);
}
- if (iser_ctask->dir[ISER_DIR_OUT]) {
- data = &iser_ctask->data[ISER_DIR_OUT];
+ if (iser_task->dir[ISER_DIR_OUT]) {
+ data = &iser_task->data[ISER_DIR_OUT];
ib_dma_unmap_sg(dev, data->buf, data->size, DMA_TO_DEVICE);
}
}
@@ -420,21 +420,21 @@ void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *iser_ctask)
*
* returns 0 on success, errno code on failure
*/
-int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
+int iser_reg_rdma_mem(struct iscsi_iser_task *iser_task,
enum iser_data_dir cmd_dir)
{
- struct iscsi_conn *iscsi_conn = iser_ctask->iser_conn->iscsi_conn;
- struct iser_conn *ib_conn = iser_ctask->iser_conn->ib_conn;
+ struct iscsi_conn *iscsi_conn = iser_task->iser_conn->iscsi_conn;
+ struct iser_conn *ib_conn = iser_task->iser_conn->ib_conn;
struct iser_device *device = ib_conn->device;
struct ib_device *ibdev = device->ib_device;
- struct iser_data_buf *mem = &iser_ctask->data[cmd_dir];
+ struct iser_data_buf *mem = &iser_task->data[cmd_dir];
struct iser_regd_buf *regd_buf;
int aligned_len;
int err;
int i;
struct scatterlist *sg;
- regd_buf = &iser_ctask->rdma_regd[cmd_dir];
+ regd_buf = &iser_task->rdma_regd[cmd_dir];
aligned_len = iser_data_buf_aligned_len(mem, ibdev);
if (aligned_len != mem->dma_nents) {
@@ -444,13 +444,13 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
iser_data_buf_dump(mem, ibdev);
/* unmap the command data before accessing it */
- iser_dma_unmap_task_data(iser_ctask);
+ iser_dma_unmap_task_data(iser_task);
/* allocate copy buf, if we are writing, copy the */
/* unaligned scatterlist, dma map the copy */
- if (iser_start_rdma_unaligned_sg(iser_ctask, cmd_dir) != 0)
+ if (iser_start_rdma_unaligned_sg(iser_task, cmd_dir) != 0)
return -ENOMEM;
- mem = &iser_ctask->data_copy[cmd_dir];
+ mem = &iser_task->data_copy[cmd_dir];
}
/* if there a single dma entry, FMR is not needed */
@@ -474,8 +474,9 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
err = iser_reg_page_vec(ib_conn, ib_conn->page_vec, ®d_buf->reg);
if (err) {
iser_data_buf_dump(mem, ibdev);
- iser_err("mem->dma_nents = %d (dlength = 0x%x)\n", mem->dma_nents,
- ntoh24(iser_ctask->desc.iscsi_header.dlength));
+ iser_err("mem->dma_nents = %d (dlength = 0x%x)\n",
+ mem->dma_nents,
+ ntoh24(iser_task->desc.iscsi_header.dlength));
iser_err("page_vec: data_size = 0x%x, length = %d, offset = 0x%x\n",
ib_conn->page_vec->data_size, ib_conn->page_vec->length,
ib_conn->page_vec->offset);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 17/25] iscsi class: user device_for_each_child instead of duplicating session list
2008-05-21 20:54 ` [PATCH 16/25] iser: " michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 18/25] iscsi class: add endpoint class michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 86d9c42..3a89039 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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;
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 33cd0ca..aa3c7f0 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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;
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 92ee6d9..e88b726 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 6b8516a..ac9d298 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -119,9 +119,8 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
struct iscsi_cls_host *ihost = shost->shost_data;
memset(ihost, 0, sizeof(*ihost));
- INIT_LIST_HEAD(&ihost->sessions);
- mutex_init(&ihost->mutex);
atomic_set(&ihost->nr_scans, 0);
+ mutex_init(&ihost->mutex);
snprintf(ihost->scan_workq_name, KOBJ_NAME_LEN, "iscsi_scan_%d",
shost->host_no);
@@ -316,42 +315,76 @@ int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time)
}
EXPORT_SYMBOL_GPL(iscsi_scan_finished);
-static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
- uint id, uint lun)
+struct iscsi_scan_data {
+ unsigned int channel;
+ unsigned int id;
+ unsigned int lun;
+};
+
+static int iscsi_user_scan_session(struct device *dev, void *data)
{
- struct iscsi_cls_host *ihost = shost->shost_data;
+ struct iscsi_scan_data *scan_data = data;
struct iscsi_cls_session *session;
+ struct Scsi_Host *shost;
+ struct iscsi_cls_host *ihost;
+ unsigned long flags;
+ unsigned int id;
+
+ if (!iscsi_is_session_dev(dev))
+ return 0;
+
+ session = iscsi_dev_to_session(dev);
+ shost = iscsi_session_to_shost(session);
+ ihost = shost->shost_data;
mutex_lock(&ihost->mutex);
- list_for_each_entry(session, &ihost->sessions, host_list) {
- if ((channel == SCAN_WILD_CARD || channel == 0) &&
- (id == SCAN_WILD_CARD || id == session->target_id))
- scsi_scan_target(&session->dev, 0,
- session->target_id, lun, 1);
+ spin_lock_irqsave(&session->lock, flags);
+ if (session->state != ISCSI_SESSION_LOGGED_IN) {
+ spin_unlock_irqrestore(&session->lock, flags);
+ mutex_unlock(&ihost->mutex);
+ return 0;
}
- mutex_unlock(&ihost->mutex);
+ id = session->target_id;
+ spin_unlock_irqrestore(&session->lock, flags);
+ if (id != ISCSI_MAX_TARGET) {
+ if ((scan_data->channel == SCAN_WILD_CARD ||
+ scan_data->channel == 0) &&
+ (scan_data->id == SCAN_WILD_CARD ||
+ scan_data->id == id))
+ scsi_scan_target(&session->dev, 0, id,
+ scan_data->lun, 1);
+ }
+ mutex_unlock(&ihost->mutex);
return 0;
}
+static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
+ uint id, uint lun)
+{
+ struct iscsi_scan_data scan_data;
+
+ scan_data.channel = channel;
+ scan_data.id = id;
+ scan_data.lun = lun;
+
+ return device_for_each_child(&shost->shost_gendev, &scan_data,
+ iscsi_user_scan_session);
+}
+
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_cls_host *ihost = shost->shost_data;
- unsigned long flags;
+ struct iscsi_scan_data scan_data;
- spin_lock_irqsave(&session->lock, flags);
- if (session->state != ISCSI_SESSION_LOGGED_IN) {
- spin_unlock_irqrestore(&session->lock, flags);
- goto done;
- }
- spin_unlock_irqrestore(&session->lock, flags);
+ scan_data.channel = 0;
+ scan_data.id = SCAN_WILD_CARD;
+ scan_data.lun = SCAN_WILD_CARD;
- scsi_scan_target(&session->dev, 0, session->target_id,
- SCAN_WILD_CARD, 1);
-done:
+ iscsi_user_scan_session(&session->dev, &scan_data);
atomic_dec(&ihost->nr_scans);
}
@@ -460,14 +493,18 @@ static void __iscsi_unbind_session(struct work_struct *work)
unbind_work);
struct Scsi_Host *shost = iscsi_session_to_shost(session);
struct iscsi_cls_host *ihost = shost->shost_data;
+ unsigned long flags;
/* Prevent new scans and make sure scanning is not in progress */
mutex_lock(&ihost->mutex);
- if (list_empty(&session->host_list)) {
+ spin_lock_irqsave(&session->lock, flags);
+ if (session->target_id == ISCSI_MAX_TARGET) {
+ spin_unlock_irqrestore(&session->lock, flags);
mutex_unlock(&ihost->mutex);
return;
}
- list_del_init(&session->host_list);
+ session->target_id = ISCSI_MAX_TARGET;
+ spin_unlock_irqrestore(&session->lock, flags);
mutex_unlock(&ihost->mutex);
scsi_remove_target(&session->dev);
@@ -497,7 +534,6 @@ iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
session->recovery_tmo = 120;
session->state = ISCSI_SESSION_FREE;
INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout);
- INIT_LIST_HEAD(&session->host_list);
INIT_LIST_HEAD(&session->sess_list);
INIT_WORK(&session->unblock_work, __iscsi_unblock_session);
INIT_WORK(&session->block_work, __iscsi_block_session);
@@ -516,16 +552,51 @@ iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
}
EXPORT_SYMBOL_GPL(iscsi_alloc_session);
+static int iscsi_get_next_target_id(struct device *dev, void *data)
+{
+ struct iscsi_cls_session *session;
+ unsigned long flags;
+ int err = 0;
+
+ if (!iscsi_is_session_dev(dev))
+ return 0;
+
+ session = iscsi_dev_to_session(dev);
+ spin_lock_irqsave(&session->lock, flags);
+ if (*((unsigned int *) data) == session->target_id)
+ err = -EEXIST;
+ spin_unlock_irqrestore(&session->lock, flags);
+ return err;
+}
+
int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
{
struct Scsi_Host *shost = iscsi_session_to_shost(session);
struct iscsi_cls_host *ihost;
unsigned long flags;
+ unsigned int id = target_id;
int err;
ihost = shost->shost_data;
session->sid = atomic_add_return(1, &iscsi_session_nr);
- session->target_id = target_id;
+
+ if (id == ISCSI_MAX_TARGET) {
+ for (id = 0; id < ISCSI_MAX_TARGET; id++) {
+ err = device_for_each_child(&shost->shost_gendev, &id,
+ iscsi_get_next_target_id);
+ if (!err)
+ break;
+ }
+
+ if (id == ISCSI_MAX_TARGET) {
+ iscsi_cls_session_printk(KERN_ERR, session,
+ "Too many iscsi targets. Max "
+ "number of targets is %d.\n",
+ ISCSI_MAX_TARGET - 1);
+ goto release_host;
+ }
+ }
+ session->target_id = id;
snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",
session->sid);
@@ -541,10 +612,6 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
list_add(&session->sess_list, &sesslist);
spin_unlock_irqrestore(&sesslock, flags);
- mutex_lock(&ihost->mutex);
- list_add(&session->host_list, &ihost->sessions);
- mutex_unlock(&ihost->mutex);
-
iscsi_session_event(session, ISCSI_KEVENT_CREATE_SESSION);
return 0;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 176353c..13c92d7 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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,
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 0553240..d6b8231 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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;
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 18/25] iscsi class: add endpoint class
2008-05-21 20:54 ` [PATCH 17/25] iscsi class: user device_for_each_child instead of duplicating session list michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 19/25] iser: Modify iser to take a iscsi_endpoint struct in ep callouts and session setup michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index ac9d298..c3c07cc 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -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);
}
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 801a677..a0f13a2 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -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;
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index d6b8231..f5444e0 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -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
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 19/25] iser: Modify iser to take a iscsi_endpoint struct in ep callouts and session setup
2008-05-21 20:54 ` [PATCH 18/25] iscsi class: add endpoint class michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 20/25] iscsi_tcp: hook iscsi_tcp into iscsi_endpoint code michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 3a89039..42e95b8 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index 05431f2..cdf4876 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -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);
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 5daed2b..81b45d4 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -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 *eve
return 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;
}
/**
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 20/25] iscsi_tcp: hook iscsi_tcp into iscsi_endpoint code
2008-05-21 20:54 ` [PATCH 19/25] iser: Modify iser to take a iscsi_endpoint struct in ep callouts and session setup michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 21/25] iscsi class: Add session initiatorname and ifacename sysfs attrs michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/iscsi_tcp.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index aa3c7f0..92d0319 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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;
}
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 21/25] iscsi class: Add session initiatorname and ifacename sysfs attrs.
2008-05-21 20:54 ` [PATCH 20/25] iscsi_tcp: hook iscsi_tcp into iscsi_endpoint code michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 22/25] libiscsi: fix cmds_max setting michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 42e95b8..08edbaf 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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,
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 92d0319..7552dd8 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index e88b726..c1af2aa 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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;
}
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index c3c07cc..9fd5c6d 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -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);
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index a0f13a2..16be12f 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -257,42 +257,49 @@ enum iscsi_param {
ISCSI_PARAM_PING_TMO,
ISCSI_PARAM_RECV_TMO,
+
+ ISCSI_PARAM_IFACE_NAME,
+ ISCSI_PARAM_ISID,
+ ISCSI_PARAM_INITIATOR_NAME,
/* must always be last */
ISCSI_PARAM_MAX,
};
-#define ISCSI_MAX_RECV_DLENGTH (1 << ISCSI_PARAM_MAX_RECV_DLENGTH)
-#define ISCSI_MAX_XMIT_DLENGTH (1 << ISCSI_PARAM_MAX_XMIT_DLENGTH)
-#define ISCSI_HDRDGST_EN (1 << ISCSI_PARAM_HDRDGST_EN)
-#define ISCSI_DATADGST_EN (1 << ISCSI_PARAM_DATADGST_EN)
-#define ISCSI_INITIAL_R2T_EN (1 << ISCSI_PARAM_INITIAL_R2T_EN)
-#define ISCSI_MAX_R2T (1 << ISCSI_PARAM_MAX_R2T)
-#define ISCSI_IMM_DATA_EN (1 << ISCSI_PARAM_IMM_DATA_EN)
-#define ISCSI_FIRST_BURST (1 << ISCSI_PARAM_FIRST_BURST)
-#define ISCSI_MAX_BURST (1 << ISCSI_PARAM_MAX_BURST)
-#define ISCSI_PDU_INORDER_EN (1 << ISCSI_PARAM_PDU_INORDER_EN)
-#define ISCSI_DATASEQ_INORDER_EN (1 << ISCSI_PARAM_DATASEQ_INORDER_EN)
-#define ISCSI_ERL (1 << ISCSI_PARAM_ERL)
-#define ISCSI_IFMARKER_EN (1 << ISCSI_PARAM_IFMARKER_EN)
-#define ISCSI_OFMARKER_EN (1 << ISCSI_PARAM_OFMARKER_EN)
-#define ISCSI_EXP_STATSN (1 << ISCSI_PARAM_EXP_STATSN)
-#define ISCSI_TARGET_NAME (1 << ISCSI_PARAM_TARGET_NAME)
-#define ISCSI_TPGT (1 << ISCSI_PARAM_TPGT)
-#define ISCSI_PERSISTENT_ADDRESS (1 << ISCSI_PARAM_PERSISTENT_ADDRESS)
-#define ISCSI_PERSISTENT_PORT (1 << ISCSI_PARAM_PERSISTENT_PORT)
-#define ISCSI_SESS_RECOVERY_TMO (1 << ISCSI_PARAM_SESS_RECOVERY_TMO)
-#define ISCSI_CONN_PORT (1 << ISCSI_PARAM_CONN_PORT)
-#define ISCSI_CONN_ADDRESS (1 << ISCSI_PARAM_CONN_ADDRESS)
-#define ISCSI_USERNAME (1 << ISCSI_PARAM_USERNAME)
-#define ISCSI_USERNAME_IN (1 << ISCSI_PARAM_USERNAME_IN)
-#define ISCSI_PASSWORD (1 << ISCSI_PARAM_PASSWORD)
-#define ISCSI_PASSWORD_IN (1 << ISCSI_PARAM_PASSWORD_IN)
-#define ISCSI_FAST_ABORT (1 << ISCSI_PARAM_FAST_ABORT)
-#define ISCSI_ABORT_TMO (1 << ISCSI_PARAM_ABORT_TMO)
-#define ISCSI_LU_RESET_TMO (1 << ISCSI_PARAM_LU_RESET_TMO)
-#define ISCSI_HOST_RESET_TMO (1 << ISCSI_PARAM_HOST_RESET_TMO)
-#define ISCSI_PING_TMO (1 << ISCSI_PARAM_PING_TMO)
-#define ISCSI_RECV_TMO (1 << ISCSI_PARAM_RECV_TMO)
+#define ISCSI_MAX_RECV_DLENGTH (1ULL << ISCSI_PARAM_MAX_RECV_DLENGTH)
+#define ISCSI_MAX_XMIT_DLENGTH (1ULL << ISCSI_PARAM_MAX_XMIT_DLENGTH)
+#define ISCSI_HDRDGST_EN (1ULL << ISCSI_PARAM_HDRDGST_EN)
+#define ISCSI_DATADGST_EN (1ULL << ISCSI_PARAM_DATADGST_EN)
+#define ISCSI_INITIAL_R2T_EN (1ULL << ISCSI_PARAM_INITIAL_R2T_EN)
+#define ISCSI_MAX_R2T (1ULL << ISCSI_PARAM_MAX_R2T)
+#define ISCSI_IMM_DATA_EN (1ULL << ISCSI_PARAM_IMM_DATA_EN)
+#define ISCSI_FIRST_BURST (1ULL << ISCSI_PARAM_FIRST_BURST)
+#define ISCSI_MAX_BURST (1ULL << ISCSI_PARAM_MAX_BURST)
+#define ISCSI_PDU_INORDER_EN (1ULL << ISCSI_PARAM_PDU_INORDER_EN)
+#define ISCSI_DATASEQ_INORDER_EN (1ULL << ISCSI_PARAM_DATASEQ_INORDER_EN)
+#define ISCSI_ERL (1ULL << ISCSI_PARAM_ERL)
+#define ISCSI_IFMARKER_EN (1ULL << ISCSI_PARAM_IFMARKER_EN)
+#define ISCSI_OFMARKER_EN (1ULL << ISCSI_PARAM_OFMARKER_EN)
+#define ISCSI_EXP_STATSN (1ULL << ISCSI_PARAM_EXP_STATSN)
+#define ISCSI_TARGET_NAME (1ULL << ISCSI_PARAM_TARGET_NAME)
+#define ISCSI_TPGT (1ULL << ISCSI_PARAM_TPGT)
+#define ISCSI_PERSISTENT_ADDRESS (1ULL << ISCSI_PARAM_PERSISTENT_ADDRESS)
+#define ISCSI_PERSISTENT_PORT (1ULL << ISCSI_PARAM_PERSISTENT_PORT)
+#define ISCSI_SESS_RECOVERY_TMO (1ULL << ISCSI_PARAM_SESS_RECOVERY_TMO)
+#define ISCSI_CONN_PORT (1ULL << ISCSI_PARAM_CONN_PORT)
+#define ISCSI_CONN_ADDRESS (1ULL << ISCSI_PARAM_CONN_ADDRESS)
+#define ISCSI_USERNAME (1ULL << ISCSI_PARAM_USERNAME)
+#define ISCSI_USERNAME_IN (1ULL << ISCSI_PARAM_USERNAME_IN)
+#define ISCSI_PASSWORD (1ULL << ISCSI_PARAM_PASSWORD)
+#define ISCSI_PASSWORD_IN (1ULL << ISCSI_PARAM_PASSWORD_IN)
+#define ISCSI_FAST_ABORT (1ULL << ISCSI_PARAM_FAST_ABORT)
+#define ISCSI_ABORT_TMO (1ULL << ISCSI_PARAM_ABORT_TMO)
+#define ISCSI_LU_RESET_TMO (1ULL << ISCSI_PARAM_LU_RESET_TMO)
+#define ISCSI_HOST_RESET_TMO (1ULL << ISCSI_PARAM_HOST_RESET_TMO)
+#define ISCSI_PING_TMO (1ULL << ISCSI_PARAM_PING_TMO)
+#define ISCSI_RECV_TMO (1ULL << ISCSI_PARAM_RECV_TMO)
+#define ISCSI_IFACE_NAME (1ULL << ISCSI_PARAM_IFACE_NAME)
+#define ISCSI_ISID (1ULL << ISCSI_PARAM_ISID)
+#define ISCSI_INITIATOR_NAME (1ULL << ISCSI_PARAM_INITIATOR_NAME)
/* iSCSI HBA params */
enum iscsi_host_param {
@@ -303,10 +310,10 @@ enum iscsi_host_param {
ISCSI_HOST_PARAM_MAX,
};
-#define ISCSI_HOST_HWADDRESS (1 << ISCSI_HOST_PARAM_HWADDRESS)
-#define ISCSI_HOST_INITIATOR_NAME (1 << ISCSI_HOST_PARAM_INITIATOR_NAME)
-#define ISCSI_HOST_NETDEV_NAME (1 << ISCSI_HOST_PARAM_NETDEV_NAME)
-#define ISCSI_HOST_IPADDRESS (1 << ISCSI_HOST_PARAM_IPADDRESS)
+#define ISCSI_HOST_HWADDRESS (1ULL << ISCSI_HOST_PARAM_HWADDRESS)
+#define ISCSI_HOST_INITIATOR_NAME (1ULL << ISCSI_HOST_PARAM_INITIATOR_NAME)
+#define ISCSI_HOST_NETDEV_NAME (1ULL << ISCSI_HOST_PARAM_NETDEV_NAME)
+#define ISCSI_HOST_IPADDRESS (1ULL << ISCSI_HOST_PARAM_IPADDRESS)
#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 13c92d7..21cfb1d 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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;
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 22/25] libiscsi: fix cmds_max setting
2008-05-21 20:54 ` [PATCH 21/25] iscsi class: Add session initiatorname and ifacename sysfs attrs michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 23/25] libiscsi, iser, tcp: remove recv_lock michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/libiscsi.c | 49 ++++++++++++++++++++++++++++++++--------------
include/scsi/libiscsi.h | 9 ++++---
2 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c1af2aa..c723e60 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 21cfb1d..5bf0187 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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)
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 23/25] libiscsi, iser, tcp: remove recv_lock
2008-05-21 20:54 ` [PATCH 22/25] libiscsi: fix cmds_max setting michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 24/25] Replace __FUNCTION__ with __func__ in iscsi_tcp michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Mike Christie
From: Mike Christie <michaelc@cs.wisc.edu>
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.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
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(-)
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 08edbaf..c02eabd 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -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;
}
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index cdf4876..a547ede 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -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 {
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 35af60a..c360839 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -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);
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 7552dd8..af7ee45 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -741,7 +741,6 @@ static int
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_task *task;
@@ -770,17 +769,17 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
switch(opcode) {
case ISCSI_OP_SCSI_DATA_IN:
+ spin_lock(&conn->session->lock);
task = iscsi_itt_to_ctask(conn, hdr->itt);
if (!task)
- return ISCSI_ERR_BAD_ITT;
- if (!task->sc)
- return ISCSI_ERR_NO_SCSI_CMD;
+ rc = ISCSI_ERR_BAD_ITT;
+ else
+ rc = iscsi_data_rsp(conn, task);
+ if (rc) {
+ spin_unlock(&conn->session->lock);
+ break;
+ }
- spin_lock(&conn->session->lock);
- rc = iscsi_data_rsp(conn, task);
- spin_unlock(&conn->session->lock);
- if (rc)
- return rc;
if (tcp_conn->in.datalen) {
struct iscsi_tcp_task *tcp_task = task->dd_data;
struct hash_desc *rx_hash = NULL;
@@ -801,15 +800,19 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
"datalen=%d)\n", tcp_conn,
tcp_task->data_offset,
tcp_conn->in.datalen);
- return iscsi_segment_seek_sg(&tcp_conn->in.segment,
- sdb->table.sgl,
- sdb->table.nents,
- tcp_task->data_offset,
- tcp_conn->in.datalen,
- iscsi_tcp_process_data_in,
- rx_hash);
+ rc = iscsi_segment_seek_sg(&tcp_conn->in.segment,
+ sdb->table.sgl,
+ sdb->table.nents,
+ tcp_task->data_offset,
+ tcp_conn->in.datalen,
+ iscsi_tcp_process_data_in,
+ rx_hash);
+ spin_unlock(&conn->session->lock);
+ return rc;
}
- /* fall through */
+ rc = __iscsi_complete_pdu(conn, hdr, NULL, 0);
+ spin_unlock(&conn->session->lock);
+ break;
case ISCSI_OP_SCSI_CMD_RSP:
if (tcp_conn->in.datalen) {
iscsi_tcp_data_recv_prep(tcp_conn);
@@ -818,20 +821,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:
+ spin_lock(&conn->session->lock);
task = iscsi_itt_to_ctask(conn, hdr->itt);
if (!task)
- return ISCSI_ERR_BAD_ITT;
- if (!task->sc)
- return ISCSI_ERR_NO_SCSI_CMD;
-
- if (ahslen)
+ rc = ISCSI_ERR_BAD_ITT;
+ else if (ahslen)
rc = ISCSI_ERR_AHSLEN;
- else if (task->sc->sc_data_direction == DMA_TO_DEVICE) {
- spin_lock(&session->lock);
+ else if (task->sc->sc_data_direction == DMA_TO_DEVICE)
rc = iscsi_r2t_rsp(conn, task);
- spin_unlock(&session->lock);
- } else
+ else
rc = ISCSI_ERR_PROTO;
+ spin_unlock(&conn->session->lock);
break;
case ISCSI_OP_LOGIN_RSP:
case ISCSI_OP_TEXT_RSP:
@@ -1553,7 +1553,6 @@ iscsi_tcp_release_conn(struct iscsi_conn *conn)
spin_lock_bh(&session->lock);
tcp_conn->sock = NULL;
- conn->recv_lock = NULL;
spin_unlock_bh(&session->lock);
sockfd_put(sock);
}
@@ -1578,6 +1577,19 @@ static void
iscsi_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
{
struct iscsi_conn *conn = cls_conn->dd_data;
+ struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
+
+ /* userspace may have goofed up and not bound us */
+ if (!tcp_conn->sock)
+ return;
+ /*
+ * Make sure our recv side is stopped.
+ * Older tools called conn stop before ep_disconnect
+ * so IO could still be coming in.
+ */
+ write_lock_bh(&tcp_conn->sock->sk->sk_callback_lock);
+ set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
+ write_unlock_bh(&tcp_conn->sock->sk->sk_callback_lock);
iscsi_conn_stop(cls_conn, flag);
iscsi_tcp_release_conn(conn);
@@ -1671,13 +1683,6 @@ iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session,
sk->sk_sndtimeo = 15 * HZ; /* FIXME: make it configurable */
sk->sk_allocation = GFP_ATOMIC;
- /* FIXME: disable Nagle's algorithm */
-
- /*
- * Intercept TCP callbacks for sendfile like receive
- * processing.
- */
- conn->recv_lock = &sk->sk_callback_lock;
iscsi_conn_set_callbacks(conn);
tcp_conn->sendpage = tcp_conn->sock->ops->sendpage;
/*
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c723e60..9c267b4 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -362,10 +362,11 @@ static void iscsi_complete_command(struct iscsi_task *task)
}
}
-static void __iscsi_get_task(struct iscsi_task *task)
+void __iscsi_get_task(struct iscsi_task *task)
{
atomic_inc(&task->refcount);
}
+EXPORT_SYMBOL_GPL(__iscsi_get_task);
static void __iscsi_put_task(struct iscsi_task *task)
{
@@ -403,9 +404,13 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task,
conn->session->queued_cmdsn--;
else
conn->session->tt->cleanup_task(conn, task);
+ /*
+ * Check if cleanup_task dropped the lock and the command completed,
+ */
+ if (!task->sc)
+ return;
sc->result = err;
-
if (!scsi_bidi_cmnd(sc))
scsi_set_resid(sc, scsi_bufflen(sc));
else {
@@ -697,6 +702,31 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
}
/**
+ * iscsi_itt_to_task - look up task by itt
+ * @conn: iscsi connection
+ * @itt: itt
+ *
+ * This should be used for mgmt tasks like login and nops, or if
+ * the LDD's itt space does not include the session age.
+ *
+ * The session lock must be held.
+ */
+static struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
+{
+ struct iscsi_session *session = conn->session;
+ uint32_t i;
+
+ if (itt == RESERVED_ITT)
+ return NULL;
+
+ i = get_itt(itt);
+ if (i >= session->cmds_max)
+ return NULL;
+
+ return session->cmds[i];
+}
+
+/**
* __iscsi_complete_pdu - complete pdu
* @conn: iscsi conn
* @hdr: iscsi header
@@ -707,8 +737,8 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
* queuecommand or send generic. session lock must be held and verify
* itt must have been called.
*/
-static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
- char *data, int datalen)
+int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
+ char *data, int datalen)
{
struct iscsi_session *session = conn->session;
int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0;
@@ -758,22 +788,36 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
goto out;
}
- task = session->cmds[itt];
switch(opcode) {
case ISCSI_OP_SCSI_CMD_RSP:
- if (!task->sc) {
- rc = ISCSI_ERR_NO_SCSI_CMD;
- break;
- }
- BUG_ON((void*)task != task->sc->SCp.ptr);
+ case ISCSI_OP_SCSI_DATA_IN:
+ task = iscsi_itt_to_ctask(conn, hdr->itt);
+ if (!task)
+ return ISCSI_ERR_BAD_ITT;
+ break;
+ case ISCSI_OP_R2T:
+ /*
+ * LLD handles R2Ts if they need to.
+ */
+ return 0;
+ case ISCSI_OP_LOGOUT_RSP:
+ case ISCSI_OP_LOGIN_RSP:
+ case ISCSI_OP_TEXT_RSP:
+ case ISCSI_OP_SCSI_TMFUNC_RSP:
+ case ISCSI_OP_NOOP_IN:
+ task = iscsi_itt_to_task(conn, hdr->itt);
+ if (!task)
+ return ISCSI_ERR_BAD_ITT;
+ break;
+ default:
+ return ISCSI_ERR_BAD_OPCODE;
+ }
+
+ switch(opcode) {
+ case ISCSI_OP_SCSI_CMD_RSP:
iscsi_scsi_cmd_rsp(conn, hdr, task, data, datalen);
break;
case ISCSI_OP_SCSI_DATA_IN:
- if (!task->sc) {
- rc = ISCSI_ERR_NO_SCSI_CMD;
- break;
- }
- BUG_ON((void*)task != task->sc->SCp.ptr);
if (hdr->flags & ISCSI_FLAG_DATA_STATUS) {
conn->scsirsp_pdus_cnt++;
iscsi_update_cmdsn(session,
@@ -781,9 +825,6 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
__iscsi_put_task(task);
}
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) {
@@ -841,6 +882,7 @@ recv_pdu:
__iscsi_put_task(task);
return rc;
}
+EXPORT_SYMBOL_GPL(__iscsi_complete_pdu);
int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
char *data, int datalen)
@@ -857,7 +899,6 @@ 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_task *task;
uint32_t i;
if (itt == RESERVED_ITT)
@@ -867,8 +908,7 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)
(session->age << ISCSI_AGE_SHIFT)) {
iscsi_conn_printk(KERN_ERR, conn,
"received itt %x expected session age (%x)\n",
- (__force u32)itt,
- session->age & ISCSI_AGE_MASK);
+ (__force u32)itt, session->age);
return ISCSI_ERR_BAD_ITT;
}
@@ -879,42 +919,36 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)
"%u.\n", i, session->cmds_max);
return ISCSI_ERR_BAD_ITT;
}
-
- task = session->cmds[i];
- if (task->sc && task->sc->SCp.phase != session->age) {
- iscsi_conn_printk(KERN_ERR, conn,
- "iscsi: task's session age %d, "
- "expected %d\n", task->sc->SCp.phase,
- session->age);
- return ISCSI_ERR_SESSION_FAILED;
- }
return 0;
}
EXPORT_SYMBOL_GPL(iscsi_verify_itt);
-struct iscsi_task *
-iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt)
+/**
+ * iscsi_itt_to_ctask - look up ctask by itt
+ * @conn: iscsi connection
+ * @itt: itt
+ *
+ * This should be used for cmd tasks.
+ *
+ * The session lock must be held.
+ */
+struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt)
{
- struct iscsi_session *session = conn->session;
struct iscsi_task *task;
- uint32_t i;
if (iscsi_verify_itt(conn, itt))
return NULL;
- if (itt == RESERVED_ITT)
+ task = iscsi_itt_to_task(conn, itt);
+ if (!task || !task->sc)
return NULL;
- i = get_itt(itt);
- if (i >= session->cmds_max)
- return NULL;
-
- task = session->cmds[i];
- if (!task->sc)
- return NULL;
-
- if (task->sc->SCp.phase != session->age)
+ if (task->sc->SCp.phase != conn->session->age) {
+ iscsi_session_printk(KERN_ERR, conn->session,
+ "task's session age %d, expected %d\n",
+ task->sc->SCp.phase, conn->session->age);
return NULL;
+ }
return task;
}
@@ -1620,16 +1654,20 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
switch (conn->tmf_state) {
case TMF_SUCCESS:
spin_unlock_bh(&session->lock);
+ /*
+ * stop tx side incase the target had sent a abort rsp but
+ * the initiator was still writing out data.
+ */
iscsi_suspend_tx(conn);
/*
- * clean up task if aborted. grab the recv lock as a writer
+ * we do not stop the recv side because targets have been
+ * good and have never sent us a successful tmf response
+ * then sent more data for the cmd.
*/
- write_lock_bh(conn->recv_lock);
spin_lock(&session->lock);
fail_command(conn, task, DID_ABORT << 16);
conn->tmf_state = TMF_INITIAL;
spin_unlock(&session->lock);
- write_unlock_bh(conn->recv_lock);
iscsi_start_tx(conn);
goto success_unlocked;
case TMF_TIMEDOUT:
@@ -1729,13 +1767,11 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
spin_unlock_bh(&session->lock);
iscsi_suspend_tx(conn);
- /* need to grab the recv lock then session lock */
- write_lock_bh(conn->recv_lock);
+
spin_lock(&session->lock);
fail_all_commands(conn, sc->device->lun, DID_ERROR);
conn->tmf_state = TMF_INITIAL;
spin_unlock(&session->lock);
- write_unlock_bh(conn->recv_lock);
iscsi_start_tx(conn);
goto done;
@@ -2257,17 +2293,6 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
}
/*
- * The LLD either freed/unset the lock on us, or userspace called
- * stop but did not create a proper connection (connection was never
- * bound or it was unbound then stop was called).
- */
- if (!conn->recv_lock) {
- spin_unlock_bh(&session->lock);
- mutex_unlock(&session->eh_mutex);
- return;
- }
-
- /*
* 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
* the recovery state again
@@ -2283,11 +2308,6 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
spin_unlock_bh(&session->lock);
iscsi_suspend_tx(conn);
-
- write_lock_bh(conn->recv_lock);
- set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
- write_unlock_bh(conn->recv_lock);
-
/*
* for connection level recovery we should not calculate
* header digest. conn->hdr_size used for optimization
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 5bf0187..5e75bb7 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -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
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 24/25] Replace __FUNCTION__ with __func__ in iscsi_tcp.
2008-05-21 20:54 ` [PATCH 23/25] libiscsi, iser, tcp: remove recv_lock michaelc
@ 2008-05-21 20:54 ` michaelc
2008-05-21 20:54 ` [PATCH 25/25] scsi: use get_unaligned_* helpers michaelc
0 siblings, 1 reply; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Harvey Harrison, Mike Christie
From: Harvey Harrison <harvey.harrison@gmail.com>
__FUNCTION__ is gcc-specific, use __func__
(Update diff by Mike Christie)
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/iscsi_tcp.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index af7ee45..c7803c3 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 25/25] scsi: use get_unaligned_* helpers
2008-05-21 20:54 ` [PATCH 24/25] Replace __FUNCTION__ with __func__ in iscsi_tcp michaelc
@ 2008-05-21 20:54 ` michaelc
0 siblings, 0 replies; 34+ messages in thread
From: michaelc @ 2008-05-21 20:54 UTC (permalink / raw)
To: linux-scsi; +Cc: Harvey Harrison, Mike Christie
From: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/libiscsi.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 9c267b4..8b4e412 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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;
--
1.5.4.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* Re: iscsi update for 2.6.27
2008-05-21 20:53 iscsi update for 2.6.27 michaelc
2008-05-21 20:53 ` [PATCH 01/25] iscsi class, iscsi_tcp/iser: add host arg to session creation michaelc
@ 2008-05-21 21:06 ` Mike Christie
2008-05-22 9:31 ` Boaz Harrosh
1 sibling, 1 reply; 34+ messages in thread
From: Mike Christie @ 2008-05-21 21:06 UTC (permalink / raw)
To: linux-scsi
michaelc@cs.wisc.edu 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.
> 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.
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: iscsi update for 2.6.27
2008-05-21 21:06 ` iscsi update for 2.6.27 Mike Christie
@ 2008-05-22 9:31 ` Boaz Harrosh
2008-05-22 16:37 ` Mike Christie
0 siblings, 1 reply; 34+ messages in thread
From: Boaz Harrosh @ 2008-05-22 9:31 UTC (permalink / raw)
To: Mike Christie, James Bottomley; +Cc: linux-scsi
Mike Christie wrote:
> michaelc@cs.wisc.edu 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
>
>> 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.
Please include the version you like. It looks like James has no farther response
on this issue.
Boaz
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: iscsi update for 2.6.27
2008-05-22 9:31 ` Boaz Harrosh
@ 2008-05-22 16:37 ` Mike Christie
2008-05-22 16:42 ` Mike Christie
0 siblings, 1 reply; 34+ messages in thread
From: Mike Christie @ 2008-05-22 16:37 UTC (permalink / raw)
To: Boaz Harrosh; +Cc: James Bottomley, linux-scsi
Boaz Harrosh wrote:
> Mike Christie wrote:
>> michaelc@cs.wisc.edu 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.
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: iscsi update for 2.6.27
2008-05-22 16:37 ` Mike Christie
@ 2008-05-22 16:42 ` Mike Christie
2008-05-26 8:31 ` [PATCH] iscsi_tcp: Enable any size command Boaz Harrosh
0 siblings, 1 reply; 34+ messages in thread
From: Mike Christie @ 2008-05-22 16:42 UTC (permalink / raw)
To: Boaz Harrosh; +Cc: James Bottomley, linux-scsi
Mike Christie wrote:
> Boaz Harrosh wrote:
>> Mike Christie wrote:
>>> michaelc@cs.wisc.edu 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.
>
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.
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH] iscsi_tcp: Enable any size command
2008-05-22 16:42 ` Mike Christie
@ 2008-05-26 8:31 ` Boaz Harrosh
2008-06-05 15:16 ` James Bottomley
0 siblings, 1 reply; 34+ messages in thread
From: Boaz Harrosh @ 2008-05-26 8:31 UTC (permalink / raw)
To: Mike Christie; +Cc: James Bottomley, linux-scsi
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 <bharrosh@panasas.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
drivers/scsi/iscsi_tcp.c | 2 +-
include/scsi/iscsi_proto.h | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 72b9b2a..826c97c 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -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,
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index e0593bf..f2a2c11 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -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 */
--
1.5.3.3
^ permalink raw reply related [flat|nested] 34+ messages in thread
* Re: [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task
2008-05-21 20:54 ` [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task michaelc
2008-05-21 20:54 ` [PATCH 15/25] iscsi_tcp: handle iscsi_cmd_task rename michaelc
@ 2008-06-05 14:53 ` James Bottomley
2008-06-05 15:00 ` James Bottomley
1 sibling, 1 reply; 34+ messages in thread
From: James Bottomley @ 2008-06-05 14:53 UTC (permalink / raw)
To: michaelc; +Cc: linux-scsi
On Wed, 2008-05-21 at 15:54 -0500, michaelc@cs.wisc.edu wrote:
> From: Mike Christie <michaelc@cs.wisc.edu>
>
> 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.
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
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task
2008-06-05 14:53 ` [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task James Bottomley
@ 2008-06-05 15:00 ` James Bottomley
0 siblings, 0 replies; 34+ messages in thread
From: James Bottomley @ 2008-06-05 15:00 UTC (permalink / raw)
To: michaelc; +Cc: linux-scsi
On Thu, 2008-06-05 at 09:53 -0500, James Bottomley wrote:
> On Wed, 2008-05-21 at 15:54 -0500, michaelc@cs.wisc.edu wrote:
> > From: Mike Christie <michaelc@cs.wisc.edu>
> >
> > 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.
>
> 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
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH] iscsi_tcp: Enable any size command
2008-05-26 8:31 ` [PATCH] iscsi_tcp: Enable any size command Boaz Harrosh
@ 2008-06-05 15:16 ` James Bottomley
0 siblings, 0 replies; 34+ messages in thread
From: James Bottomley @ 2008-06-05 15:16 UTC (permalink / raw)
To: Boaz Harrosh; +Cc: Mike Christie, linux-scsi
On Mon, 2008-05-26 at 11:31 +0300, Boaz Harrosh wrote:
> 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 <bharrosh@panasas.com>
> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
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
^ permalink raw reply [flat|nested] 34+ messages in thread
end of thread, other threads:[~2008-06-05 15:16 UTC | newest]
Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-21 20:53 iscsi update for 2.6.27 michaelc
2008-05-21 20:53 ` [PATCH 01/25] iscsi class, iscsi_tcp/iser: add host arg to session creation michaelc
2008-05-21 20:53 ` [PATCH 02/25] iscsi class, iscsi drivers: remove unused iscsi_transport attrs michaelc
2008-05-21 20:53 ` [PATCH 03/25] iscsi class: rename iscsi_host to iscsi_cls_host michaelc
2008-05-21 20:53 ` [PATCH 04/25] iscsi: remove session and host binding in libiscsi michaelc
2008-05-21 20:54 ` [PATCH 05/25] iscsi: add iscsi host helpers michaelc
2008-05-21 20:54 ` [PATCH 06/25] iscsi: remove session/conn_data_size from iscsi_transport michaelc
2008-05-21 20:54 ` [PATCH 07/25] iscsi: modify iscsi printk so it can take driver data pointers michaelc
2008-05-21 20:54 ` [PATCH 08/25] iser: fix handling of scsi cmnds during recovery michaelc
2008-05-21 20:54 ` [PATCH 09/25] libiscsi, iscsi_tcp, iser: add session cmds array accessor michaelc
2008-05-21 20:54 ` [PATCH 10/25] libiscsi: modify libiscsi so it supports offloaded data paths michaelc
2008-05-21 20:54 ` [PATCH 11/25] libiscsi: merge iscsi_mgmt_task and iscsi_cmd_task michaelc
2008-05-21 20:54 ` [PATCH 12/25] iscsi_tcp: convert iscsi_tcp to support merged tasks michaelc
2008-05-21 20:54 ` [PATCH 13/25] iser: convert ib_iser " michaelc
2008-05-21 20:54 ` [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task michaelc
2008-05-21 20:54 ` [PATCH 15/25] iscsi_tcp: handle iscsi_cmd_task rename michaelc
2008-05-21 20:54 ` [PATCH 16/25] iser: " michaelc
2008-05-21 20:54 ` [PATCH 17/25] iscsi class: user device_for_each_child instead of duplicating session list michaelc
2008-05-21 20:54 ` [PATCH 18/25] iscsi class: add endpoint class michaelc
2008-05-21 20:54 ` [PATCH 19/25] iser: Modify iser to take a iscsi_endpoint struct in ep callouts and session setup michaelc
2008-05-21 20:54 ` [PATCH 20/25] iscsi_tcp: hook iscsi_tcp into iscsi_endpoint code michaelc
2008-05-21 20:54 ` [PATCH 21/25] iscsi class: Add session initiatorname and ifacename sysfs attrs michaelc
2008-05-21 20:54 ` [PATCH 22/25] libiscsi: fix cmds_max setting michaelc
2008-05-21 20:54 ` [PATCH 23/25] libiscsi, iser, tcp: remove recv_lock michaelc
2008-05-21 20:54 ` [PATCH 24/25] Replace __FUNCTION__ with __func__ in iscsi_tcp michaelc
2008-05-21 20:54 ` [PATCH 25/25] scsi: use get_unaligned_* helpers michaelc
2008-06-05 14:53 ` [PATCH 14/25] libiscsi: rename iscsi_cmd_task to iscsi_task James Bottomley
2008-06-05 15:00 ` James Bottomley
2008-05-21 21:06 ` iscsi update for 2.6.27 Mike Christie
2008-05-22 9:31 ` Boaz Harrosh
2008-05-22 16:37 ` Mike Christie
2008-05-22 16:42 ` Mike Christie
2008-05-26 8:31 ` [PATCH] iscsi_tcp: Enable any size command Boaz Harrosh
2008-06-05 15:16 ` James Bottomley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).