Commit d703ce2f authored by Nicholas Bellinger's avatar Nicholas Bellinger Committed by Nicholas Bellinger

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: default avatarNicholas Bellinger <nab@daterainc.com>
parent 3aee26b4
...@@ -39,7 +39,6 @@ static DEFINE_MUTEX(device_list_mutex); ...@@ -39,7 +39,6 @@ static DEFINE_MUTEX(device_list_mutex);
static LIST_HEAD(device_list); static LIST_HEAD(device_list);
static struct workqueue_struct *isert_rx_wq; static struct workqueue_struct *isert_rx_wq;
static struct workqueue_struct *isert_comp_wq; static struct workqueue_struct *isert_comp_wq;
static struct kmem_cache *isert_cmd_cache;
static void static void
isert_qp_event_callback(struct ib_event *e, void *context) 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,43 +875,30 @@ isert_rx_login_req(struct iser_rx_desc *rx_desc, int rx_buflen,
schedule_delayed_work(&conn->login_work, 0); schedule_delayed_work(&conn->login_work, 0);
} }
static void
isert_release_cmd(struct iscsi_cmd *cmd)
{
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd,
iscsi_cmd);
pr_debug("Entering isert_release_cmd %p >>>>>>>>>>>>>>>.\n", isert_cmd);
kfree(cmd->buf_ptr);
kfree(cmd->tmr_req);
kmem_cache_free(isert_cmd_cache, isert_cmd);
}
static struct iscsi_cmd static struct iscsi_cmd
*isert_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp) *isert_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp)
{ {
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct isert_cmd *isert_cmd; struct isert_cmd *isert_cmd;
struct iscsi_cmd *cmd;
isert_cmd = kmem_cache_zalloc(isert_cmd_cache, gfp); cmd = iscsit_allocate_cmd(conn, gfp);
if (!isert_cmd) { if (!cmd) {
pr_err("Unable to allocate isert_cmd\n"); pr_err("Unable to allocate iscsi_cmd + isert_cmd\n");
return NULL; return NULL;
} }
isert_cmd = iscsit_priv_cmd(cmd);
isert_cmd->conn = isert_conn; isert_cmd->conn = isert_conn;
isert_cmd->iscsi_cmd.release_cmd = &isert_release_cmd; isert_cmd->iscsi_cmd = cmd;
return &isert_cmd->iscsi_cmd; return cmd;
} }
static int static int
isert_handle_scsi_cmd(struct isert_conn *isert_conn, isert_handle_scsi_cmd(struct isert_conn *isert_conn,
struct isert_cmd *isert_cmd, struct iser_rx_desc *rx_desc, struct isert_cmd *isert_cmd, struct iscsi_cmd *cmd,
unsigned char *buf) struct iser_rx_desc *rx_desc, unsigned char *buf)
{ {
struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd;
struct iscsi_conn *conn = isert_conn->conn; struct iscsi_conn *conn = isert_conn->conn;
struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf; struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf;
struct scatterlist *sg; struct scatterlist *sg;
...@@ -1019,9 +1005,9 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, ...@@ -1019,9 +1005,9 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn,
static int static int
isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
struct iser_rx_desc *rx_desc, unsigned char *buf) struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc,
unsigned char *buf)
{ {
struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd;
struct iscsi_conn *conn = isert_conn->conn; struct iscsi_conn *conn = isert_conn->conn;
struct iscsi_nopout *hdr = (struct iscsi_nopout *)buf; struct iscsi_nopout *hdr = (struct iscsi_nopout *)buf;
int rc; int rc;
...@@ -1038,9 +1024,9 @@ isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, ...@@ -1038,9 +1024,9 @@ isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
static int static int
isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
struct iser_rx_desc *rx_desc, struct iscsi_text *hdr) struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc,
struct iscsi_text *hdr)
{ {
struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd;
struct iscsi_conn *conn = isert_conn->conn; struct iscsi_conn *conn = isert_conn->conn;
u32 payload_length = ntoh24(hdr->dlength); u32 payload_length = ntoh24(hdr->dlength);
int rc; int rc;
...@@ -1085,26 +1071,26 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, ...@@ -1085,26 +1071,26 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
switch (opcode) { switch (opcode) {
case ISCSI_OP_SCSI_CMD: case ISCSI_OP_SCSI_CMD:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn, GFP_KERNEL);
if (!cmd) if (!cmd)
break; break;
isert_cmd = container_of(cmd, struct isert_cmd, iscsi_cmd); isert_cmd = iscsit_priv_cmd(cmd);
isert_cmd->read_stag = read_stag; isert_cmd->read_stag = read_stag;
isert_cmd->read_va = read_va; isert_cmd->read_va = read_va;
isert_cmd->write_stag = write_stag; isert_cmd->write_stag = write_stag;
isert_cmd->write_va = write_va; isert_cmd->write_va = write_va;
ret = isert_handle_scsi_cmd(isert_conn, isert_cmd, ret = isert_handle_scsi_cmd(isert_conn, isert_cmd, cmd,
rx_desc, (unsigned char *)hdr); rx_desc, (unsigned char *)hdr);
break; break;
case ISCSI_OP_NOOP_OUT: case ISCSI_OP_NOOP_OUT:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn, GFP_KERNEL);
if (!cmd) if (!cmd)
break; break;
isert_cmd = container_of(cmd, struct isert_cmd, iscsi_cmd); isert_cmd = iscsit_priv_cmd(cmd);
ret = isert_handle_nop_out(isert_conn, isert_cmd, ret = isert_handle_nop_out(isert_conn, isert_cmd, cmd,
rx_desc, (unsigned char *)hdr); rx_desc, (unsigned char *)hdr);
break; break;
case ISCSI_OP_SCSI_DATA_OUT: 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,7 +1098,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
(unsigned char *)hdr); (unsigned char *)hdr);
break; break;
case ISCSI_OP_SCSI_TMFUNC: case ISCSI_OP_SCSI_TMFUNC:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn, GFP_KERNEL);
if (!cmd) if (!cmd)
break; break;
...@@ -1120,7 +1106,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, ...@@ -1120,7 +1106,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
(unsigned char *)hdr); (unsigned char *)hdr);
break; break;
case ISCSI_OP_LOGOUT: case ISCSI_OP_LOGOUT:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn, GFP_KERNEL);
if (!cmd) if (!cmd)
break; break;
...@@ -1131,12 +1117,12 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, ...@@ -1131,12 +1117,12 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
HZ); HZ);
break; break;
case ISCSI_OP_TEXT: case ISCSI_OP_TEXT:
cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); cmd = isert_allocate_cmd(conn, GFP_KERNEL);
if (!cmd) if (!cmd)
break; break;
isert_cmd = container_of(cmd, struct isert_cmd, iscsi_cmd); isert_cmd = iscsit_priv_cmd(cmd);
ret = isert_handle_text_cmd(isert_conn, isert_cmd, ret = isert_handle_text_cmd(isert_conn, isert_cmd, cmd,
rx_desc, (struct iscsi_text *)hdr); rx_desc, (struct iscsi_text *)hdr);
break; break;
default: default:
...@@ -1264,7 +1250,7 @@ isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn) ...@@ -1264,7 +1250,7 @@ isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn)
static void static void
isert_put_cmd(struct isert_cmd *isert_cmd) isert_put_cmd(struct isert_cmd *isert_cmd)
{ {
struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
struct isert_conn *isert_conn = isert_cmd->conn; struct isert_conn *isert_conn = isert_cmd->conn;
struct iscsi_conn *conn = isert_conn->conn; struct iscsi_conn *conn = isert_conn->conn;
...@@ -1315,7 +1301,7 @@ isert_put_cmd(struct isert_cmd *isert_cmd) ...@@ -1315,7 +1301,7 @@ isert_put_cmd(struct isert_cmd *isert_cmd)
* Fall-through * Fall-through
*/ */
default: default:
isert_release_cmd(cmd); iscsit_release_cmd(cmd);
break; break;
} }
} }
...@@ -1351,7 +1337,7 @@ isert_completion_rdma_read(struct iser_tx_desc *tx_desc, ...@@ -1351,7 +1337,7 @@ isert_completion_rdma_read(struct iser_tx_desc *tx_desc,
struct isert_cmd *isert_cmd) struct isert_cmd *isert_cmd)
{ {
struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; struct isert_rdma_wr *wr = &isert_cmd->rdma_wr;
struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
struct se_cmd *se_cmd = &cmd->se_cmd; struct se_cmd *se_cmd = &cmd->se_cmd;
struct ib_device *ib_dev = isert_cmd->conn->conn_cm_id->device; struct ib_device *ib_dev = isert_cmd->conn->conn_cm_id->device;
...@@ -1387,7 +1373,7 @@ isert_do_control_comp(struct work_struct *work) ...@@ -1387,7 +1373,7 @@ isert_do_control_comp(struct work_struct *work)
struct isert_cmd, comp_work); struct isert_cmd, comp_work);
struct isert_conn *isert_conn = isert_cmd->conn; struct isert_conn *isert_conn = isert_cmd->conn;
struct ib_device *ib_dev = isert_conn->conn_cm_id->device; struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
switch (cmd->i_state) { switch (cmd->i_state) {
case ISTATE_SEND_TASKMGTRSP: case ISTATE_SEND_TASKMGTRSP:
...@@ -1433,7 +1419,7 @@ isert_response_completion(struct iser_tx_desc *tx_desc, ...@@ -1433,7 +1419,7 @@ isert_response_completion(struct iser_tx_desc *tx_desc,
struct isert_conn *isert_conn, struct isert_conn *isert_conn,
struct ib_device *ib_dev) struct ib_device *ib_dev)
{ {
struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
if (cmd->i_state == ISTATE_SEND_TASKMGTRSP || if (cmd->i_state == ISTATE_SEND_TASKMGTRSP ||
cmd->i_state == ISTATE_SEND_LOGOUTRSP || cmd->i_state == ISTATE_SEND_LOGOUTRSP ||
...@@ -1625,8 +1611,7 @@ isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd) ...@@ -1625,8 +1611,7 @@ isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd)
static int static int
isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd) isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
{ {
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
struct isert_cmd, iscsi_cmd);
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr;
struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *) struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *)
...@@ -1675,8 +1660,7 @@ static int ...@@ -1675,8 +1660,7 @@ static int
isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
bool nopout_response) bool nopout_response)
{ {
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
struct isert_cmd, iscsi_cmd);
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr;
...@@ -1695,8 +1679,7 @@ isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, ...@@ -1695,8 +1679,7 @@ isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
static int static int
isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
{ {
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
struct isert_cmd, iscsi_cmd);
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr;
...@@ -1714,8 +1697,7 @@ isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) ...@@ -1714,8 +1697,7 @@ isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
static int static int
isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
{ {
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
struct isert_cmd, iscsi_cmd);
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr;
...@@ -1733,8 +1715,7 @@ isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) ...@@ -1733,8 +1715,7 @@ isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
static int static int
isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
{ {
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
struct isert_cmd, iscsi_cmd);
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr;
struct ib_device *ib_dev = isert_conn->conn_cm_id->device; 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,8 +1747,7 @@ isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
static int static int
isert_put_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) isert_put_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
{ {
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
struct isert_cmd, iscsi_cmd);
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr; struct ib_send_wr *send_wr = &isert_cmd->tx_desc.send_wr;
struct iscsi_text_rsp *hdr = struct iscsi_text_rsp *hdr =
...@@ -1809,7 +1789,7 @@ isert_build_rdma_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, ...@@ -1809,7 +1789,7 @@ isert_build_rdma_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
struct ib_sge *ib_sge, struct ib_send_wr *send_wr, struct ib_sge *ib_sge, struct ib_send_wr *send_wr,
u32 data_left, u32 offset) u32 data_left, u32 offset)
{ {
struct iscsi_cmd *cmd = &isert_cmd->iscsi_cmd; struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
struct scatterlist *sg_start, *tmp_sg; struct scatterlist *sg_start, *tmp_sg;
struct ib_device *ib_dev = isert_conn->conn_cm_id->device; struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
u32 sg_off, page_off; u32 sg_off, page_off;
...@@ -1854,8 +1834,7 @@ static int ...@@ -1854,8 +1834,7 @@ static int
isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
{ {
struct se_cmd *se_cmd = &cmd->se_cmd; struct se_cmd *se_cmd = &cmd->se_cmd;
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
struct isert_cmd, iscsi_cmd);
struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; struct isert_rdma_wr *wr = &isert_cmd->rdma_wr;
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct ib_send_wr *wr_failed, *send_wr; struct ib_send_wr *wr_failed, *send_wr;
...@@ -1958,8 +1937,7 @@ static int ...@@ -1958,8 +1937,7 @@ static int
isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery)
{ {
struct se_cmd *se_cmd = &cmd->se_cmd; struct se_cmd *se_cmd = &cmd->se_cmd;
struct isert_cmd *isert_cmd = container_of(cmd, struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
struct isert_cmd, iscsi_cmd);
struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; struct isert_rdma_wr *wr = &isert_cmd->rdma_wr;
struct isert_conn *isert_conn = (struct isert_conn *)conn->context; struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
struct ib_send_wr *wr_failed, *send_wr; struct ib_send_wr *wr_failed, *send_wr;
...@@ -2405,12 +2383,12 @@ static void isert_free_conn(struct iscsi_conn *conn) ...@@ -2405,12 +2383,12 @@ static void isert_free_conn(struct iscsi_conn *conn)
static struct iscsit_transport iser_target_transport = { static struct iscsit_transport iser_target_transport = {
.name = "IB/iSER", .name = "IB/iSER",
.transport_type = ISCSI_INFINIBAND, .transport_type = ISCSI_INFINIBAND,
.priv_size = sizeof(struct isert_cmd),
.owner = THIS_MODULE, .owner = THIS_MODULE,
.iscsit_setup_np = isert_setup_np, .iscsit_setup_np = isert_setup_np,
.iscsit_accept_np = isert_accept_np, .iscsit_accept_np = isert_accept_np,
.iscsit_free_np = isert_free_np, .iscsit_free_np = isert_free_np,
.iscsit_free_conn = isert_free_conn, .iscsit_free_conn = isert_free_conn,
.iscsit_alloc_cmd = isert_alloc_cmd,
.iscsit_get_login_rx = isert_get_login_rx, .iscsit_get_login_rx = isert_get_login_rx,
.iscsit_put_login_tx = isert_put_login_tx, .iscsit_put_login_tx = isert_put_login_tx,
.iscsit_immediate_queue = isert_immediate_queue, .iscsit_immediate_queue = isert_immediate_queue,
...@@ -2437,21 +2415,10 @@ static int __init isert_init(void) ...@@ -2437,21 +2415,10 @@ static int __init isert_init(void)
goto destroy_rx_wq; goto destroy_rx_wq;
} }
isert_cmd_cache = kmem_cache_create("isert_cmd_cache",
sizeof(struct isert_cmd), __alignof__(struct isert_cmd),
0, NULL);
if (!isert_cmd_cache) {
pr_err("Unable to create isert_cmd_cache\n");
ret = -ENOMEM;
goto destroy_tx_cq;
}
iscsit_register_transport(&iser_target_transport); iscsit_register_transport(&iser_target_transport);
pr_debug("iSER_TARGET[0] - Loaded iser_target_transport\n"); pr_debug("iSER_TARGET[0] - Loaded iser_target_transport\n");
return 0; return 0;
destroy_tx_cq:
destroy_workqueue(isert_comp_wq);
destroy_rx_wq: destroy_rx_wq:
destroy_workqueue(isert_rx_wq); destroy_workqueue(isert_rx_wq);
return ret; return ret;
...@@ -2459,7 +2426,6 @@ static int __init isert_init(void) ...@@ -2459,7 +2426,6 @@ static int __init isert_init(void)
static void __exit isert_exit(void) static void __exit isert_exit(void)
{ {
kmem_cache_destroy(isert_cmd_cache);
destroy_workqueue(isert_comp_wq); destroy_workqueue(isert_comp_wq);
destroy_workqueue(isert_rx_wq); destroy_workqueue(isert_rx_wq);
iscsit_unregister_transport(&iser_target_transport); iscsit_unregister_transport(&iser_target_transport);
......
...@@ -67,7 +67,7 @@ struct isert_cmd { ...@@ -67,7 +67,7 @@ struct isert_cmd {
u32 write_va_off; u32 write_va_off;
u32 rdma_wr_num; u32 rdma_wr_num;
struct isert_conn *conn; struct isert_conn *conn;
struct iscsi_cmd iscsi_cmd; struct iscsi_cmd *iscsi_cmd;
struct ib_sge *ib_sge; struct ib_sge *ib_sge;
struct iser_tx_desc tx_desc; struct iser_tx_desc tx_desc;
struct isert_rdma_wr rdma_wr; struct isert_rdma_wr rdma_wr;
......
...@@ -63,7 +63,6 @@ spinlock_t sess_idr_lock; ...@@ -63,7 +63,6 @@ spinlock_t sess_idr_lock;
struct iscsit_global *iscsit_global; struct iscsit_global *iscsit_global;
struct kmem_cache *lio_cmd_cache;
struct kmem_cache *lio_qr_cache; struct kmem_cache *lio_qr_cache;
struct kmem_cache *lio_dr_cache; struct kmem_cache *lio_dr_cache;
struct kmem_cache *lio_ooo_cache; struct kmem_cache *lio_ooo_cache;
...@@ -500,7 +499,6 @@ static struct iscsit_transport iscsi_target_transport = { ...@@ -500,7 +499,6 @@ static struct iscsit_transport iscsi_target_transport = {
.iscsit_setup_np = iscsit_setup_np, .iscsit_setup_np = iscsit_setup_np,
.iscsit_accept_np = iscsit_accept_np, .iscsit_accept_np = iscsit_accept_np,
.iscsit_free_np = iscsit_free_np, .iscsit_free_np = iscsit_free_np,
.iscsit_alloc_cmd = iscsit_alloc_cmd,
.iscsit_get_login_rx = iscsit_get_login_rx, .iscsit_get_login_rx = iscsit_get_login_rx,
.iscsit_put_login_tx = iscsit_put_login_tx, .iscsit_put_login_tx = iscsit_put_login_tx,
.iscsit_get_dataout = iscsit_build_r2ts_for_cmd, .iscsit_get_dataout = iscsit_build_r2ts_for_cmd,
...@@ -541,22 +539,13 @@ static int __init iscsi_target_init_module(void) ...@@ -541,22 +539,13 @@ static int __init iscsi_target_init_module(void)
goto ts_out1; goto ts_out1;
} }
lio_cmd_cache = kmem_cache_create("lio_cmd_cache",
sizeof(struct iscsi_cmd), __alignof__(struct iscsi_cmd),
0, NULL);
if (!lio_cmd_cache) {
pr_err("Unable to kmem_cache_create() for"
" lio_cmd_cache\n");
goto ts_out2;
}
lio_qr_cache = kmem_cache_create("lio_qr_cache", lio_qr_cache = kmem_cache_create("lio_qr_cache",
sizeof(struct iscsi_queue_req), sizeof(struct iscsi_queue_req),
__alignof__(struct iscsi_queue_req), 0, NULL); __alignof__(struct iscsi_queue_req), 0, NULL);
if (!lio_qr_cache) { if (!lio_qr_cache) {
pr_err("nable to kmem_cache_create() for" pr_err("nable to kmem_cache_create() for"
" lio_qr_cache\n"); " lio_qr_cache\n");
goto cmd_out; goto ts_out2;
} }
lio_dr_cache = kmem_cache_create("lio_dr_cache", lio_dr_cache = kmem_cache_create("lio_dr_cache",
...@@ -600,8 +589,6 @@ static int __init iscsi_target_init_module(void) ...@@ -600,8 +589,6 @@ static int __init iscsi_target_init_module(void)
kmem_cache_destroy(lio_dr_cache); kmem_cache_destroy(lio_dr_cache);
qr_out: qr_out:
kmem_cache_destroy(lio_qr_cache); kmem_cache_destroy(lio_qr_cache);
cmd_out:
kmem_cache_destroy(lio_cmd_cache);
ts_out2: ts_out2:
iscsi_deallocate_thread_sets(); iscsi_deallocate_thread_sets();
ts_out1: ts_out1:
...@@ -619,7 +606,6 @@ static void __exit iscsi_target_cleanup_module(void) ...@@ -619,7 +606,6 @@ static void __exit iscsi_target_cleanup_module(void)
iscsi_thread_set_free(); iscsi_thread_set_free();
iscsit_release_discovery_tpg(); iscsit_release_discovery_tpg();
iscsit_unregister_transport(&iscsi_target_transport); iscsit_unregister_transport(&iscsi_target_transport);
kmem_cache_destroy(lio_cmd_cache);
kmem_cache_destroy(lio_qr_cache); kmem_cache_destroy(lio_qr_cache);
kmem_cache_destroy(lio_dr_cache); kmem_cache_destroy(lio_dr_cache);
kmem_cache_destroy(lio_ooo_cache); kmem_cache_destroy(lio_ooo_cache);
......
...@@ -39,7 +39,6 @@ extern struct target_fabric_configfs *lio_target_fabric_configfs; ...@@ -39,7 +39,6 @@ extern struct target_fabric_configfs *lio_target_fabric_configfs;
extern struct kmem_cache *lio_dr_cache; extern struct kmem_cache *lio_dr_cache;
extern struct kmem_cache *lio_ooo_cache; extern struct kmem_cache *lio_ooo_cache;
extern struct kmem_cache *lio_cmd_cache;
extern struct kmem_cache *lio_qr_cache; extern struct kmem_cache *lio_qr_cache;
extern struct kmem_cache *lio_r2t_cache; extern struct kmem_cache *lio_r2t_cache;
......
...@@ -1925,7 +1925,7 @@ static void lio_release_cmd(struct se_cmd *se_cmd) ...@@ -1925,7 +1925,7 @@ static void lio_release_cmd(struct se_cmd *se_cmd)
struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd); pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
cmd->release_cmd(cmd); iscsit_release_cmd(cmd);
} }
/* End functions for target_core_fabric_ops */ /* End functions for target_core_fabric_ops */
......
...@@ -489,7 +489,6 @@ struct iscsi_cmd { ...@@ -489,7 +489,6 @@ struct iscsi_cmd {
u32 first_data_sg_off; u32 first_data_sg_off;
u32 kmapped_nents; u32 kmapped_nents;
sense_reason_t sense_reason; sense_reason_t sense_reason;
void (*release_cmd)(struct iscsi_cmd *);
} ____cacheline_aligned; } ____cacheline_aligned;
struct iscsi_tmr_req { struct iscsi_tmr_req {
......
...@@ -149,18 +149,6 @@ void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd) ...@@ -149,18 +149,6 @@ void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd)
spin_unlock_bh(&cmd->r2t_lock); spin_unlock_bh(&cmd->r2t_lock);
} }
struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp_mask)
{
struct iscsi_cmd *cmd;
cmd = kmem_cache_zalloc(lio_cmd_cache, gfp_mask);
if (!cmd)
return NULL;
cmd->release_cmd = &iscsit_release_cmd;
return cmd;
}
/* /*
* May be called from software interrupt (timer) context for allocating * May be called from software interrupt (timer) context for allocating
* iSCSI NopINs. * iSCSI NopINs.
...@@ -168,8 +156,9 @@ struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) ...@@ -168,8 +156,9 @@ struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp_mask)
struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask)
{ {
struct iscsi_cmd *cmd; struct iscsi_cmd *cmd;
int priv_size = conn->conn_transport->priv_size;
cmd = conn->conn_transport->iscsit_alloc_cmd(conn, gfp_mask); cmd = kzalloc(sizeof(struct iscsi_cmd) + priv_size, gfp_mask);
if (!cmd) { if (!cmd) {
pr_err("Unable to allocate memory for struct iscsi_cmd.\n"); pr_err("Unable to allocate memory for struct iscsi_cmd.\n");
return NULL; return NULL;
...@@ -696,8 +685,9 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) ...@@ -696,8 +685,9 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd)
kfree(cmd->iov_data); kfree(cmd->iov_data);
kfree(cmd->text_in_ptr); kfree(cmd->text_in_ptr);
kmem_cache_free(lio_cmd_cache, cmd); kfree(cmd);
} }
EXPORT_SYMBOL(iscsit_release_cmd);
static void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd, static void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd,
bool check_queues) bool check_queues)
...@@ -761,7 +751,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) ...@@ -761,7 +751,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)
/* Fall-through */ /* Fall-through */
default: default:
__iscsit_free_cmd(cmd, false, shutdown); __iscsit_free_cmd(cmd, false, shutdown);
cmd->release_cmd(cmd); iscsit_release_cmd(cmd);
break; break;
} }
} }
......
...@@ -6,13 +6,13 @@ struct iscsit_transport { ...@@ -6,13 +6,13 @@ struct iscsit_transport {
#define ISCSIT_TRANSPORT_NAME 16 #define ISCSIT_TRANSPORT_NAME 16
char name[ISCSIT_TRANSPORT_NAME]; char name[ISCSIT_TRANSPORT_NAME];
int transport_type; int transport_type;
int priv_size;
struct module *owner; struct module *owner;
struct list_head t_node; struct list_head t_node;
int (*iscsit_setup_np)(struct iscsi_np *, struct __kernel_sockaddr_storage *); int (*iscsit_setup_np)(struct iscsi_np *, struct __kernel_sockaddr_storage *);
int (*iscsit_accept_np)(struct iscsi_np *, struct iscsi_conn *); int (*iscsit_accept_np)(struct iscsi_np *, struct iscsi_conn *);
void (*iscsit_free_np)(struct iscsi_np *); void (*iscsit_free_np)(struct iscsi_np *);
void (*iscsit_free_conn)(struct iscsi_conn *); void (*iscsit_free_conn)(struct iscsi_conn *);
struct iscsi_cmd *(*iscsit_alloc_cmd)(struct iscsi_conn *, gfp_t);
int (*iscsit_get_login_rx)(struct iscsi_conn *, struct iscsi_login *); int (*iscsit_get_login_rx)(struct iscsi_conn *, struct iscsi_login *);
int (*iscsit_put_login_tx)(struct iscsi_conn *, struct iscsi_login *, u32); int (*iscsit_put_login_tx)(struct iscsi_conn *, struct iscsi_login *, u32);
int (*iscsit_immediate_queue)(struct iscsi_conn *, struct iscsi_cmd *, int); int (*iscsit_immediate_queue)(struct iscsi_conn *, struct iscsi_cmd *, int);
...@@ -22,6 +22,11 @@ struct iscsit_transport { ...@@ -22,6 +22,11 @@ struct iscsit_transport {
int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsi_cmd *); int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsi_cmd *);
}; };
static inline void *iscsit_priv_cmd(struct iscsi_cmd *cmd)
{
return (void *)(cmd + 1);
}
/* /*
* From iscsi_target_transport.c * From iscsi_target_transport.c
*/ */
...@@ -92,3 +97,4 @@ extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *); ...@@ -92,3 +97,4 @@ extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t); extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t);
extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *, extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *,
unsigned char *, __be32); unsigned char *, __be32);
extern void iscsit_release_cmd(struct iscsi_cmd *);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment