Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Direct I/O questions

RE: Direct I/O questions

From: Kramer, James P. <james.p.kramer_at_unisys.com>
Date: Wed, 15 Dec 2004 16:31:05 -0600
Message-ID: <19D0D50E9B1D0A40A9F0323DBFA04ACC15B4ED@USRV-EXCH4.na.uis.unisys.com>


I was able to get this code to work on my server. I want to thank = everyone who helped out with this. It is a great relief.

James Kramer

THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE 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

-----Original Message-----
From: Magni Fabrizio [mailto:Fabrizio.Magni_at_rasnet.it] Sent: Monday, December 13, 2004 9:19 AM
To: Kramer, James P.; oracle-l_at_freelists.org Subject: RE: Direct I/O questions

Hello James,
eventually I was able to make O_DIRECT work even on x86_64 (kernel 2.6.5-7.97-smp and 2.6.9 vanilla).
Unfortunately I haven't got any itanium where to test it.

I had to create a file named xxx in the same directory of the executable with:

dd if=3D/dev/zero of=3Dxxx bs=3D4196 count=3D100

I tested on ext2, ext3, reiserfs.

Regards
Fabrizio

The code (Thanks to Andrea Arcangeli for the revision):

#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>

#define O_DIRECT 040000 /* direct disk access hint */

int main(int argc, char *argv[])
{

     int fd =3D open("xxx", O_RDWR|O_DIRECT);
     int len, pagesize =3D getpagesize();
     char *message;

        printf("Pagesize: %d\n", pagesize);

     posix_memalign((void **)&message, pagesize, pagesize);
     memset(message, 0xff, pagesize);
     printf("%p\n", message);
     if(fd < 0) {
         printf("Unable to open file, errno is %d.\n", errno);
     } else {
         if((len =3D read(fd, message, pagesize)) < 0) {
            perror("read");
          } else {
            printf("%d bytes read from file.\n", len);
            printf("Message: %s", message);
          }

    }
    close(fd);

    return 0;
}

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Dec 15 2004 - 16:34:14 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US