xfs
[Top] [All Lists]

Re: O_DIRECT buglet

To: Lennert Buytenhek <buytenh@xxxxxxx>
Subject: Re: O_DIRECT buglet
From: Russell Cattelan <cattelan@xxxxxxxxxxx>
Date: Sun, 01 Apr 2001 11:59:53 -0500
Cc: linux-xfs@xxxxxxxxxxx
References: <20010401121248.A14579@gnu.org> <3AC75B93.19AB5A8C@thebarn.com> <20010401125601.A15276@gnu.org>
Sender: owner-linux-xfs@xxxxxxxxxxx
Lennert Buytenhek wrote:

> 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.

Arggh terribly sorry... guess I didn't have enough coffee yet this morning.

Guess we'll have to track down the return that isn't fliping the sign.

Thanks.


>
>
> > 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
> >
> >
> >

--
Russell Cattelan
cattelan@xxxxxxxxxxx




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