Deleted Added
full compact
kern_lockf.c (50477) kern_lockf.c (53225)
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
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 * $FreeBSD: head/sys/kern/kern_lockf.c 50477 1999-08-28 01:08:13Z peter $
37 * $FreeBSD: head/sys/kern/kern_lockf.c 53225 1999-11-16 16:28:58Z phk $
38 */
39
40#include "opt_debug_lockf.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/lock.h>

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

357 /*
358 * If downgrading lock, others may be able to
359 * acquire it, otherwise take the list.
360 */
361 if (lock->lf_type == F_RDLCK &&
362 overlap->lf_type == F_WRLCK) {
363 lf_wakelock(overlap);
364 } else {
38 */
39
40#include "opt_debug_lockf.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/lock.h>

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

357 /*
358 * If downgrading lock, others may be able to
359 * acquire it, otherwise take the list.
360 */
361 if (lock->lf_type == F_RDLCK &&
362 overlap->lf_type == F_WRLCK) {
363 lf_wakelock(overlap);
364 } else {
365 while ((ltmp = overlap->lf_blkhd.tqh_first) !=
366 NOLOCKF) {
365 while (!TAILQ_EMPTY(&overlap->lf_blkhd)) {
366 ltmp = TAILQ_FIRST(&overlap->lf_blkhd);
367 TAILQ_REMOVE(&overlap->lf_blkhd, ltmp,
368 lf_block);
369 TAILQ_INSERT_TAIL(&lock->lf_blkhd,
370 ltmp, lf_block);
371 ltmp->lf_next = lock;
372 }
373 }
374 /*

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

716 * Wakeup a blocklist
717 */
718static void
719lf_wakelock(listhead)
720 struct lockf *listhead;
721{
722 register struct lockf *wakelock;
723
367 TAILQ_REMOVE(&overlap->lf_blkhd, ltmp,
368 lf_block);
369 TAILQ_INSERT_TAIL(&lock->lf_blkhd,
370 ltmp, lf_block);
371 ltmp->lf_next = lock;
372 }
373 }
374 /*

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

716 * Wakeup a blocklist
717 */
718static void
719lf_wakelock(listhead)
720 struct lockf *listhead;
721{
722 register struct lockf *wakelock;
723
724 while ((wakelock = listhead->lf_blkhd.tqh_first) != NOLOCKF) {
724 while (!TAILQ_EMPTY(&listhead->lf_blkhd)) {
725 wakelock = TAILQ_FIRST(&listhead->lf_blkhd);
725 TAILQ_REMOVE(&listhead->lf_blkhd, wakelock, lf_block);
726 wakelock->lf_next = NOLOCKF;
727#ifdef LOCKF_DEBUG
728 if (lockf_debug & 2)
729 lf_print("lf_wakelock: awakening", wakelock);
730#endif /* LOCKF_DEBUG */
731 wakeup((caddr_t)wakelock);
732 }

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

751 printf(" in ino %lu on dev <%d, %d>, %s, start %ld, end %ld",
752 (u_long)lock->lf_inode->i_number,
753 major(lock->lf_inode->i_dev),
754 minor(lock->lf_inode->i_dev),
755 lock->lf_type == F_RDLCK ? "shared" :
756 lock->lf_type == F_WRLCK ? "exclusive" :
757 lock->lf_type == F_UNLCK ? "unlock" :
758 "unknown", (long)lock->lf_start, (long)lock->lf_end);
726 TAILQ_REMOVE(&listhead->lf_blkhd, wakelock, lf_block);
727 wakelock->lf_next = NOLOCKF;
728#ifdef LOCKF_DEBUG
729 if (lockf_debug & 2)
730 lf_print("lf_wakelock: awakening", wakelock);
731#endif /* LOCKF_DEBUG */
732 wakeup((caddr_t)wakelock);
733 }

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

752 printf(" in ino %lu on dev <%d, %d>, %s, start %ld, end %ld",
753 (u_long)lock->lf_inode->i_number,
754 major(lock->lf_inode->i_dev),
755 minor(lock->lf_inode->i_dev),
756 lock->lf_type == F_RDLCK ? "shared" :
757 lock->lf_type == F_WRLCK ? "exclusive" :
758 lock->lf_type == F_UNLCK ? "unlock" :
759 "unknown", (long)lock->lf_start, (long)lock->lf_end);
759 if (lock->lf_blkhd.tqh_first)
760 printf(" block %p\n", (void *)lock->lf_blkhd.tqh_first);
760 if (!TAILQ_EMPTY(&lock->lf_blkhd))
761 printf(" block %p\n", (void *)TAILQ_FIRST(&lock->lf_blkhd));
761 else
762 printf("\n");
763}
764
765void
766lf_printlist(tag, lock)
767 char *tag;
768 struct lockf *lock;

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

781 else
782 printf("id %p", (void *)lf->lf_id);
783 /* XXX no %qd in kernel. Truncate. */
784 printf(", %s, start %ld, end %ld",
785 lf->lf_type == F_RDLCK ? "shared" :
786 lf->lf_type == F_WRLCK ? "exclusive" :
787 lf->lf_type == F_UNLCK ? "unlock" :
788 "unknown", (long)lf->lf_start, (long)lf->lf_end);
762 else
763 printf("\n");
764}
765
766void
767lf_printlist(tag, lock)
768 char *tag;
769 struct lockf *lock;

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

782 else
783 printf("id %p", (void *)lf->lf_id);
784 /* XXX no %qd in kernel. Truncate. */
785 printf(", %s, start %ld, end %ld",
786 lf->lf_type == F_RDLCK ? "shared" :
787 lf->lf_type == F_WRLCK ? "exclusive" :
788 lf->lf_type == F_UNLCK ? "unlock" :
789 "unknown", (long)lf->lf_start, (long)lf->lf_end);
789 for (blk = lf->lf_blkhd.tqh_first; blk;
790 blk = blk->lf_block.tqe_next) {
790 TAILQ_FOREACH(blk, &lf->lf_blkhd, lf_block) {
791 printf("\n\t\tlock request %p for ", (void *)blk);
792 if (blk->lf_flags & F_POSIX)
793 printf("proc %ld",
794 (long)((struct proc *)blk->lf_id)->p_pid);
795 else
796 printf("id %p", (void *)blk->lf_id);
797 /* XXX no %qd in kernel. Truncate. */
798 printf(", %s, start %ld, end %ld",
799 blk->lf_type == F_RDLCK ? "shared" :
800 blk->lf_type == F_WRLCK ? "exclusive" :
801 blk->lf_type == F_UNLCK ? "unlock" :
802 "unknown", (long)blk->lf_start,
803 (long)blk->lf_end);
791 printf("\n\t\tlock request %p for ", (void *)blk);
792 if (blk->lf_flags & F_POSIX)
793 printf("proc %ld",
794 (long)((struct proc *)blk->lf_id)->p_pid);
795 else
796 printf("id %p", (void *)blk->lf_id);
797 /* XXX no %qd in kernel. Truncate. */
798 printf(", %s, start %ld, end %ld",
799 blk->lf_type == F_RDLCK ? "shared" :
800 blk->lf_type == F_WRLCK ? "exclusive" :
801 blk->lf_type == F_UNLCK ? "unlock" :
802 "unknown", (long)blk->lf_start,
803 (long)blk->lf_end);
804 if (blk->lf_blkhd.tqh_first)
804 if (!TAILQ_EMPTY(&blk->lf_blkhd))
805 panic("lf_printlist: bad list");
806 }
807 printf("\n");
808 }
809}
810#endif /* LOCKF_DEBUG */
805 panic("lf_printlist: bad list");
806 }
807 printf("\n");
808 }
809}
810#endif /* LOCKF_DEBUG */