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 KEVENT DirectoryEnumEvent;
222 LONG DirectoryEnumCount;
228 } AFSNonPagedFcb, *PAFSNonPagedFcb;
230 typedef struct _AFS_FSD_EXTENT
233 // Linked list first - the extents and then the skip list
236 LIST_ENTRY Lists[AFS_NUM_EXTENT_LISTS];
238 AFSListEntry DirtyList;
241 // And the extent itself
244 LARGE_INTEGER FileOffset;
246 LARGE_INTEGER CacheOffset;
258 } AFSExtent, *PAFSExtent;
260 typedef struct AFS_FCB
263 FSRTL_ADVANCED_FCB_HEADER Header;
266 // This is the linked list of nodes processed asynchronously by the respective worker thread
269 AFSListEntry ListEntry;
272 // The NP portion of the Fcb
275 AFSNonPagedFcb *NPFcb;
284 // Share access mapping
287 SHARE_ACCESS ShareAccess;
290 // Open pointer count on this file
293 LONG OpenReferenceCount;
296 // Open handle count on this file
299 LONG OpenHandleCount;
305 struct _AFS_OBJECT_INFORMATION_CB *ObjectInformation;
311 struct _AFS_CCB *CcbListHead;
313 struct _AFS_CCB *CcbListTail;
316 // Union for node type specific information
325 // We set this when a flush has been sent to the
326 // server sucessfully. We use this to influence when we
329 LARGE_INTEGER LastServerFlush;
332 // We set this when the extent ref count goes to zero.
333 // we use this to influence which files to purge
335 LARGE_INTEGER LastExtentAccess;
338 // If there has been a RELEASE_FILE_EXTENTS - this is
339 // where we stopped last time this stops us from
340 // constantly refreeing the same extents and then grabbing
343 LARGE_INTEGER LastPurgePoint;
355 LIST_ENTRY ExtentsLists[AFS_NUM_EXTENT_LISTS];
358 // There is only ever one request active, so we embed it
361 AFSRequestExtentsCB ExtentsRequest;
364 // Last PID that requested extents, NOT the system process
367 ULONGLONG ExtentRequestProcessId;
370 // Dirty extent count
373 LONG ExtentsDirtyCount;
376 // Extent count for this file
382 // The Lazy writer thread
385 PETHREAD LazyWriterThread;
388 // Current count of queued flush items for the file
391 LONG QueuedFlushCount;
394 // Cache space currently held by extents for the file
397 LONG ExtentLength; // in KBs
412 typedef struct _AFS_DEVICE_EXTENSION
422 // List of device isntances
425 struct _AFS_DEVICE_EXTENSION *DeviceLink;
440 // Volume worker tracking information
443 KEVENT VolumeWorkerCloseEvent;
445 LONG VolumeWorkerThreadCount;
448 // Fcb lifetime & flush time tickcount. This is calculated
449 // in DriverEntry() for the control device.
452 LARGE_INTEGER ObjectLifeTimeCount;
453 LARGE_INTEGER FcbFlushTimeCount;
454 LARGE_INTEGER FcbPurgeTimeCount;
455 LARGE_INTEGER ExtentRequestTimeCount;
461 AFSCommSrvcCB CommServiceCB;
464 // Extent Release Interface
467 ERESOURCE ExtentReleaseResource;
469 KEVENT ExtentReleaseEvent;
471 ULONG ExtentReleaseSequence;
473 PKPROCESS ServiceProcess;
476 // SysName information control block
479 ERESOURCE SysName32ListLock;
481 AFSSysNameCB *SysName32ListHead;
483 AFSSysNameCB *SysName32ListTail;
485 ERESOURCE SysName64ListLock;
487 AFSSysNameCB *SysName64ListHead;
489 AFSSysNameCB *SysName64ListTail;
492 // Our process tree information
495 AFSTreeHdr ProcessTree;
497 ERESOURCE ProcessTreeLock;
503 AFSTreeHdr AuthGroupTree;
505 ERESOURCE AuthGroupTreeLock;
508 // Notificaiton information. This is used for change notification
511 LIST_ENTRY DirNotifyList;
513 PNOTIFY_SYNC NotifySync;
516 // Library load information
519 KEVENT LoadLibraryEvent;
523 ERESOURCE LibraryStateLock;
525 LONG InflightLibraryRequests;
527 KEVENT InflightLibraryEvent;
529 ERESOURCE LibraryQueueLock;
531 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueHead;
533 struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueTail;
535 UNICODE_STRING LibraryServicePath;
537 DEVICE_OBJECT *LibraryDeviceObject;
539 FILE_OBJECT *LibraryFileObject;
542 // Extent processing information within the library
547 LONG ExtentsHeldLength;
549 KEVENT ExtentsHeldEvent;
552 // Outstanding service request information
555 LONG OutstandingServiceRequestCount;
557 KEVENT OutstandingServiceRequestEvent;
565 // Cache file information
568 HANDLE CacheFileHandle;
570 PFILE_OBJECT CacheFileObject;
572 ULONG CacheBlockSize;
574 UNICODE_STRING CacheFile;
576 LARGE_INTEGER CacheBlockCount; // Total number of cache blocks in the cache file
578 void *CacheBaseAddress;
580 LARGE_INTEGER CacheLength;
585 // Throttles on behavior
589 LARGE_INTEGER MaxDirty;
592 // Maximum RPC length that is issued by the service. We should limit our
593 // data requests such as for extents to thsi length
596 ULONG MaximumRPCLength;
602 AFSTreeHdr VolumeTree;
604 ERESOURCE VolumeTreeLock;
606 struct _AFS_VOLUME_CB *VolumeListHead;
608 struct _AFS_VOLUME_CB *VolumeListTail;
610 ERESOURCE VolumeListLock;
613 // Queued extent release count and event
616 LONG QueuedReleaseExtentCount;
618 KEVENT QueuedReleaseExtentEvent;
621 // Name array related information
624 ULONG NameArrayLength;
629 // Our root cell tree
632 AFSTreeHdr RootCellTree;
634 ERESOURCE RootCellTreeLock;
637 // Cache file object access
640 ERESOURCE CacheFileLock;
643 // NP Connection list information
646 ERESOURCE ProviderListLock;
648 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderConnectionList;
650 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList;
658 // Worker pool information
663 struct _AFS_WORKER_QUEUE_HDR *PoolHead;
667 struct _AFS_WORK_ITEM *QueueHead;
669 struct _AFS_WORK_ITEM *QueueTail;
671 KEVENT WorkerQueueHasItems;
681 struct _AFS_WORKER_QUEUE_HDR *IOPoolHead;
683 ERESOURCE IOQueueLock;
685 struct _AFS_WORK_ITEM *IOQueueHead;
687 struct _AFS_WORK_ITEM *IOQueueTail;
689 KEVENT IOWorkerQueueHasItems;
691 LONG IOQueueItemCount;
697 } AFSDeviceExt, *PAFSDeviceExt;
700 // Network provider connection cb
702 #pragma pack(push, 1)
703 typedef struct _AFSFSD_PROVIDER_CONNECTION_CB
706 struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink;
708 struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList;
720 LARGE_INTEGER AuthenticationId;
724 UNICODE_STRING RemoteName;
726 UNICODE_STRING ComponentName;
728 UNICODE_STRING Comment;
730 } AFSProviderConnectionCB;
734 // Callbacks defined in the framework
739 (*PAFSProcessRequest)( IN ULONG RequestType,
740 IN ULONG RequestFlags,
742 IN PUNICODE_STRING FileName,
743 IN AFSFileID *FileId,
746 IN OUT void *ResultBuffer,
747 IN OUT PULONG ResultBufferLength);
751 (*PAFSDbgLogMsg)( IN ULONG Subsystem,
758 (*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName,
759 IN ULONG DisplayType,
764 (*PAFSExAllocatePoolWithTag)( IN POOL_TYPE PoolType,
765 IN SIZE_T NumberOfBytes,
770 (*PAFSExFreePool)( IN void *Pointer);
774 (*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId,
775 IN ULONGLONG ThreadId,
776 OUT GUID *AuthGroup);
778 typedef struct _AFS_LIBRARY_INIT_CB
781 PDEVICE_OBJECT AFSControlDeviceObject;
783 PDEVICE_OBJECT AFSRDRDeviceObject;
785 UNICODE_STRING AFSServerName;
789 AFSFileID GlobalRootFid;
791 CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks;
793 void *AFSCacheBaseAddress;
795 LARGE_INTEGER AFSCacheLength;
798 // Callbacks in the framework
801 PAFSProcessRequest AFSProcessRequest;
803 PAFSDbgLogMsg AFSDbgLogMsg;
805 PAFSAddConnectionEx AFSAddConnectionEx;
807 PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag;
809 PAFSExFreePool AFSExFreePool;
811 PAFSDumpTraceFiles AFSDumpTraceFiles;
813 PAFSRetrieveAuthGroup AFSRetrieveAuthGroup;