diff options
author | Nicholas Bellinger <nab@daterainc.com> | 2013-08-17 17:27:56 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-09-09 17:29:21 -0400 |
commit | d703ce2f7f4de20c03d71c22a9d5e3708798047b (patch) | |
tree | f06be5be02dc43ae0a7c34eacd986238005a003b /drivers | |
parent | 3aee26b4ae91048c933dc622f00b7bb01f7f0ff1 (diff) |
iscsi/iser-target: Convert to command priv_size usage
This command converts iscsi/isert-target to use allocations based on
iscsit_transport->priv_size within iscsit_allocate_cmd(), instead of
using an embedded isert_cmd->iscsi_cmd.
This includes removing iscsit_transport->alloc_cmd() usage, along
with updating isert-target code to use iscsit_priv_cmd().
Also, remove left-over iscsit_transport->release_cmd() usage for
direct calls to iscsit_release_cmd(), and drop the now unused
lio_cmd_cache and isert_cmd_cache.
Cc: Or Gerlitz <ogerlitz@mellanox.com>
Cc: Kent Overstreet <kmo@daterainc.com>
Signed-off-by: Nicholas Bellinger <nab@daterainc.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.c | 114 | ||||
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.h | 2 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 16 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target.h | 1 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_configfs.c | 2 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_core.h | 1 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_util.c | 20 |
7 files changed, 48 insertions, 108 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index c42748b3b257..027a818f287b 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
@@ -39,7 +39,6 @@ static DEFINE_MUTEX(device_list_mutex); | |||
39 | static LIST_HEAD(device_list); | 39 | static LIST_HEAD(device_list); |
40 | static struct workqueue_struct *isert_rx_wq; | 40 | static struct workqueue_struct *isert_rx_wq; |
41 | static struct workqueue_struct *isert_comp_wq; | 41 | static struct workqueue_struct *isert_comp_wq; |
42 | static struct kmem_cache *isert_cmd_cache; | ||
43 | 42 | ||
44 | static void | 43 | static void |
45 | isert_qp_event_callback(struct ib_event *e, void *context) | 44 | isert_qp_event_callback(struct ib_event *e, void *context) |
@@ -876,43 +875,30 @@ isert_rx_login_req(struct iser_rx_desc *rx_desc, int rx_buflen, | |||
876 | schedule_delayed_work(&conn->login_work, 0); | 875 | schedule_delayed_work(&conn->login_work, 0); |
877 | } | 876 | } |
878 | 877 | ||
879 | static void | ||
880 | isert_release_cmd(struct iscsi_cmd *cmd) | ||
881 | { | ||
882 | struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd, | ||
883 | iscsi_cmd); | ||
884 | |||
885 | pr_debug("Entering isert_release_cmd %p >>>>>>>>>>>>>>>.\n", isert_cmd); | ||
886 | |||
887 | kfree(cmd->buf_ptr); | ||
888 | kfree(cmd->tmr_req); | ||
889 | |||
890 | kmem_cache_free(isert_cmd_cache, isert_cmd); | ||
891 | } | ||
892 | |||
893 | static struct iscsi_cmd | 878 | static struct iscsi_cmd |
894 | *isert_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp) | 879 | *isert_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp) |
895 | { | 880 | { |
896 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 881 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
897 | struct isert_cmd *isert_cmd; | 882 | struct isert_cmd *isert_cmd; |
883 | struct iscsi_cmd *cmd; | ||
898 | 884 | ||
899 | isert_cmd = kmem_cache_zalloc(isert_cmd_cache, gfp); | 885 | cmd = iscsit_allocate_cmd(conn, gfp); |
900 | if (!isert_cmd) { | 886 | if (!cmd) { |
901 | pr_err("Unable to allocate isert_cmd\n"); | 887 | pr_err("Unable to allocate iscsi_cmd + isert_cmd\n"); |
902 | return NULL; | 888 | return NULL; |
903 | } | 889 | } |
890 | isert_cmd = iscsit_priv_cmd(cmd); | ||
904 | isert_cmd->conn = isert_conn; | 891 | isert_cmd->conn = isert_conn; |
905 | isert_cmd->iscsi_cmd.release_cmd = &isert_release_cmd; | 892 | isert_cmd->iscsi_cmd = cmd; |
906 | 893 | ||
907 | return &isert_cmd->iscsi_cmd; | 894 | return cmd; |
908 | } | 895 | } |
909 | 896 | ||
910 | static int | 897 | static int |
911 | isert_handle_scsi_cmd(struct isert_conn *isert_conn, | 898 | isert_handle_scsi_cmd(struct isert_conn *isert_conn, |
912 | struct isert_cmd *isert_cmd, struct iser_rx_desc *rx_desc, | 899 | struct isert_cmd *isert_cmd, struct iscsi_cmd *cmd, |
913 | unsigned char *buf) | 900 | struct iser_rx_desc *rx_desc, unsigned char *buf) |
914 | { | 901 | { |
915 | struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; | ||
916 | struct iscsi_conn *conn = isert_conn->conn; | 902 | struct iscsi_conn *conn = isert_conn->conn; |
917 | struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf; | 903 | struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf; |
918 | struct scatterlist *sg; | 904 | struct scatterlist *sg; |
@@ -1019,9 +1005,9 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, | |||
1019 | 1005 | ||
1020 | static int | 1006 | static int |
1021 | isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, | 1007 | isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, |
1022 | struct iser_rx_desc *rx_desc, unsigned char *buf) | 1008 | struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc, |
1009 | unsigned char *buf) | ||
1023 | { | 1010 | { |
1024 | struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; | ||
1025 | struct iscsi_conn *conn = isert_conn->conn; | 1011 | struct iscsi_conn *conn = isert_conn->conn; |
1026 | struct iscsi_nopout *hdr = (struct iscsi_nopout *)buf; | 1012 | struct iscsi_nopout *hdr = (struct iscsi_nopout *)buf; |
1027 | int rc; | 1013 | int rc; |
@@ -1038,9 +1024,9 @@ isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, | |||
1038 | 1024 | ||
1039 | static int | 1025 | static int |
1040 | isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, | 1026 | isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, |
1041 | struct iser_rx_desc *rx_desc, struct iscsi_text *hdr) | 1027 | struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc, |
1028 | struct iscsi_text *hdr) | ||
1042 | { | 1029 | { |
1043 | struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; | ||
1044 | struct iscsi_conn *conn = isert_conn->conn; | 1030 | struct iscsi_conn *conn = isert_conn->conn; |
1045 | u32 payload_length = ntoh24(hdr->dlength); | 1031 | u32 payload_length = ntoh24(hdr->dlength); |
1046 | int rc; | 1032 | int rc; |
@@ -1085,26 +1071,26 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, | |||
1085 | 1071 | ||
1086 | switch (opcode) { | 1072 | switch (opcode) { |
1087 | case ISCSI_OP_SCSI_CMD: | 1073 | case ISCSI_OP_SCSI_CMD: |
1088 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); | 1074 | cmd = isert_allocate_cmd(conn, GFP_KERNEL); |
1089 | if (!cmd) | 1075 | if (!cmd) |
1090 | break; | 1076 | break; |
1091 | 1077 | ||
1092 | isert_cmd = container_of(cmd, struct isert_cmd, iscsi_cmd); | 1078 | isert_cmd = iscsit_priv_cmd(cmd); |
1093 | isert_cmd->read_stag = read_stag; | 1079 | isert_cmd->read_stag = read_stag; |
1094 | isert_cmd->read_va = read_va; | 1080 | isert_cmd->read_va = read_va; |
1095 | isert_cmd->write_stag = write_stag; | 1081 | isert_cmd->write_stag = write_stag; |
1096 | isert_cmd->write_va = write_va; | 1082 | isert_cmd->write_va = write_va; |
1097 | 1083 | ||
1098 | ret = isert_handle_scsi_cmd(isert_conn, isert_cmd, | 1084 | ret = isert_handle_scsi_cmd(isert_conn, isert_cmd, cmd, |
1099 | rx_desc, (unsigned char *)hdr); | 1085 | rx_desc, (unsigned char *)hdr); |
1100 | break; | 1086 | break; |
1101 | case ISCSI_OP_NOOP_OUT: | 1087 | case ISCSI_OP_NOOP_OUT: |
1102 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); | 1088 | cmd = isert_allocate_cmd(conn, GFP_KERNEL); |
1103 | if (!cmd) | 1089 | if (!cmd) |
1104 | break; | 1090 | break; |
1105 | 1091 | ||
1106 | isert_cmd = container_of(cmd, struct isert_cmd, iscsi_cmd); | 1092 | isert_cmd = iscsit_priv_cmd(cmd); |
1107 | ret = isert_handle_nop_out(isert_conn, isert_cmd, | 1093 | ret = isert_handle_nop_out(isert_conn, isert_cmd, cmd, |
1108 | rx_desc, (unsigned char *)hdr); | 1094 | rx_desc, (unsigned char *)hdr); |
1109 | break; | 1095 | break; |
1110 | case ISCSI_OP_SCSI_DATA_OUT: | 1096 | case ISCSI_OP_SCSI_DATA_OUT: |
@@ -1112,7 +1098,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, | |||
1112 | (unsigned char *)hdr); | 1098 | (unsigned char *)hdr); |
1113 | break; | 1099 | break; |
1114 | case ISCSI_OP_SCSI_TMFUNC: | 1100 | case ISCSI_OP_SCSI_TMFUNC: |
1115 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); | 1101 | cmd = isert_allocate_cmd(conn, GFP_KERNEL); |
1116 | if (!cmd) | 1102 | if (!cmd) |
1117 | break; | 1103 | break; |
1118 | 1104 | ||
@@ -1120,7 +1106,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, | |||
1120 | (unsigned char *)hdr); | 1106 | (unsigned char *)hdr); |
1121 | break; | 1107 | break; |
1122 | case ISCSI_OP_LOGOUT: | 1108 | case ISCSI_OP_LOGOUT: |
1123 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); | 1109 | cmd = isert_allocate_cmd(conn, GFP_KERNEL); |
1124 | if (!cmd) | 1110 | if (!cmd) |
1125 | break; | 1111 | break; |
1126 | 1112 | ||
@@ -1131,12 +1117,12 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, | |||
1131 | HZ); | 1117 | HZ); |
1132 | break; | 1118 | break; |
1133 | case ISCSI_OP_TEXT: | 1119 | case ISCSI_OP_TEXT: |
1134 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); | 1120 | cmd = isert_allocate_cmd(conn, GFP_KERNEL); |
1135 | if (!cmd) | 1121 | if (!cmd) |
1136 | break; | 1122 | break; |
1137 | 1123 | ||
1138 | isert_cmd = container_of(cmd, struct isert_cmd, iscsi_cmd); | 1124 | isert_cmd = iscsit_priv_cmd(cmd); |
1139 | ret = isert_handle_text_cmd(isert_conn, isert_cmd, | 1125 | ret = isert_handle_text_cmd(isert_conn, isert_cmd, cmd, |
1140 | rx_desc, (struct iscsi_text *)hdr); | 1126 | rx_desc, (struct iscsi_text *)hdr); |
1141 | break; | 1127 | break; |
1142 | default: | 1128 | default: |
@@ -1264,7 +1250,7 @@ isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn) | |||
1264 | static void | 1250 | static void |
1265 | isert_put_cmd(struct isert_cmd *isert_cmd) | 1251 | isert_put_cmd(struct isert_cmd *isert_cmd) |
1266 | { | 1252 | { |
1267 | struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; | 1253 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; |
1268 | struct isert_conn *isert_conn = isert_cmd->conn; | 1254 | struct isert_conn *isert_conn = isert_cmd->conn; |
1269 | struct iscsi_conn *conn = isert_conn->conn; | 1255 | struct iscsi_conn *conn = isert_conn->conn; |
1270 | 1256 | ||
@@ -1315,7 +1301,7 @@ isert_put_cmd(struct isert_cmd *isert_cmd) | |||
1315 | * Fall-through | 1301 | * Fall-through |
1316 | */ | 1302 | */ |
1317 | default: | 1303 | default: |
1318 | isert_release_cmd(cmd); | 1304 | iscsit_release_cmd(cmd); |
1319 | break; | 1305 | break; |
1320 | } | 1306 | } |
1321 | } | 1307 | } |
@@ -1351,7 +1337,7 @@ isert_completion_rdma_read(struct iser_tx_desc *tx_desc, | |||
1351 | struct isert_cmd *isert_cmd) | 1337 | struct isert_cmd *isert_cmd) |
1352 | { | 1338 | { |
1353 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | 1339 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; |
1354 | struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; | 1340 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; |
1355 | struct se_cmd *se_cmd = &cmd->se_cmd; | 1341 | struct se_cmd *se_cmd = &cmd->se_cmd; |
1356 | struct ib_device *ib_dev = isert_cmd->conn->conn_cm_id->device; | 1342 | struct ib_device *ib_dev = isert_cmd->conn->conn_cm_id->device; |
1357 | 1343 | ||
@@ -1387,7 +1373,7 @@ isert_do_control_comp(struct work_struct *work) | |||
1387 | struct isert_cmd, comp_work); | 1373 | struct isert_cmd, comp_work); |
1388 | struct isert_conn *isert_conn = isert_cmd->conn; | 1374 | struct isert_conn *isert_conn = isert_cmd->conn; |
1389 | struct ib_device *ib_dev = isert_conn->conn_cm_id->device; | 1375 | struct ib_device *ib_dev = isert_conn->conn_cm_id->device; |
1390 | struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; | 1376 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; |
1391 | 1377 | ||
1392 | switch (cmd->i_state) { | 1378 | switch (cmd->i_state) { |
1393 | case ISTATE_SEND_TASKMGTRSP: | 1379 | case ISTATE_SEND_TASKMGTRSP: |
@@ -1433,7 +1419,7 @@ isert_response_completion(struct iser_tx_desc *tx_desc, | |||
1433 | struct isert_conn *isert_conn, | 1419 | struct isert_conn *isert_conn, |
1434 | struct ib_device *ib_dev) | 1420 | struct ib_device *ib_dev) |
1435 | { | 1421 | { |
1436 | struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; | 1422 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; |
1437 | 1423 | ||
1438 | if (cmd->i_state == ISTATE_SEND_TASKMGTRSP || | 1424 | if (cmd->i_state == ISTATE_SEND_TASKMGTRSP || |
1439 | cmd->i_state == ISTATE_SEND_LOGOUTRSP || | 1425 | cmd->i_state == ISTATE_SEND_LOGOUTRSP || |
@@ -1625,8 +1611,7 @@ isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd) | |||
1625 | static int | 1611 | static int |
1626 | isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | 1612 | isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd) |
1627 | { | 1613 | { |
1628 | struct isert_cmd *isert_cmd = container_of(cmd, | 1614 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1629 | struct isert_cmd, iscsi_cmd); | ||
1630 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1615 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1631 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; | 1616 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; |
1632 | struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *) | 1617 | struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *) |
@@ -1675,8 +1660,7 @@ static int | |||
1675 | isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, | 1660 | isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, |
1676 | bool nopout_response) | 1661 | bool nopout_response) |
1677 | { | 1662 | { |
1678 | struct isert_cmd *isert_cmd = container_of(cmd, | 1663 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1679 | struct isert_cmd, iscsi_cmd); | ||
1680 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1664 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1681 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; | 1665 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; |
1682 | 1666 | ||
@@ -1695,8 +1679,7 @@ isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, | |||
1695 | static int | 1679 | static int |
1696 | isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) | 1680 | isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) |
1697 | { | 1681 | { |
1698 | struct isert_cmd *isert_cmd = container_of(cmd, | 1682 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1699 | struct isert_cmd, iscsi_cmd); | ||
1700 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1683 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1701 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; | 1684 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; |
1702 | 1685 | ||
@@ -1714,8 +1697,7 @@ isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) | |||
1714 | static int | 1697 | static int |
1715 | isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) | 1698 | isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) |
1716 | { | 1699 | { |
1717 | struct isert_cmd *isert_cmd = container_of(cmd, | 1700 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1718 | struct isert_cmd, iscsi_cmd); | ||
1719 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1701 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1720 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; | 1702 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; |
1721 | 1703 | ||
@@ -1733,8 +1715,7 @@ isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) | |||
1733 | static int | 1715 | static int |
1734 | isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) | 1716 | isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) |
1735 | { | 1717 | { |
1736 | struct isert_cmd *isert_cmd = container_of(cmd, | 1718 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1737 | struct isert_cmd, iscsi_cmd); | ||
1738 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1719 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1739 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; | 1720 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; |
1740 | struct ib_device *ib_dev = isert_conn->conn_cm_id->device; | 1721 | struct ib_device *ib_dev = isert_conn->conn_cm_id->device; |
@@ -1766,8 +1747,7 @@ isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) | |||
1766 | static int | 1747 | static int |
1767 | isert_put_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) | 1748 | isert_put_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) |
1768 | { | 1749 | { |
1769 | struct isert_cmd *isert_cmd = container_of(cmd, | 1750 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1770 | struct isert_cmd, iscsi_cmd); | ||
1771 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1751 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1772 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; | 1752 | struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; |
1773 | struct iscsi_text_rsp *hdr = | 1753 | struct iscsi_text_rsp *hdr = |
@@ -1809,7 +1789,7 @@ isert_build_rdma_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, | |||
1809 | struct ib_sge *ib_sge, struct ib_send_wr *send_wr, | 1789 | struct ib_sge *ib_sge, struct ib_send_wr *send_wr, |
1810 | u32 data_left, u32 offset) | 1790 | u32 data_left, u32 offset) |
1811 | { | 1791 | { |
1812 | struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; | 1792 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; |
1813 | struct scatterlist *sg_start, *tmp_sg; | 1793 | struct scatterlist *sg_start, *tmp_sg; |
1814 | struct ib_device *ib_dev = isert_conn->conn_cm_id->device; | 1794 | struct ib_device *ib_dev = isert_conn->conn_cm_id->device; |
1815 | u32 sg_off, page_off; | 1795 | u32 sg_off, page_off; |
@@ -1854,8 +1834,7 @@ static int | |||
1854 | isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | 1834 | isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) |
1855 | { | 1835 | { |
1856 | struct se_cmd *se_cmd = &cmd->se_cmd; | 1836 | struct se_cmd *se_cmd = &cmd->se_cmd; |
1857 | struct isert_cmd *isert_cmd = container_of(cmd, | 1837 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1858 | struct isert_cmd, iscsi_cmd); | ||
1859 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | 1838 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; |
1860 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1839 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1861 | struct ib_send_wr *wr_failed, *send_wr; | 1840 | struct ib_send_wr *wr_failed, *send_wr; |
@@ -1958,8 +1937,7 @@ static int | |||
1958 | isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) | 1937 | isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) |
1959 | { | 1938 | { |
1960 | struct se_cmd *se_cmd = &cmd->se_cmd; | 1939 | struct se_cmd *se_cmd = &cmd->se_cmd; |
1961 | struct isert_cmd *isert_cmd = container_of(cmd, | 1940 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1962 | struct isert_cmd, iscsi_cmd); | ||
1963 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | 1941 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; |
1964 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1942 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1965 | struct ib_send_wr *wr_failed, *send_wr; | 1943 | struct ib_send_wr *wr_failed, *send_wr; |
@@ -2405,12 +2383,12 @@ static void isert_free_conn(struct iscsi_conn *conn) | |||
2405 | static struct iscsit_transport iser_target_transport = { | 2383 | static struct iscsit_transport iser_target_transport = { |
2406 | .name = "IB/iSER", | 2384 | .name = "IB/iSER", |
2407 | .transport_type = ISCSI_INFINIBAND, | 2385 | .transport_type = ISCSI_INFINIBAND, |
2386 | .priv_size = sizeof(struct isert_cmd), | ||
2408 | .owner = THIS_MODULE, | 2387 | .owner = THIS_MODULE, |
2409 | .iscsit_setup_np = isert_setup_np, | 2388 | .iscsit_setup_np = isert_setup_np, |
2410 | .iscsit_accept_np = isert_accept_np, | 2389 | .iscsit_accept_np = isert_accept_np, |
2411 | .iscsit_free_np = isert_free_np, | 2390 | .iscsit_free_np = isert_free_np, |
2412 | .iscsit_free_conn = isert_free_conn, | 2391 | .iscsit_free_conn = isert_free_conn, |
2413 | .iscsit_alloc_cmd = isert_alloc_cmd, | ||
2414 | .iscsit_get_login_rx = isert_get_login_rx, | 2392 | .iscsit_get_login_rx = isert_get_login_rx, |
2415 | .iscsit_put_login_tx = isert_put_login_tx, | 2393 | .iscsit_put_login_tx = isert_put_login_tx, |
2416 | .iscsit_immediate_queue = isert_immediate_queue, | 2394 | .iscsit_immediate_queue = isert_immediate_queue, |
@@ -2437,21 +2415,10 @@ static int __init isert_init(void) | |||
2437 | goto destroy_rx_wq; | 2415 | goto destroy_rx_wq; |
2438 | } | 2416 | } |
2439 | 2417 | ||
2440 | isert_cmd_cache = kmem_cache_create("isert_cmd_cache", | ||
2441 | sizeof(struct isert_cmd), __alignof__(struct isert_cmd), | ||
2442 | 0, NULL); | ||
2443 | if (!isert_cmd_cache) { | ||
2444 | pr_err("Unable to create isert_cmd_cache\n"); | ||
2445 | ret = -ENOMEM; | ||
2446 | goto destroy_tx_cq; | ||
2447 | } | ||
2448 | |||
2449 | iscsit_register_transport(&iser_target_transport); | 2418 | iscsit_register_transport(&iser_target_transport); |
2450 | pr_debug("iSER_TARGET[0] - Loaded iser_target_transport\n"); | 2419 | pr_debug("iSER_TARGET[0] - Loaded iser_target_transport\n"); |
2451 | return 0; | 2420 | return 0; |
2452 | 2421 | ||
2453 | destroy_tx_cq: | ||
2454 | destroy_workqueue(isert_comp_wq); | ||
2455 | destroy_rx_wq: | 2422 | destroy_rx_wq: |
2456 | destroy_workqueue(isert_rx_wq); | 2423 | destroy_workqueue(isert_rx_wq); |
2457 | return ret; | 2424 | return ret; |
@@ -2459,7 +2426,6 @@ destroy_rx_wq: | |||
2459 | 2426 | ||
2460 | static void __exit isert_exit(void) | 2427 | static void __exit isert_exit(void) |
2461 | { | 2428 | { |
2462 | kmem_cache_destroy(isert_cmd_cache); | ||
2463 | destroy_workqueue(isert_comp_wq); | 2429 | destroy_workqueue(isert_comp_wq); |
2464 | destroy_workqueue(isert_rx_wq); | 2430 | destroy_workqueue(isert_rx_wq); |
2465 | iscsit_unregister_transport(&iser_target_transport); | 2431 | iscsit_unregister_transport(&iser_target_transport); |
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index 191117b5b508..0d45945201cb 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h | |||
@@ -67,7 +67,7 @@ struct isert_cmd { | |||
67 | u32 write_va_off; | 67 | u32 write_va_off; |
68 | u32 rdma_wr_num; | 68 | u32 rdma_wr_num; |
69 | struct isert_conn *conn; | 69 | struct isert_conn *conn; |
70 | struct iscsi_cmd iscsi_cmd; | 70 | struct iscsi_cmd *iscsi_cmd; |
71 | struct ib_sge *ib_sge; | 71 | struct ib_sge *ib_sge; |
72 | struct iser_tx_desc tx_desc; | 72 | struct iser_tx_desc tx_desc; |
73 | struct isert_rdma_wr rdma_wr; | 73 | struct isert_rdma_wr rdma_wr; |
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 1dff3e01f92c..da6bbfe4f26d 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -63,7 +63,6 @@ spinlock_t sess_idr_lock; | |||
63 | 63 | ||
64 | struct iscsit_global *iscsit_global; | 64 | struct iscsit_global *iscsit_global; |
65 | 65 | ||
66 | struct kmem_cache *lio_cmd_cache; | ||
67 | struct kmem_cache *lio_qr_cache; | 66 | struct kmem_cache *lio_qr_cache; |
68 | struct kmem_cache *lio_dr_cache; | 67 | struct kmem_cache *lio_dr_cache; |
69 | struct kmem_cache *lio_ooo_cache; | 68 | struct kmem_cache *lio_ooo_cache; |
@@ -500,7 +499,6 @@ static struct iscsit_transport iscsi_target_transport = { | |||
500 | .iscsit_setup_np = iscsit_setup_np, | 499 | .iscsit_setup_np = iscsit_setup_np, |
501 | .iscsit_accept_np = iscsit_accept_np, | 500 | .iscsit_accept_np = iscsit_accept_np, |
502 | .iscsit_free_np = iscsit_free_np, | 501 | .iscsit_free_np = iscsit_free_np, |
503 | .iscsit_alloc_cmd = iscsit_alloc_cmd, | ||
504 | .iscsit_get_login_rx = iscsit_get_login_rx, | 502 | .iscsit_get_login_rx = iscsit_get_login_rx, |
505 | .iscsit_put_login_tx = iscsit_put_login_tx, | 503 | .iscsit_put_login_tx = iscsit_put_login_tx, |
506 | .iscsit_get_dataout = iscsit_build_r2ts_for_cmd, | 504 | .iscsit_get_dataout = iscsit_build_r2ts_for_cmd, |
@@ -541,22 +539,13 @@ static int __init iscsi_target_init_module(void) | |||
541 | goto ts_out1; | 539 | goto ts_out1; |
542 | } | 540 | } |
543 | 541 | ||
544 | lio_cmd_cache = kmem_cache_create("lio_cmd_cache", | ||
545 | sizeof(struct iscsi_cmd), __alignof__(struct iscsi_cmd), | ||
546 | 0, NULL); | ||
547 | if (!lio_cmd_cache) { | ||
548 | pr_err("Unable to kmem_cache_create() for" | ||
549 | " lio_cmd_cache\n"); | ||
550 | goto ts_out2; | ||
551 | } | ||
552 | |||
553 | lio_qr_cache = kmem_cache_create("lio_qr_cache", | 542 | lio_qr_cache = kmem_cache_create("lio_qr_cache", |
554 | sizeof(struct iscsi_queue_req), | 543 | sizeof(struct iscsi_queue_req), |
555 | __alignof__(struct iscsi_queue_req), 0, NULL); | 544 | __alignof__(struct iscsi_queue_req), 0, NULL); |
556 | if (!lio_qr_cache) { | 545 | if (!lio_qr_cache) { |
557 | pr_err("nable to kmem_cache_create() for" | 546 | pr_err("nable to kmem_cache_create() for" |
558 | " lio_qr_cache\n"); | 547 | " lio_qr_cache\n"); |
559 | goto cmd_out; | 548 | goto ts_out2; |
560 | } | 549 | } |
561 | 550 | ||
562 | lio_dr_cache = kmem_cache_create("lio_dr_cache", | 551 | lio_dr_cache = kmem_cache_create("lio_dr_cache", |
@@ -600,8 +589,6 @@ dr_out: | |||
600 | kmem_cache_destroy(lio_dr_cache); | 589 | kmem_cache_destroy(lio_dr_cache); |
601 | qr_out: | 590 | qr_out: |
602 | kmem_cache_destroy(lio_qr_cache); | 591 | kmem_cache_destroy(lio_qr_cache); |
603 | cmd_out: | ||
604 | kmem_cache_destroy(lio_cmd_cache); | ||
605 | ts_out2: | 592 | ts_out2: |
606 | iscsi_deallocate_thread_sets(); | 593 | iscsi_deallocate_thread_sets(); |
607 | ts_out1: | 594 | ts_out1: |
@@ -619,7 +606,6 @@ static void __exit iscsi_target_cleanup_module(void) | |||
619 | iscsi_thread_set_free(); | 606 | iscsi_thread_set_free(); |
620 | iscsit_release_discovery_tpg(); | 607 | iscsit_release_discovery_tpg(); |
621 | iscsit_unregister_transport(&iscsi_target_transport); | 608 | iscsit_unregister_transport(&iscsi_target_transport); |
622 | kmem_cache_destroy(lio_cmd_cache); | ||
623 | kmem_cache_destroy(lio_qr_cache); | 609 | kmem_cache_destroy(lio_qr_cache); |
624 | kmem_cache_destroy(lio_dr_cache); | 610 | kmem_cache_destroy(lio_dr_cache); |
625 | kmem_cache_destroy(lio_ooo_cache); | 611 | kmem_cache_destroy(lio_ooo_cache); |
diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index f82f6273526e..e936d56fb523 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h | |||
@@ -39,7 +39,6 @@ extern struct target_fabric_configfs *lio_target_fabric_configfs; | |||
39 | 39 | ||
40 | extern struct kmem_cache *lio_dr_cache; | 40 | extern struct kmem_cache *lio_dr_cache; |
41 | extern struct kmem_cache *lio_ooo_cache; | 41 | extern struct kmem_cache *lio_ooo_cache; |
42 | extern struct kmem_cache *lio_cmd_cache; | ||
43 | extern struct kmem_cache *lio_qr_cache; | 42 | extern struct kmem_cache *lio_qr_cache; |
44 | extern struct kmem_cache *lio_r2t_cache; | 43 | extern struct kmem_cache *lio_r2t_cache; |
45 | 44 | ||
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index ddfa32c3f564..116114ffaa8b 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -1925,7 +1925,7 @@ static void lio_release_cmd(struct se_cmd *se_cmd) | |||
1925 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); | 1925 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); |
1926 | 1926 | ||
1927 | pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd); | 1927 | pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd); |
1928 | cmd->release_cmd(cmd); | 1928 | iscsit_release_cmd(cmd); |
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | /* End functions for target_core_fabric_ops */ | 1931 | /* End functions for target_core_fabric_ops */ |
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h index 089a0e915da8..129b7d77c7cb 100644 --- a/drivers/target/iscsi/iscsi_target_core.h +++ b/drivers/target/iscsi/iscsi_target_core.h | |||
@@ -489,7 +489,6 @@ struct iscsi_cmd { | |||
489 | u32 first_data_sg_off; | 489 | u32 first_data_sg_off; |
490 | u32 kmapped_nents; | 490 | u32 kmapped_nents; |
491 | sense_reason_t sense_reason; | 491 | sense_reason_t sense_reason; |
492 | void (*release_cmd)(struct iscsi_cmd *); | ||
493 | } ____cacheline_aligned; | 492 | } ____cacheline_aligned; |
494 | 493 | ||
495 | struct iscsi_tmr_req { | 494 | struct iscsi_tmr_req { |
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 1df06d5e4e01..5784cad16be1 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c | |||
@@ -149,18 +149,6 @@ void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd) | |||
149 | spin_unlock_bh(&cmd->r2t_lock); | 149 | spin_unlock_bh(&cmd->r2t_lock); |
150 | } | 150 | } |
151 | 151 | ||
152 | struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) | ||
153 | { | ||
154 | struct iscsi_cmd *cmd; | ||
155 | |||
156 | cmd = kmem_cache_zalloc(lio_cmd_cache, gfp_mask); | ||
157 | if (!cmd) | ||
158 | return NULL; | ||
159 | |||
160 | cmd->release_cmd = &iscsit_release_cmd; | ||
161 | return cmd; | ||
162 | } | ||
163 | |||
164 | /* | 152 | /* |
165 | * May be called from software interrupt (timer) context for allocating | 153 | * May be called from software interrupt (timer) context for allocating |
166 | * iSCSI NopINs. | 154 | * iSCSI NopINs. |
@@ -168,8 +156,9 @@ struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) | |||
168 | struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) | 156 | struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) |
169 | { | 157 | { |
170 | struct iscsi_cmd *cmd; | 158 | struct iscsi_cmd *cmd; |
159 | int priv_size = conn->conn_transport->priv_size; | ||
171 | 160 | ||
172 | cmd = conn->conn_transport->iscsit_alloc_cmd(conn, gfp_mask); | 161 | cmd = kzalloc(sizeof(struct iscsi_cmd) + priv_size, gfp_mask); |
173 | if (!cmd) { | 162 | if (!cmd) { |
174 | pr_err("Unable to allocate memory for struct iscsi_cmd.\n"); | 163 | pr_err("Unable to allocate memory for struct iscsi_cmd.\n"); |
175 | return NULL; | 164 | return NULL; |
@@ -696,8 +685,9 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) | |||
696 | kfree(cmd->iov_data); | 685 | kfree(cmd->iov_data); |
697 | kfree(cmd->text_in_ptr); | 686 | kfree(cmd->text_in_ptr); |
698 | 687 | ||
699 | kmem_cache_free(lio_cmd_cache, cmd); | 688 | kfree(cmd); |
700 | } | 689 | } |
690 | EXPORT_SYMBOL(iscsit_release_cmd); | ||
701 | 691 | ||
702 | static void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd, | 692 | static void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd, |
703 | bool check_queues) | 693 | bool check_queues) |
@@ -761,7 +751,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) | |||
761 | /* Fall-through */ | 751 | /* Fall-through */ |
762 | default: | 752 | default: |
763 | __iscsit_free_cmd(cmd, false, shutdown); | 753 | __iscsit_free_cmd(cmd, false, shutdown); |
764 | cmd->release_cmd(cmd); | 754 | iscsit_release_cmd(cmd); |
765 | break; | 755 | break; |
766 | } | 756 | } |
767 | } | 757 | } |