]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
block: req->bio is always set in the merge code
authorChristoph Hellwig <hch@lst.de>
Tue, 19 Nov 2024 16:11:51 +0000 (17:11 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 20 Nov 2024 02:06:57 +0000 (19:06 -0700)
As smatch, which is a lot smarter than me noticed.  So remove the checks
for it, and condense these checks a bit including the comments stating
the obvious.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20241119161157.1328171-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-merge.c

index 64860cbd5e2780a31c20118ab594aac234ebfc0c..e01383c6e534b0a27a0db8c45d98a2a14d9ec69a 100644 (file)
@@ -864,14 +864,10 @@ static struct request *attempt_merge(struct request_queue *q,
        if (req_op(req) != req_op(next))
                return NULL;
 
-       if (req->bio && next->bio) {
-               /* Don't merge requests with different write hints. */
-               if (req->bio->bi_write_hint != next->bio->bi_write_hint)
-                       return NULL;
-               if (req->bio->bi_ioprio != next->bio->bi_ioprio)
-                       return NULL;
-       }
-
+       if (req->bio->bi_write_hint != next->bio->bi_write_hint)
+               return NULL;
+       if (req->bio->bi_ioprio != next->bio->bi_ioprio)
+               return NULL;
        if (!blk_atomic_write_mergeable_rqs(req, next))
                return NULL;
 
@@ -983,26 +979,16 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
        if (req_op(rq) != bio_op(bio))
                return false;
 
-       /* don't merge across cgroup boundaries */
        if (!blk_cgroup_mergeable(rq, bio))
                return false;
-
-       /* only merge integrity protected bio into ditto rq */
        if (blk_integrity_merge_bio(rq->q, rq, bio) == false)
                return false;
-
-       /* Only merge if the crypt contexts are compatible */
        if (!bio_crypt_rq_ctx_compatible(rq, bio))
                return false;
-
-       if (rq->bio) {
-               /* Don't merge requests with different write hints. */
-               if (rq->bio->bi_write_hint != bio->bi_write_hint)
-                       return false;
-               if (rq->bio->bi_ioprio != bio->bi_ioprio)
-                       return false;
-       }
-
+       if (rq->bio->bi_write_hint != bio->bi_write_hint)
+               return false;
+       if (rq->bio->bi_ioprio != bio->bi_ioprio)
+               return false;
        if (blk_atomic_write_mergeable_rq_bio(rq, bio) == false)
                return false;