* O_NONBLOCK, read(), select(), NFS, Ext2, etc.
@ 2001-01-12 2:34 Michael Rothwell
2001-01-12 3:28 ` Chris Wedgwood
2001-01-12 9:40 ` Alan Cox
0 siblings, 2 replies; 7+ messages in thread
From: Michael Rothwell @ 2001-01-12 2:34 UTC (permalink / raw)
To: linux-kernel
The man pages for open, read and write say that if a file is opened
using the O_NONBLOCK flag, then read() and write() will always return
immediately and not block the calling process. This does not appear to
be true; but perhaps I am doing something wrong. If I open() a file (on
2.2.18) from a floppy or NFS mount (to test in a slow environment) with
O_NONBLOCK|O_RDONLY, read() will still block. If I try to select() on
the file descriptor, select() always returns 0.
Is there a way to make open(), read() and write() live up to their
manpages?
-M
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: O_NONBLOCK, read(), select(), NFS, Ext2, etc.
2001-01-12 2:34 Michael Rothwell
@ 2001-01-12 3:28 ` Chris Wedgwood
2001-01-12 9:40 ` Alan Cox
1 sibling, 0 replies; 7+ messages in thread
From: Chris Wedgwood @ 2001-01-12 3:28 UTC (permalink / raw)
To: Michael Rothwell; +Cc: linux-kernel
On Thu, Jan 11, 2001 at 09:34:08PM -0500, Michael Rothwell wrote:
The man pages for open, read and write say that if a file is opened
using the O_NONBLOCK flag, then read() and write() will always return
immediately and not block the calling process.
the man pages are wrong
--cw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: O_NONBLOCK, read(), select(), NFS, Ext2, etc.
2001-01-12 2:34 Michael Rothwell
2001-01-12 3:28 ` Chris Wedgwood
@ 2001-01-12 9:40 ` Alan Cox
2001-01-12 14:55 ` Michael Rothwell
2001-01-12 16:34 ` Alexander V. Lukyanov
1 sibling, 2 replies; 7+ messages in thread
From: Alan Cox @ 2001-01-12 9:40 UTC (permalink / raw)
To: Michael Rothwell; +Cc: linux-kernel
> using the O_NONBLOCK flag, then read() and write() will always return
> immediately and not block the calling process. This does not appear to
> be true; but perhaps I am doing something wrong. If I open() a file (on
> 2.2.18) from a floppy or NFS mount (to test in a slow environment) with
> O_NONBLOCK|O_RDONLY, read() will still block. If I try to select() on
> the file descriptor, select() always returns 0.
The definition of immediate is not 'instant'. Otherwise no I/O system would
ever return anything but -EWOULDBLOCK. Its that it won't wait when there is
no data pending. On a floppy there is always data pending
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: O_NONBLOCK, read(), select(), NFS, Ext2, etc.
2001-01-12 9:40 ` Alan Cox
@ 2001-01-12 14:55 ` Michael Rothwell
2001-01-12 16:34 ` Alexander V. Lukyanov
1 sibling, 0 replies; 7+ messages in thread
From: Michael Rothwell @ 2001-01-12 14:55 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-kernel
Alan Cox wrote:
>
> > using the O_NONBLOCK flag, then read() and write() will always return
> > immediately and not block the calling process. This does not appear to
> > be true; but perhaps I am doing something wrong. If I open() a file (on
> > 2.2.18) from a floppy or NFS mount (to test in a slow environment) with
> > O_NONBLOCK|O_RDONLY, read() will still block. If I try to select() on
> > the file descriptor, select() always returns 0.
>
> The definition of immediate is not 'instant'. Otherwise no I/O system would
> ever return anything but -EWOULDBLOCK. Its that it won't wait when there is
> no data pending. On a floppy there is always data pending
How about using fcntl(), O_ASYNC and SIGIO? Or maybe a broader question:
what's the preferred/working way to do async file i/o on Linux?
-M
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: O_NONBLOCK, read(), select(), NFS, Ext2, etc.
@ 2001-01-12 15:18 Andries.Brouwer
0 siblings, 0 replies; 7+ messages in thread
From: Andries.Brouwer @ 2001-01-12 15:18 UTC (permalink / raw)
To: cw, rothwell; +Cc: linux-kernel
From: Chris Wedgwood <cw@f00f.org>
On Thu, Jan 11, 2001 at 09:34:08PM -0500, Michael Rothwell wrote:
The man pages for open, read and write say that if a file is opened
using the O_NONBLOCK flag, then read() and write() will always return
immediately and not block the calling process.
the man pages are wrong
Don't you think cc'ing the man page maintainer [aeb@cwi.nl]
would be a good idea whenever you think something is wrong
in the man pages? You never know, they might even improve.
In this particular case I don't think anything is actually
wrong, but I can well imagine that someone can invent clearer
wording. It would also be useful to more clearly separate
POSIX-mandated behaviour and actual Linux behaviour.
Suggestions and patches are welcome as always.
Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: O_NONBLOCK, read(), select(), NFS, Ext2, etc.
2001-01-12 9:40 ` Alan Cox
2001-01-12 14:55 ` Michael Rothwell
@ 2001-01-12 16:34 ` Alexander V. Lukyanov
1 sibling, 0 replies; 7+ messages in thread
From: Alexander V. Lukyanov @ 2001-01-12 16:34 UTC (permalink / raw)
To: Alan Cox; +Cc: Michael Rothwell, linux-kernel
On Fri, Jan 12, 2001 at 09:40:55AM +0000, Alan Cox wrote:
> > be true; but perhaps I am doing something wrong. If I open() a file (on
> > 2.2.18) from a floppy or NFS mount (to test in a slow environment) with
> > O_NONBLOCK|O_RDONLY, read() will still block. If I try to select() on
> > the file descriptor, select() always returns 0.
>
> The definition of immediate is not 'instant'. Otherwise no I/O system would
> ever return anything but -EWOULDBLOCK. Its that it won't wait when there is
> no data pending. On a floppy there is always data pending
I have a long standing idea on modifying poll/read/write behavior on
regular files opened in O_NONBLOCK mode. How about the following scheme:
* poll returns POLLIN/POLLOUT on regular files only if the data are
in buffer cache/there is room for write().
* read returns EAGAIN if the data are not in buffer cache.
* write returns EAGAIN if there is no room (yet) to store the data.
All the operation should signal to IO subsystem that the data are
needed in cache/the room has to be freed.
--
Alexander.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: O_NONBLOCK, read(), select(), NFS, Ext2, etc.
@ 2001-01-12 18:10 Dan Kegel
0 siblings, 0 replies; 7+ messages in thread
From: Dan Kegel @ 2001-01-12 18:10 UTC (permalink / raw)
To: rothwell, linux-kernel
Michael Rothwell (rothwell@holly-springs.nc.us) wrote:
> How about using fcntl(), O_ASYNC and SIGIO?
Don't think that's supported for disk files yet, at least by the
kernel. glibc does aio emulation with threads, which isn't great.
> Or maybe a broader question:
> what's the preferred/working way to do async file i/o on Linux?
SGI has done lots of work on this, using kernel threads;
they don't have a patch yet for 2.4.0, but they do support
2.2.17 and 2.4.0-test10.
TUX uses async I/O, I think, but it's inside the kernel.
I hear plans are afoot for giving userspace async I/O that
avoids creating threads; that should be more scalable than
SGI's approach, if it ever happens.
See http://www.kegel.com/c10k.html#aio for links and a few notes.
- Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2001-01-12 18:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-12 18:10 O_NONBLOCK, read(), select(), NFS, Ext2, etc Dan Kegel
-- strict thread matches above, loose matches on Subject: below --
2001-01-12 15:18 Andries.Brouwer
2001-01-12 2:34 Michael Rothwell
2001-01-12 3:28 ` Chris Wedgwood
2001-01-12 9:40 ` Alan Cox
2001-01-12 14:55 ` Michael Rothwell
2001-01-12 16:34 ` Alexander V. Lukyanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox