O_DIRECT Inside Kernel Module?



I have written a target mode SCSI device driver that can use system memory
for high speed reads and writes. I would like to be able to back these
reads and writes up to a partition (I.E. to /dev/sdb1). I have been able to
do so inside the module by opening the specified device and then I can
simply read and write to it. However, standard reads and writes are cached
and not immediately written to the hard drive and really spike CPU
utilization. O_DIRECT has served me in the past as a way to read or write
directly to a block level device, but I am getting an EFAULT (error 14 aka
Bad Address) when I attempt this from a kernel module. I have verified that
my I/O size is sector size and that my I/O's are aligned and a multiple of
sector size, so this is not the problem. Also, I used the same code in user
space and could read and write without incident.

Does anyone know why this might be happening, or any possible workarounds
for such a task?

Thanks,

-Jay


.