File Locking Release Notes¶
Andy Walker <andy@lysaker.kvaerner.no>
12 May 1997
1. What’s New?¶
1.1 Broken Flock Emulation¶
The old flock(2) emulation in the kernel was swapped for proper BSDcompatible flock(2) support in the 1.3.x series of kernels. With therelease of the 2.1.x kernel series, support for the old emulation hasbeen totally removed, so that we don’t need to carry this baggageforever.
This should not cause problems for anybody, since everybody using a2.1.x kernel should have updated their C library to a suitable versionanyway (see the file “Minimal requirements to compile the Kernel”.)
1.2 Allow Mixed Locks Again¶
1.2.1 Typical Problems - Sendmail¶
Because sendmail was unable to use the oldflock() emulation, many sendmailinstallations use fcntl() instead offlock(). This is true of Slackware 3.0for example. This gave rise to some other subtle problems if sendmail wasconfigured to rebuild the alias file. Sendmail tried to lock the aliases.dirfile with fcntl() at the same time as the GDBM routines tried to lock thisfile withflock(). With pre 1.3.96 kernels this could result in deadlocks that,over time, or under a very heavy mail load, would eventually cause the kernelto lock solid with deadlocked processes.
1.2.2 The Solution¶
The solution I have chosen, after much experimentation and discussion,is to makeflock() and fcntl() locks oblivious to each other. Both canexists, and neither will have any effect on the other.
I wanted the two lock styles to be cooperative, but there were so manyrace and deadlock conditions that the current solution was the onlypractical one. It puts us in the same position as, for example, SunOS4.1.x and several other commercial Unices. The only OS’s that supportcooperativeflock()/fcntl() are those that emulateflock() usingfcntl(), with all the problems that implies.
1.3 Mandatory Locking As A Mount Option¶
Mandatory locking was prior to this release a general configuration optionthat was valid for all mounted filesystems. This had a number of inherentdangers, not the least of which was the ability to freeze an NFS server byasking it to read a file for which a mandatory lock existed.
Such option was dropped in Kernel v5.14.