Deleted Added
full compact
kern_lockf.c (171772) kern_lockf.c (177368)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Scooter Morris at Genentech Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)ufs_lockf.c 8.3 (Berkeley) 1/6/94
33 */
34
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Scooter Morris at Genentech Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)ufs_lockf.c 8.3 (Berkeley) 1/6/94
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/kern/kern_lockf.c 171772 2007-08-07 09:04:50Z kib $");
36__FBSDID("$FreeBSD: head/sys/kern/kern_lockf.c 177368 2008-03-19 06:19:01Z jeff $");
37
38#include "opt_debug_lockf.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>
43#include <sys/limits.h>
44#include <sys/lock.h>

--- 233 unchanged lines hidden (view full) ---

278 struct thread *td;
279 struct lockf *waitblock;
280 int i = 0;
281
282 /* The block is waiting on something */
283 wproc = (struct proc *)block->lf_id;
284restart:
285 nproc = NULL;
37
38#include "opt_debug_lockf.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>
43#include <sys/limits.h>
44#include <sys/lock.h>

--- 233 unchanged lines hidden (view full) ---

278 struct thread *td;
279 struct lockf *waitblock;
280 int i = 0;
281
282 /* The block is waiting on something */
283 wproc = (struct proc *)block->lf_id;
284restart:
285 nproc = NULL;
286 PROC_SLOCK(wproc);
286 PROC_LOCK(wproc);
287 FOREACH_THREAD_IN_PROC(wproc, td) {
288 thread_lock(td);
289 while (td->td_wchan &&
290 (td->td_wmesg == lockstr) &&
291 (i++ < maxlockdepth)) {
292 waitblock = (struct lockf *)td->td_wchan;
293 /* Get the owner of the blocking lock */
294 waitblock = waitblock->lf_next;
295 if ((waitblock->lf_flags & F_POSIX) == 0)
296 break;
297 nproc = (struct proc *)waitblock->lf_id;
298 if (nproc == (struct proc *)lock->lf_id) {
287 FOREACH_THREAD_IN_PROC(wproc, td) {
288 thread_lock(td);
289 while (td->td_wchan &&
290 (td->td_wmesg == lockstr) &&
291 (i++ < maxlockdepth)) {
292 waitblock = (struct lockf *)td->td_wchan;
293 /* Get the owner of the blocking lock */
294 waitblock = waitblock->lf_next;
295 if ((waitblock->lf_flags & F_POSIX) == 0)
296 break;
297 nproc = (struct proc *)waitblock->lf_id;
298 if (nproc == (struct proc *)lock->lf_id) {
299 PROC_SUNLOCK(wproc);
300 thread_unlock(td);
299 thread_unlock(td);
300 PROC_UNLOCK(wproc);
301 lock->lf_next = *clean;
302 *clean = lock;
303 return (EDEADLK);
304 }
305 }
306 thread_unlock(td);
307 }
301 lock->lf_next = *clean;
302 *clean = lock;
303 return (EDEADLK);
304 }
305 }
306 thread_unlock(td);
307 }
308 PROC_SUNLOCK(wproc);
308 PROC_UNLOCK(wproc);
309 wproc = nproc;
310 if (wproc)
311 goto restart;
312 }
313 /*
314 * For flock type locks, we must first remove
315 * any shared locks that we hold before we sleep
316 * waiting for an exclusive lock.

--- 571 unchanged lines hidden ---
309 wproc = nproc;
310 if (wproc)
311 goto restart;
312 }
313 /*
314 * For flock type locks, we must first remove
315 * any shared locks that we hold before we sleep
316 * waiting for an exclusive lock.

--- 571 unchanged lines hidden ---