User: Password:
|
|
Subscribe / Log in / New account

A brief history of union mounts

A brief history of union mounts

Posted Jul 22, 2010 21:20 UTC (Thu) by nix (subscriber, #2304)
In reply to: A brief history of union mounts by neilbrown
Parent article: A brief history of union mounts

It could be a nice long series - with lots of guest editors probably.
Hell yes. And the suck extends to fairly simple areas. Just saying 'EINTR' and 'short reads' is enough to make anyone who's ever written even a trivial C program on a Unix platform wince. (What do you mean I need a horrible-looking for loop to read a file reliably?!)


(Log in to post comments)

A brief history of union mounts

Posted Jul 23, 2010 2:51 UTC (Fri) by neilbrown (subscriber, #359) [Link]

?? You don't get EINTR on read from a regular file - only pipes, sockets, char devices and similar things.

But in general I agree - signals make it very hard to write correct programs.

A brief history of union mounts

Posted Jul 24, 2010 18:16 UTC (Sat) by nix (subscriber, #2304) [Link]

You do get EINTR on read from a regular file if you're unlucky enough to have that file on a network device (e.g. NFS with intr turned on). And before you say 'don't do that then', before very recently we had a choice of turning intr on or losing the whole mount point and very shortly afterwards often the whole machine if the network went down. (And, yes, I have encountered both short reads and EINTR in NFS-based regular file reads on both Linux and Solaris. So it does happen.)

(Also, POSIX doesn't ban getting EINTR on reads from a regular file, so prudence dictates expecting it.)

A brief history of union mounts

Posted Jul 25, 2010 4:20 UTC (Sun) by neilbrown (subscriber, #359) [Link]

Fair point, though that is really an NFS issue rather than a general Posix issue. And NFS has a lot more than just that to answer for.

Posix has a concept of 'slow' and 'not slow' reads where 'slow' reads can result in a short read or EINTR, and disk IO is explcitly not a slow read. So if your file is on disk you cannot get EINTR.
I guess being on disk on another machine doesn't count. :-(

A brief history of union mounts

Posted Jul 31, 2010 20:27 UTC (Sat) by nix (subscriber, #2304) [Link]

I've heard this over and over again, but I've looked through the POSIX specs and I can't find it. No mention of slow reads, no mention that some devices are guaranteed not to get EINTR, no mention in the rationale either.

Now perhaps this is a de facto universal implementation detail, but as far as I can see it isn't in POSIX itself. (Maybe I just haven't looked in the right place?)

A brief history of union mounts

Posted Aug 1, 2010 10:01 UTC (Sun) by neilbrown (subscriber, #359) [Link]

It seems you are right.

http://www.opengroup.org/onlinepubs/9699919799/functions/...

appears to allow any read to be interrupted, and says in the "informative" section "The issue of which files or file types are interruptible is considered an implementation design issue. This is often affected primarily by hardware and reliability issues." which is singularly unhelpful.

I was basing my statements on "man 7 signal" which does talk about "slow" devices. Clearly this isn't normative....

As you say, POSIX by itself is enough to make one wince...

A brief history of union mounts

Posted Aug 4, 2010 22:45 UTC (Wed) by nix (subscriber, #2304) [Link]

Quite so :/

Even 'man 7 signal' says clearly that 'The details vary across Unix systems; below, the details for Linux', and that's not terribly useful really for the vast majority of software. (I suppose you can rely on it in mdadm ;} )


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds