aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/iscsi_tcp.c19
-rw-r--r--drivers/scsi/libiscsi.c15
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c7
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c24
4 files changed, 30 insertions, 35 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index e19d92f2d753..dfaf9fa57340 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -1490,7 +1490,7 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1490 struct iscsi_cls_conn *cls_conn; 1490 struct iscsi_cls_conn *cls_conn;
1491 struct iscsi_tcp_conn *tcp_conn; 1491 struct iscsi_tcp_conn *tcp_conn;
1492 1492
1493 cls_conn = iscsi_conn_setup(cls_session, conn_idx); 1493 cls_conn = iscsi_conn_setup(cls_session, sizeof(*tcp_conn), conn_idx);
1494 if (!cls_conn) 1494 if (!cls_conn)
1495 return NULL; 1495 return NULL;
1496 conn = cls_conn->dd_data; 1496 conn = cls_conn->dd_data;
@@ -1500,18 +1500,14 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1500 */ 1500 */
1501 conn->max_recv_dlength = ISCSI_DEF_MAX_RECV_SEG_LEN; 1501 conn->max_recv_dlength = ISCSI_DEF_MAX_RECV_SEG_LEN;
1502 1502
1503 tcp_conn = kzalloc(sizeof(*tcp_conn), GFP_KERNEL); 1503 tcp_conn = conn->dd_data;
1504 if (!tcp_conn)
1505 goto tcp_conn_alloc_fail;
1506
1507 conn->dd_data = tcp_conn;
1508 tcp_conn->iscsi_conn = conn; 1504 tcp_conn->iscsi_conn = conn;
1509 1505
1510 tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0, 1506 tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
1511 CRYPTO_ALG_ASYNC); 1507 CRYPTO_ALG_ASYNC);
1512 tcp_conn->tx_hash.flags = 0; 1508 tcp_conn->tx_hash.flags = 0;
1513 if (IS_ERR(tcp_conn->tx_hash.tfm)) 1509 if (IS_ERR(tcp_conn->tx_hash.tfm))
1514 goto free_tcp_conn; 1510 goto free_conn;
1515 1511
1516 tcp_conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0, 1512 tcp_conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
1517 CRYPTO_ALG_ASYNC); 1513 CRYPTO_ALG_ASYNC);
@@ -1523,14 +1519,12 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1523 1519
1524free_tx_tfm: 1520free_tx_tfm:
1525 crypto_free_hash(tcp_conn->tx_hash.tfm); 1521 crypto_free_hash(tcp_conn->tx_hash.tfm);
1526free_tcp_conn: 1522free_conn:
1527 iscsi_conn_printk(KERN_ERR, conn, 1523 iscsi_conn_printk(KERN_ERR, conn,
1528 "Could not create connection due to crc32c " 1524 "Could not create connection due to crc32c "
1529 "loading error. Make sure the crc32c " 1525 "loading error. Make sure the crc32c "
1530 "module is built as a module or into the " 1526 "module is built as a module or into the "
1531 "kernel\n"); 1527 "kernel\n");
1532 kfree(tcp_conn);
1533tcp_conn_alloc_fail:
1534 iscsi_conn_teardown(cls_conn); 1528 iscsi_conn_teardown(cls_conn);
1535 return NULL; 1529 return NULL;
1536} 1530}
@@ -1563,14 +1557,13 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_conn *cls_conn)
1563 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 1557 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1564 1558
1565 iscsi_tcp_release_conn(conn); 1559 iscsi_tcp_release_conn(conn);
1566 iscsi_conn_teardown(cls_conn);
1567 1560
1568 if (tcp_conn->tx_hash.tfm) 1561 if (tcp_conn->tx_hash.tfm)
1569 crypto_free_hash(tcp_conn->tx_hash.tfm); 1562 crypto_free_hash(tcp_conn->tx_hash.tfm);
1570 if (tcp_conn->rx_hash.tfm) 1563 if (tcp_conn->rx_hash.tfm)
1571 crypto_free_hash(tcp_conn->rx_hash.tfm); 1564 crypto_free_hash(tcp_conn->rx_hash.tfm);
1572 1565
1573 kfree(tcp_conn); 1566 iscsi_conn_teardown(cls_conn);
1574} 1567}
1575 1568
1576static void 1569static void
@@ -1983,8 +1976,6 @@ static struct iscsi_transport iscsi_tcp_transport = {
1983 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS | 1976 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
1984 ISCSI_HOST_INITIATOR_NAME | 1977 ISCSI_HOST_INITIATOR_NAME |
1985 ISCSI_HOST_NETDEV_NAME, 1978 ISCSI_HOST_NETDEV_NAME,
1986 .conndata_size = sizeof(struct iscsi_conn),
1987 .sessiondata_size = sizeof(struct iscsi_session),
1988 /* session management */ 1979 /* session management */
1989 .create_session = iscsi_tcp_session_create, 1980 .create_session = iscsi_tcp_session_create,
1990 .destroy_session = iscsi_tcp_session_destroy, 1981 .destroy_session = iscsi_tcp_session_destroy,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 73c37c04ca66..784a935fad4a 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1867,7 +1867,8 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
1867 cmds_max = ISCSI_DEF_XMIT_CMDS_MAX; 1867 cmds_max = ISCSI_DEF_XMIT_CMDS_MAX;
1868 } 1868 }
1869 1869
1870 cls_session = iscsi_alloc_session(shost, iscsit); 1870 cls_session = iscsi_alloc_session(shost, iscsit,
1871 sizeof(struct iscsi_session));
1871 if (!cls_session) 1872 if (!cls_session)
1872 return NULL; 1873 return NULL;
1873 session = cls_session->dd_data; 1874 session = cls_session->dd_data;
@@ -1968,22 +1969,26 @@ EXPORT_SYMBOL_GPL(iscsi_session_teardown);
1968/** 1969/**
1969 * iscsi_conn_setup - create iscsi_cls_conn and iscsi_conn 1970 * iscsi_conn_setup - create iscsi_cls_conn and iscsi_conn
1970 * @cls_session: iscsi_cls_session 1971 * @cls_session: iscsi_cls_session
1972 * @dd_size: private driver data size
1971 * @conn_idx: cid 1973 * @conn_idx: cid
1972 **/ 1974 */
1973struct iscsi_cls_conn * 1975struct iscsi_cls_conn *
1974iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) 1976iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
1977 uint32_t conn_idx)
1975{ 1978{
1976 struct iscsi_session *session = cls_session->dd_data; 1979 struct iscsi_session *session = cls_session->dd_data;
1977 struct iscsi_conn *conn; 1980 struct iscsi_conn *conn;
1978 struct iscsi_cls_conn *cls_conn; 1981 struct iscsi_cls_conn *cls_conn;
1979 char *data; 1982 char *data;
1980 1983
1981 cls_conn = iscsi_create_conn(cls_session, conn_idx); 1984 cls_conn = iscsi_create_conn(cls_session, sizeof(*conn) + dd_size,
1985 conn_idx);
1982 if (!cls_conn) 1986 if (!cls_conn)
1983 return NULL; 1987 return NULL;
1984 conn = cls_conn->dd_data; 1988 conn = cls_conn->dd_data;
1985 memset(conn, 0, sizeof(*conn)); 1989 memset(conn, 0, sizeof(*conn) + dd_size);
1986 1990
1991 conn->dd_data = cls_conn->dd_data + sizeof(*conn);
1987 conn->session = session; 1992 conn->session = session;
1988 conn->cls_conn = cls_conn; 1993 conn->cls_conn = cls_conn;
1989 conn->c_stage = ISCSI_CONN_INITIAL_STAGE; 1994 conn->c_stage = ISCSI_CONN_INITIAL_STAGE;
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 6c6ee0f34995..5822dd595826 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -113,8 +113,6 @@ static struct iscsi_transport qla4xxx_iscsi_transport = {
113 .host_param_mask = ISCSI_HOST_HWADDRESS | 113 .host_param_mask = ISCSI_HOST_HWADDRESS |
114 ISCSI_HOST_IPADDRESS | 114 ISCSI_HOST_IPADDRESS |
115 ISCSI_HOST_INITIATOR_NAME, 115 ISCSI_HOST_INITIATOR_NAME,
116 .sessiondata_size = sizeof(struct ddb_entry),
117
118 .tgt_dscvr = qla4xxx_tgt_dscvr, 116 .tgt_dscvr = qla4xxx_tgt_dscvr,
119 .get_conn_param = qla4xxx_conn_get_param, 117 .get_conn_param = qla4xxx_conn_get_param,
120 .get_session_param = qla4xxx_sess_get_param, 118 .get_session_param = qla4xxx_sess_get_param,
@@ -274,7 +272,7 @@ int qla4xxx_add_sess(struct ddb_entry *ddb_entry)
274 return err; 272 return err;
275 } 273 }
276 274
277 ddb_entry->conn = iscsi_create_conn(ddb_entry->sess, 0); 275 ddb_entry->conn = iscsi_create_conn(ddb_entry->sess, 0, 0);
278 if (!ddb_entry->conn) { 276 if (!ddb_entry->conn) {
279 iscsi_remove_session(ddb_entry->sess); 277 iscsi_remove_session(ddb_entry->sess);
280 DEBUG2(printk(KERN_ERR "Could not add connection.\n")); 278 DEBUG2(printk(KERN_ERR "Could not add connection.\n"));
@@ -291,7 +289,8 @@ struct ddb_entry *qla4xxx_alloc_sess(struct scsi_qla_host *ha)
291 struct ddb_entry *ddb_entry; 289 struct ddb_entry *ddb_entry;
292 struct iscsi_cls_session *sess; 290 struct iscsi_cls_session *sess;
293 291
294 sess = iscsi_alloc_session(ha->host, &qla4xxx_iscsi_transport); 292 sess = iscsi_alloc_session(ha->host, &qla4xxx_iscsi_transport,
293 sizeof(struct ddb_entry));
295 if (!sess) 294 if (!sess)
296 return NULL; 295 return NULL;
297 296
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 6fdaa2ee6632..6b8516a0970b 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -483,12 +483,12 @@ static int iscsi_unbind_session(struct iscsi_cls_session *session)
483} 483}
484 484
485struct iscsi_cls_session * 485struct iscsi_cls_session *
486iscsi_alloc_session(struct Scsi_Host *shost, 486iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
487 struct iscsi_transport *transport) 487 int dd_size)
488{ 488{
489 struct iscsi_cls_session *session; 489 struct iscsi_cls_session *session;
490 490
491 session = kzalloc(sizeof(*session) + transport->sessiondata_size, 491 session = kzalloc(sizeof(*session) + dd_size,
492 GFP_KERNEL); 492 GFP_KERNEL);
493 if (!session) 493 if (!session)
494 return NULL; 494 return NULL;
@@ -510,7 +510,7 @@ iscsi_alloc_session(struct Scsi_Host *shost,
510 session->dev.parent = &shost->shost_gendev; 510 session->dev.parent = &shost->shost_gendev;
511 session->dev.release = iscsi_session_release; 511 session->dev.release = iscsi_session_release;
512 device_initialize(&session->dev); 512 device_initialize(&session->dev);
513 if (transport->sessiondata_size) 513 if (dd_size)
514 session->dd_data = &session[1]; 514 session->dd_data = &session[1];
515 return session; 515 return session;
516} 516}
@@ -558,18 +558,18 @@ EXPORT_SYMBOL_GPL(iscsi_add_session);
558 * iscsi_create_session - create iscsi class session 558 * iscsi_create_session - create iscsi class session
559 * @shost: scsi host 559 * @shost: scsi host
560 * @transport: iscsi transport 560 * @transport: iscsi transport
561 * @dd_size: private driver data size
561 * @target_id: which target 562 * @target_id: which target
562 * 563 *
563 * This can be called from a LLD or iscsi_transport. 564 * This can be called from a LLD or iscsi_transport.
564 */ 565 */
565struct iscsi_cls_session * 566struct iscsi_cls_session *
566iscsi_create_session(struct Scsi_Host *shost, 567iscsi_create_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
567 struct iscsi_transport *transport, 568 int dd_size, unsigned int target_id)
568 unsigned int target_id)
569{ 569{
570 struct iscsi_cls_session *session; 570 struct iscsi_cls_session *session;
571 571
572 session = iscsi_alloc_session(shost, transport); 572 session = iscsi_alloc_session(shost, transport, dd_size);
573 if (!session) 573 if (!session)
574 return NULL; 574 return NULL;
575 575
@@ -671,6 +671,7 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_session);
671/** 671/**
672 * iscsi_create_conn - create iscsi class connection 672 * iscsi_create_conn - create iscsi class connection
673 * @session: iscsi cls session 673 * @session: iscsi cls session
674 * @dd_size: private driver data size
674 * @cid: connection id 675 * @cid: connection id
675 * 676 *
676 * This can be called from a LLD or iscsi_transport. The connection 677 * This can be called from a LLD or iscsi_transport. The connection
@@ -683,18 +684,17 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_session);
683 * non-zero. 684 * non-zero.
684 */ 685 */
685struct iscsi_cls_conn * 686struct iscsi_cls_conn *
686iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid) 687iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)
687{ 688{
688 struct iscsi_transport *transport = session->transport; 689 struct iscsi_transport *transport = session->transport;
689 struct iscsi_cls_conn *conn; 690 struct iscsi_cls_conn *conn;
690 unsigned long flags; 691 unsigned long flags;
691 int err; 692 int err;
692 693
693 conn = kzalloc(sizeof(*conn) + transport->conndata_size, GFP_KERNEL); 694 conn = kzalloc(sizeof(*conn) + dd_size, GFP_KERNEL);
694 if (!conn) 695 if (!conn)
695 return NULL; 696 return NULL;
696 697 if (dd_size)
697 if (transport->conndata_size)
698 conn->dd_data = &conn[1]; 698 conn->dd_data = &conn[1];
699 699
700 INIT_LIST_HEAD(&conn->conn_list); 700 INIT_LIST_HEAD(&conn->conn_list);