diff options
author | Bart Van Assche <bart.vanassche@sandisk.com> | 2017-05-23 19:48:40 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2017-07-07 02:11:24 -0400 |
commit | d17203c41185a05ecd4d1fc647f16b17ab1b27ae (patch) | |
tree | 48d019bc17625eed108fa3417a52037f00a643b5 | |
parent | 4d3895d5ea43cf40fd707692263c6f0988fe8d70 (diff) |
target/tcm_loop: Replace a waitqueue and a counter by a completion
This patch simplifies the implementation of the tcm_loop driver
but does not change its behavior.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: David Disseldorp <ddiss@suse.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 12 | ||||
-rw-r--r-- | drivers/target/loopback/tcm_loop.h | 3 |
2 files changed, 5 insertions, 10 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 79776b447b15..27f912747113 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -239,7 +239,7 @@ static int tcm_loop_issue_tmr(struct tcm_loop_tpg *tl_tpg, | |||
239 | return ret; | 239 | return ret; |
240 | } | 240 | } |
241 | 241 | ||
242 | init_waitqueue_head(&tl_cmd->tl_tmr_wait); | 242 | init_completion(&tl_cmd->tmr_done); |
243 | 243 | ||
244 | se_cmd = &tl_cmd->tl_se_cmd; | 244 | se_cmd = &tl_cmd->tl_se_cmd; |
245 | se_tpg = &tl_tpg->tl_se_tpg; | 245 | se_tpg = &tl_tpg->tl_se_tpg; |
@@ -270,7 +270,7 @@ static int tcm_loop_issue_tmr(struct tcm_loop_tpg *tl_tpg, | |||
270 | * tcm_loop_queue_tm_rsp() to wake us up. | 270 | * tcm_loop_queue_tm_rsp() to wake us up. |
271 | */ | 271 | */ |
272 | transport_generic_handle_tmr(se_cmd); | 272 | transport_generic_handle_tmr(se_cmd); |
273 | wait_event(tl_cmd->tl_tmr_wait, atomic_read(&tl_cmd->tmr_complete)); | 273 | wait_for_completion(&tl_cmd->tmr_done); |
274 | /* | 274 | /* |
275 | * The TMR LUN_RESET has completed, check the response status and | 275 | * The TMR LUN_RESET has completed, check the response status and |
276 | * then release allocations. | 276 | * then release allocations. |
@@ -665,12 +665,8 @@ static void tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd) | |||
665 | struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, | 665 | struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, |
666 | struct tcm_loop_cmd, tl_se_cmd); | 666 | struct tcm_loop_cmd, tl_se_cmd); |
667 | 667 | ||
668 | /* | 668 | /* Wake up tcm_loop_issue_tmr(). */ |
669 | * The SCSI EH thread will be sleeping on se_tmr->tl_tmr_wait, go ahead | 669 | complete(&tl_cmd->tmr_done); |
670 | * and wake up the wait_queue_head_t in tcm_loop_device_reset() | ||
671 | */ | ||
672 | atomic_set(&tl_cmd->tmr_complete, 1); | ||
673 | wake_up(&tl_cmd->tl_tmr_wait); | ||
674 | } | 670 | } |
675 | 671 | ||
676 | static void tcm_loop_aborted_task(struct se_cmd *se_cmd) | 672 | static void tcm_loop_aborted_task(struct se_cmd *se_cmd) |
diff --git a/drivers/target/loopback/tcm_loop.h b/drivers/target/loopback/tcm_loop.h index 21340781568b..3acc43c05117 100644 --- a/drivers/target/loopback/tcm_loop.h +++ b/drivers/target/loopback/tcm_loop.h | |||
@@ -16,8 +16,7 @@ struct tcm_loop_cmd { | |||
16 | /* The TCM I/O descriptor that is accessed via container_of() */ | 16 | /* The TCM I/O descriptor that is accessed via container_of() */ |
17 | struct se_cmd tl_se_cmd; | 17 | struct se_cmd tl_se_cmd; |
18 | struct work_struct work; | 18 | struct work_struct work; |
19 | atomic_t tmr_complete; | 19 | struct completion tmr_done; |
20 | wait_queue_head_t tl_tmr_wait; | ||
21 | /* Sense buffer that will be mapped into outgoing status */ | 20 | /* Sense buffer that will be mapped into outgoing status */ |
22 | unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER]; | 21 | unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER]; |
23 | }; | 22 | }; |