On Thu, Aug 28, 2025 at 04:18:20PM -0300, Jason Gunthorpe wrote:
> On Thu, Aug 28, 2025 at 01:10:32PM -0600, Keith Busch wrote:
> > 
> > Data and metadata are mapped as separate operations. They're just
> > different parts of one blk-mq request.
> 
> In that case the new bit leon proposes should only be used for the
> unmap of the data pages and the metadata unmap should always be
> unmapped as CPU?

The common path uses host allocated memory to attach integrity metadata,
but that isn't the only path. A user can attach their own metadata with
nvme passthrough or the recent io_uring application metadata, and that
could have been allocated from anywhere.

In truth though, I hadn't tried p2p metadata before today, and it looks
like bio_integrity_map_user() is missing the P2P extraction flags to
make that work. Just added this patch below, now I can set p2p or host
memory independently for data and integrity payloads:

---
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 6b077ca937f6b..cf45603e378d5 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -265,6 +265,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter 
*iter)
        unsigned int align = blk_lim_dma_alignment_and_pad(&q->limits);
        struct page *stack_pages[UIO_FASTIOV], **pages = stack_pages;
        struct bio_vec stack_vec[UIO_FASTIOV], *bvec = stack_vec;
+       iov_iter_extraction_t extraction_flags = 0;
        size_t offset, bytes = iter->count;
        unsigned int nr_bvecs;
        int ret, nr_vecs;
@@ -286,7 +287,12 @@ int bio_integrity_map_user(struct bio *bio, struct 
iov_iter *iter)
        }
 
        copy = !iov_iter_is_aligned(iter, align, align);
-       ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs, 0, &offset);
+
+       if (blk_queue_pci_p2pdma(q))
+               extraction_flags |= ITER_ALLOW_P2PDMA;
+
+       ret = iov_iter_extract_pages(iter, &pages, bytes, nr_vecs,
+                                       extraction_flags, &offset);
        if (unlikely(ret < 0))
                goto free_bvec;
 
--

Reply via email to