[PATCHv3 2/7] file: add ops to dma map bvec
Matthew Wilcox
willy at infradead.org
Sun Aug 7 18:13:41 PDT 2022
On Mon, Aug 08, 2022 at 10:21:24AM +1000, Dave Chinner wrote:
> > +#ifdef CONFIG_HAS_DMA
> > + void *(*dma_map)(struct file *, struct bio_vec *, int);
> > + void (*dma_unmap)(struct file *, void *);
> > +#endif
>
> This just smells wrong. Using a block layer specific construct as a
> primary file operation parameter shouts "layering violation" to me.
A bio_vec is also used for networking; it's in disguise as an skb_frag,
but it's there.
> What we really need is a callout that returns the bdevs that the
> struct file is mapped to (one, or many), so the caller can then map
> the memory addresses to the block devices itself. The caller then
> needs to do an {file, offset, len} -> {bdev, sector, count}
> translation so the io_uring code can then use the correct bdev and
> dma mappings for the file offset that the user is doing IO to/from.
I don't even know if what you're proposing is possible. Consider a
network filesystem which might transparently be moved from one network
interface to another. I don't even know if the filesystem would know
which network device is going to be used for the IO at the time of
IO submission.
I think a totally different model is needed where we can find out if
the bvec contains pages which are already mapped to the device, and map
them if they aren't. That also handles a DM case where extra devices
are hot-added to a RAID, for example.
More information about the Linux-nvme
mailing list