Project

General

Profile

Bug #11679

vn_rele() and friends should VERIFY after mutex

Added by Dan McDonald about 1 month ago. Updated about 1 month ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
kernel
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:

Description

vn_rele() and its friends have an antipattern:

void
vn_rele(vnode_t *vp)
{
    VERIFY(vp->v_count > 0);   /* XXX KEBE ASKS WHY HERE? */
    mutex_enter(&vp->v_lock);
    /* XXX KEBE ASKS AND NOT HERE? */
    if (vp->v_count == 1) {
        mutex_exit(&vp->v_lock);
        VOP_INACTIVE(vp, CRED(), NULL);
        return;
    }
    VN_RELE_LOCKED(vp);
    mutex_exit(&vp->v_lock);
}

Before commit b5fca8f855 put this as a VERIFY, it's predecessors had an if v_count check also outside the vp mutex. These should be checked AFTER the mutex gets held. In general the v_count should never be 0 at this point, but the more accurate measurement can only happen post-mutex-hold.

History

#1

Updated by Dan McDonald about 1 month ago

  • Difficulty changed from Medium to Bite-size
#2

Updated by Dan McDonald about 1 month ago

There are other parts of the code that check v_count without holding the v_lock. This bug (and its fix) should only focus on vn_rele() and its friends.

#3

Updated by Dan McDonald about 1 month ago

  • Description updated (diff)

Also available in: Atom PDF