[Stgt-devel] [PATCH 07/20] iser virtualize event modify
Pete Wyckoff
pw
Tue Oct 16 17:19:51 CEST 2007
Make event modification a transport-specific operation. TCP
has a nice transmit flow control mechanism that relies on
checking that the socket is writeable. RDMA cannot take
advantage of this.
Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
usr/iscsi/iscsi_tcp.c | 26 ++++++++++++++++++--------
usr/iscsi/iscsid.c | 20 +++++++++++---------
usr/iscsi/transport.h | 1 +
3 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c
index 0c35aa5..c775594 100644
--- a/usr/iscsi/iscsi_tcp.c
+++ b/usr/iscsi/iscsi_tcp.c
@@ -232,13 +232,23 @@ static int iscsi_tcp_show(int ep, char *buf, int rest)
return total > 0 ? total : 0;
}
+void iscsi_event_modify(int fd, int events)
+{
+ int ret;
+
+ ret = tgt_event_modify(fd, events);
+ if (ret)
+ eprintf("tgt_event_modify failed\n");
+}
+
struct iscsi_transport iscsi_tcp = {
- .name = "iscsi",
- .rdma = 0,
- .ep_init = iscsi_tcp_init,
- .ep_read = iscsi_tcp_read,
- .ep_write_begin = iscsi_tcp_write_begin,
- .ep_write_end = iscsi_tcp_write_end,
- .ep_close = iscsi_tcp_close,
- .ep_show = iscsi_tcp_show,
+ .name = "iscsi",
+ .rdma = 0,
+ .ep_init = iscsi_tcp_init,
+ .ep_read = iscsi_tcp_read,
+ .ep_write_begin = iscsi_tcp_write_begin,
+ .ep_write_end = iscsi_tcp_write_end,
+ .ep_close = iscsi_tcp_close,
+ .ep_show = iscsi_tcp_show,
+ .ep_event_modify = iscsi_event_modify,
};
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 5d90b06..8463947 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -1037,7 +1037,7 @@ static int iscsi_scsi_cmd_done(uint64_t nid, int result, struct scsi_cmd *scmd)
}
list_add_tail(&task->c_list, &task->conn->tx_clist);
- tgt_event_modify(task->conn->fd, EPOLLIN | EPOLLOUT);
+ task->conn->tp->ep_event_modify(task->conn->fd, EPOLLIN | EPOLLOUT);
return 0;
}
@@ -1167,7 +1167,7 @@ static int iscsi_scsi_cmd_execute(struct iscsi_task *task)
task->offset = 0; /* for use as transmit pointer for data-ins */
err = iscsi_target_cmd_queue(task);
no_queuing:
- tgt_event_modify(conn->fd, EPOLLIN|EPOLLOUT);
+ conn->tp->ep_event_modify(conn->fd, EPOLLIN | EPOLLOUT);
return err;
}
@@ -1197,7 +1197,7 @@ static int iscsi_tm_done(struct mgmt_req *mreq)
break;
}
list_add_tail(&task->c_list, &task->conn->tx_clist);
- tgt_event_modify(task->conn->fd, EPOLLIN | EPOLLOUT);
+ task->conn->tp->ep_event_modify(task->conn->fd, EPOLLIN | EPOLLOUT);
return 0;
}
@@ -1253,7 +1253,8 @@ static int iscsi_task_execute(struct iscsi_task *task)
case ISCSI_OP_NOOP_OUT:
case ISCSI_OP_LOGOUT:
list_add_tail(&task->c_list, &task->conn->tx_clist);
- tgt_event_modify(task->conn->fd, EPOLLIN | EPOLLOUT);
+ task->conn->tp->ep_event_modify(task->conn->fd,
+ EPOLLIN | EPOLLOUT);
break;
case ISCSI_OP_SCSI_CMD:
/* convenient directionality for our internal use */
@@ -1273,7 +1274,8 @@ static int iscsi_task_execute(struct iscsi_task *task)
err = iscsi_tm_execute(task);
if (err) {
list_add_tail(&task->c_list, &task->conn->tx_clist);
- tgt_event_modify(task->conn->fd, EPOLLIN | EPOLLOUT);
+ task->conn->tp->ep_event_modify(task->conn->fd,
+ EPOLLIN | EPOLLOUT);
}
break;
case ISCSI_OP_TEXT:
@@ -1717,7 +1719,7 @@ static int iscsi_task_tx_start(struct iscsi_connection *conn)
nodata:
dprintf("no more data\n");
- tgt_event_modify(conn->fd, EPOLLIN);
+ conn->tp->ep_event_modify(conn->fd, EPOLLIN);
return -EAGAIN;
}
@@ -1881,7 +1883,7 @@ again:
conn_read_pdu(conn);
} else {
conn_write_pdu(conn);
- tgt_event_modify(fd, EPOLLOUT);
+ conn->tp->ep_event_modify(fd, EPOLLOUT);
ret = cmnd_execute(conn);
if (ret)
conn->state = STATE_CLOSE;
@@ -2025,7 +2027,7 @@ static void iscsi_tx_handler(int fd, struct iscsi_connection *conn)
else {
conn->state = STATE_SCSI;
conn_read_pdu(conn);
- tgt_event_modify(fd, EPOLLIN);
+ conn->tp->ep_event_modify(fd, EPOLLIN);
}
break;
case STATE_EXIT:
@@ -2036,7 +2038,7 @@ static void iscsi_tx_handler(int fd, struct iscsi_connection *conn)
break;
default:
conn_read_pdu(conn);
- tgt_event_modify(fd, EPOLLIN);
+ conn->tp->ep_event_modify(fd, EPOLLIN);
break;
}
}
diff --git a/usr/iscsi/transport.h b/usr/iscsi/transport.h
index ec34bb0..9660396 100644
--- a/usr/iscsi/transport.h
+++ b/usr/iscsi/transport.h
@@ -11,6 +11,7 @@ struct iscsi_transport {
void (*ep_write_end)(int ep);
size_t (*ep_close) (int ep);
int (*ep_show) (int ep, char *buf, int rest);
+ void (*ep_event_modify) (int ep, int events);
};
extern struct iscsi_transport iscsi_tcp;
--
1.5.3.4
More information about the stgt
mailing list