Skip to content

Commit

Permalink
block: set FOLL_PCI_P2PDMA in bio_map_user_iov()
Browse files Browse the repository at this point in the history
When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for
iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be
passed from userspace and enables the NVMe passthru requests to
use P2PDMA pages.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
  • Loading branch information
lsgunth committed Sep 7, 2022
1 parent 59e0a21 commit d931dbb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion block/blk-map.c
Expand Up @@ -236,6 +236,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
{
unsigned int max_sectors = queue_max_hw_sectors(rq->q);
unsigned int nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS);
unsigned int gup_flags = 0;
struct bio *bio;
int ret;
int j;
Expand All @@ -248,13 +249,17 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
return -ENOMEM;
bio_init(bio, NULL, bio->bi_inline_vecs, nr_vecs, req_op(rq));

if (blk_queue_pci_p2pdma(rq->q))
gup_flags |= FOLL_PCI_P2PDMA;

while (iov_iter_count(iter)) {
struct page **pages;
ssize_t bytes;
size_t offs, added = 0;
int npages;

bytes = iov_iter_get_pages_alloc2(iter, &pages, LONG_MAX, &offs);
bytes = iov_iter_get_pages_alloc_flags(iter, &pages, LONG_MAX,
&offs, gup_flags);
if (unlikely(bytes <= 0)) {
ret = bytes ? bytes : -EFAULT;
goto out_unmap;
Expand Down

0 comments on commit d931dbb

Please sign in to comment.