diff mbox series

[v11,6/9] block: set FOLL_PCI_P2PDMA in __bio_iov_iter_get_pages()

Message ID 20221021174116.7200-7-logang@deltatee.com (mailing list archive)
State New, archived
Headers show
Series Userspace P2PDMA with O_DIRECT NVMe devices | expand

Commit Message

Logan Gunthorpe Oct. 21, 2022, 5:41 p.m. UTC
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 O_DIRECT path in iomap based filesystems
and direct to block devices.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
---
 block/bio.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Chaitanya Kulkarni Oct. 25, 2022, 1:23 a.m. UTC | #1
/*
>   	 * Each segment in the iov is required to be a block size multiple.
>   	 * However, we may not be able to get the entire segment if it spans
> @@ -1217,8 +1221,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
>   	 * result to ensure the bio's total size is correct. The remainder of
>   	 * the iov data will be picked up in the next bio iteration.
>   	 */
> -	size = iov_iter_get_pages2(iter, pages, UINT_MAX - bio->bi_iter.bi_size,
> -				  nr_pages, &offset);
> +	size = iov_iter_get_pages(iter, pages,
> +				  UINT_MAX - bio->bi_iter.bi_size,
> +				  nr_pages, &offset, gup_flags);

nit, 3rd param in above call fits on the first line ? plz check :-

iov_iter_get_pages(iter, pages, UINT_MAX - bio->bi_iter.bi_size,
                    nr_pages, &offset, gup_flags);

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Chaitanya Kulkarni Oct. 25, 2022, 1:25 a.m. UTC | #2
* Each segment in the iov is required to be a block size multiple.
>   	 * However, we may not be able to get the entire segment if it spans
> @@ -1217,8 +1221,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
>   	 * result to ensure the bio's total size is correct. The remainder of
>   	 * the iov data will be picked up in the next bio iteration.
>   	 */
> -	size = iov_iter_get_pages2(iter, pages, UINT_MAX - bio->bi_iter.bi_size,
> -				  nr_pages, &offset);
> +	size = iov_iter_get_pages(iter, pages,
> +				  UINT_MAX - bio->bi_iter.bi_size,
> +				  nr_pages, &offset, gup_flags);

nit:-
3rd parameter in the above call fits on the 1st line? plz check

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Logan Gunthorpe Oct. 25, 2022, 3:37 p.m. UTC | #3
On 2022-10-24 19:23, Chaitanya Kulkarni wrote:
> /*
>>   	 * Each segment in the iov is required to be a block size multiple.
>>   	 * However, we may not be able to get the entire segment if it spans
>> @@ -1217,8 +1221,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
>>   	 * result to ensure the bio's total size is correct. The remainder of
>>   	 * the iov data will be picked up in the next bio iteration.
>>   	 */
>> -	size = iov_iter_get_pages2(iter, pages, UINT_MAX - bio->bi_iter.bi_size,
>> -				  nr_pages, &offset);
>> +	size = iov_iter_get_pages(iter, pages,
>> +				  UINT_MAX - bio->bi_iter.bi_size,
>> +				  nr_pages, &offset, gup_flags);
> 
> nit, 3rd param in above call fits on the first line ? plz check :-
> 
> iov_iter_get_pages(iter, pages, UINT_MAX - bio->bi_iter.bi_size,
>                     nr_pages, &offset, gup_flags);

Oh, yup, this just fits. I'll queue up the fix for if I send v12.

Logan
diff mbox series

Patch

diff --git a/block/bio.c b/block/bio.c
index 439469370b7c..a7abf9b1b66a 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1197,6 +1197,7 @@  static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 	unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt;
 	struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt;
 	struct page **pages = (struct page **)bv;
+	unsigned int gup_flags = 0;
 	ssize_t size, left;
 	unsigned len, i = 0;
 	size_t offset, trim;
@@ -1210,6 +1211,9 @@  static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 	BUILD_BUG_ON(PAGE_PTRS_PER_BVEC < 2);
 	pages += entries_left * (PAGE_PTRS_PER_BVEC - 1);
 
+	if (bio->bi_bdev && blk_queue_pci_p2pdma(bio->bi_bdev->bd_disk->queue))
+		gup_flags |= FOLL_PCI_P2PDMA;
+
 	/*
 	 * Each segment in the iov is required to be a block size multiple.
 	 * However, we may not be able to get the entire segment if it spans
@@ -1217,8 +1221,9 @@  static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 	 * result to ensure the bio's total size is correct. The remainder of
 	 * the iov data will be picked up in the next bio iteration.
 	 */
-	size = iov_iter_get_pages2(iter, pages, UINT_MAX - bio->bi_iter.bi_size,
-				  nr_pages, &offset);
+	size = iov_iter_get_pages(iter, pages,
+				  UINT_MAX - bio->bi_iter.bi_size,
+				  nr_pages, &offset, gup_flags);
 	if (unlikely(size <= 0))
 		return size ? size : -EFAULT;