[openib-general] patch to ulp/iser such that it would work with latest open-iscsi

Or Gerlitz ogerlitz at voltaire.com
Thu Jan 19 06:18:47 PST 2006


Nish,

For now, please use this patch for your compilation against latest kernels 
containing latest (post official 2.6.15) open-iscsi

Or.

Common subdirectories: iser-2.6.15-open-iscsi/.svn and iser-latest-open-iscsi/.svn
diff -up iser-2.6.15-open-iscsi/iscsi_iser.c iser-latest-open-iscsi/iscsi_iser.c
--- iser-2.6.15-open-iscsi/iscsi_iser.c	2006-01-19 16:55:05.000000000 +0200
+++ iser-latest-open-iscsi/iscsi_iser.c	2006-01-19 16:50:12.000000000 +0200
@@ -980,17 +980,15 @@ dout_alloc_fail:
 	return -ENOMEM;
 }
 
-static iscsi_sessionh_t iscsi_iser_session_create(uint32_t initial_cmdsn,
-						  struct Scsi_Host *host)
+static int
+iscsi_iser_session_create(struct Scsi_Host *shost, uint32_t initial_cmdsn)
 {
-	struct iscsi_iser_session *session = NULL;
+	struct iscsi_iser_session *session = iscsi_hostdata(shost->hostdata);
 	int cmd_i;
 
-	session = iscsi_hostdata(host->hostdata);
 	memset(session, 0, sizeof(struct iscsi_iser_session));
 
-	session->host = host;
-	session->id = host->host_no;
+	session->host = shost;	
 	session->state = ISCSI_STATE_LOGGED_IN;
 	session->mgmtpool_max = ISCSI_ISER_MGMT_CMDS_MAX;
 	session->cmds_max = ISCSI_ISER_XMIT_CMDS_MAX;
@@ -1038,7 +1036,7 @@ static iscsi_sessionh_t iscsi_iser_sessi
 	if (iscsi_iser_dout_pool_alloc(session))
 		goto dout_alloc_fail;
 
-	return iscsi_handle(session);
+	return 0;
 
 dout_alloc_fail:
 	for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++)
@@ -1048,14 +1046,14 @@ immdata_alloc_fail:
 mgmtpool_alloc_fail:
 	iscsi_iser_pool_free(&session->cmdpool, (void**)session->cmds);
 cmdpool_alloc_fail:
-	return iscsi_handle(NULL);
+	return -ENOMEM;
 }
 
-static void iscsi_iser_session_destroy(iscsi_sessionh_t sessionh)
+static void iscsi_iser_session_destroy(struct Scsi_Host *shost)
 {
+	struct iscsi_iser_session *session = iscsi_hostdata(shost->hostdata);
 	int cmd_i;
 	struct iscsi_iser_data_task *dtask, *n;
-	struct iscsi_iser_session *session = iscsi_ptr(sessionh);
 
 	debug_iser("%s: enter\n", __FUNCTION__);
 
@@ -1093,16 +1091,11 @@ static void iscsi_iser_xmitworker(void *
 	up(&conn->xmitsema);
 }
 
-static iscsi_connh_t iscsi_iser_conn_create(iscsi_sessionh_t sessionh,
-					    uint32_t conn_idx)
+static int
+iscsi_iser_conn_create(struct Scsi_Host *shost, void *conndata, uint32_t conn_idx)
 {
-	struct iscsi_iser_session *session = iscsi_ptr(sessionh);
-	struct iscsi_iser_conn *conn = NULL;
-
-	conn = kzalloc(sizeof *conn, GFP_KERNEL);
-	if (conn == NULL) {
-		goto conn_alloc_fail;
-	}
+	struct iscsi_iser_session *session = iscsi_hostdata(shost->hostdata);
+	struct iscsi_iser_conn *conn = conndata;
 
 	/* Init the connection */
 	conn->c_stage = ISCSI_CONN_INITIAL_STAGE;
@@ -1151,7 +1144,7 @@ static iscsi_connh_t iscsi_iser_conn_cre
 	atomic_set(&conn->post_send_buf_count, 0);
 	init_waitqueue_head(&conn->disconnect_wait_q);
 
-	return iscsi_handle(conn);
+	return 0;
 
 login_mtask_alloc_fail:
 	kfifo_free(conn->mgmtqueue);
@@ -1160,9 +1153,7 @@ mgmtqueue_alloc_fail:
 immqueue_alloc_fail:
 	kfifo_free(conn->xmitqueue);
 xmitqueue_alloc_fail:
-	kfree(conn);
-conn_alloc_fail:
-	return iscsi_handle(NULL);
+	return -ENOMEM;
 }
 
 static int iscsi_iser_conn_bind(iscsi_sessionh_t sessionh, iscsi_connh_t connh,
@@ -1223,9 +1214,9 @@ static int iscsi_iser_conn_bind(iscsi_se
 	return 0;
 }
 
-static void iscsi_iser_conn_destroy(iscsi_connh_t connh)
+static void iscsi_iser_conn_destroy(void *data)
 {
-	struct iscsi_iser_conn *conn = iscsi_ptr(connh);
+	struct iscsi_iser_conn *conn = data;
 	struct iscsi_iser_session *session = conn->session;
 	unsigned long flags;
 
@@ -1292,8 +1283,6 @@ static void iscsi_iser_conn_destroy(iscs
 	kfifo_free(conn->immqueue);
 	kfifo_free(conn->mgmtqueue);
 
-	kfree(conn);
-
 	debug_iser("%s: exit\n", __FUNCTION__);
 }
 
@@ -1379,23 +1368,13 @@ static int iscsi_iser_conn_set_param(isc
 	return 0;
 }
 
-static int iscsi_iser_conn_get_param(iscsi_connh_t connh,
+static int iscsi_iser_session_get_param(struct Scsi_Host *shost,
 				     enum iscsi_param param,
 				     uint32_t *value)
 {
-	struct iscsi_iser_conn *conn = iscsi_ptr(connh);
-	struct iscsi_iser_session *session = conn->session;
+	struct iscsi_iser_session *session = iscsi_hostdata(shost->hostdata);
 
 	switch (param) {
-	case ISCSI_PARAM_MAX_XMIT_DLENGTH:
-		*value = conn->max_xmit_dlength;
-		break;
-	case ISCSI_PARAM_HDRDGST_EN:
-		*value = 0;
-		break;
-	case ISCSI_PARAM_DATADGST_EN:
-		*value = 0;
-		break;
 	case ISCSI_PARAM_INITIAL_R2T_EN:
 		*value = session->initial_r2t_en;
 		break;
@@ -1429,12 +1408,6 @@ static int iscsi_iser_conn_get_param(isc
 	case ISCSI_PARAM_RDMAEXTENSIONS:
 		*value = 1;
 		break;
-	/*case ISCSI_PARAM_TARGET_RECV_DLENGTH:
-		*value = conn->target_recv_dlength;
-		break;
-	case ISCSI_PARAM_INITIATOR_RECV_DLENGTH:
-		*value = conn->initiator_recv_dlength;
-		break;*/
 	default:
 		return ISCSI_ERR_PARAM_NOT_FOUND;
 	}
@@ -1442,6 +1415,28 @@ static int iscsi_iser_conn_get_param(isc
 	return 0;
 }
 
+static int
+iscsi_iser_conn_get_param(void *data, enum iscsi_param param, uint32_t *value)
+{
+	 struct iscsi_iser_conn *conn = data;
+
+	 switch (param) {
+	 case ISCSI_PARAM_MAX_XMIT_DLENGTH:
+		*value = conn->max_xmit_dlength;
+		break;
+	 case ISCSI_PARAM_HDRDGST_EN:
+		*value = 0;
+		break;
+	 case ISCSI_PARAM_DATADGST_EN:
+		*value = 0;
+		break;
+	 default:
+		return ISCSI_ERR_PARAM_NOT_FOUND;
+	 }
+
+	 return 0;
+}
+
 static int iscsi_iser_conn_start(iscsi_connh_t connh)
 {
 	struct iscsi_iser_conn *conn = iscsi_ptr(connh);
@@ -1568,6 +1563,7 @@ static struct iscsi_transport iscsi_iser
 	.rdma                   = 1,
 	.host_template          = &iscsi_iser_sht,
 	.hostdata_size          = sizeof(struct iscsi_iser_session),
+	.conndata_size		= sizeof(struct iscsi_iser_conn),
 	.max_lun                = ISCSI_ISER_MAX_LUN,
 	.max_cmd_len            = ISCSI_ISER_MAX_CMD_LEN,
 	.create_session         = iscsi_iser_session_create,
@@ -1576,7 +1572,8 @@ static struct iscsi_transport iscsi_iser
 	.bind_conn              = iscsi_iser_conn_bind,
 	.destroy_conn           = iscsi_iser_conn_destroy,
 	.set_param              = iscsi_iser_conn_set_param,
-	.get_param              = iscsi_iser_conn_get_param,
+	.get_conn_param         = iscsi_iser_conn_get_param,
+	.get_session_param      = iscsi_iser_session_get_param,
 	.start_conn             = iscsi_iser_conn_start,
 	.stop_conn              = iscsi_iser_conn_stop,
 	.send_pdu               = iscsi_iser_conn_send_pdu,
@@ -1872,8 +1869,6 @@ iscsi_iser_hdr_recv(struct iscsi_iser_co
 
 int iscsi_iser_init(void)
 {
-	int error;
-
 	if (iscsi_max_lun < 1) {
 		printk(KERN_ERR "Invalid max_lun value of %u\n", iscsi_max_lun);
 		return -EINVAL;
@@ -1883,11 +1878,9 @@ int iscsi_iser_init(void)
 	if (iscsi_iser_slabs_create())
 		return -ENOMEM;
 
-	error = iscsi_register_transport(&iscsi_iser_transport);
-	if (error) {
+	if (!iscsi_register_transport(&iscsi_iser_transport)) {
 		printk(KERN_ERR "iscsi_register_transport failed\n");
-		iscsi_iser_slabs_destroy();
-		return error;
+		iscsi_iser_slabs_destroy();		
 	}
 	return 0;
 }




More information about the general mailing list