[Stgt-devel] [PATCH 09/20] iser event handler to tcp
Pete Wyckoff
pw
Tue Oct 16 17:20:22 CEST 2007
Move iscsi_event_handler to iscsi_tcp.c as it is TCP-specific. RDMA will
have its own event handler. Both will call into iscsi_tx_handler and
iscsi_rx_handler, which are now exported, along with iscsi_scsi_cmd_execute
that will be needed when an RDMA read collects all the write data.
Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
usr/iscsi/iscsi_tcp.c | 23 ++++++++++++++++++++++-
usr/iscsi/iscsid.c | 25 +++----------------------
usr/iscsi/iscsid.h | 4 +++-
3 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c
index 0d189c7..7e0ab90 100644
--- a/usr/iscsi/iscsi_tcp.c
+++ b/usr/iscsi/iscsi_tcp.c
@@ -40,6 +40,8 @@
#define LISTEN_MAX 4
#define INCOMING_MAX 32
+static void iscsi_tcp_event_handler(int fd, int events, void *data);
+
static int set_keepalive(int fd)
{
int ret, opt;
@@ -97,7 +99,7 @@ static void accept_connection(int afd, int events, void *data)
conn_read_pdu(conn);
set_non_blocking(fd);
- err = tgt_event_add(fd, EPOLLIN, iscsi_event_handler, conn);
+ err = tgt_event_add(fd, EPOLLIN, iscsi_tcp_event_handler, conn);
if (err)
goto free_conn;
@@ -109,6 +111,25 @@ out:
return;
}
+static void iscsi_tcp_event_handler(int fd, int events, void *data)
+{
+ struct iscsi_connection *conn = (struct iscsi_connection *) data;
+
+ if (events & EPOLLIN)
+ iscsi_rx_handler(fd, conn);
+
+ if (conn->state == STATE_CLOSE)
+ dprintf("connection closed\n");
+
+ if (conn->state != STATE_CLOSE && events & EPOLLOUT)
+ iscsi_tx_handler(fd, conn);
+
+ if (conn->state == STATE_CLOSE) {
+ conn_close(conn, fd);
+ dprintf("connection closed\n");
+ }
+}
+
static int iscsi_tcp_init(void)
{
struct addrinfo hints, *res, *res0;
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 59f226c..85c7724 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -1151,7 +1151,7 @@ static int iscsi_target_cmd_queue(struct iscsi_task *task)
return target_cmd_queue(conn->session->target->tid, scmd);
}
-static int iscsi_scsi_cmd_execute(struct iscsi_task *task)
+int iscsi_scsi_cmd_execute(struct iscsi_task *task)
{
struct iscsi_connection *conn = task->conn;
struct iscsi_cmd *req = (struct iscsi_cmd *) &task->req;
@@ -1746,7 +1746,7 @@ static int do_recv(int fd, struct iscsi_connection *conn, int next_state)
return ret;
}
-static void iscsi_rx_handler(int fd, struct iscsi_connection *conn)
+void iscsi_rx_handler(int fd, struct iscsi_connection *conn)
{
int ret = 0, hdigest, ddigest;
uint32_t crc;
@@ -1913,7 +1913,7 @@ again:
return 0;
}
-static void iscsi_tx_handler(int fd, struct iscsi_connection *conn)
+void iscsi_tx_handler(int fd, struct iscsi_connection *conn)
{
int ret = 0, hdigest, ddigest;
uint32_t crc;
@@ -2043,25 +2043,6 @@ static void iscsi_tx_handler(int fd, struct iscsi_connection *conn)
}
}
-void iscsi_event_handler(int fd, int events, void *data)
-{
- struct iscsi_connection *conn = (struct iscsi_connection *) data;
-
- if (events & EPOLLIN)
- iscsi_rx_handler(fd, conn);
-
- if (conn->state == STATE_CLOSE)
- dprintf("connection closed\n");
-
- if (conn->state != STATE_CLOSE && events & EPOLLOUT)
- iscsi_tx_handler(fd, conn);
-
- if (conn->state == STATE_CLOSE) {
- conn_close(conn, fd);
- dprintf("connection closed\n");
- }
-}
-
struct tgt_driver iscsi = {
.name = "iscsi",
.use_kernel = 0,
diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h
index 2f6c7c8..524c2f3 100644
--- a/usr/iscsi/iscsid.h
+++ b/usr/iscsi/iscsid.h
@@ -259,10 +259,12 @@ extern int conn_take_fd(struct iscsi_connection *conn, int fd);
extern void conn_add_to_session(struct iscsi_connection *conn, struct iscsi_session *session);
/* iscsid.c */
-extern void iscsi_event_handler(int fd, int events, void *data);
extern char *text_key_find(struct iscsi_connection *conn, char *searchKey);
extern void text_key_add(struct iscsi_connection *conn, char *key, char *value);
extern void conn_read_pdu(struct iscsi_connection *conn);
+extern void iscsi_tx_handler(int fd, struct iscsi_connection *conn);
+extern void iscsi_rx_handler(int fd, struct iscsi_connection *conn);
+extern int iscsi_scsi_cmd_execute(struct iscsi_task *task);
/* iscsid.c iscsi_task */
extern void iscsi_free_task(struct iscsi_task *task);
--
1.5.3.4
More information about the stgt
mailing list