Commit a014c364 authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: target/core: Make it possible to wait from more than one context for command completion

This patch does not change any functionality but makes the patch that makes
TMF handling synchronous easier to read.

Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Disseldorp <ddiss@suse.de>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent db5b21a2
...@@ -1328,7 +1328,8 @@ void transport_init_se_cmd( ...@@ -1328,7 +1328,8 @@ void transport_init_se_cmd(
INIT_LIST_HEAD(&cmd->se_cmd_list); INIT_LIST_HEAD(&cmd->se_cmd_list);
INIT_LIST_HEAD(&cmd->state_list); INIT_LIST_HEAD(&cmd->state_list);
init_completion(&cmd->t_transport_stop_comp); init_completion(&cmd->t_transport_stop_comp);
cmd->compl = NULL; cmd->free_compl = NULL;
cmd->abrt_compl = NULL;
spin_lock_init(&cmd->t_state_lock); spin_lock_init(&cmd->t_state_lock);
INIT_WORK(&cmd->work, NULL); INIT_WORK(&cmd->work, NULL);
kref_init(&cmd->cmd_kref); kref_init(&cmd->cmd_kref);
...@@ -2689,7 +2690,7 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) ...@@ -2689,7 +2690,7 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
transport_lun_remove_cmd(cmd); transport_lun_remove_cmd(cmd);
} }
if (aborted) if (aborted)
cmd->compl = &compl; cmd->free_compl = &compl;
if (!aborted || tas) if (!aborted || tas)
ret = target_put_sess_cmd(cmd); ret = target_put_sess_cmd(cmd);
if (aborted) { if (aborted) {
...@@ -2756,7 +2757,8 @@ static void target_release_cmd_kref(struct kref *kref) ...@@ -2756,7 +2757,8 @@ static void target_release_cmd_kref(struct kref *kref)
{ {
struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref); struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref);
struct se_session *se_sess = se_cmd->se_sess; struct se_session *se_sess = se_cmd->se_sess;
struct completion *compl = se_cmd->compl; struct completion *free_compl = se_cmd->free_compl;
struct completion *abrt_compl = se_cmd->abrt_compl;
unsigned long flags; unsigned long flags;
if (se_sess) { if (se_sess) {
...@@ -2767,8 +2769,10 @@ static void target_release_cmd_kref(struct kref *kref) ...@@ -2767,8 +2769,10 @@ static void target_release_cmd_kref(struct kref *kref)
target_free_cmd_mem(se_cmd); target_free_cmd_mem(se_cmd);
se_cmd->se_tfo->release_cmd(se_cmd); se_cmd->se_tfo->release_cmd(se_cmd);
if (compl) if (free_compl)
complete(compl); complete(free_compl);
if (abrt_compl)
complete(abrt_compl);
percpu_ref_put(&se_sess->cmd_count); percpu_ref_put(&se_sess->cmd_count);
} }
......
...@@ -476,7 +476,8 @@ struct se_cmd { ...@@ -476,7 +476,8 @@ struct se_cmd {
struct se_session *se_sess; struct se_session *se_sess;
struct se_tmr_req *se_tmr_req; struct se_tmr_req *se_tmr_req;
struct list_head se_cmd_list; struct list_head se_cmd_list;
struct completion *compl; struct completion *free_compl;
struct completion *abrt_compl;
const struct target_core_fabric_ops *se_tfo; const struct target_core_fabric_ops *se_tfo;
sense_reason_t (*execute_cmd)(struct se_cmd *); sense_reason_t (*execute_cmd)(struct se_cmd *);
sense_reason_t (*transport_complete_callback)(struct se_cmd *, bool, int *); sense_reason_t (*transport_complete_callback)(struct se_cmd *, bool, int *);
......
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