[lkml]   [2003]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRE: DIRECT IO for ext3/ext2.
    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
    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
    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

    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?


    >>-----Original Message-----
    >>From: Andrew Morton []
    >>Sent: Friday, November 21, 2003 11:11 PM
    >>Subject: Re: DIRECT IO for ext3/ext2.
    >><> 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.
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:58    [W:0.025 / U:25.964 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site