I am trying to move data from a buffer in kernel space to a hard drive without the need to make additional copies from the kernel buffer to user buffers or any other kernel buffers. Any ideas / suggestions would be most helpful.
A use case is basically a demux driver that collects data in demux in kernel space, and this buffer should be emptied periodically by copying the contents to a FUSE-based partition on disk. As the buffer fills, a user process is transferred, which then determines the sector numbers on the disk whose contents must be copied to.
I was hoping to process the aforementioned demux kernel buffer into the user address and issue a write system call to the raw splitter. But from what I see, this data is cached by the kernel to its path to the hard disk driver. And so I assume that additional copies of the linux kernel.
At this point, I wonder if there is any other mechanism for this without involving additional copies by the kernel. I understand that this is an unusual usage scenario for non-embedded environments, but I would appreciate any feedback on possible options.
BTW - I tried to use O_DIRECT when opening an unprocessed partition, but the subsequent write call fails if the transmitted buffer is mmapped buffer.
Thanx!
source
share