2 * Copyright (c) 2008-2011 Kernel Drivers, LLC.
3 * Copyright (c) 2009-2011 Your File System, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * - Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
14 * this list of conditions and the following disclaimer in the
16 * and/or other materials provided with the distribution.
17 * - Neither the name of Kernel Drivers, LLC nor the names of its
19 * used to endorse or promote products derived from this software without
20 * specific prior written permission from Kernel Drivers, LLC
21 * and Your File System, Inc.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef _AFS_REDIR_COMMON_STRUCTS_H
37 #define _AFS_REDIR_COMMON_STRUCTS_H
43 typedef struct AFS_BTREE_ENTRY
54 } AFSBTreeEntry, *PAFSBTreeEntry;
56 typedef struct AFS_LIST_ENTRY
65 typedef struct _AFS_TREE_HDR
68 AFSBTreeEntry *TreeHead;
75 // Sys Name Information CB
78 typedef struct _AFS_SYS_NAME_CB
81 struct _AFS_SYS_NAME_CB *fLink;
83 UNICODE_STRING SysName;
88 // Communication service control structures
91 typedef struct _AFSFSD_SRVC_CONTROL_BLOCK
94 ULONG IrpPoolRequestIndex;
96 struct _POOL_ENTRY *RequestPoolHead;
98 struct _POOL_ENTRY *RequestPoolTail;
100 ERESOURCE IrpPoolLock;
102 struct _POOL_ENTRY *ResultPoolHead;
104 struct _POOL_ENTRY *ResultPoolTail;
106 ERESOURCE ResultPoolLock;
108 KEVENT IrpPoolHasEntries;
110 KEVENT IrpPoolHasReleaseEntries;
112 ULONG IrpPoolControlFlag;
116 } AFSCommSrvcCB, *PAFSCommSrvcCB;
122 typedef struct _POOL_ENTRY
125 struct _POOL_ENTRY *fLink;
127 struct _POOL_ENTRY *bLink;
135 UNICODE_STRING FileName;
151 ULONG *ResultBufferLength;
156 // The first portion is the non-paged section of the Fcb
159 typedef struct _AFS_NONPAGED_FCB
166 // Ranking - File Resource, Paging Resource,
167 // then SectionObject Resource
172 ERESOURCE PagingResource;
174 ERESOURCE SectionObjectResource;
177 // The section object pointer
180 SECTION_OBJECT_POINTERS SectionObjectPointers;
182 FAST_MUTEX AdvancedHdrMutex;
184 ERESOURCE CcbListLock;
192 ERESOURCE ExtentsResource;
195 // This is set when an Extents Request completes. Do not wait for this
196 // with the Extents resource held!
198 KEVENT ExtentsRequestComplete;
200 NTSTATUS ExtentsRequestStatus;
202 GUID ExtentsRequestAuthGroup;
204 struct _AFS_FSD_EXTENT *DirtyListHead;
206 struct _AFS_FSD_EXTENT *DirtyListTail;
208 ERESOURCE DirtyExtentsListLock;
213 // Queued Flush event. This event is set when the queued flush count
214 // is zero, cleared otherwise.
216 KEVENT QueuedFlushEvent;
223 LONG DirectoryEnumCount;
229 } AFSNonPagedFcb, *PAFSNonPagedFcb;
231 typedef struct _AFS_FSD_EXTENT
234 // Linked list first - the extents and then the skip list
237 LIST_ENTRY Lists[AFS_NUM_EXTENT_LISTS];
239 AFSListEntry DirtyList;
242 // And the extent itself
245 LARGE_INTEGER FileOffset;
247 LARGE_INTEGER CacheOffset;
259 } AFSExtent, *PAFSExtent;
261 typedef struct AFS_FCB
264 FSRTL_ADVANCED_FCB_HEADER Header;
267 // This is the linked list of nodes processed asynchronously by the respective worker thread
270 AFSListEntry ListEntry;
273 // The NP portion of the Fcb
276 AFSNonPagedFcb *NPFcb;
285 // Share access mapping
288 SHARE_ACCESS ShareAccess;
291 // Open pointer count on this file
294 LONG OpenReferenceCount;
297 // Open handle count on this file
300 LONG OpenHandleCount;
306 struct _AFS_OBJECT_INFORMATION_CB *ObjectInformation;
312 struct _AFS_CCB *CcbListHead;
314 struct _AFS_CCB *CcbListTail;
317 // Union for node type specific information
326 // We set this when a flush has been sent to the
327 // server sucessfully. We use this to influence when we
330 LARGE_INTEGER LastServerFlush;
333 // We set this when the extent ref count goes to zero.
334 // we use this to influence which files to purge
336 LARGE_INTEGER LastExtentAccess;
339 // If there has been a RELEASE_FILE_EXTENTS - this is
340 // where we stopped last time this stops us from
341 // constantly refreeing the same extents and then grabbing
344 LARGE_INTEGER LastPurgePoint;
356 LIST_ENTRY ExtentsLists[AFS_NUM_EXTENT_LISTS];
359 // There is only ever one request active, so we embed it
362 AFSRequestExtentsCB ExtentsRequest;
365 // Last PID that requested extents, NOT the system process
368 ULONGLONG ExtentRequestProcessId;
371 // Dirty extent count
374 LONG ExtentsDirtyCount;
377 // Extent count for this file
383 // Current count of queued flush items for the file
386 LONG QueuedFlushCount;
389 // Cache space currently held by extents for the file
392 LONG ExtentLength; // in KBs
395 // We pin the Cc File Object between AcquireFileForNtCreateSection
396 // and ReleaseFileForNtCreateSection. Protected by SOP lock
399 PFILE_OBJECT SectionCreateFO;
414 typedef struct _AFS_DEVICE_EXTENSION
424 // List of device isntances
427 struct _AFS_DEVICE_EXTENSION *DeviceLink;
444 // Volume worker tracking information
447 KEVENT VolumeWorkerCloseEvent;
449 LONG VolumeWorkerThreadCount;
452 // Fcb lifetime & flush time tickcount. This is calculated
453 // in DriverEntry() for the control device.
456 LARGE_INTEGER ObjectLifeTimeCount;
457 LARGE_INTEGER FcbFlushTimeCount;
458 LARGE_INTEGER FcbPurgeTimeCount;
459 LARGE_INTEGER ExtentRequestTimeCount;
465 AFSCommSrvcCB CommServiceCB;
468 // Extent Release Interface
471 ERESOURCE ExtentReleaseResource;
473 KEVENT ExtentReleaseEvent;
475 ULONG ExtentReleaseSequence;
477 PKPROCESS ServiceProcess;
480 // SysName information control block
483 ERESOURCE SysName32ListLock;
485 AFSSysNameCB *SysName32ListHead;
487 AFSSysNameCB *SysName32ListTail;
489 ERESOURCE SysName64ListLock;
491 AFSSysNameCB *SysName64ListHead;
493 AFSSysNameCB *SysName64ListTail;
496 // Our process tree information
499 AFSTreeHdr ProcessTree;
501 ERESOURCE ProcessTreeLock;
507 AFSTreeHdr AuthGroupTree;
509 ERESOURCE AuthGroupTreeLock;
512 // Notificaiton information. This is used for change notification
515 LIST_ENTRY DirNotifyList;
517 PNOTIFY_SYNC NotifySync;
520 // Library load information
523 KEVENT LoadLibraryEvent;
527 ERESOURCE LibraryStateLock;
529 LONG InflightLibraryRequests;
531 KEVENT InflightLibraryEvent;
533 ERESOURCE LibraryQueueLock;
535 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueHead;
537 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueTail;
539 UNICODE_STRING LibraryServicePath;
541 DEVICE_OBJECT *LibraryDeviceObject;
543 FILE_OBJECT *LibraryFileObject;
546 // Extent processing information within the library
551 LONG ExtentsHeldLength;
553 KEVENT ExtentsHeldEvent;
556 // Outstanding service request information
559 LONG OutstandingServiceRequestCount;
561 KEVENT OutstandingServiceRequestEvent;
564 // Out of memory signalling
567 LONG WaitingForMemoryCount;
569 KEVENT MemoryAvailableEvent;
572 // Worker Pool Queues
577 struct _AFS_WORK_ITEM *QueueHead;
579 struct _AFS_WORK_ITEM *QueueTail;
581 KEVENT WorkerQueueHasItems;
585 ERESOURCE IOQueueLock;
587 struct _AFS_WORK_ITEM *IOQueueHead;
589 struct _AFS_WORK_ITEM *IOQueueTail;
591 KEVENT IOWorkerQueueHasItems;
593 LONG IOQueueItemCount;
603 // Cache file information
606 HANDLE CacheFileHandle;
608 PFILE_OBJECT CacheFileObject;
610 ULONG CacheBlockSize;
612 UNICODE_STRING CacheFile;
614 LARGE_INTEGER CacheBlockCount; // Total number of cache blocks in the cache file
616 void *CacheBaseAddress;
618 LARGE_INTEGER CacheLength;
623 // Throttles on behavior
627 LARGE_INTEGER MaxDirty;
630 // Maximum RPC length that is issued by the service. We should limit our
631 // data requests such as for extents to this length
634 ULONG MaximumRPCLength;
640 AFSTreeHdr VolumeTree;
642 ERESOURCE VolumeTreeLock;
644 struct _AFS_VOLUME_CB *VolumeListHead;
646 struct _AFS_VOLUME_CB *VolumeListTail;
648 ERESOURCE VolumeListLock;
651 // Queued extent release count and event
654 LONG QueuedReleaseExtentCount;
656 KEVENT QueuedReleaseExtentEvent;
659 // Name array related information
662 ULONG NameArrayLength;
667 // Our root cell tree
670 AFSTreeHdr RootCellTree;
672 ERESOURCE RootCellTreeLock;
675 // Cache file object access
678 ERESOURCE CacheFileLock;
681 // NP Connection list information
684 ERESOURCE ProviderListLock;
686 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderConnectionList;
688 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList;
691 // Reparse point policy
694 ULONG ReparsePointPolicy;
702 // Worker pool information
707 struct _AFS_WORKER_QUEUE_HDR *PoolHead;
715 struct _AFS_WORKER_QUEUE_HDR *IOPoolHead;
721 } AFSDeviceExt, *PAFSDeviceExt;
724 // Network provider connection cb
726 #pragma pack(push, 1)
727 typedef struct _AFSFSD_PROVIDER_CONNECTION_CB
730 struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink;
732 struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList;
744 LARGE_INTEGER AuthenticationId;
748 UNICODE_STRING RemoteName;
750 UNICODE_STRING ComponentName;
752 UNICODE_STRING Comment;
754 } AFSProviderConnectionCB;
758 // Callbacks defined in the framework
763 (*PAFSProcessRequest)( IN ULONG RequestType,
764 IN ULONG RequestFlags,
766 IN PUNICODE_STRING FileName,
767 IN AFSFileID *FileId,
772 IN OUT void *ResultBuffer,
773 IN OUT PULONG ResultBufferLength);
777 (*PAFSDbgLogMsg)( IN ULONG Subsystem,
784 (*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName,
785 IN ULONG DisplayType,
790 (*PAFSExAllocatePoolWithTag)( IN POOL_TYPE PoolType,
791 IN SIZE_T NumberOfBytes,
796 (*PAFSExFreePoolWithTag)( IN void *Pointer, IN ULONG Tag);
800 (*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId,
801 IN ULONGLONG ThreadId,
802 OUT GUID *AuthGroup);
804 typedef struct _AFS_LIBRARY_INIT_CB
807 PDEVICE_OBJECT AFSControlDeviceObject;
809 PDEVICE_OBJECT AFSRDRDeviceObject;
811 UNICODE_STRING AFSServerName;
813 UNICODE_STRING AFSMountRootName;
817 AFSFileID GlobalRootFid;
819 CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks;
821 void *AFSCacheBaseAddress;
823 LARGE_INTEGER AFSCacheLength;
826 // Callbacks in the framework
829 PAFSProcessRequest AFSProcessRequest;
831 PAFSDbgLogMsg AFSDbgLogMsg;
833 PAFSAddConnectionEx AFSAddConnectionEx;
835 PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag;
837 PAFSExFreePoolWithTag AFSExFreePoolWithTag;
839 PAFSDumpTraceFiles AFSDumpTraceFiles;
841 PAFSRetrieveAuthGroup AFSRetrieveAuthGroup;
845 typedef struct _AFS_TRACE_CONFIG_CB
848 PAFSDbgLogMsg AFSDbgLogMsg;
850 } AFSDebugTraceConfigCB;