18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci==========================
48c2ecf20Sopenharmony_ciFile Locking Release Notes
58c2ecf20Sopenharmony_ci==========================
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci		Andy Walker <andy@lysaker.kvaerner.no>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci			    12 May 1997
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci1. What's New?
138c2ecf20Sopenharmony_ci==============
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci1.1 Broken Flock Emulation
168c2ecf20Sopenharmony_ci--------------------------
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciThe old flock(2) emulation in the kernel was swapped for proper BSD
198c2ecf20Sopenharmony_cicompatible flock(2) support in the 1.3.x series of kernels. With the
208c2ecf20Sopenharmony_cirelease of the 2.1.x kernel series, support for the old emulation has
218c2ecf20Sopenharmony_cibeen totally removed, so that we don't need to carry this baggage
228c2ecf20Sopenharmony_ciforever.
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciThis should not cause problems for anybody, since everybody using a
258c2ecf20Sopenharmony_ci2.1.x kernel should have updated their C library to a suitable version
268c2ecf20Sopenharmony_cianyway (see the file "Documentation/process/changes.rst".)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci1.2 Allow Mixed Locks Again
298c2ecf20Sopenharmony_ci---------------------------
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci1.2.1 Typical Problems - Sendmail
328c2ecf20Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
338c2ecf20Sopenharmony_ciBecause sendmail was unable to use the old flock() emulation, many sendmail
348c2ecf20Sopenharmony_ciinstallations use fcntl() instead of flock(). This is true of Slackware 3.0
358c2ecf20Sopenharmony_cifor example. This gave rise to some other subtle problems if sendmail was
368c2ecf20Sopenharmony_ciconfigured to rebuild the alias file. Sendmail tried to lock the aliases.dir
378c2ecf20Sopenharmony_cifile with fcntl() at the same time as the GDBM routines tried to lock this
388c2ecf20Sopenharmony_cifile with flock(). With pre 1.3.96 kernels this could result in deadlocks that,
398c2ecf20Sopenharmony_ciover time, or under a very heavy mail load, would eventually cause the kernel
408c2ecf20Sopenharmony_cito lock solid with deadlocked processes.
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci1.2.2 The Solution
448c2ecf20Sopenharmony_ci^^^^^^^^^^^^^^^^^^
458c2ecf20Sopenharmony_ciThe solution I have chosen, after much experimentation and discussion,
468c2ecf20Sopenharmony_ciis to make flock() and fcntl() locks oblivious to each other. Both can
478c2ecf20Sopenharmony_ciexists, and neither will have any effect on the other.
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciI wanted the two lock styles to be cooperative, but there were so many
508c2ecf20Sopenharmony_cirace and deadlock conditions that the current solution was the only
518c2ecf20Sopenharmony_cipractical one. It puts us in the same position as, for example, SunOS
528c2ecf20Sopenharmony_ci4.1.x and several other commercial Unices. The only OS's that support
538c2ecf20Sopenharmony_cicooperative flock()/fcntl() are those that emulate flock() using
548c2ecf20Sopenharmony_cifcntl(), with all the problems that implies.
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci1.3 Mandatory Locking As A Mount Option
588c2ecf20Sopenharmony_ci---------------------------------------
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ciMandatory locking, as described in
618c2ecf20Sopenharmony_ci'Documentation/filesystems/mandatory-locking.rst' was prior to this release a
628c2ecf20Sopenharmony_cigeneral configuration option that was valid for all mounted filesystems.  This
638c2ecf20Sopenharmony_cihad a number of inherent dangers, not the least of which was the ability to
648c2ecf20Sopenharmony_cifreeze an NFS server by asking it to read a file for which a mandatory lock
658c2ecf20Sopenharmony_ciexisted.
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ciFrom this release of the kernel, mandatory locking can be turned on and off
688c2ecf20Sopenharmony_cion a per-filesystem basis, using the mount options 'mand' and 'nomand'.
698c2ecf20Sopenharmony_ciThe default is to disallow mandatory locking. The intention is that
708c2ecf20Sopenharmony_cimandatory locking only be enabled on a local filesystem as the specific need
718c2ecf20Sopenharmony_ciarises.
728c2ecf20Sopenharmony_ci
73