sys: cache FileDesc->DispositionStatus

DeleteFileW and RemoveDirectoryW in recent versions of Windows 10 have
been changed to perform a FileDispositionInformationEx with POSIX
semantics and if that fails to retry with FileDispositionInformation.
Unfortunately this is done even for legitimate error codes such as
STATUS_DIRECTORY_NOT_EMPTY.

This means that user mode file systems have to do unnecessary CanDelete
checks even when they support FileDispositionInformationEx. The extra
check incurs extra context switches, and in some cases it may also be
costly to compute (e.g. FUSE).

We optimize this away by storing the status of the last CanDelete check
in the FileDesc and then continue returning the same status code for
all checks for the same FileDesc.
This commit is contained in:
Bill Zissimopoulos
2021-12-04 12:36:12 +00:00
parent 87389f010b
commit c208e0ecbd
2 changed files with 73 additions and 2 deletions

View File

@ -1497,6 +1497,7 @@ typedef struct
DidSetFileAttributes:1, DidSetReparsePoint:1, DidSetSecurity:1,
DidSetCreationTime:1, DidSetLastAccessTime:1, DidSetLastWriteTime:1, DidSetChangeTime:1,
DirectoryHasSuchFile:1;
NTSTATUS DispositionStatus;
UNICODE_STRING DirectoryPattern;
UNICODE_STRING DirectoryMarker;
UINT64 DirInfo;