linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* O_DIRECT for block device
@ 2005-09-22  8:21 Karthik Sarangan
  2005-09-22  8:34 ` Avi Kivity
  2005-09-22  8:40 ` Joel Becker
  0 siblings, 2 replies; 4+ messages in thread
From: Karthik Sarangan @ 2005-09-22  8:21 UTC (permalink / raw)
  To: linux-kernel

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: O_DIRECT for block device
  2005-09-22  8:21 O_DIRECT for block device Karthik Sarangan
@ 2005-09-22  8:34 ` Avi Kivity
  2005-09-22  8:40 ` Joel Becker
  1 sibling, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2005-09-22  8:34 UTC (permalink / raw)
  To: Karthik Sarangan; +Cc: linux-kernel

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: O_DIRECT for block device
  2005-09-22  8:21 O_DIRECT for block device Karthik Sarangan
  2005-09-22  8:34 ` Avi Kivity
@ 2005-09-22  8:40 ` Joel Becker
       [not found]   ` <43329590.3050006@cdac.in>
  1 sibling, 1 reply; 4+ messages in thread
From: Joel Becker @ 2005-09-22  8:40 UTC (permalink / raw)
  To: Karthik Sarangan; +Cc: linux-kernel

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: joel.becker@oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: O_DIRECT for block device
       [not found]     ` <20050922152028.GJ27375@ca-server1.us.oracle.com>
@ 2005-09-23  5:36       ` Karthik Sarangan
  0 siblings, 0 replies; 4+ messages in thread
From: Karthik Sarangan @ 2005-09-23  5:36 UTC (permalink / raw)
  To: Joel Becker; +Cc: linux-kernel

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-09-23  5:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-22  8:21 O_DIRECT for block device Karthik Sarangan
2005-09-22  8:34 ` Avi Kivity
2005-09-22  8:40 ` Joel Becker
     [not found]   ` <43329590.3050006@cdac.in>
     [not found]     ` <20050922152028.GJ27375@ca-server1.us.oracle.com>
2005-09-23  5:36       ` Karthik Sarangan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).