forked from luck/tmp_suning_uos_patched
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>
This commit is contained in:
parent
db1620a278
commit
35462975b2
|
@ -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
|
||||
* 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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called from struct target_core_fabric_ops->release_cmd_to_pool()
|
||||
*/
|
||||
static void tcm_loop_deallocate_core_cmd(struct se_cmd *se_cmd)
|
||||
static void tcm_loop_release_cmd(struct se_cmd *se_cmd)
|
||||
{
|
||||
struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
|
||||
struct tcm_loop_cmd, tl_se_cmd);
|
||||
|
@ -395,7 +392,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
|
|||
SUCCESS : FAILED;
|
||||
release:
|
||||
if (se_cmd)
|
||||
transport_generic_free_cmd(se_cmd, 1, 1, 0);
|
||||
transport_generic_free_cmd(se_cmd, 1, 0);
|
||||
else
|
||||
kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
|
||||
kfree(tl_tmr);
|
||||
|
@ -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.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_direct = &tcm_loop_deallocate_core_cmd;
|
||||
fabric->tf_ops.release_cmd = &tcm_loop_release_cmd;
|
||||
fabric->tf_ops.shutdown_session = &tcm_loop_shutdown_session;
|
||||
fabric->tf_ops.close_session = &tcm_loop_close_session;
|
||||
fabric->tf_ops.stop_session = &tcm_loop_stop_session;
|
||||
|
|
|
@ -427,12 +427,8 @@ static int target_fabric_tf_ops_check(
|
|||
printk(KERN_ERR "Missing tfo->tpg_get_inst_index()\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!(tfo->release_cmd_to_pool)) {
|
||||
printk(KERN_ERR "Missing tfo->release_cmd_to_pool()\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!(tfo->release_cmd_direct)) {
|
||||
printk(KERN_ERR "Missing tfo->release_cmd_direct()\n");
|
||||
if (!tfo->release_cmd) {
|
||||
printk(KERN_ERR "Missing tfo->release_cmd()\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!(tfo->shutdown_session)) {
|
||||
|
|
|
@ -212,7 +212,7 @@ static u32 transport_allocate_tasks(struct se_cmd *cmd,
|
|||
struct list_head *mem_list, int set_counts);
|
||||
static int transport_generic_get_mem(struct se_cmd *cmd, u32 length);
|
||||
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_map_sg_to_mem(struct se_cmd *cmd,
|
||||
struct list_head *se_mem_list, struct scatterlist *sgl);
|
||||
|
@ -737,7 +737,7 @@ void transport_cmd_finish_abort(struct se_cmd *cmd, int remove)
|
|||
if (transport_cmd_check_stop_to_fabric(cmd))
|
||||
return;
|
||||
if (remove)
|
||||
transport_generic_remove(cmd, 0, 0);
|
||||
transport_generic_remove(cmd, 0);
|
||||
}
|
||||
|
||||
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))
|
||||
return;
|
||||
|
||||
transport_generic_remove(cmd, 0, 0);
|
||||
transport_generic_remove(cmd, 0);
|
||||
}
|
||||
|
||||
static void transport_add_cmd_to_queue(
|
||||
|
@ -2146,7 +2146,7 @@ static void transport_generic_request_timeout(struct se_cmd *cmd)
|
|||
}
|
||||
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
|
||||
|
||||
transport_generic_remove(cmd, 0, 0);
|
||||
transport_generic_remove(cmd, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -3825,13 +3825,11 @@ static void transport_release_fe_cmd(struct se_cmd *cmd)
|
|||
free_pages:
|
||||
transport_free_pages(cmd);
|
||||
transport_free_se_cmd(cmd);
|
||||
cmd->se_tfo->release_cmd_direct(cmd);
|
||||
cmd->se_tfo->release_cmd(cmd);
|
||||
}
|
||||
|
||||
static int transport_generic_remove(
|
||||
struct se_cmd *cmd,
|
||||
int release_to_pool,
|
||||
int session_reinstatement)
|
||||
static int
|
||||
transport_generic_remove(struct se_cmd *cmd, int session_reinstatement)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
|
@ -3858,14 +3856,7 @@ static int transport_generic_remove(
|
|||
|
||||
free_pages:
|
||||
transport_free_pages(cmd);
|
||||
|
||||
if (release_to_pool) {
|
||||
transport_release_cmd_to_pool(cmd);
|
||||
} else {
|
||||
transport_free_se_cmd(cmd);
|
||||
cmd->se_tfo->release_cmd_direct(cmd);
|
||||
}
|
||||
|
||||
transport_release_cmd(cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4894,18 +4885,14 @@ static int transport_generic_write_pending(struct se_cmd *cmd)
|
|||
return PYX_TRANSPORT_WRITE_PENDING;
|
||||
}
|
||||
|
||||
/* transport_release_cmd_to_pool():
|
||||
*
|
||||
*
|
||||
*/
|
||||
void transport_release_cmd_to_pool(struct se_cmd *cmd)
|
||||
void transport_release_cmd(struct se_cmd *cmd)
|
||||
{
|
||||
BUG_ON(!cmd->se_tfo);
|
||||
|
||||
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():
|
||||
*
|
||||
|
@ -4914,11 +4901,10 @@ EXPORT_SYMBOL(transport_release_cmd_to_pool);
|
|||
void transport_generic_free_cmd(
|
||||
struct se_cmd *cmd,
|
||||
int wait_for_tasks,
|
||||
int release_to_pool,
|
||||
int session_reinstatement)
|
||||
{
|
||||
if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD))
|
||||
transport_release_cmd_to_pool(cmd);
|
||||
transport_release_cmd(cmd);
|
||||
else {
|
||||
core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd);
|
||||
|
||||
|
@ -4936,8 +4922,7 @@ void transport_generic_free_cmd(
|
|||
|
||||
transport_free_dev_tasks(cmd);
|
||||
|
||||
transport_generic_remove(cmd, release_to_pool,
|
||||
session_reinstatement);
|
||||
transport_generic_remove(cmd, session_reinstatement);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(transport_generic_free_cmd);
|
||||
|
@ -5210,7 +5195,7 @@ static void transport_generic_wait_for_tasks(
|
|||
if (!remove_cmd)
|
||||
return;
|
||||
|
||||
transport_generic_free_cmd(cmd, 0, 0, session_reinstatement);
|
||||
transport_generic_free_cmd(cmd, 0, session_reinstatement);
|
||||
}
|
||||
|
||||
static int transport_get_sense_codes(
|
||||
|
@ -5616,7 +5601,7 @@ static void transport_processing_shutdown(struct se_device *dev)
|
|||
transport_lun_remove_cmd(cmd);
|
||||
|
||||
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);
|
||||
|
@ -5644,7 +5629,7 @@ static void transport_processing_shutdown(struct se_device *dev)
|
|||
transport_lun_remove_cmd(cmd);
|
||||
|
||||
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);
|
||||
|
@ -5667,7 +5652,7 @@ static void transport_processing_shutdown(struct se_device *dev)
|
|||
} else {
|
||||
transport_lun_remove_cmd(cmd);
|
||||
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)
|
|||
transport_generic_complete_ok(cmd);
|
||||
break;
|
||||
case TRANSPORT_REMOVE:
|
||||
transport_generic_remove(cmd, 1, 0);
|
||||
transport_generic_remove(cmd, 0);
|
||||
break;
|
||||
case TRANSPORT_FREE_CMD_INTR:
|
||||
transport_generic_free_cmd(cmd, 0, 1, 0);
|
||||
transport_generic_free_cmd(cmd, 0, 0);
|
||||
break;
|
||||
case TRANSPORT_PROCESS_TMR:
|
||||
transport_generic_do_tmr(cmd);
|
||||
|
|
|
@ -147,7 +147,7 @@ void ft_release_cmd(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)
|
|||
/* XXX need to find cmd if queued */
|
||||
cmd->se_cmd.t_state = TRANSPORT_REMOVE;
|
||||
cmd->seq = NULL;
|
||||
transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0);
|
||||
transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
__func__, fh->fh_r_ctl);
|
||||
fc_frame_free(fp);
|
||||
transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0);
|
||||
transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
|
|||
sess = cmd->sess;
|
||||
transport_send_check_condition_and_sense(&cmd->se_cmd,
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -645,7 +645,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
|
|||
if (ret == -ENOMEM) {
|
||||
transport_send_check_condition_and_sense(se_cmd,
|
||||
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
|
||||
transport_generic_free_cmd(se_cmd, 0, 1, 0);
|
||||
transport_generic_free_cmd(se_cmd, 0, 0);
|
||||
return;
|
||||
}
|
||||
if (ret == -EINVAL) {
|
||||
|
@ -654,7 +654,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
|
|||
else
|
||||
transport_send_check_condition_and_sense(se_cmd,
|
||||
se_cmd->scsi_sense_reason, 0);
|
||||
transport_generic_free_cmd(se_cmd, 0, 1, 0);
|
||||
transport_generic_free_cmd(se_cmd, 0, 0);
|
||||
return;
|
||||
}
|
||||
transport_generic_handle_cdb(se_cmd);
|
||||
|
|
|
@ -536,8 +536,7 @@ static struct target_core_fabric_ops ft_fabric_ops = {
|
|||
.tpg_release_fabric_acl = ft_tpg_release_fabric_acl,
|
||||
.tpg_get_inst_index = ft_tpg_get_inst_index,
|
||||
.check_stop_free = ft_check_stop_free,
|
||||
.release_cmd_to_pool = ft_release_cmd,
|
||||
.release_cmd_direct = ft_release_cmd,
|
||||
.release_cmd = ft_release_cmd,
|
||||
.shutdown_session = ft_sess_shutdown,
|
||||
.close_session = ft_sess_close,
|
||||
.stop_session = ft_sess_stop,
|
||||
|
|
|
@ -43,8 +43,7 @@ struct target_core_fabric_ops {
|
|||
* I/O descriptor in transport_cmd_check_stop()
|
||||
*/
|
||||
void (*check_stop_free)(struct se_cmd *);
|
||||
void (*release_cmd_to_pool)(struct se_cmd *);
|
||||
void (*release_cmd_direct)(struct se_cmd *);
|
||||
void (*release_cmd)(struct se_cmd *);
|
||||
/*
|
||||
* 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 *);
|
|||
extern int transport_check_aborted_status(struct se_cmd *, 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_release_cmd_to_pool(struct se_cmd *);
|
||||
extern void transport_generic_free_cmd(struct se_cmd *, int, int, int);
|
||||
extern void transport_release_cmd(struct se_cmd *);
|
||||
extern void transport_generic_free_cmd(struct se_cmd *, int, 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_map_mem_to_sg(struct se_task *, struct list_head *,
|
||||
|
|
Loading…
Reference in New Issue
Block a user