summaryrefslogtreecommitdiff
path: root/include/target
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@sandisk.com>2017-01-09 11:13:03 -0800
committerBart Van Assche <bart.vanassche@sandisk.com>2017-02-08 16:41:09 -0800
commitfddf38b8bfd92541a1aabca574f87fa55a2cfa23 (patch)
treee7400df4b6a0636e02f0fea2dd2c549eb88c8b09 /include/target
parent606d26c3076596f8d30162437271245d0b980326 (diff)
target: Simplify session shutdown code
Target drivers must call target_sess_cmd_list_set_waiting() and target_wait_for_sess_cmds() before freeing a session. Instead of setting a flag in each pending command from the former function and waiting in the latter function on a per-command completion, only set a per-session flag in the former function and wait on a per-session completion in the latter function. Note: this patch changes the behavior from aborting outstanding commands back to waiting for command completion. This makes the session shutdown code simpler. This change is safe because once a SCSI initiator system has submitted a command a target system is always allowed to execute it to completion. See also commit 0f4a943168f3 ("target: Fix remote-port TMR ABORT + se_cmd fabric stop"). This patch is based on the following two patches: * Bart Van Assche, target: Simplify session shutdown code, February 19, 2015 (https://github.com/bvanassche/linux/commit/8df5463d7d7619f2f1b70cfe5172eaef0aa52815). * Christoph Hellwig, target: Rework session shutdown code, December 7, 2015 (http://thread.gmane.org/gmane.linux.scsi.target.devel/10695). Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Sagi Grimberg <sagig@mellanox.com> Cc: Andy Grover <agrover@redhat.com>
Diffstat (limited to 'include/target')
-rw-r--r--include/target/target_core_base.h4
1 files changed, 1 insertions, 3 deletions
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index e5e0fd852ff5..187caa258253 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -441,7 +441,6 @@ struct se_cmd {
u8 scsi_asc;
u8 scsi_ascq;
u16 scsi_sense_length;
- unsigned cmd_wait_set:1;
unsigned unknown_data_length:1;
bool state_active:1;
bool send_abort_response:1;
@@ -474,7 +473,6 @@ struct se_cmd {
struct se_session *se_sess;
struct se_tmr_req *se_tmr_req;
struct list_head se_cmd_list;
- struct completion cmd_wait_comp;
const struct target_core_fabric_ops *se_tfo;
sense_reason_t (*execute_cmd)(struct se_cmd *);
sense_reason_t (*transport_complete_callback)(struct se_cmd *, bool, int *);
@@ -606,8 +604,8 @@ struct se_session {
struct list_head sess_list;
struct list_head sess_acl_list;
struct list_head sess_cmd_list;
- struct list_head sess_wait_list;
spinlock_t sess_cmd_lock;
+ wait_queue_head_t cmd_list_wq;
void *sess_cmd_map;
struct percpu_ida sess_tag_pool;
struct workqueue_struct *tmf_wq;