Deleted Added
full compact
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

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

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)ufs_lockf.c 8.3 (Berkeley) 1/6/94
37 * $Id: kern_lockf.c,v 1.3 1994/10/25 11:27:51 davidg Exp $
38 */
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>
43#include <sys/file.h>
44#include <sys/proc.h>
45#include <sys/vnode.h>

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

56
57#ifdef LOCKF_DEBUG
58int lockf_debug = 0;
59#endif
60
61#define NOLOCKF (struct lockf *)0
62#define SELF 0x1
63#define OTHERS 0x2
64
65/*
66 * Advisory record locking support
67 */
68int
69lf_advlock(ap, head, size)
70 struct vop_advlock_args /* {
71 struct vnode *a_vp;

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

152 return (EINVAL);
153 }
154 /* NOTREACHED */
155}
156
157/*
158 * Set a byte-range lock.
159 */
160int
161lf_setlock(lock)
162 register struct lockf *lock;
163{
164 register struct lockf *block;
165 struct lockf **head = lock->lf_head;
166 struct lockf **prev, *overlap, *ltmp;
167 static char lockstr[] = "lockf";
168 int ovcase, priority, needtolink, error;

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

394}
395
396/*
397 * Remove a byte-range lock on an inode.
398 *
399 * Generally, find the lock (or an overlap to that lock)
400 * and remove it (or shrink it), then wakeup anyone we can.
401 */
402int
403lf_clearlock(unlock)
404 register struct lockf *unlock;
405{
406 struct lockf **head = unlock->lf_head;
407 register struct lockf *lf = *head;
408 struct lockf *overlap, **prev;
409 int ovcase;
410

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

463#endif /* LOCKF_DEBUG */
464 return (0);
465}
466
467/*
468 * Check whether there is a blocking lock,
469 * and if so return its process identifier.
470 */
471int
472lf_getlock(lock, fl)
473 register struct lockf *lock;
474 register struct flock *fl;
475{
476 register struct lockf *block;
477
478#ifdef LOCKF_DEBUG
479 if (lockf_debug & 1)

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

497 }
498 return (0);
499}
500
501/*
502 * Walk the list of locks for an inode and
503 * return the first blocking lock.
504 */
505struct lockf *
506lf_getblock(lock)
507 register struct lockf *lock;
508{
509 struct lockf **prev, *overlap, *lf = *(lock->lf_head);
510 int ovcase;
511
512 prev = lock->lf_head;
513 while ((ovcase = lf_findoverlap(lf, lock, OTHERS, &prev, &overlap))) {

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

527
528/*
529 * Walk the list of locks for an inode to
530 * find an overlapping lock (if any).
531 *
532 * NOTE: this returns only the FIRST overlapping lock. There
533 * may be more than one.
534 */
535int
536lf_findoverlap(lf, lock, type, prev, overlap)
537 register struct lockf *lf;
538 struct lockf *lock;
539 int type;
540 struct lockf ***prev;
541 struct lockf **overlap;
542{
543 off_t start, end;

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

636 panic("lf_findoverlap: default");
637 }
638 return (0);
639}
640
641/*
642 * Add a lock to the end of the blocked list.
643 */
644void
645lf_addblock(blocklist, lock)
646 struct lockf *blocklist;
647 struct lockf *lock;
648{
649 register struct lockf *lf;
650
651 if (lock == NOLOCKF)
652 return;

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

665 lf->lf_block = lock;
666 return;
667}
668
669/*
670 * Split a lock and a contained region into
671 * two or three locks as necessary.
672 */
673void
674lf_split(lock1, lock2)
675 register struct lockf *lock1;
676 register struct lockf *lock2;
677{
678 register struct lockf *splitlock;
679
680#ifdef LOCKF_DEBUG
681 if (lockf_debug & 2) {

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

712 splitlock->lf_next = lock1->lf_next;
713 lock2->lf_next = splitlock;
714 lock1->lf_next = lock2;
715}
716
717/*
718 * Wakeup a blocklist
719 */
720void
721lf_wakelock(listhead)
722 struct lockf *listhead;
723{
724 register struct lockf *blocklist, *wakelock;
725
726 blocklist = listhead->lf_block;
727 listhead->lf_block = NOLOCKF;
728 while (blocklist != NOLOCKF) {

--- 70 unchanged lines hidden ---