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
407 typedef struct _AFS_DEVICE_EXTENSION
417 // List of device isntances
420 struct _AFS_DEVICE_EXTENSION *DeviceLink;
437 // Volume worker tracking information
440 KEVENT VolumeWorkerCloseEvent;
442 LONG VolumeWorkerThreadCount;
445 // Fcb lifetime & flush time tickcount. This is calculated
446 // in DriverEntry() for the control device.
449 LARGE_INTEGER ObjectLifeTimeCount;
450 LARGE_INTEGER FcbFlushTimeCount;
451 LARGE_INTEGER FcbPurgeTimeCount;
452 LARGE_INTEGER ExtentRequestTimeCount;
458 AFSCommSrvcCB CommServiceCB;
461 // Extent Release Interface
464 ERESOURCE ExtentReleaseResource;
466 KEVENT ExtentReleaseEvent;
468 ULONG ExtentReleaseSequence;
470 PKPROCESS ServiceProcess;
473 // SysName information control block
476 ERESOURCE SysName32ListLock;
478 AFSSysNameCB *SysName32ListHead;
480 AFSSysNameCB *SysName32ListTail;
482 ERESOURCE SysName64ListLock;
484 AFSSysNameCB *SysName64ListHead;
486 AFSSysNameCB *SysName64ListTail;
489 // Our process tree information
492 AFSTreeHdr ProcessTree;
494 ERESOURCE ProcessTreeLock;
500 AFSTreeHdr AuthGroupTree;
502 ERESOURCE AuthGroupTreeLock;
505 // Notificaiton information. This is used for change notification
508 LIST_ENTRY DirNotifyList;
510 PNOTIFY_SYNC NotifySync;
513 // Library load information
516 KEVENT LoadLibraryEvent;
520 ERESOURCE LibraryStateLock;
522 LONG InflightLibraryRequests;
524 KEVENT InflightLibraryEvent;
526 ERESOURCE LibraryQueueLock;
528 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueHead;
530 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueTail;
532 UNICODE_STRING LibraryServicePath;
534 DEVICE_OBJECT *LibraryDeviceObject;
536 FILE_OBJECT *LibraryFileObject;
539 // Extent processing information within the library
544 LONG ExtentsHeldLength;
546 KEVENT ExtentsHeldEvent;
549 // Outstanding service request information
552 LONG OutstandingServiceRequestCount;
554 KEVENT OutstandingServiceRequestEvent;
557 // Out of memory signalling
560 LONG WaitingForMemoryCount;
562 KEVENT MemoryAvailableEvent;
565 // Worker Pool Queues
570 struct _AFS_WORK_ITEM *QueueHead;
572 struct _AFS_WORK_ITEM *QueueTail;
574 KEVENT WorkerQueueHasItems;
578 ERESOURCE IOQueueLock;
580 struct _AFS_WORK_ITEM *IOQueueHead;
582 struct _AFS_WORK_ITEM *IOQueueTail;
584 KEVENT IOWorkerQueueHasItems;
586 LONG IOQueueItemCount;
596 // Cache file information
599 HANDLE CacheFileHandle;
601 PFILE_OBJECT CacheFileObject;
603 ULONG CacheBlockSize;
605 UNICODE_STRING CacheFile;
607 LARGE_INTEGER CacheBlockCount; // Total number of cache blocks in the cache file
609 void *CacheBaseAddress;
611 LARGE_INTEGER CacheLength;
616 // Throttles on behavior
620 LARGE_INTEGER MaxDirty;
623 // Maximum RPC length that is issued by the service. We should limit our
624 // data requests such as for extents to this length
627 ULONG MaximumRPCLength;
633 AFSTreeHdr VolumeTree;
635 ERESOURCE VolumeTreeLock;
637 struct _AFS_VOLUME_CB *VolumeListHead;
639 struct _AFS_VOLUME_CB *VolumeListTail;
641 ERESOURCE VolumeListLock;
644 // Queued extent release count and event
647 LONG QueuedReleaseExtentCount;
649 KEVENT QueuedReleaseExtentEvent;
652 // Name array related information
655 ULONG NameArrayLength;
660 // Our root cell tree
663 AFSTreeHdr RootCellTree;
665 ERESOURCE RootCellTreeLock;
668 // Cache file object access
671 ERESOURCE CacheFileLock;
674 // NP Connection list information
677 ERESOURCE ProviderListLock;
679 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderConnectionList;
681 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList;
689 // Worker pool information
694 struct _AFS_WORKER_QUEUE_HDR *PoolHead;
702 struct _AFS_WORKER_QUEUE_HDR *IOPoolHead;
708 } AFSDeviceExt, *PAFSDeviceExt;
711 // Network provider connection cb
713 #pragma pack(push, 1)
714 typedef struct _AFSFSD_PROVIDER_CONNECTION_CB
717 struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink;
719 struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList;
731 LARGE_INTEGER AuthenticationId;
735 UNICODE_STRING RemoteName;
737 UNICODE_STRING ComponentName;
739 UNICODE_STRING Comment;
741 } AFSProviderConnectionCB;
745 // Callbacks defined in the framework
750 (*PAFSProcessRequest)( IN ULONG RequestType,
751 IN ULONG RequestFlags,
753 IN PUNICODE_STRING FileName,
754 IN AFSFileID *FileId,
759 IN OUT void *ResultBuffer,
760 IN OUT PULONG ResultBufferLength);
764 (*PAFSDbgLogMsg)( IN ULONG Subsystem,
771 (*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName,
772 IN ULONG DisplayType,
777 (*PAFSExAllocatePoolWithTag)( IN POOL_TYPE PoolType,
778 IN SIZE_T NumberOfBytes,
783 (*PAFSExFreePoolWithTag)( IN void *Pointer, IN ULONG Tag);
787 (*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId,
788 IN ULONGLONG ThreadId,
789 OUT GUID *AuthGroup);
791 typedef struct _AFS_LIBRARY_INIT_CB
794 PDEVICE_OBJECT AFSControlDeviceObject;
796 PDEVICE_OBJECT AFSRDRDeviceObject;
798 UNICODE_STRING AFSServerName;
800 UNICODE_STRING AFSMountRootName;
804 AFSFileID GlobalRootFid;
806 CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks;
808 void *AFSCacheBaseAddress;
810 LARGE_INTEGER AFSCacheLength;
813 // Callbacks in the framework
816 PAFSProcessRequest AFSProcessRequest;
818 PAFSDbgLogMsg AFSDbgLogMsg;
820 PAFSAddConnectionEx AFSAddConnectionEx;
822 PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag;
824 PAFSExFreePoolWithTag AFSExFreePoolWithTag;
826 PAFSDumpTraceFiles AFSDumpTraceFiles;
828 PAFSRetrieveAuthGroup AFSRetrieveAuthGroup;
832 typedef struct _AFS_TRACE_CONFIG_CB
835 PAFSDbgLogMsg AFSDbgLogMsg;
837 } AFSDebugTraceConfigCB;