Windows: Name Array store mount point and volume root
authorJeffrey Altman <jaltman@your-file-system.com>
Mon, 2 Apr 2012 22:10:07 +0000 (18:10 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 6 Apr 2012 15:03:37 +0000 (08:03 -0700)
Modify the Name Array processing to store both the mount point
object and the volume root directory object in the array.  This
is necessary for proper operation of
AFSPopulateNameArrayFromRelatedArray when the DirectoryCB parameter
is a mount point object.

Modify AFSBackupEntry to remove two entries if a volume root
directory entry is being removed.

Remove AFSReplaceCurrentElement() as it is no longer used.

Change-Id: Iaa0a4effc3448351d04bcdd72be9ee726ffe4e9a
Reviewed-on: http://gerrit.openafs.org/7021
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp
src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp
src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h

index 5179da0..add53f1 100644 (file)
@@ -5346,83 +5346,13 @@ try_exit:
     return ntStatus;
 }
 
-void
-AFSReplaceCurrentElement( IN AFSNameArrayHdr *NameArray,
-                          IN AFSDirectoryCB *DirectoryCB)
-{
-    AFSNameArrayCB *pCurrentElement = NULL;
-    LONG lCount;
-
-    AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
-                  AFS_TRACE_LEVEL_VERBOSE,
-                  "AFSReplaceCurrentElement [NA:%p] passed DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
-                  NameArray,
-                  DirectoryCB,
-                  DirectoryCB->ObjectInformation->FileId.Cell,
-                  DirectoryCB->ObjectInformation->FileId.Volume,
-                  DirectoryCB->ObjectInformation->FileId.Vnode,
-                  DirectoryCB->ObjectInformation->FileId.Unique,
-                  &DirectoryCB->NameInformation.FileName,
-                  DirectoryCB->ObjectInformation->FileType);
-
-    ASSERT( NameArray->CurrentEntry != NULL);
-
-    pCurrentElement = NameArray->CurrentEntry;
-
-    AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
-                  AFS_TRACE_LEVEL_VERBOSE,
-                  "AFSReplaceCurrentElement [NA:%p] Replacing Element[%d] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
-                  NameArray,
-                  NameArray->Count - 1,
-                  pCurrentElement->DirectoryCB,
-                  pCurrentElement->FileId.Cell,
-                  pCurrentElement->FileId.Volume,
-                  pCurrentElement->FileId.Vnode,
-                  pCurrentElement->FileId.Unique,
-                  &pCurrentElement->DirectoryCB->NameInformation.FileName,
-                  pCurrentElement->DirectoryCB->ObjectInformation->FileType);
-
-    lCount = InterlockedDecrement( &NameArray->CurrentEntry->DirectoryCB->OpenReferenceCount);
-
-    AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
-                  AFS_TRACE_LEVEL_VERBOSE,
-                  "AFSReplaceCurrentElement Decrement count on %wZ DE %p Cnt %d\n",
-                  &pCurrentElement->DirectoryCB->NameInformation.FileName,
-                  pCurrentElement->DirectoryCB,
-                  lCount);
-
-    lCount = InterlockedIncrement( &DirectoryCB->OpenReferenceCount);
-
-    AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
-                  AFS_TRACE_LEVEL_VERBOSE,
-                  "AFSReplaceCurrentElement Increment count on %wZ DE %p Cnt %d\n",
-                  &DirectoryCB->NameInformation.FileName,
-                  DirectoryCB,
-                  lCount);
-
-    pCurrentElement->DirectoryCB = DirectoryCB;
-
-    pCurrentElement->Component = DirectoryCB->NameInformation.FileName;
-
-    pCurrentElement->FileId = DirectoryCB->ObjectInformation->FileId;
-
-    pCurrentElement->Flags = 0;
-
-    if( pCurrentElement->FileId.Vnode == 1)
-    {
-
-        SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
-    }
-
-    return;
-}
-
 AFSDirectoryCB *
 AFSBackupEntry( IN AFSNameArrayHdr *NameArray)
 {
 
     AFSDirectoryCB *pDirectoryCB = NULL;
     AFSNameArrayCB *pCurrentElement = NULL;
+    BOOLEAN         bVolumeRoot = FALSE;
     LONG lCount;
 
     __Enter
@@ -5468,6 +5398,9 @@ AFSBackupEntry( IN AFSNameArrayHdr *NameArray)
         }
         else
         {
+
+            bVolumeRoot = BooleanFlagOn( NameArray->CurrentEntry->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
+
             NameArray->CurrentEntry--;
 
             pCurrentElement = NameArray->CurrentEntry;
@@ -5488,6 +5421,17 @@ AFSBackupEntry( IN AFSNameArrayHdr *NameArray)
                           pCurrentElement->DirectoryCB->ObjectInformation->FileType);
         }
 
+        //
+        // If the entry we are removing is a volume root,
+        // we must remove the mount point entry as well.
+        //
+
+        if ( bVolumeRoot)
+        {
+
+            pDirectoryCB = AFSBackupEntry( NameArray);
+        }
+
 try_exit:
 
         NOTHING;
index 40da6ee..18a291d 100644 (file)
@@ -915,11 +915,12 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                     ASSERT( pCurrentVolume->VolumeReferenceCount > 1);
 
                     //
-                    // Replace the current name for the mp with the volume root of the target
+                    // The name array stores both the mount point and the target.
+                    // Insert the target.
                     //
 
-                    AFSReplaceCurrentElement( pNameArray,
-                                              pCurrentVolume->DirectoryCB);
+                    AFSInsertNextElement( pNameArray,
+                                          pCurrentVolume->DirectoryCB);
 
                     //
                     // We want to restart processing here on the new parent ...
index 003b3a7..ab3eb8e 100644 (file)
@@ -1253,10 +1253,6 @@ NTSTATUS
 AFSInsertNextElement( IN AFSNameArrayHdr *NameArray,
                       IN AFSDirectoryCB *DirEntry);
 
-void
-AFSReplaceCurrentElement( IN AFSNameArrayHdr *NameArray,
-                          IN AFSDirectoryCB *DirectoryCB);
-
 AFSDirectoryCB *
 AFSBackupEntry( IN AFSNameArrayHdr *NameArray);