OpenAFS Master Repository branch, master, updated. openafs-devel-1_5_76-2066-g8e15e16

Gerrit Code Review
Tue, 3 Jan 2012 07:59:50 -0800 (PST)

The following commit has been merged in the master branch:
commit 8e15e16c9e6a5768f31976cc21b48d5bb10617b7
Author: Andrew Deason <>
Date:   Fri Nov 18 10:25:08 2011 -0600

    DAFS: Atomically re-hash vnode in VGetFreeVnode_r
    VGetFreeVnode_r pulls a vnode off of the vnode LRU, and removes the
    vnode from the vnode hash table. In DAFS, we may drop the volume glock
    immediately afterwards in order to close the ihandle for the old vnode
    While we have the glock dropped, another thread may try to
    VLookupVnode for the new vnode we are creating, find that it is not
    hashed, and call VGetFreeVnode_r itself. This can result in two
    threads having two separate copies of the same vnode, which bypasses
    any mutual exclusion ensured by per-vnode locks, since they will lock
    their own version of the vnode. This can result in a variety of
    different problems where two threads try to write to the same vnode at
    the same time. One example is calling CopyOnWrite on the same file in
    parallel, which can cause link undercounts, writes to the wrong vnode
    tag, and other CoW-related errors.
    To prevent all this, make VGetFreeVnode_r atomically remove the old
    vnode structure from the relevant hashes, and add it to the new hashes
    before dropping the glock. This ensures that any other thread trying
    to load the same vnode will see the new vnode in the hash table,
    though it will not yet be valid until the vnode is loaded.
    Note that this only solves this race for DAFS. For non-DAFS, the vol
    glock is held over the ihandle close, so this race does not exist.
    The comments around the callers of VGetFreeVnode_r indicate that
    similar extant races exist here for non-DAFS, but they are unsolvable
    without significant DAFS-like changes to the vnode package.
    Change-Id: I84c5d1bdd29f9e7140e905388b4b65629932c951
    Tested-by: BuildBot <>
    Reviewed-by: Derrick Brashear <>

 src/vol/vnode.c |   45 +++++++++++++++++++++++++--------------------
 src/vol/vnode.h |    3 ++-
 2 files changed, 27 insertions(+), 21 deletions(-)

OpenAFS Master Repository