summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lockf.c
Commit message (Collapse)AuthorAgeFilesLines
* Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.ed2011-11-071-1/+1
| | | | This means that their use is restricted to a single C file.
* In lf_iteratelocks_vnode, increment state->ls_threads around iteratingkib2009-06-251-1/+10
| | | | | | | | of the vnode advisory lock list. This prevents deallocation of state while inside the loop. Reported and tested by: pho MFC after: 2 weeks
* Decrement state->ls_threads when vnode appeared to be doomed.kib2009-06-171-0/+2
| | | | Reported and tested by: pho
* Do not leak the state->ls_lock after VI_DOOMED check introducedkib2009-06-101-0/+1
| | | | | | | in the r192683. Reported by: pho Submitted by: jhb
* The advisory lock may be activated or activated and removed during thekib2009-05-241-2/+15
| | | | | | | | | | | | | | | 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
* In lf_purgelocks(), assert that state->ls_pending is empty after wekib2009-05-241-1/+3
| | | | | | | | weeded out threads, and clean ls_active instead of ls_pending. Reviewed by: dfr Tested by: pho MFC after: 1 month
* In lf_advlockasync(), recheck for doomed vnode after the state->ls_lockkib2009-05-241-2/+17
| | | | | | | | | | | 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
* Replace the while statement with the if for clarity. The loop bodykib2009-05-241-1/+1
| | | | | | | | cannot be executed more then once. Reviewed by: dfr Tested by: pho MFC after: 1 month
* Remove unused variable.ganbold2008-11-271-2/+1
| | | | | | | Found with: Coverity Prevent(tm) CID: 3664 Approved by: kib
* Don't rely on the value of *statep without first taking the vnode interlock.dfr2008-10-241-1/+4
| | | | | Reviewed by: Mike Tancsa MFC after: 2 weeks
* Re-implement the client side of rpc.lockd in the kernel. This implementationdfr2008-06-261-26/+110
| | | | | | | | | | | | 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
* When blocking on an F_FLOCK style lock request which is upgrading adfr2008-05-091-11/+12
| | | | | | | shared lock to exclusive, drop the shared lock before deadlock detection. MFC after: 2 days
* Fix compilation with LOCKF_DEBUG.dfr2008-04-161-1/+1
|
* Move the head of byte-level advisory lock list from thekib2008-04-161-1/+96
| | | | | | | | | | | | | | | | | | | | | | 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
* Don't try to use an SX lock while holding the vnode interlock.dfr2008-04-011-5/+10
| | | | Sponsored by: Isilon Systems
* Add the new kernel-mode NFS Lock Manager. To use it instead of thedfr2008-03-261-465/+1888
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* - Fix the last of the threading bugs that were introduced as far back asjeff2008-03-191-6/+12
| | | | | | | | | | | | 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
* - Relax requirements for p_numthreads, p_threads, p_swtick, and p_nice fromjeff2008-03-191-3/+3
| | | | | | | 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.
* Do not call free() while holding vnode interlock.kib2007-08-071-27/+44
| | | | | | Reported and tested by: Peter Holm Reviewed by: jeff Approved by: re (kensmith)
* - Remove explicit Giant protection from lockf. Use the vnode interlockjeff2007-07-031-54/+56
| | | | | | | | | | 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
* Commit 14/14 of sched_lock decomposition.jeff2007-06-051-8/+16
| | | | | | | | | | | - 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)
* Print name of device instead of useless major/minor numbers.phk2005-03-291-3/+2
|
* Fix a debug message to print a usable device name rather than uselessphk2005-03-151-3/+2
| | | | major+minor tupple.
* - Make lf_print static and move its prototype into kern_lockf.cjeff2005-01-251-18/+40
| | | | | | | - Protect all of the advlock code with Giant as some filesystems may not be entering with Giant held now. Sponsored by: Isilon Systems, Inc.
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Remove advertising clause from University of California Regent's license,imp2004-04-051-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core
* Use __FBSDID().obrien2003-06-111-1/+3
|
* Deprecate machine/limits.h in favor of new sys/limits.h.kan2003-04-291-2/+1
| | | | | | | Change all in-tree consumers to include <sys/limits.h> Discussed on: standards@ Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>
* Including <sys/stdint.h> is (almost?) universally only to be able to usephk2003-03-181-1/+0
| | | | | %j in printfs, so put a newsted include in <sys/systm.h> where the printf prototype lives and save everybody else the trouble.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-2/+2
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-2/+2
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* - Fix a bunch of casts to long which were truncating off_t's.mux2002-11-071-17/+15
| | | | | | | - 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).
* Remove a conditional #include <sys/kernel.h>, it is alreadymux2002-09-141-1/+0
| | | | | | included unconditionally before. Submitted by: Olivier Houchard <cognet@ci0.org>
* Add a #include for <sys/mount.h>phk2002-08-131-0/+1
|
* More caddr_t removal.alfred2002-06-291-3/+3
| | | | Change struct knote's kn_hook from caddr_t to void *.
* Remove __P.alfred2002-03-191-8/+8
|
* make LOCKF_DEBUG kernel option work (sorta)alfred2001-12-021-10/+26
| | | | | Submitted by: Maxim Konovalov <maxim@macomnet.ru> PR: kern/32267
* KSE Milestone 2julian2001-09-121-13/+17
| | | | | | | | | | | | | | 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
* advlock: simplify overflow checksache2001-08-291-2/+2
|
* Cosmetique & style fixes from bdeache2001-08-261-5/+2
|
* Remove extra check unneded nowache2001-08-241-2/+0
|
* Add yet one check for SEEK_END overflowache2001-08-231-1/+2
|
* Oops, fix my broken handling of new l_len<0 caseache2001-08-231-2/+4
|
* Originally BSD return EINVAL for l_len < 0, but now POSIX wants it too,ache2001-08-231-3/+6
| | | | so implement POSIX l_len < 0 handling.
* Cosmetique: correct English in commentsache2001-08-231-2/+2
| | | | Pointed by: bde
* Move <machine/*> after <sys/*>ache2001-08-231-2/+2
| | | | Pointed by: bde
* Detect off_t EOVERFLOW of start/end offsets calculations for adv. lock,ache2001-08-231-1/+12
| | | | as POSIX require.
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-0/+1
| | | | | | | | | | | 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)
* Implement client side NFS locks.alfred2001-04-171-1/+1
| | | | | Obtained from: BSD/os Import Ok'd by: mckusick, jkh, motd on builder.freebsd.org
* Protect p_wmesg and p_wchan with sched_lock while checking for deadlocksjhb2001-03-241-0/+3
| | | | with other byte range file locks.
OpenPOWER on IntegriCloud