summaryrefslogtreecommitdiffstats
path: root/block/blk-merge.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-06-06 06:29:02 -0400
committerJens Axboe <axboe@kernel.dk>2019-06-20 12:29:22 -0400
commite9cd19c0c198aa1c893e142b015fde6da862ed52 (patch)
tree323cfe08f79300ebe2fa72105e4c7f4d6d1c17d5 /block/blk-merge.c
parent14ccb66b3f585b2bc21e7256c96090abed5a512c (diff)
block: simplify blk_recalc_rq_segments
Return the segement and let the callers assign them, which makes the code a littler more obvious. Also pass the request instead of q plus bio chain, allowing for the use of rq_for_each_bvec. Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r--block/blk-merge.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 72b4fd89a22d..2ea21ffd5f72 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -310,17 +310,16 @@ void blk_queue_split(struct request_queue *q, struct bio **bio)
310} 310}
311EXPORT_SYMBOL(blk_queue_split); 311EXPORT_SYMBOL(blk_queue_split);
312 312
313static unsigned int __blk_recalc_rq_segments(struct request_queue *q, 313unsigned int blk_recalc_rq_segments(struct request *rq)
314 struct bio *bio)
315{ 314{
316 unsigned int nr_phys_segs = 0; 315 unsigned int nr_phys_segs = 0;
317 struct bvec_iter iter; 316 struct req_iterator iter;
318 struct bio_vec bv; 317 struct bio_vec bv;
319 318
320 if (!bio) 319 if (!rq->bio)
321 return 0; 320 return 0;
322 321
323 switch (bio_op(bio)) { 322 switch (bio_op(rq->bio)) {
324 case REQ_OP_DISCARD: 323 case REQ_OP_DISCARD:
325 case REQ_OP_SECURE_ERASE: 324 case REQ_OP_SECURE_ERASE:
326 case REQ_OP_WRITE_ZEROES: 325 case REQ_OP_WRITE_ZEROES:
@@ -329,19 +328,11 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
329 return 1; 328 return 1;
330 } 329 }
331 330
332 for_each_bio(bio) { 331 rq_for_each_bvec(bv, rq, iter)
333 bio_for_each_bvec(bv, bio, iter) 332 bvec_split_segs(rq->q, &bv, &nr_phys_segs, NULL, UINT_MAX);
334 bvec_split_segs(q, &bv, &nr_phys_segs, NULL, UINT_MAX);
335 }
336
337 return nr_phys_segs; 333 return nr_phys_segs;
338} 334}
339 335
340void blk_recalc_rq_segments(struct request *rq)
341{
342 rq->nr_phys_segments = __blk_recalc_rq_segments(rq->q, rq->bio);
343}
344
345static inline struct scatterlist *blk_next_sg(struct scatterlist **sg, 336static inline struct scatterlist *blk_next_sg(struct scatterlist **sg,
346 struct scatterlist *sglist) 337 struct scatterlist *sglist)
347{ 338{