Direct I/O questions

  • From: "Kramer, James P." <james.p.kramer@xxxxxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Wed, 8 Dec 2004 14:58:56 -0600

> First things first, this isn't an oracle question but rather a series =
of questions based on a previous message on the oracle-l list.  If you =
think I should post it on a different list please let me know which one.
> The message I am talking about can be found here.
> Also, I am new to the Linux world (just thought I'd let you know what =
kind of a guy your dealing with...newbie).
> Here is the following information about our Linux server.
> We are running SUSE LINUX Enterprise Server 9.  From the files located =
in /usr/src, the version is 2.6.5-7.97.  I'm not sure how else to get =
the version.
> There are 8 IA64 processors.
> I have been researching ways to get direct I/O to work on our Linux =
machine when I stumbled across the above message.  Within the message =
was a small code example that tested direct I/O.  I tried this code out =
to see if it would work.  I could not get the code to compile as is.  =
With some modifying (changed the headers), I was able to get it to =
compile but the direct I/O read kept giving me EINVAL (Invalid =
> Here is the modified code that I used.
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <errno.h>
> #include <string.h>
> #include <fcntl.h>
> #include <unistd.h>
> #define BUFFSIZE 65536
> #define ALIGN    4096
> int main()=20
> {=20
>    char  *buff;
>    int stat1=3D0,stat2=3D0,stat3=3D0;
>    int fd1=3D0,fd2=3D0;
>    if (stat3=3Dposix_memalign((void **)&buff,ALIGN,BUFFSIZE)) {
>       fprintf(stderr,"ALIGN ERR:%s\n",strerror(stat3));
>       exit(0);
>    }
>    fd1=3Dopen("/home/rrd/workspace/IORead.txt", =
>    =
>    while(stat1=3Dread(fd1,buff,BUFFSIZE)) {
>          if (errno) {
>             fprintf(stderr,"READ ERR:%s\n",strerror(errno));
>             exit(0);
>          }
>          stat2=3Dwrite(fd2,buff,(unsigned) stat1);
>          if (errno) {
>             fprintf(stderr,"WRITE ERR:%s\n",strerror(errno));
>             exit(0);
>          }
>    }
>    close(fd1);
>    close(fd2);
>   =20
>    return 0;
> }
> Also, is there a programmatic way of retrieving the alignment and =
block size?  I have seen the fcntl call for F_DIOINFO.  However, I have =
read articles that Linux doesn't have this.  Instead one must use ioctl =
with XFS_IOC_DIOINFO.  When I do a search in /usr/, the only *DIOINFO =
that I find is in xfs_fs.h.  When I try calling this function, I get an =
error and from what I gather it is because the file doesn't support this =
type of ioctl.  Does this mean I am missing some feature?
> I have been searching Google about direct I/O and have come across =
countless articles that seem to contradict one another.  Some articles =
say that Linux doesn't support O_DIRECT and that you need to convert =
your file system to XFS and use those libraries.  Others say it does =
support it.  From the example above it seems it doesn't support it.  =
What must be done to the file system (if anything) to get direct I/O to =
work?  Do I need to convert to XFS?
> Could it be that I'm using the wrong libraries?  How can I find out =
what libraries it is using?
> Is there anything I should look at on the server to make sure I have =
the most up-to-date stuff?  Any other ideas on how I should proceed?
> Any help would greatly be appreciated.
> James Kramer
PROPRIETARY MATERIAL and is thus for use only by the intended recipient. =
If you received this in error, please contact the sender and delete the =
e-mail and its attachments from all computers.=20

Other related posts: