xfs
[Top] [All Lists]

Re: O_DIRECT buglet

To: Russell Cattelan <cattelan@xxxxxxxxxxx>
Subject: Re: O_DIRECT buglet
From: Lennert Buytenhek <buytenh@xxxxxxx>
Date: Sun, 1 Apr 2001 12:56:01 -0400
Cc: linux-xfs@xxxxxxxxxxx
In-reply-to: <3AC75B93.19AB5A8C@xxxxxxxxxxx>; from cattelan@xxxxxxxxxxx on Sun, Apr 01, 2001 at 11:47:15AM -0500
References: <20010401121248.A14579@xxxxxxx> <3AC75B93.19AB5A8C@xxxxxxxxxxx>
Sender: owner-linux-xfs@xxxxxxxxxxx
User-agent: Mutt/1.2.5i

On Sun, Apr 01, 2001 at 11:47:15AM -0500, Russell Cattelan wrote:

> Lennert Buytenhek wrote:
> 
> > (Not on the list, please CC on replies)
> 
> page aligned memory is necessary

Doh. I know how O_DIRECT works, thank you. Please reread my original mail.




> This isn't complete obviously but it is the basic code
> to get a buffer that starts on a page boundary.
> 
> 
>     struct dioattr              finfo;
>     ioctl(fd, XFS_IOC_DIOINFO, &finfo)
> buf = (char *)malloc(<buffer size> +finfo.d_mem);
> if( ((long)buf % finfo.d_mem != 0) ) {
>                 buf += finfo.d_mem - ((long)buf % finfo.d_mem);
>             }
> 
> 
> 
> 
> >
> >
> > Hi,
> >
> > Doing O_DIRECT I/O to a buffer which is not on an appropriate block boundary
> > seem to fail with return code 22 instead of -22 (EINVAL). This is on 2.4.2
> > with an XFS tree checkout from 20010329.
> >
> > tia,
> > Lennert
> >
> > -- test.c
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <fcntl.h>
> > #include <sys/stat.h>
> > #include <sys/types.h>
> > #include <unistd.h>
> >
> > #define O_DIRECT         040000 /* direct disk access hint */
> >
> > int main()
> > {
> >         char buf[16384];
> >         int fd;
> >         char *p;
> >
> >         p = (char *)((((unsigned long)buf) + 8191) & ~8191L);
> >         fd = open("blah", O_CREAT | O_RDWR | O_DIRECT);
> >
> >         printf("write returns %i\n", write(fd, buf, 8192));
> >         printf("write returns %i\n", write(fd, p, 1));
> >
> >         return 0;
> > }
> > -- actual output
> > [buytenh@mara test]$ ./test
> > write returns 22
> > write returns 22
> 
> --
> Russell Cattelan
> cattelan@xxxxxxxxxxx
> 
> 
> 

<Prev in Thread] Current Thread [Next in Thread>