Skip to contentSkip to conversation

block: simplify blk_mq_finish_request()

PATCH In review Damien Le Moal 2 participants 3 messages Feb 24 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: simplify blk_mq_finish_request()

Remove the local q variable as it is not necessary. This also removes a useless pointer dereference when RQF_USE_SCHED is not set for a request.

---
 block/blk-mq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
block/blk-mq.c +1 -3
index 9af8c3dec3f6..55a255750ad1 100644
@@ -781,12 +781,10 @@ EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx);
 
 static void blk_mq_finish_request(struct request *rq)
 {
-	struct request_queue *q = rq->q;
-
 	blk_zone_finish_request(rq);
 
 	if (rq->rq_flags & RQF_USE_SCHED) {
-		q->elevator->type->ops.finish_request(rq);
+		rq->q->elevator->type->ops.finish_request(rq);
 		/*
 		 * For postflush request that may need to be
 		 * completed twice, we should clear this flag
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 16 lines · Damien Le Moal

Remove the local q variable as it is not necessary. This also removes a useless pointer dereference when RQF_USE_SCHED is not set for a request.

---
 block/blk-mq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
block/blk-mq.c +0 -0
index 9af8c3dec3f6..55a255750ad1 100644
@@ -781,12 +781,10 @@ EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx);
 
 static void blk_mq_finish_request(struct request *rq)
 {

block/blk-mq.c EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx); · line 790

Quoted 10 lines
block/blk-mq.c +1 -3
-	struct request_queue *q = rq->q;
-
 	blk_zone_finish_request(rq);
 
 	if (rq->rq_flags & RQF_USE_SCHED) {
-		q->elevator->type->ops.finish_request(rq);
+		rq->q->elevator->type->ops.finish_request(rq);
 		/*
 		 * For postflush request that may need to be
 		 * completed twice, we should clear this flag

This will compile to the same code...

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 21 lines · Jens Axboe
Quoted 20 lines · Damien Le Moal

Remove the local q variable as it is not necessary. This also removes a useless pointer dereference when RQF_USE_SCHED is not set for a request.

---
 block/blk-mq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
block/blk-mq.c +0 -2
index 9af8c3dec3f6..55a255750ad1 100644
@@ -781,12 +781,10 @@ EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx);
 
 static void blk_mq_finish_request(struct request *rq)
 {
-	struct request_queue *q = rq->q;
-
 	blk_zone_finish_request(rq);
 
Quoted 8 lines

block/blk-mq.c EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx); · line 790

Quoted 6 lines
block/blk-mq.c +1 -1
 	if (rq->rq_flags & RQF_USE_SCHED) {
-		q->elevator->type->ops.finish_request(rq);
+		rq->q->elevator->type->ops.finish_request(rq);
 		/*
 		 * For postflush request that may need to be
 		 * completed twice, we should clear this flag

This will compile to the same code...

OK. I had not check the compiled code. Sorry for the noise.

Signature · 2 lines
Damien Le Moal
Western Digital Research