aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-05-31 23:56:57 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-07-22 05:37:44 -0400
commit35462975b2b197b990fedbb74b81f9bea9d344cb (patch)
tree72aea1508e81292f7fe7a17b39ed7f59de3dc3ce
parentdb1620a2788f6c470804f6a5f983a0152188bd90 (diff)
target: merge release_cmd methods
The release_cmd_to_pool and release_cmd_direct methods are always the same. Merge them into a single release_cmd method, and clean up the fallout. (nab: fix breakage in transport_generic_free_cmd() parameter build breakage in drivers/target/tcm_fc/tfc_cmd.c) Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/loopback/tcm_loop.c12
-rw-r--r--drivers/target/target_core_configfs.c8
-rw-r--r--drivers/target/target_core_transport.c53
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c12
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c3
-rw-r--r--include/target/target_core_fabric_ops.h3
-rw-r--r--include/target/target_core_transport.h4
7 files changed, 35 insertions, 60 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index cb4a9b906a4b..c2937b2035d3 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -204,13 +204,10 @@ static void tcm_loop_check_stop_free(struct se_cmd *se_cmd)
204 * Release the struct se_cmd, which will make a callback to release 204 * Release the struct se_cmd, which will make a callback to release
205 * struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd() 205 * struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd()
206 */ 206 */
207 transport_generic_free_cmd(se_cmd, 0, 1, 0); 207 transport_generic_free_cmd(se_cmd, 0, 0);
208} 208}
209 209
210/* 210static void tcm_loop_release_cmd(struct se_cmd *se_cmd)
211 * Called from struct target_core_fabric_ops->release_cmd_to_pool()
212 */
213static void tcm_loop_deallocate_core_cmd(struct se_cmd *se_cmd)
214{ 211{
215 struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, 212 struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
216 struct tcm_loop_cmd, tl_se_cmd); 213 struct tcm_loop_cmd, tl_se_cmd);
@@ -395,7 +392,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
395 SUCCESS : FAILED; 392 SUCCESS : FAILED;
396release: 393release:
397 if (se_cmd) 394 if (se_cmd)
398 transport_generic_free_cmd(se_cmd, 1, 1, 0); 395 transport_generic_free_cmd(se_cmd, 1, 0);
399 else 396 else
400 kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); 397 kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
401 kfree(tl_tmr); 398 kfree(tl_tmr);
@@ -1418,8 +1415,7 @@ static int tcm_loop_register_configfs(void)
1418 */ 1415 */
1419 fabric->tf_ops.new_cmd_map = &tcm_loop_new_cmd_map; 1416 fabric->tf_ops.new_cmd_map = &tcm_loop_new_cmd_map;
1420 fabric->tf_ops.check_stop_free = &tcm_loop_check_stop_free; 1417 fabric->tf_ops.check_stop_free = &tcm_loop_check_stop_free;
1421 fabric->tf_ops.release_cmd_to_pool = &tcm_loop_deallocate_core_cmd; 1418 fabric->tf_ops.release_cmd = &tcm_loop_release_cmd;
1422 fabric->tf_ops.release_cmd_direct = &tcm_loop_deallocate_core_cmd;
1423 fabric->tf_ops.shutdown_session = &tcm_loop_shutdown_session; 1419 fabric->tf_ops.shutdown_session = &tcm_loop_shutdown_session;
1424 fabric->tf_ops.close_session = &tcm_loop_close_session; 1420 fabric->tf_ops.close_session = &tcm_loop_close_session;
1425 fabric->tf_ops.stop_session = &tcm_loop_stop_session; 1421 fabric->tf_ops.stop_session = &tcm_loop_stop_session;
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index aac0ee993b90..63cba1e243ef 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -427,12 +427,8 @@ static int target_fabric_tf_ops_check(
427 printk(KERN_ERR "Missing tfo->tpg_get_inst_index()\n"); 427 printk(KERN_ERR "Missing tfo->tpg_get_inst_index()\n");
428 return -EINVAL; 428 return -EINVAL;
429 } 429 }
430 if (!(tfo->release_cmd_to_pool)) { 430 if (!tfo->release_cmd) {
431 printk(KERN_ERR "Missing tfo->release_cmd_to_pool()\n"); 431 printk(KERN_ERR "Missing tfo->release_cmd()\n");
432 return -EINVAL;
433 }
434 if (!(tfo->release_cmd_direct)) {
435 printk(KERN_ERR "Missing tfo->release_cmd_direct()\n");
436 return -EINVAL; 432 return -EINVAL;
437 } 433 }
438 if (!(tfo->shutdown_session)) { 434 if (!(tfo->shutdown_session)) {
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 43fd2778d602..d42a98e4725b 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -212,7 +212,7 @@ static u32 transport_allocate_tasks(struct se_cmd *cmd,
212 struct list_head *mem_list, int set_counts); 212 struct list_head *mem_list, int set_counts);
213static int transport_generic_get_mem(struct se_cmd *cmd, u32 length); 213static int transport_generic_get_mem(struct se_cmd *cmd, u32 length);
214static int transport_generic_remove(struct se_cmd *cmd, 214static int transport_generic_remove(struct se_cmd *cmd,
215 int release_to_pool, int session_reinstatement); 215 int session_reinstatement);
216static int transport_cmd_get_valid_sectors(struct se_cmd *cmd); 216static int transport_cmd_get_valid_sectors(struct se_cmd *cmd);
217static int transport_map_sg_to_mem(struct se_cmd *cmd, 217static int transport_map_sg_to_mem(struct se_cmd *cmd,
218 struct list_head *se_mem_list, struct scatterlist *sgl); 218 struct list_head *se_mem_list, struct scatterlist *sgl);
@@ -737,7 +737,7 @@ void transport_cmd_finish_abort(struct se_cmd *cmd, int remove)
737 if (transport_cmd_check_stop_to_fabric(cmd)) 737 if (transport_cmd_check_stop_to_fabric(cmd))
738 return; 738 return;
739 if (remove) 739 if (remove)
740 transport_generic_remove(cmd, 0, 0); 740 transport_generic_remove(cmd, 0);
741} 741}
742 742
743void transport_cmd_finish_abort_tmr(struct se_cmd *cmd) 743void transport_cmd_finish_abort_tmr(struct se_cmd *cmd)
@@ -747,7 +747,7 @@ void transport_cmd_finish_abort_tmr(struct se_cmd *cmd)
747 if (transport_cmd_check_stop_to_fabric(cmd)) 747 if (transport_cmd_check_stop_to_fabric(cmd))
748 return; 748 return;
749 749
750 transport_generic_remove(cmd, 0, 0); 750 transport_generic_remove(cmd, 0);
751} 751}
752 752
753static void transport_add_cmd_to_queue( 753static void transport_add_cmd_to_queue(
@@ -2146,7 +2146,7 @@ static void transport_generic_request_timeout(struct se_cmd *cmd)
2146 } 2146 }
2147 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2147 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2148 2148
2149 transport_generic_remove(cmd, 0, 0); 2149 transport_generic_remove(cmd, 0);
2150} 2150}
2151 2151
2152static int 2152static int
@@ -3825,13 +3825,11 @@ static void transport_release_fe_cmd(struct se_cmd *cmd)
3825free_pages: 3825free_pages:
3826 transport_free_pages(cmd); 3826 transport_free_pages(cmd);
3827 transport_free_se_cmd(cmd); 3827 transport_free_se_cmd(cmd);
3828 cmd->se_tfo->release_cmd_direct(cmd); 3828 cmd->se_tfo->release_cmd(cmd);
3829} 3829}
3830 3830
3831static int transport_generic_remove( 3831static int
3832 struct se_cmd *cmd, 3832transport_generic_remove(struct se_cmd *cmd, int session_reinstatement)
3833 int release_to_pool,
3834 int session_reinstatement)
3835{ 3833{
3836 unsigned long flags; 3834 unsigned long flags;
3837 3835
@@ -3858,14 +3856,7 @@ static int transport_generic_remove(
3858 3856
3859free_pages: 3857free_pages:
3860 transport_free_pages(cmd); 3858 transport_free_pages(cmd);
3861 3859 transport_release_cmd(cmd);
3862 if (release_to_pool) {
3863 transport_release_cmd_to_pool(cmd);
3864 } else {
3865 transport_free_se_cmd(cmd);
3866 cmd->se_tfo->release_cmd_direct(cmd);
3867 }
3868
3869 return 0; 3860 return 0;
3870} 3861}
3871 3862
@@ -4894,18 +4885,14 @@ static int transport_generic_write_pending(struct se_cmd *cmd)
4894 return PYX_TRANSPORT_WRITE_PENDING; 4885 return PYX_TRANSPORT_WRITE_PENDING;
4895} 4886}
4896 4887
4897/* transport_release_cmd_to_pool(): 4888void transport_release_cmd(struct se_cmd *cmd)
4898 *
4899 *
4900 */
4901void transport_release_cmd_to_pool(struct se_cmd *cmd)
4902{ 4889{
4903 BUG_ON(!cmd->se_tfo); 4890 BUG_ON(!cmd->se_tfo);
4904 4891
4905 transport_free_se_cmd(cmd); 4892 transport_free_se_cmd(cmd);
4906 cmd->se_tfo->release_cmd_to_pool(cmd); 4893 cmd->se_tfo->release_cmd(cmd);
4907} 4894}
4908EXPORT_SYMBOL(transport_release_cmd_to_pool); 4895EXPORT_SYMBOL(transport_release_cmd);
4909 4896
4910/* transport_generic_free_cmd(): 4897/* transport_generic_free_cmd():
4911 * 4898 *
@@ -4914,11 +4901,10 @@ EXPORT_SYMBOL(transport_release_cmd_to_pool);
4914void transport_generic_free_cmd( 4901void transport_generic_free_cmd(
4915 struct se_cmd *cmd, 4902 struct se_cmd *cmd,
4916 int wait_for_tasks, 4903 int wait_for_tasks,
4917 int release_to_pool,
4918 int session_reinstatement) 4904 int session_reinstatement)
4919{ 4905{
4920 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) 4906 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD))
4921 transport_release_cmd_to_pool(cmd); 4907 transport_release_cmd(cmd);
4922 else { 4908 else {
4923 core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd); 4909 core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd);
4924 4910
@@ -4936,8 +4922,7 @@ void transport_generic_free_cmd(
4936 4922
4937 transport_free_dev_tasks(cmd); 4923 transport_free_dev_tasks(cmd);
4938 4924
4939 transport_generic_remove(cmd, release_to_pool, 4925 transport_generic_remove(cmd, session_reinstatement);
4940 session_reinstatement);
4941 } 4926 }
4942} 4927}
4943EXPORT_SYMBOL(transport_generic_free_cmd); 4928EXPORT_SYMBOL(transport_generic_free_cmd);
@@ -5210,7 +5195,7 @@ remove:
5210 if (!remove_cmd) 5195 if (!remove_cmd)
5211 return; 5196 return;
5212 5197
5213 transport_generic_free_cmd(cmd, 0, 0, session_reinstatement); 5198 transport_generic_free_cmd(cmd, 0, session_reinstatement);
5214} 5199}
5215 5200
5216static int transport_get_sense_codes( 5201static int transport_get_sense_codes(
@@ -5616,7 +5601,7 @@ static void transport_processing_shutdown(struct se_device *dev)
5616 transport_lun_remove_cmd(cmd); 5601 transport_lun_remove_cmd(cmd);
5617 5602
5618 if (transport_cmd_check_stop(cmd, 1, 0)) 5603 if (transport_cmd_check_stop(cmd, 1, 0))
5619 transport_generic_remove(cmd, 0, 0); 5604 transport_generic_remove(cmd, 0);
5620 } 5605 }
5621 5606
5622 spin_lock_irqsave(&dev->execute_task_lock, flags); 5607 spin_lock_irqsave(&dev->execute_task_lock, flags);
@@ -5644,7 +5629,7 @@ static void transport_processing_shutdown(struct se_device *dev)
5644 transport_lun_remove_cmd(cmd); 5629 transport_lun_remove_cmd(cmd);
5645 5630
5646 if (transport_cmd_check_stop(cmd, 1, 0)) 5631 if (transport_cmd_check_stop(cmd, 1, 0))
5647 transport_generic_remove(cmd, 0, 0); 5632 transport_generic_remove(cmd, 0);
5648 } 5633 }
5649 5634
5650 spin_lock_irqsave(&dev->execute_task_lock, flags); 5635 spin_lock_irqsave(&dev->execute_task_lock, flags);
@@ -5667,7 +5652,7 @@ static void transport_processing_shutdown(struct se_device *dev)
5667 } else { 5652 } else {
5668 transport_lun_remove_cmd(cmd); 5653 transport_lun_remove_cmd(cmd);
5669 if (transport_cmd_check_stop(cmd, 1, 0)) 5654 if (transport_cmd_check_stop(cmd, 1, 0))
5670 transport_generic_remove(cmd, 0, 0); 5655 transport_generic_remove(cmd, 0);
5671 } 5656 }
5672 } 5657 }
5673} 5658}
@@ -5739,10 +5724,10 @@ get_cmd:
5739 transport_generic_complete_ok(cmd); 5724 transport_generic_complete_ok(cmd);
5740 break; 5725 break;
5741 case TRANSPORT_REMOVE: 5726 case TRANSPORT_REMOVE:
5742 transport_generic_remove(cmd, 1, 0); 5727 transport_generic_remove(cmd, 0);
5743 break; 5728 break;
5744 case TRANSPORT_FREE_CMD_INTR: 5729 case TRANSPORT_FREE_CMD_INTR:
5745 transport_generic_free_cmd(cmd, 0, 1, 0); 5730 transport_generic_free_cmd(cmd, 0, 0);
5746 break; 5731 break;
5747 case TRANSPORT_PROCESS_TMR: 5732 case TRANSPORT_PROCESS_TMR:
5748 transport_generic_do_tmr(cmd); 5733 transport_generic_do_tmr(cmd);
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index 9a3b486e1aad..74d5bb766201 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -147,7 +147,7 @@ void ft_release_cmd(struct se_cmd *se_cmd)
147 147
148void ft_check_stop_free(struct se_cmd *se_cmd) 148void ft_check_stop_free(struct se_cmd *se_cmd)
149{ 149{
150 transport_generic_free_cmd(se_cmd, 0, 1, 0); 150 transport_generic_free_cmd(se_cmd, 0, 0);
151} 151}
152 152
153/* 153/*
@@ -304,7 +304,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
304 /* XXX need to find cmd if queued */ 304 /* XXX need to find cmd if queued */
305 cmd->se_cmd.t_state = TRANSPORT_REMOVE; 305 cmd->se_cmd.t_state = TRANSPORT_REMOVE;
306 cmd->seq = NULL; 306 cmd->seq = NULL;
307 transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0); 307 transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
308 return; 308 return;
309 } 309 }
310 310
@@ -321,7 +321,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
321 printk(KERN_INFO "%s: unhandled frame r_ctl %x\n", 321 printk(KERN_INFO "%s: unhandled frame r_ctl %x\n",
322 __func__, fh->fh_r_ctl); 322 __func__, fh->fh_r_ctl);
323 fc_frame_free(fp); 323 fc_frame_free(fp);
324 transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0); 324 transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
325 break; 325 break;
326 } 326 }
327} 327}
@@ -443,7 +443,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
443 sess = cmd->sess; 443 sess = cmd->sess;
444 transport_send_check_condition_and_sense(&cmd->se_cmd, 444 transport_send_check_condition_and_sense(&cmd->se_cmd,
445 cmd->se_cmd.scsi_sense_reason, 0); 445 cmd->se_cmd.scsi_sense_reason, 0);
446 transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0); 446 transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
447 ft_sess_put(sess); 447 ft_sess_put(sess);
448 return; 448 return;
449 } 449 }
@@ -645,7 +645,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
645 if (ret == -ENOMEM) { 645 if (ret == -ENOMEM) {
646 transport_send_check_condition_and_sense(se_cmd, 646 transport_send_check_condition_and_sense(se_cmd,
647 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); 647 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
648 transport_generic_free_cmd(se_cmd, 0, 1, 0); 648 transport_generic_free_cmd(se_cmd, 0, 0);
649 return; 649 return;
650 } 650 }
651 if (ret == -EINVAL) { 651 if (ret == -EINVAL) {
@@ -654,7 +654,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
654 else 654 else
655 transport_send_check_condition_and_sense(se_cmd, 655 transport_send_check_condition_and_sense(se_cmd,
656 se_cmd->scsi_sense_reason, 0); 656 se_cmd->scsi_sense_reason, 0);
657 transport_generic_free_cmd(se_cmd, 0, 1, 0); 657 transport_generic_free_cmd(se_cmd, 0, 0);
658 return; 658 return;
659 } 659 }
660 transport_generic_handle_cdb(se_cmd); 660 transport_generic_handle_cdb(se_cmd);
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index 20097728e8a0..1cb3d345183f 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -536,8 +536,7 @@ static struct target_core_fabric_ops ft_fabric_ops = {
536 .tpg_release_fabric_acl = ft_tpg_release_fabric_acl, 536 .tpg_release_fabric_acl = ft_tpg_release_fabric_acl,
537 .tpg_get_inst_index = ft_tpg_get_inst_index, 537 .tpg_get_inst_index = ft_tpg_get_inst_index,
538 .check_stop_free = ft_check_stop_free, 538 .check_stop_free = ft_check_stop_free,
539 .release_cmd_to_pool = ft_release_cmd, 539 .release_cmd = ft_release_cmd,
540 .release_cmd_direct = ft_release_cmd,
541 .shutdown_session = ft_sess_shutdown, 540 .shutdown_session = ft_sess_shutdown,
542 .close_session = ft_sess_close, 541 .close_session = ft_sess_close,
543 .stop_session = ft_sess_stop, 542 .stop_session = ft_sess_stop,
diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
index eba7201e5609..2de8fe907596 100644
--- a/include/target/target_core_fabric_ops.h
+++ b/include/target/target_core_fabric_ops.h
@@ -43,8 +43,7 @@ struct target_core_fabric_ops {
43 * I/O descriptor in transport_cmd_check_stop() 43 * I/O descriptor in transport_cmd_check_stop()
44 */ 44 */
45 void (*check_stop_free)(struct se_cmd *); 45 void (*check_stop_free)(struct se_cmd *);
46 void (*release_cmd_to_pool)(struct se_cmd *); 46 void (*release_cmd)(struct se_cmd *);
47 void (*release_cmd_direct)(struct se_cmd *);
48 /* 47 /*
49 * Called with spin_lock_bh(struct se_portal_group->session_lock held. 48 * Called with spin_lock_bh(struct se_portal_group->session_lock held.
50 */ 49 */
diff --git a/include/target/target_core_transport.h b/include/target/target_core_transport.h
index c9846d521945..604e669527b4 100644
--- a/include/target/target_core_transport.h
+++ b/include/target/target_core_transport.h
@@ -179,8 +179,8 @@ extern int transport_clear_lun_from_sessions(struct se_lun *);
179extern int transport_check_aborted_status(struct se_cmd *, int); 179extern int transport_check_aborted_status(struct se_cmd *, int);
180extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int); 180extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int);
181extern void transport_send_task_abort(struct se_cmd *); 181extern void transport_send_task_abort(struct se_cmd *);
182extern void transport_release_cmd_to_pool(struct se_cmd *); 182extern void transport_release_cmd(struct se_cmd *);
183extern void transport_generic_free_cmd(struct se_cmd *, int, int, int); 183extern void transport_generic_free_cmd(struct se_cmd *, int, int);
184extern void transport_generic_wait_for_cmds(struct se_cmd *, int); 184extern void transport_generic_wait_for_cmds(struct se_cmd *, int);
185extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32); 185extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32);
186extern int transport_map_mem_to_sg(struct se_task *, struct list_head *, 186extern int transport_map_mem_to_sg(struct se_task *, struct list_head *,