OpenAFS Master Repository branch, openafs-stable-1_6_x, updated. openafs-stable-1_6_1pre1-9-g6479bb2

Gerrit Code Review gerrit@openafs.org
Sat, 7 Jan 2012 06:23:03 -0800 (PST)


The following commit has been merged in the openafs-stable-1_6_x branch:
commit 6479bb29d494077f31d0ddc3d165164b302b2e3f
Author: Andrew Deason <adeason@sinenomine.net>
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
    structure.
    
    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.
    
    Reviewed-on: http://gerrit.openafs.org/6385
    Tested-by: BuildBot <buildbot@rampaginggeek.com>
    Reviewed-by: Derrick Brashear <shadow@dementix.org>
    (cherry picked from commit 8e15e16c9e6a5768f31976cc21b48d5bb10617b7)
    
    Change-Id: I915d18c4252b698f39fdf65793311a39381096b4
    Reviewed-on: http://gerrit.openafs.org/6495
    Tested-by: BuildBot <buildbot@rampaginggeek.com>
    Reviewed-by: Derrick Brashear <shadow@dementix.org>

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

-- 
OpenAFS Master Repository