OpenAFS Master Repository branch, master, updated. openafs-devel-1_9_1-135-gfad319f

Gerrit Code Review gerrit@openafs.org
Mon, 21 Feb 2022 20:44:44 -0500


The following commit has been merged in the master branch:
commit fad319fea28ea72fa695edca4b56492c8d352055
Author: Andrew Deason <adeason@dson.org>
Date:   Sun May 10 17:26:27 2020 -0500

    FBSD: Check VOP_ISLOCKED for LK_EXCLUSIVE
    
    A couple of places in the code check if a vnode is locked by the
    current thread by simply checking 'if (VOP_ISLOCKED(vp))'. But
    VOP_ISLOCKED() doesn't just return a simple 1 or 0, it returns LK_*
    constants (or 0). LK_EXCLUSIVE indicates that the calling thread holds
    an exclusive lock on the vnode, but LK_SHARED means someone holds a
    shared lock (possibly not the current thread), and LK_EXCLOTHER
    indicates that a different thread holds an exclusive lock.
    
    Because of this, it's possible for us to skip grabbing the vnode lock
    for certain operations, if someone else holds the lock at the same
    time. For example, this can happen when we call vinvalbuf() inside
    afs_GetVCache(), and FreeBSD will warn us that we didn't lock the
    vnode:
    
        #0 0xffffffff80bf6557 at kdb_backtrace+0x67
        #1 0xffffffff80c7a337 at assert_vop_locked+0x77
        #2 0xffffffff80c7a273 at vinvalbuf+0x23
        #3 0xffffffff8285aa2d at afs_GetVCache+0x25d
        #4 0xffffffff828d3325 at afs_root+0x145
        #5 0xffffffff80c70296 at lookup+0x8c6
        #6 0xffffffff80c6f599 at namei+0x4a9
        #7 0xffffffff80c872e4 at sys_lpathconf+0x54
        #8 0xffffffff81074581 at amd64_syscall+0x291
        #9 0xffffffff8104cde0 at fast_syscall_common+0x101
        vnode 0xfffff8012a62bc58: tag afs, type VDIR
            usecount 2, writecount 0, refcount 2 mountedhere 0
            flags (VV_ROOT|VI_ACTIVE)
            lock type afs: UNLOCKED
        #0 0xffffffff80b81fc2 at lockmgr_lock_fast_path+0x1e2
        #1 0xffffffff811fa9f6 at VOP_LOCK1_APV+0x96
        #2 0xffffffff80c8c705 at _vn_lock+0x65
        #3 0xffffffff80c7c066 at vget+0xa6
        #4 0xffffffff828d3437 at afs_root+0x257
        #5 0xffffffff80c70296 at lookup+0x8c6
        #6 0xffffffff80c6f599 at namei+0x4a9
        #7 0xffffffff80c872e4 at sys_lpathconf+0x54
        #8 0xffffffff81074581 at amd64_syscall+0x291
        #9 0xffffffff8104cde0 at fast_syscall_common+0x101
        vc 0xfffffe002be00000 vp 0xfffff8012a62bc58 tag afs, fid: 1.536870924.1.1, opens 0, writers 0
    
    To fix this, change our "islocked"-style checks to check if
    VOP_ISLOCKED() returns LK_EXCLUSIVE specifically.
    
    Change-Id: If322f62dc443ee9acc2349a23c6c618afd3e29d4
    Reviewed-on: https://gerrit.openafs.org/14204
    Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
    Tested-by: BuildBot <buildbot@rampaginggeek.com>

 src/afs/afs_pioctl.c | 2 +-
 src/afs/afs_vcache.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

-- 
OpenAFS Master Repository