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;
187 ERESOURCE ExtentsResource;
190 // This is set when an Extents Request completes. Do not wait for this
191 // with the Extents resource held!
193 KEVENT ExtentsRequestComplete;
195 NTSTATUS ExtentsRequestStatus;
197 struct _AFS_FSD_EXTENT *DirtyListHead;
199 struct _AFS_FSD_EXTENT *DirtyListTail;
201 ERESOURCE DirtyExtentsListLock;
206 // Queued Flush event. This event is set when the queued flush count
207 // is zero, cleared otherwise.
209 KEVENT QueuedFlushEvent;
216 KEVENT DirectoryEnumEvent;
218 LONG DirectoryEnumCount;
224 } AFSNonPagedFcb, *PAFSNonPagedFcb;
226 typedef struct _AFS_FSD_EXTENT
229 // Linked list first - the extents and then the skip list
232 LIST_ENTRY Lists[AFS_NUM_EXTENT_LISTS];
234 AFSListEntry DirtyList;
237 // And the extent itself
240 LARGE_INTEGER FileOffset;
242 LARGE_INTEGER CacheOffset;
254 } AFSExtent, *PAFSExtent;
256 typedef struct AFS_FCB
259 FSRTL_ADVANCED_FCB_HEADER Header;
262 // This is the linked list of nodes processed asynchronously by the respective worker thread
265 AFSListEntry ListEntry;
268 // The NP portion of the Fcb
271 AFSNonPagedFcb *NPFcb;
280 // Share access mapping
283 SHARE_ACCESS ShareAccess;
286 // Open pointer count on this file
289 LONG OpenReferenceCount;
292 // Open handle count on this file
295 LONG OpenHandleCount;
301 struct _AFS_OBJECT_INFORMATION_CB *ObjectInformation;
304 // Authentication group GUID
310 // Union for node type specific information
319 // We set this when a flush has been sent to the
320 // server sucessfully. We use this to influence when we
323 LARGE_INTEGER LastServerFlush;
326 // We set this when the extent ref count goes to zero.
327 // we use this to influence which files to purge
329 LARGE_INTEGER LastExtentAccess;
332 // If there has been a RELEASE_FILE_EXTENTS - this is
333 // where we stopped last time this stops us from
334 // constantly refreeing the same extents and then grabbing
337 LARGE_INTEGER LastPurgePoint;
349 LIST_ENTRY ExtentsLists[AFS_NUM_EXTENT_LISTS];
352 // There is only ever one request active, so we embed it
355 AFSRequestExtentsCB ExtentsRequest;
358 // Last PID that requested extents, NOT the system process
361 ULONGLONG ExtentRequestProcessId;
364 // Dirty extent count
367 LONG ExtentsDirtyCount;
370 // Extent count for this file
376 // The Lazy writer thread
379 PETHREAD LazyWriterThread;
382 // Current count of queued flush items for the file
385 LONG QueuedFlushCount;
388 // Cache space currently held by extents for the file
391 LONG ExtentLength; // in KBs
406 typedef struct _AFS_DEVICE_EXTENSION
416 // List of device isntances
419 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;
559 // Cache file information
562 HANDLE CacheFileHandle;
564 PFILE_OBJECT CacheFileObject;
566 ULONG CacheBlockSize;
568 UNICODE_STRING CacheFile;
570 LARGE_INTEGER CacheBlockCount; // Total number of cache blocks in the cache file
572 void *CacheBaseAddress;
574 LARGE_INTEGER CacheLength;
579 // Throttles on behavior
583 LARGE_INTEGER MaxDirty;
586 // Maximum RPC length that is issued by the service. We should limit our
587 // data requests such as for extents to thsi length
590 ULONG MaximumRPCLength;
596 AFSTreeHdr VolumeTree;
598 ERESOURCE VolumeTreeLock;
600 struct _AFS_VOLUME_CB *VolumeListHead;
602 struct _AFS_VOLUME_CB *VolumeListTail;
604 ERESOURCE VolumeListLock;
607 // Queued extent release count and event
610 LONG QueuedReleaseExtentCount;
612 KEVENT QueuedReleaseExtentEvent;
615 // Name array related information
618 ULONG NameArrayLength;
623 // Our root cell tree
626 AFSTreeHdr RootCellTree;
628 ERESOURCE RootCellTreeLock;
631 // Cache file object access
634 ERESOURCE CacheFileLock;
637 // NP Connection list information
640 ERESOURCE ProviderListLock;
642 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderConnectionList;
644 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList;
652 // Worker pool information
657 struct _AFS_WORKER_QUEUE_HDR *PoolHead;
661 struct _AFS_WORK_ITEM *QueueHead;
663 struct _AFS_WORK_ITEM *QueueTail;
665 KEVENT WorkerQueueHasItems;
675 struct _AFS_WORKER_QUEUE_HDR *IOPoolHead;
677 ERESOURCE IOQueueLock;
679 struct _AFS_WORK_ITEM *IOQueueHead;
681 struct _AFS_WORK_ITEM *IOQueueTail;
683 KEVENT IOWorkerQueueHasItems;
685 LONG IOQueueItemCount;
691 } AFSDeviceExt, *PAFSDeviceExt;
694 // Network provider connection cb
696 #pragma pack(push, 1)
697 typedef struct _AFSFSD_PROVIDER_CONNECTION_CB
700 struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink;
702 struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList;
714 LARGE_INTEGER AuthenticationId;
718 UNICODE_STRING RemoteName;
720 UNICODE_STRING ComponentName;
722 UNICODE_STRING Comment;
724 } AFSProviderConnectionCB;
728 // Callbacks defined in the framework
733 (*PAFSProcessRequest)( IN ULONG RequestType,
734 IN ULONG RequestFlags,
736 IN PUNICODE_STRING FileName,
737 IN AFSFileID *FileId,
740 IN OUT void *ResultBuffer,
741 IN OUT PULONG ResultBufferLength);
745 (*PAFSDbgLogMsg)( IN ULONG Subsystem,
752 (*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName,
753 IN ULONG DisplayType,
758 (*PAFSExAllocatePoolWithTag)( IN POOL_TYPE PoolType,
759 IN SIZE_T NumberOfBytes,
764 (*PAFSExFreePool)( IN void *Pointer);
768 (*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId,
769 IN ULONGLONG ThreadId,
770 OUT GUID *AuthGroup);
772 typedef struct _AFS_LIBRARY_INIT_CB
775 PDEVICE_OBJECT AFSControlDeviceObject;
777 PDEVICE_OBJECT AFSRDRDeviceObject;
779 UNICODE_STRING AFSServerName;
783 AFSFileID GlobalRootFid;
785 CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks;
787 void *AFSCacheBaseAddress;
789 LARGE_INTEGER AFSCacheLength;
792 // Callbacks in the framework
795 PAFSProcessRequest AFSProcessRequest;
797 PAFSDbgLogMsg AFSDbgLogMsg;
799 PAFSAddConnectionEx AFSAddConnectionEx;
801 PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag;
803 PAFSExFreePool AFSExFreePool;
805 PAFSDumpTraceFiles AFSDumpTraceFiles;
807 PAFSRetrieveAuthGroup AFSRetrieveAuthGroup;