X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/94ff46dc2849db4d43eaaf144872decc522aafb4..a991bd8d3e7fe02dbca0644054bab73c5b75324a:/bsd/kern/kern_lockf.c diff --git a/bsd/kern/kern_lockf.c b/bsd/kern/kern_lockf.c index d67a8f84b..03f86bef2 100644 --- a/bsd/kern/kern_lockf.c +++ b/bsd/kern/kern_lockf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2019-2020 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -99,12 +99,11 @@ static int lockf_debug = 0; /* was 2, could be 3 ;-) */ SYSCTL_INT(_debug, OID_AUTO, lockf_debug, CTLFLAG_RW | CTLFLAG_LOCKED, &lockf_debug, 0, ""); /* - * If there is no mask bit selector, or there is one, and the selector is - * set, then output the debugging diagnostic. + * If the selector is set, then output the debugging diagnostic. */ #define LOCKF_DEBUG(mask, ...) \ do { \ - if (!(mask) || ((mask) & lockf_debug)) { \ + if ((mask) & lockf_debug) { \ printf("%s>", __FUNCTION__); \ printf(__VA_ARGS__); \ } \ @@ -298,7 +297,7 @@ lf_advlock(struct vnop_advlock_args *ap) lock->lf_head = head; lock->lf_next = (struct lockf *)0; TAILQ_INIT(&lock->lf_blkhd); - lock->lf_flags = ap->a_flags; + lock->lf_flags = (short)ap->a_flags; #if IMPORTANCE_INHERITANCE lock->lf_boosted = LF_NOT_BOOSTED; #endif @@ -507,7 +506,7 @@ lf_setlock(struct lockf *lock, struct timespec *timeout) { struct lockf *block; struct lockf **head = lock->lf_head; - struct lockf **prev, *overlap, *ltmp; + struct lockf **prev, *overlap; static const char lockstr[] = "lockf"; int priority, needtolink, error; struct vnode *vp = lock->lf_vnode; @@ -852,6 +851,7 @@ scan: lf_wakelock(overlap, TRUE); } overlap->lf_type = lock->lf_type; + lf_move_blocked(overlap, lock); FREE(lock, M_LOCKF); lock = overlap; /* for lf_coalesce_adjacent() */ break; @@ -861,6 +861,7 @@ scan: * Check for common starting point and different types. */ if (overlap->lf_type == lock->lf_type) { + lf_move_blocked(overlap, lock); FREE(lock, M_LOCKF); lock = overlap; /* for lf_coalesce_adjacent() */ break; @@ -892,14 +893,7 @@ scan: overlap->lf_type == F_WRLCK) { lf_wakelock(overlap, TRUE); } else { - while (!TAILQ_EMPTY(&overlap->lf_blkhd)) { - ltmp = TAILQ_FIRST(&overlap->lf_blkhd); - TAILQ_REMOVE(&overlap->lf_blkhd, ltmp, - lf_block); - TAILQ_INSERT_TAIL(&lock->lf_blkhd, - ltmp, lf_block); - ltmp->lf_next = lock; - } + lf_move_blocked(lock, overlap); } /* * Add the new lock if necessary and delete the overlap.