kern_lockf.c (788390df0ae7efc76b5498bfd1230637c48468b0) kern_lockf.c (abd80ddb9474948fb291becc395d72b40927a32b)
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
5 * Authors: Doug Rabson <dfr@rabson.org>
6 * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
7 *
8 * Redistribution and use in source and binary forms, with or without

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

587
588 /*
589 * Do the requested operation. First find our state structure
590 * and create a new one if necessary - the caller's *statep
591 * variable and the state's ls_threads count is protected by
592 * the vnode interlock.
593 */
594 VI_LOCK(vp);
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
5 * Authors: Doug Rabson <dfr@rabson.org>
6 * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
7 *
8 * Redistribution and use in source and binary forms, with or without

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

587
588 /*
589 * Do the requested operation. First find our state structure
590 * and create a new one if necessary - the caller's *statep
591 * variable and the state's ls_threads count is protected by
592 * the vnode interlock.
593 */
594 VI_LOCK(vp);
595 if (vp->v_iflag & VI_DOOMED) {
595 if (VN_IS_DOOMED(vp)) {
596 VI_UNLOCK(vp);
597 lf_free_lock(lock);
598 return (ENOENT);
599 }
600
601 /*
602 * Allocate a state structure if necessary.
603 */

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

617 LIST_INSERT_HEAD(&lf_lock_states, ls, ls_link);
618 sx_xunlock(&lf_lock_states_lock);
619
620 /*
621 * Cope if we lost a race with some other thread while
622 * trying to allocate memory.
623 */
624 VI_LOCK(vp);
596 VI_UNLOCK(vp);
597 lf_free_lock(lock);
598 return (ENOENT);
599 }
600
601 /*
602 * Allocate a state structure if necessary.
603 */

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

617 LIST_INSERT_HEAD(&lf_lock_states, ls, ls_link);
618 sx_xunlock(&lf_lock_states_lock);
619
620 /*
621 * Cope if we lost a race with some other thread while
622 * trying to allocate memory.
623 */
624 VI_LOCK(vp);
625 if (vp->v_iflag & VI_DOOMED) {
625 if (VN_IS_DOOMED(vp)) {
626 VI_UNLOCK(vp);
627 sx_xlock(&lf_lock_states_lock);
628 LIST_REMOVE(ls, ls_link);
629 sx_xunlock(&lf_lock_states_lock);
630 sx_destroy(&ls->ls_lock);
631 free(ls, M_LOCKF);
632 lf_free_lock(lock);
633 return (ENOENT);

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

650 state->ls_threads++;
651 VI_UNLOCK(vp);
652 }
653
654 sx_xlock(&state->ls_lock);
655 /*
656 * Recheck the doomed vnode after state->ls_lock is
657 * locked. lf_purgelocks() requires that no new threads add
626 VI_UNLOCK(vp);
627 sx_xlock(&lf_lock_states_lock);
628 LIST_REMOVE(ls, ls_link);
629 sx_xunlock(&lf_lock_states_lock);
630 sx_destroy(&ls->ls_lock);
631 free(ls, M_LOCKF);
632 lf_free_lock(lock);
633 return (ENOENT);

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

650 state->ls_threads++;
651 VI_UNLOCK(vp);
652 }
653
654 sx_xlock(&state->ls_lock);
655 /*
656 * Recheck the doomed vnode after state->ls_lock is
657 * locked. lf_purgelocks() requires that no new threads add
658 * pending locks when vnode is marked by VI_DOOMED flag.
658 * pending locks when vnode is marked by VIRF_DOOMED flag.
659 */
660 VI_LOCK(vp);
659 */
660 VI_LOCK(vp);
661 if (vp->v_iflag & VI_DOOMED) {
661 if (VN_IS_DOOMED(vp)) {
662 state->ls_threads--;
663 wakeup(state);
664 VI_UNLOCK(vp);
665 sx_xunlock(&state->ls_lock);
666 lf_free_lock(lock);
667 return (ENOENT);
668 }
669 VI_UNLOCK(vp);

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

766lf_purgelocks(struct vnode *vp, struct lockf **statep)
767{
768 struct lockf *state;
769 struct lockf_entry *lock, *nlock;
770
771 /*
772 * For this to work correctly, the caller must ensure that no
773 * other threads enter the locking system for this vnode,
662 state->ls_threads--;
663 wakeup(state);
664 VI_UNLOCK(vp);
665 sx_xunlock(&state->ls_lock);
666 lf_free_lock(lock);
667 return (ENOENT);
668 }
669 VI_UNLOCK(vp);

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

766lf_purgelocks(struct vnode *vp, struct lockf **statep)
767{
768 struct lockf *state;
769 struct lockf_entry *lock, *nlock;
770
771 /*
772 * For this to work correctly, the caller must ensure that no
773 * other threads enter the locking system for this vnode,
774 * e.g. by checking VI_DOOMED. We wake up any threads that are
774 * e.g. by checking VIRF_DOOMED. We wake up any threads that are
775 * sleeping waiting for locks on this vnode and then free all
776 * the remaining locks.
777 */
778 VI_LOCK(vp);
775 * sleeping waiting for locks on this vnode and then free all
776 * the remaining locks.
777 */
778 VI_LOCK(vp);
779 KASSERT(vp->v_iflag & VI_DOOMED,
779 KASSERT(VN_IS_DOOMED(vp),
780 ("lf_purgelocks: vp %p has not vgone yet", vp));
781 state = *statep;
782 if (state == NULL) {
783 VI_UNLOCK(vp);
784 return;
785 }
786 *statep = NULL;
787 if (LIST_EMPTY(&state->ls_active) && state->ls_threads == 0) {

--- 1771 unchanged lines hidden ---
780 ("lf_purgelocks: vp %p has not vgone yet", vp));
781 state = *statep;
782 if (state == NULL) {
783 VI_UNLOCK(vp);
784 return;
785 }
786 *statep = NULL;
787 if (LIST_EMPTY(&state->ls_active) && state->ls_threads == 0) {

--- 1771 unchanged lines hidden ---