提交 35462975 编写于 作者: C Christoph Hellwig 提交者: Nicholas Bellinger

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: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
上级 db1620a2
...@@ -204,13 +204,10 @@ static void tcm_loop_check_stop_free(struct se_cmd *se_cmd) ...@@ -204,13 +204,10 @@ static void tcm_loop_check_stop_free(struct se_cmd *se_cmd)
* Release the struct se_cmd, which will make a callback to release * Release the struct se_cmd, which will make a callback to release
* struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd() * struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd()
*/ */
transport_generic_free_cmd(se_cmd, 0, 1, 0); transport_generic_free_cmd(se_cmd, 0, 0);
} }
/* static void tcm_loop_release_cmd(struct se_cmd *se_cmd)
* Called from struct target_core_fabric_ops->release_cmd_to_pool()
*/
static void tcm_loop_deallocate_core_cmd(struct se_cmd *se_cmd)
{ {
struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
struct tcm_loop_cmd, tl_se_cmd); struct tcm_loop_cmd, tl_se_cmd);
...@@ -395,7 +392,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) ...@@ -395,7 +392,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
SUCCESS : FAILED; SUCCESS : FAILED;
release: release:
if (se_cmd) if (se_cmd)
transport_generic_free_cmd(se_cmd, 1, 1, 0); transport_generic_free_cmd(se_cmd, 1, 0);
else else
kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
kfree(tl_tmr); kfree(tl_tmr);
...@@ -1418,8 +1415,7 @@ static int tcm_loop_register_configfs(void) ...@@ -1418,8 +1415,7 @@ static int tcm_loop_register_configfs(void)
*/ */
fabric->tf_ops.new_cmd_map = &tcm_loop_new_cmd_map; fabric->tf_ops.new_cmd_map = &tcm_loop_new_cmd_map;
fabric->tf_ops.check_stop_free = &tcm_loop_check_stop_free; fabric->tf_ops.check_stop_free = &tcm_loop_check_stop_free;
fabric->tf_ops.release_cmd_to_pool = &tcm_loop_deallocate_core_cmd; fabric->tf_ops.release_cmd = &tcm_loop_release_cmd;
fabric->tf_ops.release_cmd_direct = &tcm_loop_deallocate_core_cmd;
fabric->tf_ops.shutdown_session = &tcm_loop_shutdown_session; fabric->tf_ops.shutdown_session = &tcm_loop_shutdown_session;
fabric->tf_ops.close_session = &tcm_loop_close_session; fabric->tf_ops.close_session = &tcm_loop_close_session;
fabric->tf_ops.stop_session = &tcm_loop_stop_session; fabric->tf_ops.stop_session = &tcm_loop_stop_session;
......
...@@ -427,12 +427,8 @@ static int target_fabric_tf_ops_check( ...@@ -427,12 +427,8 @@ static int target_fabric_tf_ops_check(
printk(KERN_ERR "Missing tfo->tpg_get_inst_index()\n"); printk(KERN_ERR "Missing tfo->tpg_get_inst_index()\n");
return -EINVAL; return -EINVAL;
} }
if (!(tfo->release_cmd_to_pool)) { if (!tfo->release_cmd) {
printk(KERN_ERR "Missing tfo->release_cmd_to_pool()\n"); printk(KERN_ERR "Missing tfo->release_cmd()\n");
return -EINVAL;
}
if (!(tfo->release_cmd_direct)) {
printk(KERN_ERR "Missing tfo->release_cmd_direct()\n");
return -EINVAL; return -EINVAL;
} }
if (!(tfo->shutdown_session)) { if (!(tfo->shutdown_session)) {
......
...@@ -212,7 +212,7 @@ static u32 transport_allocate_tasks(struct se_cmd *cmd, ...@@ -212,7 +212,7 @@ static u32 transport_allocate_tasks(struct se_cmd *cmd,
struct list_head *mem_list, int set_counts); struct list_head *mem_list, int set_counts);
static int transport_generic_get_mem(struct se_cmd *cmd, u32 length); static int transport_generic_get_mem(struct se_cmd *cmd, u32 length);
static int transport_generic_remove(struct se_cmd *cmd, static int transport_generic_remove(struct se_cmd *cmd,
int release_to_pool, int session_reinstatement); int session_reinstatement);
static int transport_cmd_get_valid_sectors(struct se_cmd *cmd); static int transport_cmd_get_valid_sectors(struct se_cmd *cmd);
static int transport_map_sg_to_mem(struct se_cmd *cmd, static int transport_map_sg_to_mem(struct se_cmd *cmd,
struct list_head *se_mem_list, struct scatterlist *sgl); 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,7 +737,7 @@ void transport_cmd_finish_abort(struct se_cmd *cmd, int remove)
if (transport_cmd_check_stop_to_fabric(cmd)) if (transport_cmd_check_stop_to_fabric(cmd))
return; return;
if (remove) if (remove)
transport_generic_remove(cmd, 0, 0); transport_generic_remove(cmd, 0);
} }
void transport_cmd_finish_abort_tmr(struct se_cmd *cmd) void transport_cmd_finish_abort_tmr(struct se_cmd *cmd)
...@@ -747,7 +747,7 @@ void transport_cmd_finish_abort_tmr(struct se_cmd *cmd) ...@@ -747,7 +747,7 @@ void transport_cmd_finish_abort_tmr(struct se_cmd *cmd)
if (transport_cmd_check_stop_to_fabric(cmd)) if (transport_cmd_check_stop_to_fabric(cmd))
return; return;
transport_generic_remove(cmd, 0, 0); transport_generic_remove(cmd, 0);
} }
static void transport_add_cmd_to_queue( static void transport_add_cmd_to_queue(
...@@ -2146,7 +2146,7 @@ static void transport_generic_request_timeout(struct se_cmd *cmd) ...@@ -2146,7 +2146,7 @@ static void transport_generic_request_timeout(struct se_cmd *cmd)
} }
spin_unlock_irqrestore(&cmd->t_state_lock, flags); spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_generic_remove(cmd, 0, 0); transport_generic_remove(cmd, 0);
} }
static int static int
...@@ -3825,13 +3825,11 @@ static void transport_release_fe_cmd(struct se_cmd *cmd) ...@@ -3825,13 +3825,11 @@ static void transport_release_fe_cmd(struct se_cmd *cmd)
free_pages: free_pages:
transport_free_pages(cmd); transport_free_pages(cmd);
transport_free_se_cmd(cmd); transport_free_se_cmd(cmd);
cmd->se_tfo->release_cmd_direct(cmd); cmd->se_tfo->release_cmd(cmd);
} }
static int transport_generic_remove( static int
struct se_cmd *cmd, transport_generic_remove(struct se_cmd *cmd, int session_reinstatement)
int release_to_pool,
int session_reinstatement)
{ {
unsigned long flags; unsigned long flags;
...@@ -3858,14 +3856,7 @@ static int transport_generic_remove( ...@@ -3858,14 +3856,7 @@ static int transport_generic_remove(
free_pages: free_pages:
transport_free_pages(cmd); transport_free_pages(cmd);
transport_release_cmd(cmd);
if (release_to_pool) {
transport_release_cmd_to_pool(cmd);
} else {
transport_free_se_cmd(cmd);
cmd->se_tfo->release_cmd_direct(cmd);
}
return 0; return 0;
} }
...@@ -4894,18 +4885,14 @@ static int transport_generic_write_pending(struct se_cmd *cmd) ...@@ -4894,18 +4885,14 @@ static int transport_generic_write_pending(struct se_cmd *cmd)
return PYX_TRANSPORT_WRITE_PENDING; return PYX_TRANSPORT_WRITE_PENDING;
} }
/* transport_release_cmd_to_pool(): void transport_release_cmd(struct se_cmd *cmd)
*
*
*/
void transport_release_cmd_to_pool(struct se_cmd *cmd)
{ {
BUG_ON(!cmd->se_tfo); BUG_ON(!cmd->se_tfo);
transport_free_se_cmd(cmd); transport_free_se_cmd(cmd);
cmd->se_tfo->release_cmd_to_pool(cmd); cmd->se_tfo->release_cmd(cmd);
} }
EXPORT_SYMBOL(transport_release_cmd_to_pool); EXPORT_SYMBOL(transport_release_cmd);
/* transport_generic_free_cmd(): /* transport_generic_free_cmd():
* *
...@@ -4914,11 +4901,10 @@ EXPORT_SYMBOL(transport_release_cmd_to_pool); ...@@ -4914,11 +4901,10 @@ EXPORT_SYMBOL(transport_release_cmd_to_pool);
void transport_generic_free_cmd( void transport_generic_free_cmd(
struct se_cmd *cmd, struct se_cmd *cmd,
int wait_for_tasks, int wait_for_tasks,
int release_to_pool,
int session_reinstatement) int session_reinstatement)
{ {
if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD))
transport_release_cmd_to_pool(cmd); transport_release_cmd(cmd);
else { else {
core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd); core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd);
...@@ -4936,8 +4922,7 @@ void transport_generic_free_cmd( ...@@ -4936,8 +4922,7 @@ void transport_generic_free_cmd(
transport_free_dev_tasks(cmd); transport_free_dev_tasks(cmd);
transport_generic_remove(cmd, release_to_pool, transport_generic_remove(cmd, session_reinstatement);
session_reinstatement);
} }
} }
EXPORT_SYMBOL(transport_generic_free_cmd); EXPORT_SYMBOL(transport_generic_free_cmd);
...@@ -5210,7 +5195,7 @@ static void transport_generic_wait_for_tasks( ...@@ -5210,7 +5195,7 @@ static void transport_generic_wait_for_tasks(
if (!remove_cmd) if (!remove_cmd)
return; return;
transport_generic_free_cmd(cmd, 0, 0, session_reinstatement); transport_generic_free_cmd(cmd, 0, session_reinstatement);
} }
static int transport_get_sense_codes( static int transport_get_sense_codes(
...@@ -5616,7 +5601,7 @@ static void transport_processing_shutdown(struct se_device *dev) ...@@ -5616,7 +5601,7 @@ static void transport_processing_shutdown(struct se_device *dev)
transport_lun_remove_cmd(cmd); transport_lun_remove_cmd(cmd);
if (transport_cmd_check_stop(cmd, 1, 0)) if (transport_cmd_check_stop(cmd, 1, 0))
transport_generic_remove(cmd, 0, 0); transport_generic_remove(cmd, 0);
} }
spin_lock_irqsave(&dev->execute_task_lock, flags); spin_lock_irqsave(&dev->execute_task_lock, flags);
...@@ -5644,7 +5629,7 @@ static void transport_processing_shutdown(struct se_device *dev) ...@@ -5644,7 +5629,7 @@ static void transport_processing_shutdown(struct se_device *dev)
transport_lun_remove_cmd(cmd); transport_lun_remove_cmd(cmd);
if (transport_cmd_check_stop(cmd, 1, 0)) if (transport_cmd_check_stop(cmd, 1, 0))
transport_generic_remove(cmd, 0, 0); transport_generic_remove(cmd, 0);
} }
spin_lock_irqsave(&dev->execute_task_lock, flags); spin_lock_irqsave(&dev->execute_task_lock, flags);
...@@ -5667,7 +5652,7 @@ static void transport_processing_shutdown(struct se_device *dev) ...@@ -5667,7 +5652,7 @@ static void transport_processing_shutdown(struct se_device *dev)
} else { } else {
transport_lun_remove_cmd(cmd); transport_lun_remove_cmd(cmd);
if (transport_cmd_check_stop(cmd, 1, 0)) if (transport_cmd_check_stop(cmd, 1, 0))
transport_generic_remove(cmd, 0, 0); transport_generic_remove(cmd, 0);
} }
} }
} }
...@@ -5739,10 +5724,10 @@ static int transport_processing_thread(void *param) ...@@ -5739,10 +5724,10 @@ static int transport_processing_thread(void *param)
transport_generic_complete_ok(cmd); transport_generic_complete_ok(cmd);
break; break;
case TRANSPORT_REMOVE: case TRANSPORT_REMOVE:
transport_generic_remove(cmd, 1, 0); transport_generic_remove(cmd, 0);
break; break;
case TRANSPORT_FREE_CMD_INTR: case TRANSPORT_FREE_CMD_INTR:
transport_generic_free_cmd(cmd, 0, 1, 0); transport_generic_free_cmd(cmd, 0, 0);
break; break;
case TRANSPORT_PROCESS_TMR: case TRANSPORT_PROCESS_TMR:
transport_generic_do_tmr(cmd); transport_generic_do_tmr(cmd);
......
...@@ -147,7 +147,7 @@ void ft_release_cmd(struct se_cmd *se_cmd) ...@@ -147,7 +147,7 @@ void ft_release_cmd(struct se_cmd *se_cmd)
void ft_check_stop_free(struct se_cmd *se_cmd) void ft_check_stop_free(struct se_cmd *se_cmd)
{ {
transport_generic_free_cmd(se_cmd, 0, 1, 0); transport_generic_free_cmd(se_cmd, 0, 0);
} }
/* /*
...@@ -304,7 +304,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg) ...@@ -304,7 +304,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
/* XXX need to find cmd if queued */ /* XXX need to find cmd if queued */
cmd->se_cmd.t_state = TRANSPORT_REMOVE; cmd->se_cmd.t_state = TRANSPORT_REMOVE;
cmd->seq = NULL; cmd->seq = NULL;
transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0); transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
return; return;
} }
...@@ -321,7 +321,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg) ...@@ -321,7 +321,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
printk(KERN_INFO "%s: unhandled frame r_ctl %x\n", printk(KERN_INFO "%s: unhandled frame r_ctl %x\n",
__func__, fh->fh_r_ctl); __func__, fh->fh_r_ctl);
fc_frame_free(fp); fc_frame_free(fp);
transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0); transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
break; break;
} }
} }
...@@ -443,7 +443,7 @@ static void ft_send_tm(struct ft_cmd *cmd) ...@@ -443,7 +443,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
sess = cmd->sess; sess = cmd->sess;
transport_send_check_condition_and_sense(&cmd->se_cmd, transport_send_check_condition_and_sense(&cmd->se_cmd,
cmd->se_cmd.scsi_sense_reason, 0); cmd->se_cmd.scsi_sense_reason, 0);
transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0); transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
ft_sess_put(sess); ft_sess_put(sess);
return; return;
} }
...@@ -645,7 +645,7 @@ static void ft_send_cmd(struct ft_cmd *cmd) ...@@ -645,7 +645,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
if (ret == -ENOMEM) { if (ret == -ENOMEM) {
transport_send_check_condition_and_sense(se_cmd, transport_send_check_condition_and_sense(se_cmd,
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
transport_generic_free_cmd(se_cmd, 0, 1, 0); transport_generic_free_cmd(se_cmd, 0, 0);
return; return;
} }
if (ret == -EINVAL) { if (ret == -EINVAL) {
...@@ -654,7 +654,7 @@ static void ft_send_cmd(struct ft_cmd *cmd) ...@@ -654,7 +654,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
else else
transport_send_check_condition_and_sense(se_cmd, transport_send_check_condition_and_sense(se_cmd,
se_cmd->scsi_sense_reason, 0); se_cmd->scsi_sense_reason, 0);
transport_generic_free_cmd(se_cmd, 0, 1, 0); transport_generic_free_cmd(se_cmd, 0, 0);
return; return;
} }
transport_generic_handle_cdb(se_cmd); transport_generic_handle_cdb(se_cmd);
......
...@@ -536,8 +536,7 @@ static struct target_core_fabric_ops ft_fabric_ops = { ...@@ -536,8 +536,7 @@ static struct target_core_fabric_ops ft_fabric_ops = {
.tpg_release_fabric_acl = ft_tpg_release_fabric_acl, .tpg_release_fabric_acl = ft_tpg_release_fabric_acl,
.tpg_get_inst_index = ft_tpg_get_inst_index, .tpg_get_inst_index = ft_tpg_get_inst_index,
.check_stop_free = ft_check_stop_free, .check_stop_free = ft_check_stop_free,
.release_cmd_to_pool = ft_release_cmd, .release_cmd = ft_release_cmd,
.release_cmd_direct = ft_release_cmd,
.shutdown_session = ft_sess_shutdown, .shutdown_session = ft_sess_shutdown,
.close_session = ft_sess_close, .close_session = ft_sess_close,
.stop_session = ft_sess_stop, .stop_session = ft_sess_stop,
......
...@@ -43,8 +43,7 @@ struct target_core_fabric_ops { ...@@ -43,8 +43,7 @@ struct target_core_fabric_ops {
* I/O descriptor in transport_cmd_check_stop() * I/O descriptor in transport_cmd_check_stop()
*/ */
void (*check_stop_free)(struct se_cmd *); void (*check_stop_free)(struct se_cmd *);
void (*release_cmd_to_pool)(struct se_cmd *); void (*release_cmd)(struct se_cmd *);
void (*release_cmd_direct)(struct se_cmd *);
/* /*
* Called with spin_lock_bh(struct se_portal_group->session_lock held. * Called with spin_lock_bh(struct se_portal_group->session_lock held.
*/ */
......
...@@ -179,8 +179,8 @@ extern int transport_clear_lun_from_sessions(struct se_lun *); ...@@ -179,8 +179,8 @@ extern int transport_clear_lun_from_sessions(struct se_lun *);
extern int transport_check_aborted_status(struct se_cmd *, int); extern int transport_check_aborted_status(struct se_cmd *, int);
extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int); extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int);
extern void transport_send_task_abort(struct se_cmd *); extern void transport_send_task_abort(struct se_cmd *);
extern void transport_release_cmd_to_pool(struct se_cmd *); extern void transport_release_cmd(struct se_cmd *);
extern void transport_generic_free_cmd(struct se_cmd *, int, int, int); extern void transport_generic_free_cmd(struct se_cmd *, int, int);
extern void transport_generic_wait_for_cmds(struct se_cmd *, int); extern void transport_generic_wait_for_cmds(struct se_cmd *, int);
extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32); extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32);
extern int transport_map_mem_to_sg(struct se_task *, struct list_head *, extern int transport_map_mem_to_sg(struct se_task *, struct list_head *,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册