Commit dcdca753 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: clean up __bio_add_pc_page a bit

Share the bi_size update by moving the done label up, and duplicate
the bv_len update in the two callers to get rid of the bvec_merge
label.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6601e44e
...@@ -731,9 +731,7 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio, ...@@ -731,9 +731,7 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
offset == bvec->bv_offset + bvec->bv_len) { offset == bvec->bv_offset + bvec->bv_len) {
if (put_same_page) if (put_same_page)
put_page(page); put_page(page);
bvec_merge:
bvec->bv_len += len; bvec->bv_len += len;
bio->bi_iter.bi_size += len;
goto done; goto done;
} }
...@@ -745,8 +743,10 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio, ...@@ -745,8 +743,10 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
return 0; return 0;
if (page_is_mergeable(bvec, page, len, offset, false) && if (page_is_mergeable(bvec, page, len, offset, false) &&
can_add_page_to_seg(q, bvec, page, len, offset)) can_add_page_to_seg(q, bvec, page, len, offset)) {
goto bvec_merge; bvec->bv_len += len;
goto done;
}
} }
if (bio_full(bio)) if (bio_full(bio))
...@@ -760,9 +760,8 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio, ...@@ -760,9 +760,8 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
bvec->bv_len = len; bvec->bv_len = len;
bvec->bv_offset = offset; bvec->bv_offset = offset;
bio->bi_vcnt++; bio->bi_vcnt++;
bio->bi_iter.bi_size += len;
done: done:
bio->bi_iter.bi_size += len;
bio->bi_phys_segments = bio->bi_vcnt; bio->bi_phys_segments = bio->bi_vcnt;
bio_set_flag(bio, BIO_SEG_VALID); bio_set_flag(bio, BIO_SEG_VALID);
return len; return len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment