Windows: AFSInitDirEntry allocated ObjInfoCBs valid
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 12 Apr 2013 14:58:47 +0000 (10:58 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 26 Apr 2013 13:23:00 +0000 (06:23 -0700)
commita1aa06e82ca770456884b1b96b4f0c109cd06a85
treea08560bec2ca31540a0751d4ae8b9b91b9a4e94d
parent9fd825790e4e61aa5fdf8996874fc9be8b1d1cc0
Windows: AFSInitDirEntry allocated ObjInfoCBs valid

In AFSInitDirEntry the pattern was to find or allocate an
ObjectInfoCB then destroy it if the DirectoryCB creation fails
for some reason.  The problem with this approach is that once the
VolumeCB ObjectInfoTree.TreeLock is dropped the ObjectInfoCB is findable.
That means that the contents of the ObjectInfoCB must be valid.

This patchset makes three changes.  First, in the case where the
ObjectInfoCB is allocated, the fields of the ObjectInfoCB are populated
from the DirEnumEntry before the TreeLock is dropped.  Second, if the
DirectoryCB allocation fails the ObjectInfoCB is not deleted.  It is
perfectly valid and can be used by a subsequent AFSInitDirEntry call.
Perhaps one that is racing with this thread.   It will eventually be
cleaned up by the AFSPrimaryVolumeWorkerThread.  Finally, when the
ObjectInfoCB reference count is decremented the TreeLock is held shared in
order to prevent races with other threads that might be incrementing it
themselves.

Change-Id: If3091d4fa640bbb614a1a405c3afc910d649aad6
Reviewed-on: http://gerrit.openafs.org/9781
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp