block: use memcpy_from_bvec in __blk_queue_bounce
Rewrite the actual bounce buffering loop in __blk_queue_bounce to that the memcpy_to_bvec helper can be used to perform the data copies. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Link: https://lore.kernel.org/r/20210727055646.118787-14-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
d24920e20c
commit
4aebe8596a
@@ -239,24 +239,19 @@ void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig)
|
|||||||
* because the 'bio' is single-page bvec.
|
* because the 'bio' is single-page bvec.
|
||||||
*/
|
*/
|
||||||
for (i = 0, to = bio->bi_io_vec; i < bio->bi_vcnt; to++, i++) {
|
for (i = 0, to = bio->bi_io_vec; i < bio->bi_vcnt; to++, i++) {
|
||||||
struct page *page = to->bv_page;
|
struct page *bounce_page;
|
||||||
|
|
||||||
if (!PageHighMem(page))
|
if (!PageHighMem(to->bv_page))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
to->bv_page = mempool_alloc(&page_pool, GFP_NOIO);
|
bounce_page = mempool_alloc(&page_pool, GFP_NOIO);
|
||||||
inc_zone_page_state(to->bv_page, NR_BOUNCE);
|
inc_zone_page_state(bounce_page, NR_BOUNCE);
|
||||||
|
|
||||||
if (rw == WRITE) {
|
if (rw == WRITE) {
|
||||||
char *vto, *vfrom;
|
flush_dcache_page(to->bv_page);
|
||||||
|
memcpy_from_bvec(page_address(bounce_page), to);
|
||||||
flush_dcache_page(page);
|
|
||||||
|
|
||||||
vto = page_address(to->bv_page) + to->bv_offset;
|
|
||||||
vfrom = kmap_atomic(page) + to->bv_offset;
|
|
||||||
memcpy(vto, vfrom, to->bv_len);
|
|
||||||
kunmap_atomic(vfrom);
|
|
||||||
}
|
}
|
||||||
|
to->bv_page = bounce_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_block_bio_bounce(*bio_orig);
|
trace_block_bio_bounce(*bio_orig);
|
||||||
|
|||||||
Reference in New Issue
Block a user