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 struct _AFS_FSD_EXTENT *DirtyListHead;
201 struct _AFS_FSD_EXTENT *DirtyListTail;
203 ERESOURCE DirtyExtentsListLock;
208 // Queued Flush event. This event is set when the queued flush count
209 // is zero, cleared otherwise.
211 KEVENT QueuedFlushEvent;
218 KEVENT DirectoryEnumEvent;
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 // The Lazy writer thread
383 PETHREAD LazyWriterThread;
386 // Current count of queued flush items for the file
389 LONG QueuedFlushCount;
392 // Cache space currently held by extents for the file
395 LONG ExtentLength; // in KBs
410 typedef struct _AFS_DEVICE_EXTENSION
420 // List of device isntances
423 struct _AFS_DEVICE_EXTENSION *DeviceLink;
438 // Volume worker tracking information
441 KEVENT VolumeWorkerCloseEvent;
443 LONG VolumeWorkerThreadCount;
446 // Fcb lifetime & flush time tickcount. This is calculated
447 // in DriverEntry() for the control device.
450 LARGE_INTEGER ObjectLifeTimeCount;
451 LARGE_INTEGER FcbFlushTimeCount;
452 LARGE_INTEGER FcbPurgeTimeCount;
453 LARGE_INTEGER ExtentRequestTimeCount;
459 AFSCommSrvcCB CommServiceCB;
462 // Extent Release Interface
465 ERESOURCE ExtentReleaseResource;
467 KEVENT ExtentReleaseEvent;
469 ULONG ExtentReleaseSequence;
471 PKPROCESS ServiceProcess;
474 // SysName information control block
477 ERESOURCE SysName32ListLock;
479 AFSSysNameCB *SysName32ListHead;
481 AFSSysNameCB *SysName32ListTail;
483 ERESOURCE SysName64ListLock;
485 AFSSysNameCB *SysName64ListHead;
487 AFSSysNameCB *SysName64ListTail;
490 // Our process tree information
493 AFSTreeHdr ProcessTree;
495 ERESOURCE ProcessTreeLock;
501 AFSTreeHdr AuthGroupTree;
503 ERESOURCE AuthGroupTreeLock;
506 // Notificaiton information. This is used for change notification
509 LIST_ENTRY DirNotifyList;
511 PNOTIFY_SYNC NotifySync;
514 // Library load information
517 KEVENT LoadLibraryEvent;
521 ERESOURCE LibraryStateLock;
523 LONG InflightLibraryRequests;
525 KEVENT InflightLibraryEvent;
527 ERESOURCE LibraryQueueLock;
529 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueHead;
531 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueTail;
533 UNICODE_STRING LibraryServicePath;
535 DEVICE_OBJECT *LibraryDeviceObject;
537 FILE_OBJECT *LibraryFileObject;
540 // Extent processing information within the library
545 LONG ExtentsHeldLength;
547 KEVENT ExtentsHeldEvent;
550 // Outstanding service request information
553 LONG OutstandingServiceRequestCount;
555 KEVENT OutstandingServiceRequestEvent;
563 // Cache file information
566 HANDLE CacheFileHandle;
568 PFILE_OBJECT CacheFileObject;
570 ULONG CacheBlockSize;
572 UNICODE_STRING CacheFile;
574 LARGE_INTEGER CacheBlockCount; // Total number of cache blocks in the cache file
576 void *CacheBaseAddress;
578 LARGE_INTEGER CacheLength;
583 // Throttles on behavior
587 LARGE_INTEGER MaxDirty;
590 // Maximum RPC length that is issued by the service. We should limit our
591 // data requests such as for extents to thsi length
594 ULONG MaximumRPCLength;
600 AFSTreeHdr VolumeTree;
602 ERESOURCE VolumeTreeLock;
604 struct _AFS_VOLUME_CB *VolumeListHead;
606 struct _AFS_VOLUME_CB *VolumeListTail;
608 ERESOURCE VolumeListLock;
611 // Queued extent release count and event
614 LONG QueuedReleaseExtentCount;
616 KEVENT QueuedReleaseExtentEvent;
619 // Name array related information
622 ULONG NameArrayLength;
627 // Our root cell tree
630 AFSTreeHdr RootCellTree;
632 ERESOURCE RootCellTreeLock;
635 // Cache file object access
638 ERESOURCE CacheFileLock;
641 // NP Connection list information
644 ERESOURCE ProviderListLock;
646 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderConnectionList;
648 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList;
656 // Worker pool information
661 struct _AFS_WORKER_QUEUE_HDR *PoolHead;
665 struct _AFS_WORK_ITEM *QueueHead;
667 struct _AFS_WORK_ITEM *QueueTail;
669 KEVENT WorkerQueueHasItems;
679 struct _AFS_WORKER_QUEUE_HDR *IOPoolHead;
681 ERESOURCE IOQueueLock;
683 struct _AFS_WORK_ITEM *IOQueueHead;
685 struct _AFS_WORK_ITEM *IOQueueTail;
687 KEVENT IOWorkerQueueHasItems;
689 LONG IOQueueItemCount;
695 } AFSDeviceExt, *PAFSDeviceExt;
698 // Network provider connection cb
700 #pragma pack(push, 1)
701 typedef struct _AFSFSD_PROVIDER_CONNECTION_CB
704 struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink;
706 struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList;
718 LARGE_INTEGER AuthenticationId;
722 UNICODE_STRING RemoteName;
724 UNICODE_STRING ComponentName;
726 UNICODE_STRING Comment;
728 } AFSProviderConnectionCB;
732 // Callbacks defined in the framework
737 (*PAFSProcessRequest)( IN ULONG RequestType,
738 IN ULONG RequestFlags,
740 IN PUNICODE_STRING FileName,
741 IN AFSFileID *FileId,
744 IN OUT void *ResultBuffer,
745 IN OUT PULONG ResultBufferLength);
749 (*PAFSDbgLogMsg)( IN ULONG Subsystem,
756 (*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName,
757 IN ULONG DisplayType,
762 (*PAFSExAllocatePoolWithTag)( IN POOL_TYPE PoolType,
763 IN SIZE_T NumberOfBytes,
768 (*PAFSExFreePool)( IN void *Pointer);
772 (*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId,
773 IN ULONGLONG ThreadId,
774 OUT GUID *AuthGroup);
776 typedef struct _AFS_LIBRARY_INIT_CB
779 PDEVICE_OBJECT AFSControlDeviceObject;
781 PDEVICE_OBJECT AFSRDRDeviceObject;
783 UNICODE_STRING AFSServerName;
787 AFSFileID GlobalRootFid;
789 CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks;
791 void *AFSCacheBaseAddress;
793 LARGE_INTEGER AFSCacheLength;
796 // Callbacks in the framework
799 PAFSProcessRequest AFSProcessRequest;
801 PAFSDbgLogMsg AFSDbgLogMsg;
803 PAFSAddConnectionEx AFSAddConnectionEx;
805 PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag;
807 PAFSExFreePool AFSExFreePool;
809 PAFSDumpTraceFiles AFSDumpTraceFiles;
811 PAFSRetrieveAuthGroup AFSRetrieveAuthGroup;