lockf: elide avoidable locking in lf_advlockasync
While here assert on ls_threads state.
This commit is contained in:
parent
34fc29e0c9
commit
d363fa4127
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362950
@ -637,6 +637,7 @@ lf_advlockasync(struct vop_advlockasync_args *ap, struct lockf **statep,
|
|||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
} else {
|
} else {
|
||||||
state = *statep;
|
state = *statep;
|
||||||
|
MPASS(state->ls_threads >= 0);
|
||||||
state->ls_threads++;
|
state->ls_threads++;
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
|
|
||||||
@ -647,6 +648,7 @@ lf_advlockasync(struct vop_advlockasync_args *ap, struct lockf **statep,
|
|||||||
free(ls, M_LOCKF);
|
free(ls, M_LOCKF);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
MPASS(state->ls_threads >= 0);
|
||||||
state->ls_threads++;
|
state->ls_threads++;
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
}
|
}
|
||||||
@ -657,8 +659,9 @@ lf_advlockasync(struct vop_advlockasync_args *ap, struct lockf **statep,
|
|||||||
* locked. lf_purgelocks() requires that no new threads add
|
* locked. lf_purgelocks() requires that no new threads add
|
||||||
* pending locks when vnode is marked by VIRF_DOOMED flag.
|
* pending locks when vnode is marked by VIRF_DOOMED flag.
|
||||||
*/
|
*/
|
||||||
VI_LOCK(vp);
|
|
||||||
if (VN_IS_DOOMED(vp)) {
|
if (VN_IS_DOOMED(vp)) {
|
||||||
|
VI_LOCK(vp);
|
||||||
|
MPASS(state->ls_threads > 0);
|
||||||
state->ls_threads--;
|
state->ls_threads--;
|
||||||
wakeup(state);
|
wakeup(state);
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
@ -666,7 +669,6 @@ lf_advlockasync(struct vop_advlockasync_args *ap, struct lockf **statep,
|
|||||||
lf_free_lock(lock);
|
lf_free_lock(lock);
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
}
|
}
|
||||||
VI_UNLOCK(vp);
|
|
||||||
|
|
||||||
switch (ap->a_op) {
|
switch (ap->a_op) {
|
||||||
case F_SETLK:
|
case F_SETLK:
|
||||||
@ -728,15 +730,11 @@ lf_advlockasync(struct vop_advlockasync_args *ap, struct lockf **statep,
|
|||||||
sx_xunlock(&state->ls_lock);
|
sx_xunlock(&state->ls_lock);
|
||||||
|
|
||||||
VI_LOCK(vp);
|
VI_LOCK(vp);
|
||||||
|
MPASS(state->ls_threads > 0);
|
||||||
state->ls_threads--;
|
state->ls_threads--;
|
||||||
if (LIST_EMPTY(&state->ls_active) && state->ls_threads == 0) {
|
if (state->ls_threads != 0) {
|
||||||
KASSERT(LIST_EMPTY(&state->ls_pending),
|
|
||||||
("freeable state with pending locks"));
|
|
||||||
} else {
|
|
||||||
wakeup(state);
|
wakeup(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
|
|
||||||
if (error == EDOOFUS) {
|
if (error == EDOOFUS) {
|
||||||
@ -790,6 +788,7 @@ lf_purgelocks(struct vnode *vp, struct lockf **statep)
|
|||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
MPASS(state->ls_threads >= 0);
|
||||||
state->ls_threads++;
|
state->ls_threads++;
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
|
|
||||||
@ -1953,6 +1952,7 @@ lf_iteratelocks_vnode(struct vnode *vp, lf_iterator *fn, void *arg)
|
|||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
MPASS(ls->ls_threads >= 0);
|
||||||
ls->ls_threads++;
|
ls->ls_threads++;
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
|
|
||||||
@ -1976,6 +1976,7 @@ lf_iteratelocks_vnode(struct vnode *vp, lf_iterator *fn, void *arg)
|
|||||||
}
|
}
|
||||||
sx_xunlock(&ls->ls_lock);
|
sx_xunlock(&ls->ls_lock);
|
||||||
VI_LOCK(vp);
|
VI_LOCK(vp);
|
||||||
|
MPASS(ls->ls_threads > 0);
|
||||||
ls->ls_threads--;
|
ls->ls_threads--;
|
||||||
wakeup(ls);
|
wakeup(ls);
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
|
Loading…
Reference in New Issue
Block a user