mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* RE: DIRECT IO for ext3/ext2.
@ 2003-11-21 19:30 dhruv.anand
  2003-11-21 19:45 ` Andrew Morton
  2003-11-25  8:16 ` Michael Kerrisk
  0 siblings, 2 replies; 5+ messages in thread
From: dhruv.anand @ 2003-11-21 19:30 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Hi Andrew,

Thanks for your reply. I looked into the boundary alignment issue. 
Observed something strange happening;

I wrote my own kernel module and then;
1. retrieved the block size = 4096 using block_size(struct block_device
*bdev) 
2. in the user application i did a lseek by 4906 (block size seek) 
3. then found the address of the variable i wanted to read into, to be
block 
   size aligned.

However, the read still seems to fail with the O_DIRECT flag specified. 
The same check _passes if i do not specify the flag in open of the
device.

Boundary issues seem to be not the cause of failure here.
Would have any more kind suggestions on something that i should do or
could be missing on?

Regards
Dhruv

>>-----Original Message-----
>>From: Andrew Morton [mailto:akpm@osdl.org] 
>>Sent: Friday, November 21, 2003 11:11 PM
>>To: Dhruv Prem Anand (WT01 - EMBEDDED & PRODUCT ENGINEERING SOLUTIONS)
>>Cc: linux-kernel@vger.kernel.org; akpm@zip.com.au; 
>>janetinc@us.ibm.com; pbadari@us.ibm.com; nathans@sgi.com
>>Subject: Re: DIRECT IO for ext3/ext2.
>>
>>
>><dhruv.anand@wipro.com> wrote:
>>>
>>> 
>>> Hi,
>>> I am working on an application on linux-2.6 that needs to 
>>bypass the 
>>> buffer cache. In order to do so i use the direct IO functionality. 
>>> Although open to the device succeeds with the DIRECT_IO flag, read 
>>> from the device fails.
>>> 
>>> Following is the exceprt fromt he code to open and read;
>>> --------------------------------------------------------
>>> 
>>> if ((devf = open(dumpdev, O_RDONLY | O_DIRECT, 0)) < 0) {
>>>      fprintf(KL_ERRORFP, "Error: open failed!\n");
>>>      ...
>>> }
>>> 
>>> if(err = read(devf, &magic_nr, sizeof(magic_nr)) != 
>>sizeof(magic_nr)) {
>>>      fprintf(KL_ERRORFP, "Error: read() failed!\n");
>>>       ...
>>> }
>>> 
>>> ---------------------------------------------------------
>>> I am returned an errno=22, indicating 'Invalid argument'
>>> 
>>
>>O_DIRECT reads must be aligned to the filesystem blocksize.  
>>Both the memory address and the file offset must be thus aligned.
>>
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread
* DIRECT IO for ext3/ext2.
@ 2003-11-21 15:53 dhruv.anand
  2003-11-21 17:40 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: dhruv.anand @ 2003-11-21 15:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, janetinc, akpm, pbadari, nathans

Hi,
I am working on an application on linux-2.6 that needs to
bypass the buffer cache. In order to do so i use the direct
IO functionality. Although open to the device succeeds with
the DIRECT_IO flag, read from the device fails.

Following is the exceprt fromt he code to open and read;
--------------------------------------------------------

if ((devf = open(dumpdev, O_RDONLY | O_DIRECT, 0)) < 0) {
     fprintf(KL_ERRORFP, "Error: open failed!\n");
     ...
}

if(err = read(devf, &magic_nr, sizeof(magic_nr)) != sizeof(magic_nr)) {
     fprintf(KL_ERRORFP, "Error: read() failed!\n");
      ...
}

---------------------------------------------------------
I am returned an errno=22, indicating 'Invalid argument'

I would appreciate it, if you could knowledge me importantly about
the completeness of the 'direct IO' functionality in ext3 file-system.
Or if i am doing something wrong in usage?


Regards
Dhruv.

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

end of thread, other threads:[~2003-11-25  8:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-21 19:30 DIRECT IO for ext3/ext2 dhruv.anand
2003-11-21 19:45 ` Andrew Morton
2003-11-25  8:16 ` Michael Kerrisk
  -- strict thread matches above, loose matches on Subject: below --
2003-11-21 15:53 dhruv.anand
2003-11-21 17:40 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®