Skip to content

Commit 05ceea5

Browse files
keithbuschaxboe
authored andcommitted
blk-integrity: enable p2p source and destination
Set the extraction flags to allow p2p pages for the metadata buffer if the block device allows it. Similar to data payloads, ensure the bio does not use merging if we see a p2p page. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b475272 commit 05ceea5

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

block/bio-integrity.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ static int bio_integrity_init_user(struct bio *bio, struct bio_vec *bvec,
230230
}
231231

232232
static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages,
233-
int nr_vecs, ssize_t bytes, ssize_t offset)
233+
int nr_vecs, ssize_t bytes, ssize_t offset,
234+
bool *is_p2p)
234235
{
235236
unsigned int nr_bvecs = 0;
236237
int i, j;
@@ -251,6 +252,9 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages,
251252
bytes -= next;
252253
}
253254

255+
if (is_pci_p2pdma_page(pages[i]))
256+
*is_p2p = true;
257+
254258
bvec_set_page(&bvec[nr_bvecs], pages[i], size, offset);
255259
offset = 0;
256260
nr_bvecs++;
@@ -264,10 +268,11 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
264268
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
265269
struct page *stack_pages[UIO_FASTIOV], **pages = stack_pages;
266270
struct bio_vec stack_vec[UIO_FASTIOV], *bvec = stack_vec;
271+
iov_iter_extraction_t extraction_flags = 0;
267272
size_t offset, bytes = iter->count;
273+
bool copy, is_p2p = false;
268274
unsigned int nr_bvecs;
269275
int ret, nr_vecs;
270-
bool copy;
271276

272277
if (bio_integrity(bio))
273278
return -EINVAL;
@@ -286,15 +291,23 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
286291

287292
copy = iov_iter_alignment(iter) &
288293
blk_lim_dma_alignment_and_pad(&q->limits);
289-
ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs, 0, &offset);
294+
295+
if (blk_queue_pci_p2pdma(q))
296+
extraction_flags |= ITER_ALLOW_P2PDMA;
297+
298+
ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs,
299+
extraction_flags, &offset);
290300
if (unlikely(ret < 0))
291301
goto free_bvec;
292302

293-
nr_bvecs = bvec_from_pages(bvec, pages, nr_vecs, bytes, offset);
303+
nr_bvecs = bvec_from_pages(bvec, pages, nr_vecs, bytes, offset,
304+
&is_p2p);
294305
if (pages != stack_pages)
295306
kvfree(pages);
296307
if (nr_bvecs > queue_max_integrity_segments(q))
297308
copy = true;
309+
if (is_p2p)
310+
bio->bi_opf |= REQ_NOMERGE;
298311

299312
if (copy)
300313
ret = bio_integrity_copy_user(bio, bvec, nr_bvecs, bytes);

0 commit comments

Comments
 (0)