History log of /freebsd-current/sys/kern/kern_lockf.c
Revision Date Author Comments
# 29363fb4 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 658e7620 04-Jul-2023 Konstantin Belousov <kib@FreeBSD.org>

kern_lockf.c: fix typo

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 43fbd0e7 14-Sep-2022 Mateusz Guzik <mjg@FreeBSD.org>

lockf: elide vnode interlock in the common case in lf_purgelocks

The interlock was already taken and released when dooming, thus by
API contract locking state cannot be legally installed.

At the same time the state is almost never there to begin with.


# 8ae76949 17-Jun-2022 Damjan Jovanovic <damjan.jov@gmail.com>

KERN_LOCKF: report kl_file_fsid consistently with stat(2)

PR: 264723
Reviewed by: kib
Discussed with: markj
MFC after: 1 week


# eca39864 01-Apr-2022 Konstantin Belousov <kib@FreeBSD.org>

Add sysctl KERN_LOCKF

reporting the shapshot of the active advisory locks.

A new VFS ops method vfs_report_lockf if provided in the mount point
op table. If it is NULL, as it is currently for all existing
filesystems, vfs_report_lockf() function is used, which gathers
information from the standard implementation inside kern/kern_lockf.c.

Filesystems implementing its own locking (NFSv4 as example) can provide
a custom implementation.

Reviewed by: markj, rmacklem
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34756


# 147e4fe3 01-Apr-2022 Konstantin Belousov <kib@FreeBSD.org>

kern_lockf.c: remove no longer neeeded UFS headers

Reviewed by: markj, rmacklem
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34756


# 59e85819 01-Apr-2022 Konstantin Belousov <kib@FreeBSD.org>

lockf: remove lf_inode from struct lockf_entry

The UFS-specific struct inode cannot be used in generic advisory lock
code. It was probably used as a shortcut for the debugging, as the
remnants of the code around it indicates.

Use somewhat more verbose and less concentrated, but universal,
VOP_PRINT(), where needed.

Reviewed by: markj, rmacklem
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34756


# 6fed89b1 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

kern: clean up empty lines in .c and .h files


# d363fa41 05-Jul-2020 Mateusz Guzik <mjg@FreeBSD.org>

lockf: elide avoidable locking in lf_advlockasync

While here assert on ls_threads state.


# 3ff65f71 30-Jan-2020 Mateusz Guzik <mjg@FreeBSD.org>

Remove duplicated empty lines from kern/*.c

No functional changes.


# abd80ddb 08-Dec-2019 Mateusz Guzik <mjg@FreeBSD.org>

vfs: introduce v_irflag and make v_type smaller

The current vnode layout is not smp-friendly by having frequently read data
avoidably sharing cachelines with very frequently modified fields. In
particular v_iflag inspected for VI_DOOMED can be found in the same line with
v_usecount. Instead make it available in the same cacheline as the v_op, v_data
and v_type which all get read all the time.

v_type is avoidably 4 bytes while the necessary data will easily fit in 1.
Shrinking it frees up 3 bytes, 2 of which get used here to introduce a new
flag field with a new value: VIRF_DOOMED.

Reviewed by: kib, jeff
Differential Revision: https://reviews.freebsd.org/D22715


# 788390df 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

lockf: annotate LOCKF_DEBUG only var


# d357c16a 24-Apr-2018 Mateusz Guzik <mjg@FreeBSD.org>

lockf: change the owner hash from pid to vnode-based

This adds a bit missed due to the patch split, see r332882

Tested by: pho


# 833dc05a 23-Apr-2018 Mateusz Guzik <mjg@FreeBSD.org>

lockf: add per-chain locks to the owner hash

This combined with previous changes significantly depessimizes the behaviour
under contentnion.

In particular the lock1_processes test (locking/unlocking separate files)
from the will-it-scale suite was executed with 128 concurrency on a
4-socket Broadwell with 128 hardware threads.

Operations/second (lock+unlock) go from ~750000 to ~45000000 (6000%)
For reference single-process is ~1680000 (i.e. on stock kernel the resulting
perf is less than *half* of the single-threaded run),

Note this still does not really scale all that well as the locks were just
bolted on top of the current implementation. Significant room for improvement
is still here. In particular the top performance fluctuates depending on the
extent of false sharing in given run (which extends beyond the file).
Added chain+lock pairs were not padded w.r.t. cacheline size.

One big ticket item is the hash used for spreading threads: it used to be the
process pid (which basically serialized all threaded ops). Temporarily the
vnode addr was slapped in instead.

Tested by: pho


# 63286976 23-Apr-2018 Mateusz Guzik <mjg@FreeBSD.org>

lockf: skip locking the graph if not necessary (common case)

Tested by: pho


# 717df0b0 23-Apr-2018 Mateusz Guzik <mjg@FreeBSD.org>

lockf: perform wakeup onlly when there is anybody waiting

Tested by: pho


# c72ead28 23-Apr-2018 Mateusz Guzik <mjg@FreeBSD.org>

lockf: skip the hard work in lf_purgelocks if possible

Tested by: pho


# 0d3323f5 23-Apr-2018 Mateusz Guzik <mjg@FreeBSD.org>

lockf: free state only when recycling the vnode

This avoids malloc/free cycles when locking/unlocking the vnode when
nobody is contending.

Tested by: pho


# 7d853f62 22-Apr-2018 Mateusz Guzik <mjg@FreeBSD.org>

lockf: slightly depessimize

1. check if P_ADVLOCK is already set and if so, don't lock to set it
(stolen from DragonFly)
2. when trying for fast path unlock, check that we are doing unlock
first instead of taking the interlock for no reason (e.g. if we want
to *lock*). whilere make it more likely that falling fast path will
not take the interlock either by checking for state

Note the code is severely pessimized both single- and multithreaded.


# 51369649 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# 826b3d31 30-Jan-2017 Andriy Gapon <avg@FreeBSD.org>

put very expensive sanity checks of advisory locks under DIAGNOSTIC

The checks have quadratic complexity over a number of advisory locks
active for a file and that could be a lot. What's the worse is that the
checks are done while holding ls_lock. That could lead to a long a very
long backlog and performance degradation even if all requested locks are
compatible (e.g. all shared locks).

The checks used to be under INVARIANTS.

Discussed with: kib
MFC after: 2 weeks
Sponsored by: Panzura


# a5ec35df 18-Sep-2016 Sepherosa Ziehau <sephe@FreeBSD.org>

Fix LINT building.

Sponsored by: Microsoft


# 69a28758 15-Sep-2016 Ed Maste <emaste@FreeBSD.org>

Renumber license clauses in sys/kern to avoid skipping #3


# 883a5a4a 26-Jun-2016 Konstantin Belousov <kib@FreeBSD.org>

When sleeping waiting for either local or remote advisory lock,
interrupt sleeps with the ERESTART on the suspension attempts.
Otherwise, single-threading requests are deferred until the locks are
granted for NFS files, which causes hangs.

When retrying local registration of the remotely-granted adv lock,
allow full suspension and check for suspension, for usual reasons.

Reported by: markj, pho
Reviewed by: jilles
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Approved by: re (gjb)


# e3043798 29-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/kern: spelling fixes in comments.

No functional change.


# 6e19f0de 09-Jan-2015 Xin LI <delphij@FreeBSD.org>

Improve style and fix a possible use-after-free case introduced in r268384
by reinitializing the 'freestate' pointer after freeing the memory.

Obtained from: HardenedBSD (71fab80c5dd3034b71a29a61064625018671bbeb)
PR: 194525
Submitted by: Oliver Pinter <oliver.pinter@hardenedbsd.org>
MFC after: 2 weeks


# 3bcc218f 08-Jul-2014 Konstantin Belousov <kib@FreeBSD.org>

Correct the problem reported by test16 from
tools/regression/file/flock/flock.c, which completes the fix in
r192685. When the lock was stolen from us, retry the whole lock
sequence in kernel, instead of returning EINTR to usermode and hoping
that application would handle it correctly by restarting the lock
acquire.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks


# d745c852 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 28fe6a3f 25-Jun-2009 Konstantin Belousov <kib@FreeBSD.org>

In lf_iteratelocks_vnode, increment state->ls_threads around iterating
of the vnode advisory lock list. This prevents deallocation of state
while inside the loop.

Reported and tested by: pho
MFC after: 2 weeks


# f02c9d28 16-Jun-2009 Konstantin Belousov <kib@FreeBSD.org>

Decrement state->ls_threads when vnode appeared to be doomed.

Reported and tested by: pho


# 5dd6aaba 10-Jun-2009 Konstantin Belousov <kib@FreeBSD.org>

Do not leak the state->ls_lock after VI_DOOMED check introduced
in the r192683.

Reported by: pho
Submitted by: jhb


# 8af54d4c 23-May-2009 Konstantin Belousov <kib@FreeBSD.org>

The advisory lock may be activated or activated and removed during the
sleep waiting for conditions when the lock may be granted.
To prevent lf_setlock() from accessing possibly freed memory, add reference
counting to the struct lockf_entry. Bump refcount around the sleep.

Make lf_free_lock() return non-zero when structure was freed, and use
this after the sleep to return EINTR to the caller. The error code might
need a clarification, but we cannot return success to usermode, since
the lock is not owned anymore.

Reviewed by: dfr
Tested by: pho
MFC after: 1 month


# 9727972e 23-May-2009 Konstantin Belousov <kib@FreeBSD.org>

In lf_purgelocks(), assert that state->ls_pending is empty after we
weeded out threads, and clean ls_active instead of ls_pending.

Reviewed by: dfr
Tested by: pho
MFC after: 1 month


# b33d6177 23-May-2009 Konstantin Belousov <kib@FreeBSD.org>

In lf_advlockasync(), recheck for doomed vnode after the state->ls_lock
is acquired. In the lf_purgelocks(), assert that vnode is doomed and set
*statep to NULL before clearing ls_pending list. Otherwise, we allow for
the thread executing lf_advlockasync() to put new pending entry after
state->ls_lock is dropped in lf_purgelocks().

Reviewed by: dfr
Tested by: pho
MFC after: 1 month


# 8aec91b5 23-May-2009 Konstantin Belousov <kib@FreeBSD.org>

Replace the while statement with the if for clarity. The loop body
cannot be executed more then once.

Reviewed by: dfr
Tested by: pho
MFC after: 1 month


# 559b717f 26-Nov-2008 Ganbold Tsagaankhuu <ganbold@FreeBSD.org>

Remove unused variable.

Found with: Coverity Prevent(tm)
CID: 3664

Approved by: kib


# 842832ae 24-Oct-2008 Doug Rabson <dfr@FreeBSD.org>

Don't rely on the value of *statep without first taking the vnode interlock.

Reviewed by: Mike Tancsa
MFC after: 2 weeks


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# c675522f 26-Jun-2008 Doug Rabson <dfr@FreeBSD.org>

Re-implement the client side of rpc.lockd in the kernel. This implementation
provides the correct semantics for flock(2) style locks which are used by the
lockf(1) command line tool and the pidfile(3) library. It also implements
recovery from server restarts and ensures that dirty cache blocks are written
to the server before obtaining locks (allowing multiple clients to use file
locking to safely share data).

Sponsored by: Isilon Systems
PR: 94256
MFC after: 2 weeks


# 06c85cef 09-May-2008 Doug Rabson <dfr@FreeBSD.org>

When blocking on an F_FLOCK style lock request which is upgrading a
shared lock to exclusive, drop the shared lock before deadlock
detection.

MFC after: 2 days


# a365ea5f 16-Apr-2008 Doug Rabson <dfr@FreeBSD.org>

Fix compilation with LOCKF_DEBUG.


# eab626f1 16-Apr-2008 Konstantin Belousov <kib@FreeBSD.org>

Move the head of byte-level advisory lock list from the
filesystem-specific vnode data to the struct vnode. Provide the
default implementation for the vop_advlock and vop_advlockasync.
Purge the locks on the vnode reclaim by using the lf_purgelocks().
The default implementation is augmented for the nfs and smbfs.
In the nfs_advlock, push the Giant inside the nfs_dolock.

Before the change, the vop_advlock and vop_advlockasync have taken the
unlocked vnode and dereferenced the fs-private inode data, racing with
with the vnode reclamation due to forced unmount. Now, the vop_getattr
under the shared vnode lock is used to obtain the inode size, and
later, in the lf_advlockasync, after locking the vnode interlock, the
VI_DOOMED flag is checked to prevent an operation on the doomed vnode.

The implementation of the lf_purgelocks() is submitted by dfr.

Reported by: kris
Tested by: kris, pho
Discussed with: jeff, dfr
MFC after: 2 weeks


# 60cdfde0 01-Apr-2008 Doug Rabson <dfr@FreeBSD.org>

Don't try to use an SX lock while holding the vnode interlock.

Sponsored by: Isilon Systems


# dfdcada3 26-Mar-2008 Doug Rabson <dfr@FreeBSD.org>

Add the new kernel-mode NFS Lock Manager. To use it instead of the
user-mode lock manager, build a kernel with the NFSLOCKD option and
add '-k' to 'rpc_lockd_flags' in rc.conf.

Highlights include:

* Thread-safe kernel RPC client - many threads can use the same RPC
client handle safely with replies being de-multiplexed at the socket
upcall (typically driven directly by the NIC interrupt) and handed
off to whichever thread matches the reply. For UDP sockets, many RPC
clients can share the same socket. This allows the use of a single
privileged UDP port number to talk to an arbitrary number of remote
hosts.

* Single-threaded kernel RPC server. Adding support for multi-threaded
server would be relatively straightforward and would follow
approximately the Solaris KPI. A single thread should be sufficient
for the NLM since it should rarely block in normal operation.

* Kernel mode NLM server supporting cancel requests and granted
callbacks. I've tested the NLM server reasonably extensively - it
passes both my own tests and the NFS Connectathon locking tests
running on Solaris, Mac OS X and Ubuntu Linux.

* Userland NLM client supported. While the NLM server doesn't have
support for the local NFS client's locking needs, it does have to
field async replies and granted callbacks from remote NLMs that the
local client has contacted. We relay these replies to the userland
rpc.lockd over a local domain RPC socket.

* Robust deadlock detection for the local lock manager. In particular
it will detect deadlocks caused by a lock request that covers more
than one blocking request. As required by the NLM protocol, all
deadlock detection happens synchronously - a user is guaranteed that
if a lock request isn't rejected immediately, the lock will
eventually be granted. The old system allowed for a 'deferred
deadlock' condition where a blocked lock request could wake up and
find that some other deadlock-causing lock owner had beaten them to
the lock.

* Since both local and remote locks are managed by the same kernel
locking code, local and remote processes can safely use file locks
for mutual exclusion. Local processes have no fairness advantage
compared to remote processes when contending to lock a region that
has just been unlocked - the local lock manager enforces a strict
first-come first-served model for both local and remote lockers.

Sponsored by: Isilon Systems
PR: 95247 107555 115524 116679
MFC after: 2 weeks


# fbd762f1 19-Mar-2008 Jeff Roberson <jeff@FreeBSD.org>

- Fix the last of the threading bugs that were introduced as far back as
1.38 in 2001. Break out of the FOREACH_THREAD_IN_PROC loop when we've
discovered a new proc in the chain.
- Increment i and check for maxlockdepth once per matching process not
once per thread. This didn't properly terminate the loop before.
- Fix a bug which has existed potentially since rev 1.1. waitblock->lf_next
can be NULL when a thread has been woken-up but not yet scheduled. Check
for this condition rather than blindly dereferencing.

Found by: libMicro


# 374ae2a3 19-Mar-2008 Jeff Roberson <jeff@FreeBSD.org>

- Relax requirements for p_numthreads, p_threads, p_swtick, and p_nice from
requiring the per-process spinlock to only requiring the process lock.
- Reflect these changes in the proc.h documentation and consumers throughout
the kernel. This is a substantial reduction in locking cost for these
fields and was made possible by recent changes to threading support.


# 004e08be 07-Aug-2007 Konstantin Belousov <kib@FreeBSD.org>

Do not call free() while holding vnode interlock.

Reported and tested by: Peter Holm
Reviewed by: jeff
Approved by: re (kensmith)


# bc02f1d9 03-Jul-2007 Jeff Roberson <jeff@FreeBSD.org>

- Remove explicit Giant protection from lockf. Use the vnode interlock
to protect this datastructure instead.
- Preallocate an extra lockf structure in case we want to split a lock
on insert or delete.
- msleep() on the vnode interlock when blocking on a lock.

Reviewed by: rwatson
Approved by: re


# 982d11f8 04-Jun-2007 Jeff Roberson <jeff@FreeBSD.org>

Commit 14/14 of sched_lock decomposition.
- Use thread_lock() rather than sched_lock for per-thread scheduling
sychronization.
- Use the per-process spinlock rather than the sched_lock for per-process
scheduling synchronization.

Tested by: kris, current@
Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc.
Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)


# 97eb8cfa 29-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Print name of device instead of useless major/minor numbers.


# 7933351a 15-Mar-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Fix a debug message to print a usable device name rather than useless
major+minor tupple.


# 013e6650 25-Jan-2005 Jeff Roberson <jeff@FreeBSD.org>

- Make lf_print static and move its prototype into kern_lockf.c
- Protect all of the advlock code with Giant as some filesystems
may not be entering with Giant held now.

Sponsored by: Isilon Systems, Inc.


# 9454b2d8 06-Jan-2005 Warner Losh <imp@FreeBSD.org>

/* -> /*- for copyright notices, minor format tweaks as necessary


# 7f8a436f 05-Apr-2004 Warner Losh <imp@FreeBSD.org>

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core


# 677b542e 10-Jun-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID().


# 104a9b7e 29-Apr-2003 Alexander Kabaev <kan@FreeBSD.org>

Deprecate machine/limits.h in favor of new sys/limits.h.
Change all in-tree consumers to include <sys/limits.h>

Discussed on: standards@
Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>


# b4b138c2 18-Mar-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Including <sys/stdint.h> is (almost?) universally only to be able to use
%j in printfs, so put a newsted include in <sys/systm.h> where the printf
prototype lives and save everybody else the trouble.


# a163d034 18-Feb-2003 Warner Losh <imp@FreeBSD.org>

Back out M_* changes, per decision of the TRB.

Approved by: trb


# 44956c98 21-Jan-2003 Alfred Perlstein <alfred@FreeBSD.org>

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


# a7a00d05 07-Nov-2002 Maxime Henrion <mux@FreeBSD.org>

- Fix a bunch of casts to long which were truncating off_t's.
- Remove the comments which were justifying this by the fact
that we don't have %q in the kernel, this was probably right
back in time, but we now have %q, and we even have better to
print those types (%j).


# 8179ab99 14-Sep-2002 Maxime Henrion <mux@FreeBSD.org>

Remove a conditional #include <sys/kernel.h>, it is already
included unconditionally before.

Submitted by: Olivier Houchard <cognet@ci0.org>


# 7f52a691 13-Aug-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Add a #include for <sys/mount.h>


# 80208239 28-Jun-2002 Alfred Perlstein <alfred@FreeBSD.org>

More caddr_t removal.
Change struct knote's kn_hook from caddr_t to void *.


# 4d77a549 19-Mar-2002 Alfred Perlstein <alfred@FreeBSD.org>

Remove __P.


# 59aff5fc 01-Dec-2001 Alfred Perlstein <alfred@FreeBSD.org>

make LOCKF_DEBUG kernel option work (sorta)

Submitted by: Maxim Konovalov <maxim@macomnet.ru>
PR: kern/32267


# b40ce416 12-Sep-2001 Julian Elischer <julian@FreeBSD.org>

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


# c8e76343 29-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

advlock: simplify overflow checks


# c4778eed 26-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

Cosmetique & style fixes from bde


# dc6e1079 24-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

Remove extra check unneded now


# 6fb9fbce 23-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

Add yet one check for SEEK_END overflow


# 62be011e 23-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

Oops, fix my broken handling of new l_len<0 case


# f510e1c2 23-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

Originally BSD return EINVAL for l_len < 0, but now POSIX wants it too,
so implement POSIX l_len < 0 handling.


# 6d24c65d 23-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

Cosmetique: correct English in comments

Pointed by: bde


# b44af710 23-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

Move <machine/*> after <sys/*>

Pointed by: bde


# 69cc1d0d 23-Aug-2001 Andrey A. Chernov <ache@FreeBSD.org>

Detect off_t EOVERFLOW of start/end offsets calculations for adv. lock,
as POSIX require.


# fb919e4d 01-May-2001 Mark Murray <markm@FreeBSD.org>

Undo part of the tangle of having sys/lock.h and sys/mutex.h included in
other "system" header files.

Also help the deprecation of lockmgr.h by making it a sub-include of
sys/lock.h and removing sys/lockmgr.h form kernel .c files.

Sort sys/*.h includes where possible in affected files.

OK'ed by: bde (with reservations)


# 603c8667 17-Apr-2001 Alfred Perlstein <alfred@FreeBSD.org>

Implement client side NFS locks.

Obtained from: BSD/os
Import Ok'd by: mckusick, jkh, motd on builder.freebsd.org


# 8d272518 23-Mar-2001 John Baldwin <jhb@FreeBSD.org>

Protect p_wmesg and p_wchan with sched_lock while checking for deadlocks
with other byte range file locks.


# 1b727751 16-Nov-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Commit the remaining part of PR14914:

Alot of the code in sys/kern directly accesses the *Q_HEAD and *Q_ENTRY
structures for list operations. This patch makes all list operations
in sys/kern use the queue(3) macros, rather than directly accessing the
*Q_{HEAD,ENTRY} structures.

Reviewed by: phk
Submitted by: Jake Burkholder <jake@checker.org>
PR: 14914


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 1168ab08 04-Jul-1999 Bruce Evans <bde@FreeBSD.org>

Fixed corruption of the "blocked" list in lf_setlock() when tsleep()
returns 0 after ptrace() attach and/or detach doesn't quite quite
deliver a signal. Perhaps the process shouldn't be woken in this
case, but avoiding the problem is easy.

PR: 12247

Fixed a couple of places where mechanical fixing of compiler warnings
caused misspelling of NOLOCKF as NULL.


# db72e058 08-May-1999 Dmitrij Tejblum <dt@FreeBSD.org>

Fix a freelist trashing under following confitions:
- first program lock a region in a file,
- second program wait on the lock,
- first program extend the region,
- second program interrupted by a signal.


# d254af07 27-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile


# 1c5bb3ea 10-Nov-1998 Peter Wemm <peter@FreeBSD.org>

add #include <sys/kernel.h> where it's needed by MALLOC_DEFINE()


# d974cf4d 29-Jul-1998 Bruce Evans <bde@FreeBSD.org>

Fixed printf format errors.


# 3f2076da 31-Jan-1998 Eivind Eklund <eivind@FreeBSD.org>

Make the debug options new-style.

This also zaps a DPT option from lint; it wasn't referenced from
anywhere.


# 1cd52ec3 05-Dec-1997 Bruce Evans <bde@FreeBSD.org>

Don't include <sys/lock.h> in headers when only `struct simplelock' is
required. Fixed everything that depended on the pollution.


# a1c995b6 12-Oct-1997 Poul-Henning Kamp <phk@FreeBSD.org>

Last major round (Unless Bruce thinks of somthing :-) of malloc changes.

Distribute all but the most fundamental malloc types. This time I also
remembered the trick to making things static: Put "static" in front of
them.

A couple of finer points by: bde


# 55166637 11-Oct-1997 Poul-Henning Kamp <phk@FreeBSD.org>

Distribute and statizice a lot of the malloc M_* types.

Substantial input from: bde


# 7f725eac 01-Apr-1997 Bruce Evans <bde@FreeBSD.org>

Use OID_AUTO instead of a magic number for Lite2 sysctl debug.lockf_debug.

Removed unused #includes.


# 6875d254 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.


# a8687b6d 18-Feb-1997 Bruce Evans <bde@FreeBSD.org>

Added some ufs #includes so that this compiles with option LOCKF_DEBUG.
Moving this all from ufs wasn't a good move. At least the debugging
routines depend on the file system.

Cleaned up the LOCKF_DEBUG #includes.


# b52748be 12-Feb-1997 Bruce Evans <bde@FreeBSD.org>

Restored some lost function return types.


# 996c772f 09-Feb-1997 John Dyson <dyson@FreeBSD.org>

This is the kernel Lite/2 commit. There are some requisite userland
changes, so don't expect to be able to run the kernel as-is (very well)
without the appropriate Lite/2 userland changes.

The system boots and can mount UFS filesystems.

Untested: ext2fs, msdosfs, NFS
Known problems: Incorrect Berkeley ID strings in some files.
Mount_std mounts will not work until the getfsent
library routine is changed.

Reviewed by: various people
Submitted by: Jeffery Hsu <hsu@freebsd.org>


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 675526e8 29-Dec-1996 David Greenman <dg@FreeBSD.org>

Delete bogus inconsistency check that could cause a gratuitous panic. I
had added this years ago when I didn't understand all the subtilties of
the flock code.


# a88bd8aa 19-Dec-1996 Bruce Evans <bde@FreeBSD.org>

Fixed arg checking in if_advlock(). Invalid args were accepted in an
optimized case. Preposterous lengths weren't checked for.

Found by: NIST-PCTS


# b71fec07 03-Sep-1996 Bruce Evans <bde@FreeBSD.org>

Eliminated nested include of <sys/unistd.h> in <sys/file.h> in the kernel.
Include it directly in the few places where it is used.

Reduced some #includes of <sys/file.h> to #includes of <sys/fcntl.h> or
nothing.


# 87b6de2b 14-Dec-1995 Poul-Henning Kamp <phk@FreeBSD.org>

A Major staticize sweep. Generates a couple of warnings that I'll deal
with later.
A number of unused vars removed.
A number of unused procs removed or #ifdefed.


# 9b2e5354 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# f15b8850 25-Oct-1994 David Greenman <dg@FreeBSD.org>

Changed some variable names in lf_addblock to make the code both
understandable and conform to other conventions used in the file.


# bb56ec4a 25-Sep-1994 Poul-Henning Kamp <phk@FreeBSD.org>

While in the real world, I had a bad case of being swapped out for a lot of
cycles. While waiting there I added a lot of the extra ()'s I have, (I have
never used LISP to any extent). So I compiled the kernel with -Wall and
shut up a lot of "suggest you add ()'s", removed a bunch of unused var's
and added a couple of declarations here and there. Having a lap-top is
highly recommended. My kernel still runs, yell at me if you kernel breaks.


# 92dc7331 08-Aug-1994 David Greenman <dg@FreeBSD.org>

Made lockf advisory locking code generic (rather than ufs specific), and
use it in NFS. This is required both for diskless support and for POSIX
compliance. Note: the support in NFS is only for the local node.

Submitted by: based on work originally done by Yuval Yurom