Windows: AFSPrimaryVolumeWorkerThread reorg
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 2 Apr 2013 04:46:27 +0000 (00:46 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 6 Apr 2013 02:27:48 +0000 (19:27 -0700)
commitba78ac675c2a90359dedc9cf16e38e6d7e606eaf
treee8015bf4da13ea23244a811fc9a8bcaa6961d47b
parent9285cc3d5270306377ef3d6f90468129a8cfd376
Windows: AFSPrimaryVolumeWorkerThread reorg

Periodically there is a lost race which results in a valid DirectoryCB
with a non-NULL ObjectInformation pointer that refers to freed memory.
This major reorganization simplifies the logic and attempts to close
potential loopholes.

First, the AFSExamineDirectory() function is removed and replaced by
a call to AFSDeleteDirEntry().  The AFSExamineDirectory() function
examined all of the children AFSObjectInfoCB objects which in turn
duplicated much of the logic of AFSExamineObjInfo at the cost of
increased complexity due to the additional layer of locked objects.
Once the AFSDirectoryCB is removed a subsequent pass of the worker
thread will free the AFSObjectInfoCBs.

Second, the AFS_OBJECT_REFERENCE_DIRENTRY category had been used for
both DirectoryCB references and the Pioctl references.  A new
AFS_OBJECT_REFERENCE_PIOCTL category has been created to improve the
ability to track the allocations and releases.

Third, the AFSPrimaryVolumeWorker thread now attempts to hold onto the
VolumeCB TreeLock exclusively.  Previously the lock was held shared.
However, it is not safe for both the garbage collection and the find
routines to both be shared.  One has to be exclusive.  Although holding
the TreeLock exclusively in the garbage collection processing will result
in the lock being held for extended periods of time, it is more likely
that there will be benefits from parallel access during AFSFindObjectInfo()
calls.

Attempts to obtain most other locks are non-blocking.  If the lock cannot
be obtained, the object must be in use.  Therefore, it should not be
garbage collected.

Change-Id: I75e0302c1737aadfbd9afc0c8a03e28513e785f5
Reviewed-on: http://gerrit.openafs.org/9720
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp
src/WINNT/afsrdr/kernel/lib/AFSVolume.cpp
src/WINNT/afsrdr/kernel/lib/AFSWorker.cpp
src/WINNT/afsrdr/kernel/lib/Include/AFSDefines.h