Skip to content

Commit 81314bf

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: req->bio is always set in the merge code
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>
1 parent 9f8d682 commit 81314bf

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

block/blk-merge.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -864,14 +864,10 @@ static struct request *attempt_merge(struct request_queue *q,
864864
if (req_op(req) != req_op(next))
865865
return NULL;
866866

867-
if (req->bio && next->bio) {
868-
/* Don't merge requests with different write hints. */
869-
if (req->bio->bi_write_hint != next->bio->bi_write_hint)
870-
return NULL;
871-
if (req->bio->bi_ioprio != next->bio->bi_ioprio)
872-
return NULL;
873-
}
874-
867+
if (req->bio->bi_write_hint != next->bio->bi_write_hint)
868+
return NULL;
869+
if (req->bio->bi_ioprio != next->bio->bi_ioprio)
870+
return NULL;
875871
if (!blk_atomic_write_mergeable_rqs(req, next))
876872
return NULL;
877873

@@ -983,26 +979,16 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
983979
if (req_op(rq) != bio_op(bio))
984980
return false;
985981

986-
/* don't merge across cgroup boundaries */
987982
if (!blk_cgroup_mergeable(rq, bio))
988983
return false;
989-
990-
/* only merge integrity protected bio into ditto rq */
991984
if (blk_integrity_merge_bio(rq->q, rq, bio) == false)
992985
return false;
993-
994-
/* Only merge if the crypt contexts are compatible */
995986
if (!bio_crypt_rq_ctx_compatible(rq, bio))
996987
return false;
997-
998-
if (rq->bio) {
999-
/* Don't merge requests with different write hints. */
1000-
if (rq->bio->bi_write_hint != bio->bi_write_hint)
1001-
return false;
1002-
if (rq->bio->bi_ioprio != bio->bi_ioprio)
1003-
return false;
1004-
}
1005-
988+
if (rq->bio->bi_write_hint != bio->bi_write_hint)
989+
return false;
990+
if (rq->bio->bi_ioprio != bio->bi_ioprio)
991+
return false;
1006992
if (blk_atomic_write_mergeable_rq_bio(rq, bio) == false)
1007993
return false;
1008994

0 commit comments

Comments
 (0)