I have a scsi hdd configured at /dev/sdb.
open("/dev/sdb", O_DIRECT) succeeds.
A 'read' or 'write' returns -1 and errno is EINVAL.
How to read and write data to it? They do not seem to work. I have a
262144 byte buffer for data transfer.
My kernel is 2.6.9-11 and I use RedHat Enterprise Linux.
Karthik Sarangan wrote:
> I have a scsi hdd configured at /dev/sdb.
>
> open("/dev/sdb", O_DIRECT) succeeds.
> A 'read' or 'write' returns -1 and errno is EINVAL.
>
> How to read and write data to it? They do not seem to work. I have a
> 262144 byte buffer for data transfer.
make sure your buffer is aligned on a 512 byte boundary.
On Thu, Sep 22, 2005 at 01:51:16PM +0530, Karthik Sarangan wrote:
> open("/dev/sdb", O_DIRECT) succeeds.
> A 'read' or 'write' returns -1 and errno is EINVAL.
You must align your buffer to at least sector size. See
posix_memalign(3).
--
Life's Little Instruction Book #30
"Never buy a house without a fireplace."
Joel Becker
Principal Software Developer
Oracle
E-mail: [email protected]
Phone: (650) 506-8127
Joel Becker wrote:
> On Thu, Sep 22, 2005 at 04:59:20PM +0530, Karthik Sarangan wrote:
>
>>I tried your tip and the read works beautifully but the write returns -1
>>and errno = EBADF!
>
>
> Did you open with O_RDWR?
>
> Joel
>
Alright I didn't, though using O_DIRECT | O_RDWR the second time solved
it :-) I finally got 69MBps read and 49 MBps writes on my SCSI disk.
Thanks for helping me out.