aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2012-01-19 16:39:17 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2012-02-25 17:37:47 -0500
commitc8e31f26feeb03dc6f51bff68135cc58431e099b (patch)
tree8d584fcb7cb7a58988cd2463a9a26f577410e6ac
parent35b2cdc4fea1f0d13e1602c07e62c797c9fe5ed4 (diff)
target: Add SCF_SCSI_TMR_CDB usage and drop se_tmr_req_cache
Change the test for if a cmd is a tmr request to checking if SCF_SCSI_TMR_CDB (a new flag) is set in cmd->se_cmd_flags. Also remove se_tmr_req_cache usage in favor of kzalloc usage, and make core_tmr_alloc_req() return int + setup se_cmd->se_tmr_req directly and fix up various fabric module usages Cc: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.c4
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c7
-rw-r--r--drivers/target/loopback/tcm_loop.c13
-rw-r--r--drivers/target/target_core_tmr.c15
-rw-r--r--drivers/target/target_core_transport.c26
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c6
-rw-r--r--include/target/target_core_base.h39
-rw-r--r--include/target/target_core_fabric.h2
8 files changed, 51 insertions, 61 deletions
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index e1e6b5b03c96..3290a57b248e 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1878,8 +1878,8 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch,
1878 TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED; 1878 TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED;
1879 goto process_tmr; 1879 goto process_tmr;
1880 } 1880 }
1881 cmd->se_tmr_req = core_tmr_alloc_req(cmd, NULL, tcm_tmr, GFP_KERNEL); 1881 res = core_tmr_alloc_req(cmd, NULL, tcm_tmr, GFP_KERNEL);
1882 if (!cmd->se_tmr_req) { 1882 if (res < 0) {
1883 send_ioctx->cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 1883 send_ioctx->cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
1884 send_ioctx->cmd.se_tmr_req->response = TMR_FUNCTION_REJECTED; 1884 send_ioctx->cmd.se_tmr_req->response = TMR_FUNCTION_REJECTED;
1885 goto process_tmr; 1885 goto process_tmr;
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index 11287e1ece13..4eba86d2bd82 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -229,6 +229,7 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr(
229{ 229{
230 struct iscsi_cmd *cmd; 230 struct iscsi_cmd *cmd;
231 struct se_cmd *se_cmd; 231 struct se_cmd *se_cmd;
232 int rc;
232 u8 tcm_function; 233 u8 tcm_function;
233 234
234 cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); 235 cmd = iscsit_allocate_cmd(conn, GFP_KERNEL);
@@ -286,10 +287,8 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr(
286 goto out; 287 goto out;
287 } 288 }
288 289
289 se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, 290 rc = core_tmr_alloc_req(se_cmd, cmd->tmr_req, tcm_function, GFP_KERNEL);
290 cmd->tmr_req, tcm_function, 291 if (rc < 0)
291 GFP_KERNEL);
292 if (!se_cmd->se_tmr_req)
293 goto out; 292 goto out;
294 293
295 cmd->tmr_req->se_tmr_req = se_cmd->se_tmr_req; 294 cmd->tmr_req->se_tmr_req = se_cmd->se_tmr_req;
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index c47ff7f59e57..7cfbcb00b3c3 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -187,7 +187,7 @@ static int tcm_loop_check_stop_free(struct se_cmd *se_cmd)
187 * pointer. These will be released directly in tcm_loop_device_reset() 187 * pointer. These will be released directly in tcm_loop_device_reset()
188 * with transport_generic_free_cmd(). 188 * with transport_generic_free_cmd().
189 */ 189 */
190 if (se_cmd->se_tmr_req) 190 if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
191 return 0; 191 return 0;
192 /* 192 /*
193 * Release the struct se_cmd, which will make a callback to release 193 * Release the struct se_cmd, which will make a callback to release
@@ -324,7 +324,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
324 struct tcm_loop_nexus *tl_nexus; 324 struct tcm_loop_nexus *tl_nexus;
325 struct tcm_loop_tmr *tl_tmr = NULL; 325 struct tcm_loop_tmr *tl_tmr = NULL;
326 struct tcm_loop_tpg *tl_tpg; 326 struct tcm_loop_tpg *tl_tpg;
327 int ret = FAILED; 327 int ret = FAILED, rc;
328 /* 328 /*
329 * Locate the tcm_loop_hba_t pointer 329 * Locate the tcm_loop_hba_t pointer
330 */ 330 */
@@ -365,12 +365,9 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
365 transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, 0, 365 transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, 0,
366 DMA_NONE, MSG_SIMPLE_TAG, 366 DMA_NONE, MSG_SIMPLE_TAG,
367 &tl_cmd->tl_sense_buf[0]); 367 &tl_cmd->tl_sense_buf[0]);
368 /* 368
369 * Allocate the LUN_RESET TMR 369 rc = core_tmr_alloc_req(se_cmd, tl_tmr, TMR_LUN_RESET, GFP_KERNEL);
370 */ 370 if (rc < 0)
371 se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, tl_tmr,
372 TMR_LUN_RESET, GFP_KERNEL);
373 if (IS_ERR(se_cmd->se_tmr_req))
374 goto release; 371 goto release;
375 /* 372 /*
376 * Locate the underlying TCM struct se_lun from sc->device->lun 373 * Locate the underlying TCM struct se_lun from sc->device->lun
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index a5c2e41debf8..5d3eb9e6c2ed 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -40,7 +40,7 @@
40#include "target_core_alua.h" 40#include "target_core_alua.h"
41#include "target_core_pr.h" 41#include "target_core_pr.h"
42 42
43struct se_tmr_req *core_tmr_alloc_req( 43int core_tmr_alloc_req(
44 struct se_cmd *se_cmd, 44 struct se_cmd *se_cmd,
45 void *fabric_tmr_ptr, 45 void *fabric_tmr_ptr,
46 u8 function, 46 u8 function,
@@ -48,17 +48,20 @@ struct se_tmr_req *core_tmr_alloc_req(
48{ 48{
49 struct se_tmr_req *tmr; 49 struct se_tmr_req *tmr;
50 50
51 tmr = kmem_cache_zalloc(se_tmr_req_cache, gfp_flags); 51 tmr = kzalloc(sizeof(struct se_tmr_req), gfp_flags);
52 if (!tmr) { 52 if (!tmr) {
53 pr_err("Unable to allocate struct se_tmr_req\n"); 53 pr_err("Unable to allocate struct se_tmr_req\n");
54 return ERR_PTR(-ENOMEM); 54 return -ENOMEM;
55 } 55 }
56
57 se_cmd->se_cmd_flags |= SCF_SCSI_TMR_CDB;
58 se_cmd->se_tmr_req = tmr;
56 tmr->task_cmd = se_cmd; 59 tmr->task_cmd = se_cmd;
57 tmr->fabric_tmr_ptr = fabric_tmr_ptr; 60 tmr->fabric_tmr_ptr = fabric_tmr_ptr;
58 tmr->function = function; 61 tmr->function = function;
59 INIT_LIST_HEAD(&tmr->tmr_list); 62 INIT_LIST_HEAD(&tmr->tmr_list);
60 63
61 return tmr; 64 return 0;
62} 65}
63EXPORT_SYMBOL(core_tmr_alloc_req); 66EXPORT_SYMBOL(core_tmr_alloc_req);
64 67
@@ -69,7 +72,7 @@ void core_tmr_release_req(
69 unsigned long flags; 72 unsigned long flags;
70 73
71 if (!dev) { 74 if (!dev) {
72 kmem_cache_free(se_tmr_req_cache, tmr); 75 kfree(tmr);
73 return; 76 return;
74 } 77 }
75 78
@@ -77,7 +80,7 @@ void core_tmr_release_req(
77 list_del(&tmr->tmr_list); 80 list_del(&tmr->tmr_list);
78 spin_unlock_irqrestore(&dev->se_tmr_lock, flags); 81 spin_unlock_irqrestore(&dev->se_tmr_lock, flags);
79 82
80 kmem_cache_free(se_tmr_req_cache, tmr); 83 kfree(tmr);
81} 84}
82 85
83static void core_tmr_handle_tas_abort( 86static void core_tmr_handle_tas_abort(
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index affbd4d1446a..c10c3653eabc 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -58,7 +58,6 @@ static int sub_api_initialized;
58 58
59static struct workqueue_struct *target_completion_wq; 59static struct workqueue_struct *target_completion_wq;
60static struct kmem_cache *se_sess_cache; 60static struct kmem_cache *se_sess_cache;
61struct kmem_cache *se_tmr_req_cache;
62struct kmem_cache *se_ua_cache; 61struct kmem_cache *se_ua_cache;
63struct kmem_cache *t10_pr_reg_cache; 62struct kmem_cache *t10_pr_reg_cache;
64struct kmem_cache *t10_alua_lu_gp_cache; 63struct kmem_cache *t10_alua_lu_gp_cache;
@@ -82,21 +81,13 @@ static void target_complete_ok_work(struct work_struct *work);
82 81
83int init_se_kmem_caches(void) 82int init_se_kmem_caches(void)
84{ 83{
85 se_tmr_req_cache = kmem_cache_create("se_tmr_cache",
86 sizeof(struct se_tmr_req), __alignof__(struct se_tmr_req),
87 0, NULL);
88 if (!se_tmr_req_cache) {
89 pr_err("kmem_cache_create() for struct se_tmr_req"
90 " failed\n");
91 goto out;
92 }
93 se_sess_cache = kmem_cache_create("se_sess_cache", 84 se_sess_cache = kmem_cache_create("se_sess_cache",
94 sizeof(struct se_session), __alignof__(struct se_session), 85 sizeof(struct se_session), __alignof__(struct se_session),
95 0, NULL); 86 0, NULL);
96 if (!se_sess_cache) { 87 if (!se_sess_cache) {
97 pr_err("kmem_cache_create() for struct se_session" 88 pr_err("kmem_cache_create() for struct se_session"
98 " failed\n"); 89 " failed\n");
99 goto out_free_tmr_req_cache; 90 goto out;
100 } 91 }
101 se_ua_cache = kmem_cache_create("se_ua_cache", 92 se_ua_cache = kmem_cache_create("se_ua_cache",
102 sizeof(struct se_ua), __alignof__(struct se_ua), 93 sizeof(struct se_ua), __alignof__(struct se_ua),
@@ -169,8 +160,6 @@ out_free_ua_cache:
169 kmem_cache_destroy(se_ua_cache); 160 kmem_cache_destroy(se_ua_cache);
170out_free_sess_cache: 161out_free_sess_cache:
171 kmem_cache_destroy(se_sess_cache); 162 kmem_cache_destroy(se_sess_cache);
172out_free_tmr_req_cache:
173 kmem_cache_destroy(se_tmr_req_cache);
174out: 163out:
175 return -ENOMEM; 164 return -ENOMEM;
176} 165}
@@ -178,7 +167,6 @@ out:
178void release_se_kmem_caches(void) 167void release_se_kmem_caches(void)
179{ 168{
180 destroy_workqueue(target_completion_wq); 169 destroy_workqueue(target_completion_wq);
181 kmem_cache_destroy(se_tmr_req_cache);
182 kmem_cache_destroy(se_sess_cache); 170 kmem_cache_destroy(se_sess_cache);
183 kmem_cache_destroy(se_ua_cache); 171 kmem_cache_destroy(se_ua_cache);
184 kmem_cache_destroy(t10_pr_reg_cache); 172 kmem_cache_destroy(t10_pr_reg_cache);
@@ -553,7 +541,7 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd)
553 541
554void transport_cmd_finish_abort(struct se_cmd *cmd, int remove) 542void transport_cmd_finish_abort(struct se_cmd *cmd, int remove)
555{ 543{
556 if (!cmd->se_tmr_req) 544 if (!(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB))
557 transport_lun_remove_cmd(cmd); 545 transport_lun_remove_cmd(cmd);
558 546
559 if (transport_cmd_check_stop_to_fabric(cmd)) 547 if (transport_cmd_check_stop_to_fabric(cmd))
@@ -3367,7 +3355,7 @@ static void transport_release_cmd(struct se_cmd *cmd)
3367{ 3355{
3368 BUG_ON(!cmd->se_tfo); 3356 BUG_ON(!cmd->se_tfo);
3369 3357
3370 if (cmd->se_tmr_req) 3358 if (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
3371 core_tmr_release_req(cmd->se_tmr_req); 3359 core_tmr_release_req(cmd->se_tmr_req);
3372 if (cmd->t_task_cdb != cmd->__t_task_cdb) 3360 if (cmd->t_task_cdb != cmd->__t_task_cdb)
3373 kfree(cmd->t_task_cdb); 3361 kfree(cmd->t_task_cdb);
@@ -3956,7 +3944,7 @@ queue_full:
3956void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) 3944void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
3957{ 3945{
3958 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) { 3946 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) {
3959 if (wait_for_tasks && cmd->se_tmr_req) 3947 if (wait_for_tasks && (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB))
3960 transport_wait_for_tasks(cmd); 3948 transport_wait_for_tasks(cmd);
3961 3949
3962 transport_release_cmd(cmd); 3950 transport_release_cmd(cmd);
@@ -4282,7 +4270,8 @@ bool transport_wait_for_tasks(struct se_cmd *cmd)
4282 unsigned long flags; 4270 unsigned long flags;
4283 4271
4284 spin_lock_irqsave(&cmd->t_state_lock, flags); 4272 spin_lock_irqsave(&cmd->t_state_lock, flags);
4285 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && !(cmd->se_tmr_req)) { 4273 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) &&
4274 !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) {
4286 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 4275 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4287 return false; 4276 return false;
4288 } 4277 }
@@ -4290,7 +4279,8 @@ bool transport_wait_for_tasks(struct se_cmd *cmd)
4290 * Only perform a possible wait_for_tasks if SCF_SUPPORTED_SAM_OPCODE 4279 * Only perform a possible wait_for_tasks if SCF_SUPPORTED_SAM_OPCODE
4291 * has been set in transport_set_supported_SAM_opcode(). 4280 * has been set in transport_set_supported_SAM_opcode().
4292 */ 4281 */
4293 if (!(cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) && !cmd->se_tmr_req) { 4282 if (!(cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) &&
4283 !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) {
4294 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 4284 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4295 return false; 4285 return false;
4296 } 4286 }
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index a76661178d6b..bdf25593b81c 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -356,6 +356,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
356 struct se_tmr_req *tmr; 356 struct se_tmr_req *tmr;
357 struct fcp_cmnd *fcp; 357 struct fcp_cmnd *fcp;
358 struct ft_sess *sess; 358 struct ft_sess *sess;
359 int rc;
359 u8 tm_func; 360 u8 tm_func;
360 361
361 transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops, 362 transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops,
@@ -392,13 +393,12 @@ static void ft_send_tm(struct ft_cmd *cmd)
392 } 393 }
393 394
394 pr_debug("alloc tm cmd fn %d\n", tm_func); 395 pr_debug("alloc tm cmd fn %d\n", tm_func);
395 tmr = core_tmr_alloc_req(&cmd->se_cmd, cmd, tm_func, GFP_KERNEL); 396 rc = core_tmr_alloc_req(&cmd->se_cmd, cmd, tm_func, GFP_KERNEL);
396 if (!tmr) { 397 if (rc < 0) {
397 pr_debug("alloc failed\n"); 398 pr_debug("alloc failed\n");
398 ft_send_resp_code_and_free(cmd, FCP_TMF_FAILED); 399 ft_send_resp_code_and_free(cmd, FCP_TMF_FAILED);
399 return; 400 return;
400 } 401 }
401 cmd->se_cmd.se_tmr_req = tmr;
402 402
403 switch (fcp->fc_tm_flags) { 403 switch (fcp->fc_tm_flags) {
404 case FCP_TMF_LUN_RESET: 404 case FCP_TMF_LUN_RESET:
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 41dd91b98907..9d514e06625f 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -169,7 +169,8 @@ enum se_cmd_flags_table {
169 SCF_EMULATED_TASK_SENSE = 0x00000004, 169 SCF_EMULATED_TASK_SENSE = 0x00000004,
170 SCF_SCSI_DATA_SG_IO_CDB = 0x00000008, 170 SCF_SCSI_DATA_SG_IO_CDB = 0x00000008,
171 SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010, 171 SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010,
172 SCF_SCSI_NON_DATA_CDB = 0x00000040, 172 SCF_SCSI_NON_DATA_CDB = 0x00000020,
173 SCF_SCSI_TMR_CDB = 0x00000040,
173 SCF_SCSI_CDB_EXCEPTION = 0x00000080, 174 SCF_SCSI_CDB_EXCEPTION = 0x00000080,
174 SCF_SCSI_RESERVATION_CONFLICT = 0x00000100, 175 SCF_SCSI_RESERVATION_CONFLICT = 0x00000100,
175 SCF_FUA = 0x00000200, 176 SCF_FUA = 0x00000200,
@@ -498,6 +499,24 @@ struct se_task {
498 struct completion task_stop_comp; 499 struct completion task_stop_comp;
499}; 500};
500 501
502struct se_tmr_req {
503 /* Task Management function to be performed */
504 u8 function;
505 /* Task Management response to send */
506 u8 response;
507 int call_transport;
508 /* Reference to ITT that Task Mgmt should be performed */
509 u32 ref_task_tag;
510 /* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */
511 u64 ref_task_lun;
512 void *fabric_tmr_ptr;
513 struct se_cmd *task_cmd;
514 struct se_cmd *ref_cmd;
515 struct se_device *tmr_dev;
516 struct se_lun *tmr_lun;
517 struct list_head tmr_list;
518};
519
501struct se_cmd { 520struct se_cmd {
502 /* SAM response code being sent to initiator */ 521 /* SAM response code being sent to initiator */
503 u8 scsi_status; 522 u8 scsi_status;
@@ -586,24 +605,6 @@ struct se_cmd {
586 605
587}; 606};
588 607
589struct se_tmr_req {
590 /* Task Management function to be performed */
591 u8 function;
592 /* Task Management response to send */
593 u8 response;
594 int call_transport;
595 /* Reference to ITT that Task Mgmt should be performed */
596 u32 ref_task_tag;
597 /* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */
598 u64 ref_task_lun;
599 void *fabric_tmr_ptr;
600 struct se_cmd *task_cmd;
601 struct se_cmd *ref_cmd;
602 struct se_device *tmr_dev;
603 struct se_lun *tmr_lun;
604 struct list_head tmr_list;
605};
606
607struct se_ua { 608struct se_ua {
608 u8 ua_asc; 609 u8 ua_asc;
609 u8 ua_ascq; 610 u8 ua_ascq;
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index d36fad317e78..c5c16efe396d 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -139,7 +139,7 @@ void target_wait_for_sess_cmds(struct se_session *, int);
139 139
140int core_alua_check_nonop_delay(struct se_cmd *); 140int core_alua_check_nonop_delay(struct se_cmd *);
141 141
142struct se_tmr_req *core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t); 142int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t);
143void core_tmr_release_req(struct se_tmr_req *); 143void core_tmr_release_req(struct se_tmr_req *);
144int transport_generic_handle_tmr(struct se_cmd *); 144int transport_generic_handle_tmr(struct se_cmd *);
145int transport_lookup_tmr_lun(struct se_cmd *, u32); 145int transport_lookup_tmr_lun(struct se_cmd *, u32);