O_DIRECT write to file by block-aligned, block-multiple buf fails?

O_DIRECT write to file by block-aligned, block-multiple buf fails?

Post by Scott McDermot » Fri, 16 May 2003 07:40:08



I thought based on searching the archives that 2.4 O_DIRECT
requires fs block size alignment of the buffer, and that the
buffer is an exact multiple of block size.  This should mean
I can write aligned pages with direct IO, right?

        int
        main (void)
        {
                char *buf;
                int fd;

                buf = memalign(getpagesize(), getpagesize());
                fd = open("/tmp/testfile", O_TRUNC|O_WRONLY|O_DIRECT);
                if (write(fd, buf, getpagesize()) == -1)
                        perror("write");
        }

        $ ./test
        write: Invalid argument

        $ grep /tmp /proc/mounts
        /dev/hda5 /mnt/tmp ext3 rw 0 0

        $ sudo dumpe2fs /dev/hda5 | grep Block\ size
        dumpe2fs 1.27 (8-Mar-2002)
        Block size:               4096

        $ uname -rm
        2.4.21-pre4-ac1 i686

what silly thing am I not understanding here?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

O_DIRECT write to file by block-aligned, block-multiple buf fails?

Post by Andreas Dilge » Fri, 16 May 2003 08:10:08



Quote:> This should mean I can write aligned pages with direct IO, right?

>         write: Invalid argument

>         $ grep /tmp /proc/mounts
>         /dev/hda5 /mnt/tmp ext3 rw 0 0

ext3 does not support O_DIRECT in 2.4 yet.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

O_DIRECT write to file by block-aligned, block-multiple buf fails?

Post by Scott McDermot » Fri, 16 May 2003 08:20:11


Andreas Dilger on Thu 15/05 00:04 -0600:


> > This should mean I can write aligned pages with direct
> > IO, right?

> >         write: Invalid argument

> >         $ grep /tmp /proc/mounts
> >         /dev/hda5 /mnt/tmp ext3 rw 0 0

> ext3 does not support O_DIRECT in 2.4 yet.

should open() on an ext3-based file fail when O_DIRECT is
among the flags?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
 
 
 

O_DIRECT write to file by block-aligned, block-multiple buf fails?

Post by Andrew Morto » Fri, 16 May 2003 08:30:11




> > This should mean I can write aligned pages with direct IO, right?

> >         write: Invalid argument

> >         $ grep /tmp /proc/mounts
> >         /dev/hda5 /mnt/tmp ext3 rw 0 0

> ext3 does not support O_DIRECT in 2.4 yet.

It does if you apply

ftp://ftp.kernel.org/pub/linux/kernel/people/andrea/kernels/v2.4/2.4....
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. Non blocking socket blocks; says 'read would block' ?

Hi all,

I have three sockets in server which I am reading in a continuous loop,
so don't want to wait on any one. I have designated them as 'non blocking'
but when run the server exits on the very first read() and says 'would
block'. (Is it the same as 'EWOULDBLOCK' mentioned in R. Steven's book ?)
I don't want that I should get any error msg and exit, in fact the
whole purpose of nonblocking is that if something is available, read it
else proceed in the loop and come back to read next time.
The client (sender) is sending msgs on all three sockets. The sockets
are conn_oriented. I am using SunOS 4.1. The small code part is below:

int emer_s, env_s, sens_s;            /* socket fds */
//----------- making sockets nonblocking ******
if ((res=fcntl(emer_s,F_SETFL,FNDELAY)) < 0)
        {
          perror("fcntl res = -1");
          exit(1);
        }
if ((res=fcntl(env_s,F_SETFL,FNDELAY)) < 0)
        {
          perror("fcntl res = -1");
          exit(1);
        }
if ((res=fcntl(sens_s,F_SETFL,FNDELAY)) < 0)
        {
          perror("fcntl res = -1");
          exit(1);
        }

for(; ;)
   {

      if ((cc=read(emer_s,(char*)&gen_struct,size)) < size)
        {
        perror("read error");
          exit(1);
        }
......... do something
      if ((cc=read(env_s,(char*)&gen_struct,size)) < size)
        {
         perror("read error");
          exit(1);
        }
        ......... do something
      if ((cc=read(sens_s,(char*)&gen_struct,size)) < size)
        {
          perror("read error");
          exit(1);
        }
        ......... do something

   }

Any help is appreciated.

hashmi

--
-----
Atiqullah Hashmi                    
UTA (Univ. of Texas at Arlington)  

2. ATI radeon 7000 and or SuSE 8.1 pro HELP!!

3. File - How to cut a file block by block ?

4. How can my ip change??

5. [2.5] Non-blocking write can block

6. Error while ejecting cd-rom with eject command...

7. Blocking connect() fails, non-blocking succeeds?

8. IBM G50 and Trident 9680

9. Finding the block size of a file on tape - block.c (0/1)

10. FreeBSD File System 512 byte-blocks --> 1024 byte-blocks

11. write (socket, buf, 0) and read (socket, buf, 0)

12. READ/WRITE multiple blocks

13. incomplete socket writes (when write blocks)