aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2019-08-01 18:50:42 -0400
committerJens Axboe <axboe@kernel.dk>2019-08-04 23:41:29 -0400
commitff9811b3cf2092fe6c39cf694e5e7f949f3b2c16 (patch)
treef61263180210bb5edf1294aa76ef37669928453b /block
parentdad7758459bc6097115f5e783eda232f36b1ad99 (diff)
block: Simplify bvec_split_segs()
Simplify this function by by removing two if-tests. Other than requiring that the @sectors pointer is not NULL, this patch does not change the behavior of bvec_split_segs(). Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Cc: Christoph Hellwig <hch@lst.de> Cc: Ming Lei <ming.lei@redhat.com> Cc: Hannes Reinecke <hare@suse.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-merge.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 51ed971709c3..7cea5050bbcf 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -167,17 +167,17 @@ static bool bvec_split_segs(const struct request_queue *q,
167{ 167{
168 unsigned len = bv->bv_len; 168 unsigned len = bv->bv_len;
169 unsigned total_len = 0; 169 unsigned total_len = 0;
170 unsigned new_nsegs = 0, seg_size = 0; 170 unsigned seg_size = 0;
171 171
172 /* 172 /*
173 * Multi-page bvec may be too big to hold in one segment, so the 173 * Multi-page bvec may be too big to hold in one segment, so the
174 * current bvec has to be splitted as multiple segments. 174 * current bvec has to be splitted as multiple segments.
175 */ 175 */
176 while (len && new_nsegs + *nsegs < max_segs) { 176 while (len && *nsegs < max_segs) {
177 seg_size = get_max_segment_size(q, bv->bv_offset + total_len); 177 seg_size = get_max_segment_size(q, bv->bv_offset + total_len);
178 seg_size = min(seg_size, len); 178 seg_size = min(seg_size, len);
179 179
180 new_nsegs++; 180 (*nsegs)++;
181 total_len += seg_size; 181 total_len += seg_size;
182 len -= seg_size; 182 len -= seg_size;
183 183
@@ -185,11 +185,7 @@ static bool bvec_split_segs(const struct request_queue *q,
185 break; 185 break;
186 } 186 }
187 187
188 if (new_nsegs) { 188 *sectors += total_len >> 9;
189 *nsegs += new_nsegs;
190 if (sectors)
191 *sectors += total_len >> 9;
192 }
193 189
194 /* split in the middle of the bvec if len != 0 */ 190 /* split in the middle of the bvec if len != 0 */
195 return !!len; 191 return !!len;
@@ -349,6 +345,7 @@ EXPORT_SYMBOL(blk_queue_split);
349unsigned int blk_recalc_rq_segments(struct request *rq) 345unsigned int blk_recalc_rq_segments(struct request *rq)
350{ 346{
351 unsigned int nr_phys_segs = 0; 347 unsigned int nr_phys_segs = 0;
348 unsigned int nr_sectors = 0;
352 struct req_iterator iter; 349 struct req_iterator iter;
353 struct bio_vec bv; 350 struct bio_vec bv;
354 351
@@ -365,7 +362,8 @@ unsigned int blk_recalc_rq_segments(struct request *rq)
365 } 362 }
366 363
367 rq_for_each_bvec(bv, rq, iter) 364 rq_for_each_bvec(bv, rq, iter)
368 bvec_split_segs(rq->q, &bv, &nr_phys_segs, NULL, UINT_MAX); 365 bvec_split_segs(rq->q, &bv, &nr_phys_segs, &nr_sectors,
366 UINT_MAX);
369 return nr_phys_segs; 367 return nr_phys_segs;
370} 368}
371 369