diff mbox series

block: remove redundant req_op in blk_rq_is_passthrough

Message ID 20230522085355.1740772-1-linan666@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series block: remove redundant req_op in blk_rq_is_passthrough | expand

Commit Message

Li Nan May 22, 2023, 8:53 a.m. UTC
From: Li Nan <linan122@huawei.com>

op &= REQ_OP_MASK in blk_op_is_passthrough() is exactly what req_op() do.
Therefore, it is redundant to call req_op() for blk_op_is_passthrough().

Signed-off-by: Li Nan <linan122@huawei.com>
---
 include/linux/blk-mq.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chaitanya Kulkarni May 22, 2023, 9:31 a.m. UTC | #1
On 5/22/23 01:53, linan666@huaweicloud.com wrote:
> From: Li Nan <linan122@huawei.com>
>
> op &= REQ_OP_MASK in blk_op_is_passthrough() is exactly what req_op() do.
> Therefore, it is redundant to call req_op() for blk_op_is_passthrough().

I couldn't understand commit log, feel free to ignore following
if others are okay with it :-

req_op() returns the REQ_OP_XXX with req->cmd_flags & REQ_OP_MASKS.

blk_op_is_passthrugh() masks op with REQ_OP_MASKS to compare
REQ_OP_XXX with passthrough requests REQ_OP_IN/REQ_OP_OUT.
  245
  246 static inline bool blk_op_is_passthrough(blk_opf_t op)
  247 {
  248         op &= REQ_OP_MASK;
  249         return op == REQ_OP_DRV_IN || op == REQ_OP_DRV_OUT;
  250 }
  251

Passing req_op(rq) argument to blk_op_is_passthru() results in double
masking of request flags first in req_op() and again in
blk_op_is_passthrough().

Avoid that by passing req->cmd_flags instead of req_op(req) as
an argument to blk_op_is_passthrough() when it is called from
blk_rq_is_passthruough().


irrespective of above suggestion, looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Christoph Hellwig May 23, 2023, 6:19 a.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Jens Axboe May 23, 2023, 5:13 p.m. UTC | #3
On Mon, 22 May 2023 16:53:55 +0800, linan666@huaweicloud.com wrote:
> op &= REQ_OP_MASK in blk_op_is_passthrough() is exactly what req_op() do.
> Therefore, it is redundant to call req_op() for blk_op_is_passthrough().
> 
> 

Applied, thanks!

[1/1] block: remove redundant req_op in blk_rq_is_passthrough
      commit: 712fd23a90eed6a73ea5135a500e59d30356d4f1

Best regards,
diff mbox series

Patch

diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index d778cb6b2112..59b52ec155b1 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -201,7 +201,7 @@  static inline enum req_op req_op(const struct request *req)
 
 static inline bool blk_rq_is_passthrough(struct request *rq)
 {
-	return blk_op_is_passthrough(req_op(rq));
+	return blk_op_is_passthrough(rq->cmd_flags);
 }
 
 static inline unsigned short req_get_ioprio(struct request *req)