blk-rq-qos: remove redundant finish_wait to rq_qos_wait.
diff mbox series

Message ID 20200624130400.2902189-1-guoxuenan@huawei.com
State New
Headers show
Series
  • blk-rq-qos: remove redundant finish_wait to rq_qos_wait.
Related show

Commit Message

Guo Xuenan June 24, 2020, 1:04 p.m. UTC
It is no need do finish_wait twice after acquiring inflight.

Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
---
 block/blk-rq-qos.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Jens Axboe June 24, 2020, 3:06 p.m. UTC | #1
On 6/24/20 7:04 AM, Guo Xuenan wrote:
> It is no need do finish_wait twice after acquiring inflight.

Seems cleaner to kill the redundant one, rather than adding
a new one and removing another one. We end up with less
code that way.

diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index 656460636ad3..18f3eab9f768 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -273,8 +273,6 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
 		if (data.got_token)
 			break;
 		if (!has_sleeper && acquire_inflight_cb(rqw, private_data)) {
-			finish_wait(&rqw->wait, &data.wq);
-
 			/*
 			 * We raced with wbt_wake_function() getting a token,
 			 * which means we now have two. Put our local token

Patch
diff mbox series

diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index 656460636ad3..00a08e53dc24 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -270,8 +270,10 @@  void rq_qos_wait(struct rq_wait *rqw, void *private_data,
 	has_sleeper = !wq_has_single_sleeper(&rqw->wait);
 	do {
 		/* The memory barrier in set_task_state saves us here. */
-		if (data.got_token)
-			break;
+		if (data.got_token) {
+			finish_wait(&rqw->wait, &data.wq);
+			return;
+		}
 		if (!has_sleeper && acquire_inflight_cb(rqw, private_data)) {
 			finish_wait(&rqw->wait, &data.wq);
 
@@ -289,7 +291,6 @@  void rq_qos_wait(struct rq_wait *rqw, void *private_data,
 		has_sleeper = true;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 	} while (1);
-	finish_wait(&rqw->wait, &data.wq);
 }
 
 void rq_qos_exit(struct request_queue *q)