From 42aba4391ab3fadca2103e1df1f47445e40c436e Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 10 Feb 2012 08:56:12 -0500 Subject: [PATCH] Windows: Perform rename to self check earlier In AFSSetRenameInfo(), the rename to itself check was performed after the name collision check. Move the check earlier in the routine to ensure that we catch the no-op before any real work is done. Change-Id: I580dd9958a259d4a1819c6bd882dae8067d2853d Reviewed-on: http://gerrit.openafs.org/6692 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp | 73 +++++++++++---------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp b/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp index eb643b380..86751d0fa 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp @@ -2094,6 +2094,7 @@ AFSSetRenameInfo( IN PIRP Irp) pSrcCcb = (AFSCcb *)pSrcFileObj->FsContext2; pSrcObject = pSrcFcb->ObjectInformation; + pSrcParentObject = pSrcFcb->ObjectInformation->ParentObjectInformation; // // Perform some basic checks to ensure FS integrity @@ -2132,6 +2133,15 @@ AFSSetRenameInfo( IN PIRP Irp) } } + // + // Extract off the final component name from the Fcb + // + + uniSourceName.Length = (USHORT)pSrcCcb->DirectoryCB->NameInformation.FileName.Length; + uniSourceName.MaximumLength = uniSourceName.Length; + + uniSourceName.Buffer = pSrcCcb->DirectoryCB->NameInformation.FileName.Buffer; + // // Resolve the target fileobject // @@ -2146,7 +2156,7 @@ AFSSetRenameInfo( IN PIRP Irp) pRenameInfo = (PFILE_RENAME_INFORMATION)Irp->AssociatedIrp.SystemBuffer; - pTargetParentObject = pSrcFcb->ObjectInformation->ParentObjectInformation; + pTargetParentObject = pSrcParentObject; pTargetDcb = pTargetParentObject->Fcb; @@ -2174,6 +2184,31 @@ AFSSetRenameInfo( IN PIRP Irp) uniTargetName = *((PUNICODE_STRING)&pTargetFileObj->FileName); } + // + // The quick check to see if they are not really performing a rename + // Do the names match? Only do this where the parent directories are + // the same + // + + if( pTargetParentObject == pSrcParentObject) + { + + if( FsRtlAreNamesEqual( &uniTargetName, + &uniSourceName, + FALSE, + NULL)) + { + try_return( ntStatus = STATUS_SUCCESS); + } + + bCommonParent = TRUE; + } + else + { + + bCommonParent = FALSE; + } + // // We do not allow cross-volume renames to occur // @@ -2197,7 +2232,7 @@ AFSSetRenameInfo( IN PIRP Irp) bReleaseTargetDirLock = TRUE; - if( pTargetParentObject != pSrcFcb->ObjectInformation->ParentObjectInformation) + if( pTargetParentObject != pSrcParentObject) { AFSAcquireExcl( pSrcFcb->ObjectInformation->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock, TRUE); @@ -2285,40 +2320,6 @@ AFSSetRenameInfo( IN PIRP Irp) "AFSSetRenameInfo Target does NOT exist, normal rename\n"); } - // - // Extract off the final component name from the Fcb - // - - uniSourceName.Length = (USHORT)pSrcCcb->DirectoryCB->NameInformation.FileName.Length; - uniSourceName.MaximumLength = uniSourceName.Length; - - uniSourceName.Buffer = pSrcCcb->DirectoryCB->NameInformation.FileName.Buffer; - - // - // The quick check to see if they are not really performing a rename - // Do the names match? Only do this where the parent directories are - // the same - // - - if( pTargetParentObject == pSrcFcb->ObjectInformation->ParentObjectInformation) - { - - bCommonParent = TRUE; - - if( FsRtlAreNamesEqual( &uniTargetName, - &uniSourceName, - FALSE, - NULL)) - { - try_return( ntStatus = STATUS_SUCCESS); - } - } - else - { - - bCommonParent = FALSE; - } - // // We need to remove the DirEntry from the parent node, update the index // and reinsert it into the parent tree. Note that for entries with the -- 2.39.5