[openib-general] [PATCH] iser: more cleanups following the iscsi_iser/iser merge

Or Gerlitz ogerlitz at voltaire.com
Thu Jan 5 03:08:23 PST 2006


more cleanups which are possible following the iscsi_iser/iser merge:
remove unused struct iscsi_buf, make some func call pathes shorter.


Index: ulp/iser/iscsi_iser.h
===================================================================
--- ulp/iser/iscsi_iser.h	(revision 4768)
+++ ulp/iser/iscsi_iser.h	(working copy)
@@ -25,6 +25,7 @@
 #include <linux/types.h>
 #include <linux/net.h>
 #include <scsi/iscsi_proto.h>
+#include <scsi/iscsi_if.h>
 #define AF_ISER	 28 /* to be defined properly */
 
 #define ISCSI_ISER_XMIT_CMDS_MAX	128		/* must be power of 2 */
@@ -227,19 +228,11 @@ struct iscsi_iser_queue {
 	int			max;		/* Max number of elements */
 };
 
-struct iscsi_buf {
-	struct scatterlist	sg;
-	struct kvec		iov;
-	unsigned int		sent;
-};
-
 struct iscsi_iser_mgmt_task {
 	struct iscsi_hdr	hdr;
 	uint32_t	itt;			/* this ITT */
 	char		*data;			/* mgmt payload */
 	int			data_count;	/* counts data to be sent */
-	struct iscsi_buf	headbuf;	/* header buffer */
-	struct iscsi_buf	sendbuf;	/* in progress buffer */
 };
 
 struct iscsi_iser_cmd_task {
@@ -348,14 +341,11 @@ int iser_send_data_out(struct iscsi_iser
 /* terminate a connection */
 int iser_conn_term(struct iscsi_iser_conn *p_iscsi_iser_conn);
 
+int iscsi_iser_hdr_recv(struct iscsi_iser_conn *conn, struct iscsi_hdr *hdr,
+			char *rx_data);
 
-void iscsi_iser_control_notify(struct iscsi_iser_conn *p_iscsi_conn,
-			       struct iscsi_hdr *hdr, char *rx_data);
-
-void iscsi_iser_conn_term_notify(struct iscsi_iser_conn *p_iscsi_conn);
+void iscsi_iser_conn_failure(struct iscsi_iser_conn *conn, enum iscsi_err err);
 
 int  iscsi_iser_init(void);
 void iscsi_iser_exit(void);
 
-void iser_conn_init_lowpart(struct iscsi_iser_conn *p_iser_conn);
-
Index: ulp/iser/iser_conn.c
===================================================================
--- ulp/iser/iser_conn.c	(revision 4768)
+++ ulp/iser/iser_conn.c	(working copy)
@@ -85,15 +85,6 @@ void iser_conn_init(struct iser_conn *p_
 	init_waitqueue_head(&p_iser_conn->connect_wait_q);
 }
 
-void iser_conn_init_lowpart(struct iscsi_iser_conn *p_iser_conn)
-{
-	/* moved from iser_conn_init */
-	atomic_set(&p_iser_conn->post_recv_buf_count, 0);
-	atomic_set(&p_iser_conn->post_send_buf_count, 0);
-
-	init_waitqueue_head(&p_iser_conn->disconnect_wait_q);
-}
-
 /**
  * Initializes iSER adaptor structure.
  *
@@ -454,7 +445,8 @@ int iser_complete_conn_termination(struc
 
 		/* Notify the upper layer about asynch terminations */
 		if (cur_conn_state == ISER_CONN_ASYNC_TERM)
-			iscsi_iser_conn_term_notify(p_iser_conn);
+			iscsi_iser_conn_failure(p_iser_conn,
+						ISCSI_ERR_CONN_FAILED);
 
 		if (cur_conn_state == ISER_CONN_SYNC_TERM)
 			wake_up_interruptible(&p_iser_conn->disconnect_wait_q);
Index: ulp/iser/iser_initiator.c
===================================================================
--- ulp/iser/iser_initiator.c	(revision 4768)
+++ ulp/iser/iser_initiator.c	(working copy)
@@ -537,7 +537,7 @@ void iser_rcv_dto_completion(struct iser
 	struct iscsi_iser_cmd_task *p_iser_task = NULL;
 	struct iscsi_hdr *p_hdr;
 	char   *rx_data;
-	int     rx_data_size;
+	int     rx_data_size,rc;
 	unsigned int itt;
 	unsigned char opcode;
 	int no_more_task_sends = 0;
@@ -581,9 +581,9 @@ void iser_rcv_dto_completion(struct iser
 		}
 	}
 
-	iser_dbg("Control notify, DTO:0x%p, as PDU:0x%p\n", p_dto, p_hdr);
-
-	iscsi_iser_control_notify(p_iser_conn, p_hdr, rx_data);
+	rc = iscsi_iser_hdr_recv(p_iser_conn, p_hdr, rx_data);
+	if(rc)
+		iscsi_iser_conn_failure(p_iser_conn, rc);
 
 	if(p_iser_task != NULL) {
 		spin_lock(&p_iser_task->task_lock);
Index: ulp/iser/iscsi_iser.c
===================================================================
--- ulp/iser/iscsi_iser.c	(revision 4768)
+++ ulp/iser/iscsi_iser.c	(working copy)
@@ -79,15 +79,6 @@ module_param_named(max_lun, iscsi_max_lu
 
 static kmem_cache_t            *task_mem_cache;
 
-static inline void iscsi_buf_init_iov(struct iscsi_buf *ibuf,
-				      char *vbuf, int size)
-{
-	ibuf->sg.page = (void*)vbuf;
-	ibuf->sg.offset = (unsigned int)-1;
-	ibuf->sg.length = size;
-	ibuf->sent = 0;
-}
-
 /**
  * iscsi_iser_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands
  *
@@ -185,26 +176,18 @@ static int iscsi_iser_mtask_xmit(struct 
 {
 	int error = 0;
 
-	debug_scsi("mtask deq [cid %d itt 0x%x]\n",
-		   conn->id, mtask->itt);
-
-	debug_scsi("%s: sending: size = 0x%x, data = 0x%p\n",
-		   __FUNCTION__,
-		   mtask->data_count,
-		   mtask->data);
+	debug_scsi("mtask deq [cid %d itt 0x%x]\n", conn->id, mtask->itt);
 
 	/* Send the control */
-	/* FIXME enough to call with (conn, mtask) */
 	error = iser_send_control(conn, mtask);
 
-	if (error) {
+	if (error)
 		printk(KERN_ERR "send_control failed\n");
-	}
 
 	return error;
 }
 
-static void
+void
 iscsi_iser_conn_failure(struct iscsi_iser_conn *conn, enum iscsi_err err)
 {
 	struct iscsi_iser_session *session = conn->session;
@@ -222,36 +205,6 @@ iscsi_iser_conn_failure(struct iscsi_ise
 	debug_iser("%s: exit\n", __FUNCTION__);
 }
 
-static int iscsi_iser_ctask_xmit_cmd(struct iscsi_iser_conn *conn,
-				     struct iscsi_iser_cmd_task *ctask)
-{
-	int error = 0;
-	switch (ctask->sc->sc_data_direction) {
-	case DMA_TO_DEVICE:
-	case DMA_FROM_DEVICE:
-		break;
-	case DMA_NONE:
-		break;
-	default:
-		printk(KERN_ERR "Illegal data direction (%d)\n",
-		       ctask->sc->sc_data_direction);
-		error = -1;
-		goto iscsi_iser_ctask_xmit_cmd_exit;
-
-	}
-
-	/* Send the command */
-	error = iser_send_command(conn, ctask);
-
-	if (error) {
-		printk(KERN_ERR "send_command failed\n");
-		iscsi_iser_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
-	}
-
-iscsi_iser_ctask_xmit_cmd_exit:
-	return error;
-}
-
 static void iscsi_iser_unsolicit_data_init(struct iscsi_iser_conn *conn,
 					   struct iscsi_iser_cmd_task *ctask)
 {
@@ -313,7 +266,6 @@ static int iscsi_iser_ctask_xmit_unsol_d
 		error = iser_send_data_out(conn, ctask, &dtask->hdr);
 		if (error) {
 			printk(KERN_ERR "send_data_out failed\n");
-			iscsi_iser_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
 			goto iscsi_iser_ctask_xmit_unsol_data_exit;
 		}
 
@@ -341,7 +293,7 @@ static int iscsi_iser_ctask_xmit(struct 
 		return error;
 
 	/* Send the cmd PDU */
-	error = iscsi_iser_ctask_xmit_cmd(conn,ctask);
+	error = iser_send_command(conn, ctask);
 	if (error) {
 		printk(KERN_ERR "Couldn't send a cmd PDU\n");
 		goto iscsi_iser_ctask_xmit_exit;
@@ -349,14 +301,15 @@ static int iscsi_iser_ctask_xmit(struct 
 
 	/* Send unsolicited data-out PDU(s) if necessary */
 	if (ctask->unsol_count) {
-		error = iscsi_iser_ctask_xmit_unsol_data(conn,ctask);
-		if (error) {
+		error = iscsi_iser_ctask_xmit_unsol_data(conn, ctask);
+		if (error)
 			printk(KERN_ERR "Couldn't send unsolicited "
 			       "data-out PDU(s)\n");
-		}
 	}
 
  iscsi_iser_ctask_xmit_exit:
+	if(error)
+		iscsi_iser_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
 	return error;
 }
 
@@ -563,19 +516,6 @@ fault:
 	return 0;
 }
 
-static inline void iscsi_buf_init_virt(struct iscsi_buf *ibuf,
-				       char *vbuf, int size)
-{
-	sg_init_one(&ibuf->sg, (u8 *)vbuf, size);
-	ibuf->sent = 0;
-}
-
-static inline void iscsi_buf_init_hdr(struct iscsi_iser_conn *conn,
-				      struct iscsi_buf *ibuf, char *vbuf)
-{
-	iscsi_buf_init_virt(ibuf, vbuf, sizeof(struct iscsi_hdr));
-}
-
 static int iscsi_iser_conn_send_generic(iscsi_connh_t connh,
 					 struct iscsi_hdr *hdr,
 					 char *data, uint32_t data_size)
@@ -627,8 +567,6 @@ static int iscsi_iser_conn_send_generic(
 
 	memcpy(&mtask->hdr, hdr, sizeof(struct iscsi_hdr));
 
-	iscsi_buf_init_hdr(conn, &mtask->headbuf, (char*)&mtask->hdr);
-
 	spin_unlock_bh(&session->lock);
 
 	if (data_size) {
@@ -637,11 +575,6 @@ static int iscsi_iser_conn_send_generic(
 	} else
 		mtask->data_count = 0;
 
-	if (mtask->data_count) {
-		iscsi_buf_init_iov(&mtask->sendbuf, (char*)mtask->data,
-				   mtask->data_count);
-	}
-
 	debug_scsi("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n",
 		   hdr->opcode, hdr->itt, data_size);
 
@@ -1219,8 +1152,9 @@ static iscsi_connh_t iscsi_iser_conn_cre
 	init_MUTEX(&conn->xmitsema);
 	init_waitqueue_head(&conn->ehwait);
 
-	/* MERGE_ADDED */
-	iser_conn_init_lowpart(conn);
+	atomic_set(&conn->post_recv_buf_count, 0);
+	atomic_set(&conn->post_send_buf_count, 0);
+	init_waitqueue_head(&conn->disconnect_wait_q);
 
 	return iscsi_handle(conn);
 
@@ -1761,7 +1695,7 @@ out:
 	return rc;
 }
 
-static int
+int
 iscsi_iser_hdr_recv(struct iscsi_iser_conn *conn, struct iscsi_hdr *hdr, char *rx_data)
 {
 	int rc = 0;
@@ -1937,31 +1871,6 @@ iscsi_iser_hdr_recv(struct iscsi_iser_co
 	return rc;
 }
 
-void iscsi_iser_control_notify(struct iscsi_iser_conn *conn,/*void *conn_h,*/
-			       struct iscsi_hdr *hdr, char *rx_data)
-{
-	int rc;
-
-	/*
-	 * Verify and process incoming PDU header.
-	 */
-	rc = iscsi_iser_hdr_recv(conn, hdr, rx_data);
-	if (rc) {
-		debug_iser("%s: calling iscsi_iser_conn_failure\n", __FUNCTION__);
-		iscsi_iser_conn_failure(conn, rc);
-	}
-}
-
-void iscsi_iser_conn_term_notify(struct iscsi_iser_conn *conn)
-{
-	debug_iser("%s: entry\n", __FUNCTION__);
-
-	debug_iser("%s: calling iscsi_iser_conn_failure\n", __FUNCTION__);
-	iscsi_iser_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
-
-	debug_iser("%s: exit\n", __FUNCTION__);
-}
-
 int iscsi_iser_init(void)
 {
 	int error;





More information about the general mailing list