[Stgt-devel] [PATCH 12/20] iser task transport data
Pete Wyckoff
pw
Tue Oct 16 17:42:06 CEST 2007
RDMA will need to store some per-task data to use initiator-provided tags
in later RDMA operations. Provide some space for this and hook into the
transport at task initialization time.
Based on the patch by Erez Zilber <erezz at voltaire.com>.
Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
usr/iscsi/iscsi_tcp.c | 6 ++++++
usr/iscsi/iscsid.c | 15 ++++++++++++---
usr/iscsi/iscsid.h | 8 ++++----
usr/iscsi/transport.h | 3 +++
4 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c
index 566dd9e..53cf0e5 100644
--- a/usr/iscsi/iscsi_tcp.c
+++ b/usr/iscsi/iscsi_tcp.c
@@ -215,6 +215,10 @@ static int iscsi_tcp_conn_init(struct iscsi_connection *conn)
return 0;
}
+static void iscsi_tcp_task_init(struct iscsi_task *task)
+{
+}
+
static size_t iscsi_tcp_read(struct iscsi_connection *conn, void *buf,
size_t nbytes)
{
@@ -316,8 +320,10 @@ int iscsi_tcp_getpeername(struct iscsi_connection *conn, struct sockaddr *sa,
struct iscsi_transport iscsi_tcp = {
.name = "iscsi",
.rdma = 0,
+ .task_trans_len = 0,
.ep_init = iscsi_tcp_init,
.ep_conn_init = iscsi_tcp_conn_init,
+ .ep_task_init = iscsi_tcp_task_init,
.ep_read = iscsi_tcp_read,
.ep_write_begin = iscsi_tcp_write_begin,
.ep_write_end = iscsi_tcp_write_end,
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 27b17f4..0d7ad43 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -985,18 +985,25 @@ iscsi_alloc_task(struct iscsi_connection *conn, int ext_len)
struct iscsi_hdr *req = (struct iscsi_hdr *) &conn->req.bhs;
struct iscsi_task *task;
- task = conn->tp->ep_malloc(conn, sizeof(*task) + ext_len);
+ task = conn->tp->ep_malloc(conn, sizeof(*task) +
+ conn->tp->task_trans_len + ext_len);
if (!task)
return NULL;
- memset(task, 0, sizeof(*task));
+ memset(task, 0, sizeof(*task) + conn->tp->task_trans_len);
memcpy(&task->req, req, sizeof(*req));
task->conn = conn;
INIT_LIST_HEAD(&task->c_hlist);
INIT_LIST_HEAD(&task->c_list);
- if (ext_len)
+ if (conn->tp->task_trans_len)
+ task->trans_data = (void *) &task[1];
+
+ if (ext_len) {
+ task->extdata = (void *)((uintptr_t) &task[1] +
+ conn->tp->task_trans_len);
task->data = task->extdata;
+ }
conn_get(conn);
return task;
@@ -1430,6 +1437,8 @@ static int iscsi_scsi_cmd_rx_start(struct iscsi_connection *conn)
task->tag = req->itt;
+ conn->tp->ep_task_init(task);
+
if (ahs_len) {
task->ahs = task->data + sizeof(req->cdb);
task->data = task->ahs + ahs_len;
diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h
index d4b4799..915c47d 100644
--- a/usr/iscsi/iscsid.h
+++ b/usr/iscsi/iscsid.h
@@ -122,12 +122,12 @@ struct iscsi_task {
int unsol_count;
int exp_r2tsn;
- void *ahs;
- void *data;
-
struct scsi_cmd scmd;
- unsigned long extdata[0];
+ void *trans_data; /* transport specific data */
+ void *extdata; /* extra data, after transport, incl ahs and data */
+ void *ahs;
+ void *data;
};
struct iscsi_connection {
diff --git a/usr/iscsi/transport.h b/usr/iscsi/transport.h
index 3421371..a8b8680 100644
--- a/usr/iscsi/transport.h
+++ b/usr/iscsi/transport.h
@@ -4,13 +4,16 @@
#include <sys/socket.h>
struct iscsi_connection;
+struct iscsi_task;
struct iscsi_transport {
const char *name;
int rdma;
+ int task_trans_len;
int (*ep_init) (void);
int (*ep_conn_init) (struct iscsi_connection *conn);
+ void (*ep_task_init) (struct iscsi_task *task);
size_t (*ep_read) (struct iscsi_connection *conn, void *buf,
size_t nbytes);
size_t (*ep_write_begin) (struct iscsi_connection *conn, void *buf,
--
1.5.3.4
More information about the stgt
mailing list