Poettering: Revisiting how we put together Linux systems
Poettering: Revisiting how we put together Linux systems
Posted Sep 5, 2014 0:44 UTC (Fri) by mezcalero (subscriber, #45103)In reply to: Poettering: Revisiting how we put together Linux systems by nix
Parent article: Poettering: Revisiting how we put together Linux systems
Just pretending that locking works, even if it doesn't, and returning success to apps is really the worst thing to do...
Posted Sep 8, 2014 16:12 UTC (Mon)
by nix (subscriber, #2304)
[Link] (4 responses)
Posted Sep 8, 2014 18:56 UTC (Mon)
by bfields (subscriber, #19510)
[Link] (1 responses)
That wouldn't help. I think he's suggesting just returning -ENOLCK to BSD locks unconditionally. I agree that that's cleanest but in practice I suspect it would break a lot of existing setups.
I suppose you could make it yet another mount option and then advocate making it the default. Or just add support NFS protocol support for BSD locks if it's really a priority, doesn't seem like it should be that hard.
Posted Sep 9, 2014 13:56 UTC (Tue)
by nix (subscriber, #2304)
[Link]
Posted Sep 9, 2014 14:43 UTC (Tue)
by foom (subscriber, #14868)
[Link] (1 responses)
Linux also had that behavior a long time ago IIRC. Not sure why it changed, that was before I paid attention.
Posted Sep 9, 2014 15:27 UTC (Tue)
by bfields (subscriber, #19510)
[Link]
If a file is locked by a process through flock(), any record within the file will be seen as locked from the viewpoint of another process using fcntl(2) or lockf(3), and vice versa. Recent linux's flock(2) suggests the Linux behavior was an attempt to match BSD behavior that has since changed?:
Since kernel 2.0, flock() is implemented as a system call in its own right rather than being emulated in the GNU C library as a call to fcntl(2). This yields classical BSD semantics: there is no interaction between the types of lock placed by flock() and fcntl(2), and flock() does not detect deadlock. (Note, however, that on some modern BSDs, flock() and fcntl(2) locks do interact with one another.) Strange. In any case, changing the local Linux behavior is probably out of the question at this point.
Poettering: Revisiting how we put together Linux systems
Poettering: Revisiting how we put together Linux systems
Poettering: Revisiting how we put together Linux systems
That wouldn't help. I think he's suggesting just returning -ENOLCK to BSD locks unconditionally. I agree that that's cleanest but in practice I suspect it would break a lot of existing setups.
Given how awful POSIX locks are (until you have a very recent kernel and glibc 2.20), and how sane people therefore avoided using the bloody things, I'd say it would break almost every setup relying on locking over NFS at all. A very bad idea.
Poettering: Revisiting how we put together Linux systems
A BSD lock will block a POSIX lock, and v.v.. (At least that's what happens locally; no idea what the BSD's NFS clients do.)
Huh. A freebsd man page agrees with you:
Poettering: Revisiting how we put together Linux systems
https://www.freebsd.org/cgi/man.cgi?query=flock&sektion=2
http://man7.org/linux/man-pages/man2/flock.2.html