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 first, then Paging Resource
171 ERESOURCE PagingResource;
174 // The section object pointer
177 SECTION_OBJECT_POINTERS SectionObjectPointers;
179 FAST_MUTEX AdvancedHdrMutex;
181 ERESOURCE CcbListLock;
189 ERESOURCE ExtentsResource;
192 // This is set when an Extents Request completes. Do not wait for this
193 // with the Extents resource held!
195 KEVENT ExtentsRequestComplete;
197 NTSTATUS ExtentsRequestStatus;
199 GUID ExtentsRequestAuthGroup;
201 struct _AFS_FSD_EXTENT *DirtyListHead;
203 struct _AFS_FSD_EXTENT *DirtyListTail;
205 ERESOURCE DirtyExtentsListLock;
210 // Queued Flush event. This event is set when the queued flush count
211 // is zero, cleared otherwise.
213 KEVENT QueuedFlushEvent;
220 LONG DirectoryEnumCount;
226 } AFSNonPagedFcb, *PAFSNonPagedFcb;
228 typedef struct _AFS_FSD_EXTENT
231 // Linked list first - the extents and then the skip list
234 LIST_ENTRY Lists[AFS_NUM_EXTENT_LISTS];
236 AFSListEntry DirtyList;
239 // And the extent itself
242 LARGE_INTEGER FileOffset;
244 LARGE_INTEGER CacheOffset;
256 } AFSExtent, *PAFSExtent;
258 typedef struct AFS_FCB
261 FSRTL_ADVANCED_FCB_HEADER Header;
264 // This is the linked list of nodes processed asynchronously by the respective worker thread
267 AFSListEntry ListEntry;
270 // The NP portion of the Fcb
273 AFSNonPagedFcb *NPFcb;
282 // Share access mapping
285 SHARE_ACCESS ShareAccess;
288 // Open pointer count on this file
291 LONG OpenReferenceCount;
294 // Open handle count on this file
297 LONG OpenHandleCount;
303 struct _AFS_OBJECT_INFORMATION_CB *ObjectInformation;
309 struct _AFS_CCB *CcbListHead;
311 struct _AFS_CCB *CcbListTail;
314 // Union for node type specific information
323 // We set this when a flush has been sent to the
324 // server sucessfully. We use this to influence when we
327 LARGE_INTEGER LastServerFlush;
330 // We set this when the extent ref count goes to zero.
331 // we use this to influence which files to purge
333 LARGE_INTEGER LastExtentAccess;
336 // If there has been a RELEASE_FILE_EXTENTS - this is
337 // where we stopped last time this stops us from
338 // constantly refreeing the same extents and then grabbing
341 LARGE_INTEGER LastPurgePoint;
353 LIST_ENTRY ExtentsLists[AFS_NUM_EXTENT_LISTS];
356 // There is only ever one request active, so we embed it
359 AFSRequestExtentsCB ExtentsRequest;
362 // Last PID that requested extents, NOT the system process
365 ULONGLONG ExtentRequestProcessId;
368 // Dirty extent count
371 LONG ExtentsDirtyCount;
374 // Extent count for this file
380 // Current count of queued flush items for the file
383 LONG QueuedFlushCount;
386 // Cache space currently held by extents for the file
389 LONG ExtentLength; // in KBs
404 typedef struct _AFS_DEVICE_EXTENSION
414 // List of device isntances
417 struct _AFS_DEVICE_EXTENSION *DeviceLink;
434 // Volume worker tracking information
437 KEVENT VolumeWorkerCloseEvent;
439 LONG VolumeWorkerThreadCount;
442 // Fcb lifetime & flush time tickcount. This is calculated
443 // in DriverEntry() for the control device.
446 LARGE_INTEGER ObjectLifeTimeCount;
447 LARGE_INTEGER FcbFlushTimeCount;
448 LARGE_INTEGER FcbPurgeTimeCount;
449 LARGE_INTEGER ExtentRequestTimeCount;
455 AFSCommSrvcCB CommServiceCB;
458 // Extent Release Interface
461 ERESOURCE ExtentReleaseResource;
463 KEVENT ExtentReleaseEvent;
465 ULONG ExtentReleaseSequence;
467 PKPROCESS ServiceProcess;
470 // SysName information control block
473 ERESOURCE SysName32ListLock;
475 AFSSysNameCB *SysName32ListHead;
477 AFSSysNameCB *SysName32ListTail;
479 ERESOURCE SysName64ListLock;
481 AFSSysNameCB *SysName64ListHead;
483 AFSSysNameCB *SysName64ListTail;
486 // Our process tree information
489 AFSTreeHdr ProcessTree;
491 ERESOURCE ProcessTreeLock;
497 AFSTreeHdr AuthGroupTree;
499 ERESOURCE AuthGroupTreeLock;
502 // Notificaiton information. This is used for change notification
505 LIST_ENTRY DirNotifyList;
507 PNOTIFY_SYNC NotifySync;
510 // Library load information
513 KEVENT LoadLibraryEvent;
517 ERESOURCE LibraryStateLock;
519 LONG InflightLibraryRequests;
521 KEVENT InflightLibraryEvent;
523 ERESOURCE LibraryQueueLock;
525 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueHead;
527 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueTail;
529 UNICODE_STRING LibraryServicePath;
531 DEVICE_OBJECT *LibraryDeviceObject;
533 FILE_OBJECT *LibraryFileObject;
536 // Extent processing information within the library
541 LONG ExtentsHeldLength;
543 KEVENT ExtentsHeldEvent;
546 // Outstanding service request information
549 LONG OutstandingServiceRequestCount;
551 KEVENT OutstandingServiceRequestEvent;
554 // Out of memory signalling
557 LONG WaitingForMemoryCount;
559 KEVENT MemoryAvailableEvent;
567 // Cache file information
570 HANDLE CacheFileHandle;
572 PFILE_OBJECT CacheFileObject;
574 ULONG CacheBlockSize;
576 UNICODE_STRING CacheFile;
578 LARGE_INTEGER CacheBlockCount; // Total number of cache blocks in the cache file
580 void *CacheBaseAddress;
582 LARGE_INTEGER CacheLength;
587 // Throttles on behavior
591 LARGE_INTEGER MaxDirty;
594 // Maximum RPC length that is issued by the service. We should limit our
595 // data requests such as for extents to this length
598 ULONG MaximumRPCLength;
604 AFSTreeHdr VolumeTree;
606 ERESOURCE VolumeTreeLock;
608 struct _AFS_VOLUME_CB *VolumeListHead;
610 struct _AFS_VOLUME_CB *VolumeListTail;
612 ERESOURCE VolumeListLock;
615 // Queued extent release count and event
618 LONG QueuedReleaseExtentCount;
620 KEVENT QueuedReleaseExtentEvent;
623 // Name array related information
626 ULONG NameArrayLength;
631 // Our root cell tree
634 AFSTreeHdr RootCellTree;
636 ERESOURCE RootCellTreeLock;
639 // Cache file object access
642 ERESOURCE CacheFileLock;
645 // NP Connection list information
648 ERESOURCE ProviderListLock;
650 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderConnectionList;
652 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList;
660 // Worker pool information
665 struct _AFS_WORKER_QUEUE_HDR *PoolHead;
669 struct _AFS_WORK_ITEM *QueueHead;
671 struct _AFS_WORK_ITEM *QueueTail;
673 KEVENT WorkerQueueHasItems;
683 struct _AFS_WORKER_QUEUE_HDR *IOPoolHead;
685 ERESOURCE IOQueueLock;
687 struct _AFS_WORK_ITEM *IOQueueHead;
689 struct _AFS_WORK_ITEM *IOQueueTail;
691 KEVENT IOWorkerQueueHasItems;
693 LONG IOQueueItemCount;
699 } AFSDeviceExt, *PAFSDeviceExt;
702 // Network provider connection cb
704 #pragma pack(push, 1)
705 typedef struct _AFSFSD_PROVIDER_CONNECTION_CB
708 struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink;
710 struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList;
722 LARGE_INTEGER AuthenticationId;
726 UNICODE_STRING RemoteName;
728 UNICODE_STRING ComponentName;
730 UNICODE_STRING Comment;
732 } AFSProviderConnectionCB;
736 // Callbacks defined in the framework
741 (*PAFSProcessRequest)( IN ULONG RequestType,
742 IN ULONG RequestFlags,
744 IN PUNICODE_STRING FileName,
745 IN AFSFileID *FileId,
748 IN OUT void *ResultBuffer,
749 IN OUT PULONG ResultBufferLength);
753 (*PAFSDbgLogMsg)( IN ULONG Subsystem,
760 (*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName,
761 IN ULONG DisplayType,
766 (*PAFSExAllocatePoolWithTag)( IN POOL_TYPE PoolType,
767 IN SIZE_T NumberOfBytes,
772 (*PAFSExFreePoolWithTag)( IN void *Pointer, IN ULONG Tag);
776 (*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId,
777 IN ULONGLONG ThreadId,
778 OUT GUID *AuthGroup);
780 typedef struct _AFS_LIBRARY_INIT_CB
783 PDEVICE_OBJECT AFSControlDeviceObject;
785 PDEVICE_OBJECT AFSRDRDeviceObject;
787 UNICODE_STRING AFSServerName;
789 UNICODE_STRING AFSMountRootName;
793 AFSFileID GlobalRootFid;
795 CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks;
797 void *AFSCacheBaseAddress;
799 LARGE_INTEGER AFSCacheLength;
802 // Callbacks in the framework
805 PAFSProcessRequest AFSProcessRequest;
807 PAFSDbgLogMsg AFSDbgLogMsg;
809 PAFSAddConnectionEx AFSAddConnectionEx;
811 PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag;
813 PAFSExFreePoolWithTag AFSExFreePoolWithTag;
815 PAFSDumpTraceFiles AFSDumpTraceFiles;
817 PAFSRetrieveAuthGroup AFSRetrieveAuthGroup;