lockf: skip the hard work in lf_purgelocks if possible

Tested by:      pho
This commit is contained in:
Mateusz Guzik 2018-04-23 07:52:10 +00:00
parent 0d3323f557
commit c72ead2815
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=332879

View File

@ -777,6 +777,12 @@ lf_purgelocks(struct vnode *vp, struct lockf **statep)
return;
}
*statep = NULL;
if (LIST_EMPTY(&state->ls_active) && state->ls_threads == 0) {
KASSERT(LIST_EMPTY(&state->ls_pending),
("freeing state with pending locks"));
VI_UNLOCK(vp);
goto out_free;
}
state->ls_threads++;
VI_UNLOCK(vp);
@ -823,6 +829,7 @@ lf_purgelocks(struct vnode *vp, struct lockf **statep)
LIST_REMOVE(lock, lf_link);
lf_free_lock(lock);
}
out_free:
sx_xlock(&lf_lock_states_lock);
LIST_REMOVE(state, ls_link);
sx_xunlock(&lf_lock_states_lock);