direct-to-BIO for O_DIRECT
Quoted 9 lines · Ingo Oeser
Quoted 8 lines · Andrew Morton
Question is: what do we want to do with this sucker? These are the remaining users of kiovecs:
drivers/md/lvm-snap.c
drivers/media/video/video-buf.c
drivers/mtd/devices/blkmtd.c
drivers/scsi/sg.c
Quoted 5 lines
Quoted 3 lines
the video and mtd drivers seems to be fairly easy to de-kiobufize. I'm aware of one proprietary driver which uses kiobufs. XFS uses kiobufs a little bit - just to map the pages.
It would be nice if we could just map a set of user pages to a scatterlist.
After disabling kiobufs in sg I would like such a drop in replacement.
Quoted 2 lines
Developers of mass transfer devices (video grabbers, dsp devices, sg and many others) would just LOVE you for this ;-)
Agreed. Tape devices could be added to your list. Large page support will make for very efficient zero copy IO.
Quoted 6 lines
Block devices are the common case worth optimizing for, but character devices just need to reimplement most of this, if they want the same optimizations. Some devices need mass transfers and are NOT blockdevices.
Please consider supporting them better for 2.5 in stuff similiar to BIOs and DMA to/from user pages.
CIOs?
Doug Gilbert
Quoted 12 lines · Douglas Gilbert
Quoted 9 lines · Ingo Oeser
Quoted 8 lines · Andrew Morton
Question is: what do we want to do with this sucker? These are the remaining users of kiovecs:
drivers/md/lvm-snap.c
drivers/media/video/video-buf.c
drivers/mtd/devices/blkmtd.c
drivers/scsi/sg.c
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
the video and mtd drivers seems to be fairly easy to de-kiobufize. I'm aware of one proprietary driver which uses kiobufs. XFS uses kiobufs a little bit - just to map the pages.
It would be nice if we could just map a set of user pages to a scatterlist.
After disabling kiobufs in sg I would like such a drop in replacement.
Ben had lightweight sg structures called kvecs' and kveclets'. And library functions to map pages into them. And code to attach them to BIOs. So we'll be looking at getting that happening.
The other common requirement (used in several places in the kernel, and in LVM2) is the ability to perform bulk I/O against a blockdev - simply read and write a chunk of disk into a list of kernel pages. So we'll need a
library function for that. And the O_DIRECT/raw implementation can be bent
around to use those things.
Quoted 6 lines
Quoted 2 lines
Developers of mass transfer devices (video grabbers, dsp devices, sg and many others) would just LOVE you for this ;-)
Agreed. Tape devices could be added to your list. Large page support will make for very efficient zero copy IO.
Haven't thought about large pages. We don't seem to have an implementation of them yet, and I'm not sure how the DMA mapping API would get along with them.
-
Quoted 9 lines · Andrew Morton
Quoted 5 lines
Quoted 2 lines
It would be nice if we could just map a set of user pages to a scatterlist.
After disabling kiobufs in sg I would like such a drop in replacement.
Ben had lightweight sg structures called
kvecs' andkveclets'. And library functions to map pages into them. And code to attach them to BIOs. So we'll be looking at getting that happening.
BIOs are for BLOCK devices we want sth. like this for CHARACTER devices.
I just want sth. along the lines of this:
/* Pin down (COMPLETE!) user pages and put them into a scatter gather list */ int sg_map_user_pages(struct scatterlist *sgl, const unsigned int nr_pages,
unsigned long uaddr, int rw) {
int res, i;
struct page *pages[nr_pages];
down_read(¤t->mm->mmap_sem);
res = get_user_pages(
current,
current->mm,
uaddr,
nr_pages,
rw == READ, /* logic is perversed^Wreversed here :-( */
0, /* don't force */
&pages[0],
NULL);
up_read(¤t->mm->mmap_sem);
/* Errors and no page mapped should return here */
if (res <= 0) return res;
for (i=1; i < res; i++) {
sgl[i].page = pages[i];
}
return res;
}/* And unmap them... */
int sg_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages) {
int i;
for (i=0; i < nr_pages; i++)
page_cache_release(sgl[i].page);
return 0;
}Possibly more complicated and less error prone, but you get the idea ;-)
Regards
Ingo Oeser
Signature · 1 line
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth
Quoted 3 lines · Andrew Morton
Ben had lightweight sg structures called
kvecs' andkveclets'. And library functions to map pages into them. And code to attach them to BIOs. So we'll be looking at getting that happening.
Ok, I've looked at them and they don't help me at all.
A user, who splits its IO into single pages, wants to do DMA and needs bus addresses for that. So he needs "struct scatterlist".
If one doesn't need to DMA, one can do copy_{from,to}_user directly with an immediate buffer, so the splitup isn't needed.
For this I conclude, that using the EXISTING 'struct scatterlist' will be enough for both. Attaching a vector of these to the BIOs is no problem. Neither it is for CHARACTER device IOs (CIOs).
So by using this simple abstraction we MIGHT waste only 4-8 bytes per page submitted, but by page-splitting the IO only for devices, that need DMA (e.g. make the request that explicitly) we don't really waste it and support BIOs and CIOs the same way.
I will refine that code for my own uses anyway, so if nobody with more clues about IO than me implements it, I will submit it later.
Regards
Ingo Oeser
Signature · 1 line
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth
Quoted 3 lines · Andrew Morton
Ben had lightweight sg structures called
kvecs' andkveclets'. And library functions to map pages into them. And code to attach them to BIOs. So we'll be looking at getting that happening.
And as I recall, a grand plan was hatched at the kernel summit to slice and dice all the various forms of block IO into that model.
Seeing -> believing
Signature · 1 line
Daniel