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 // 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;
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;
560 // Out of memory signalling
563 LONG WaitingForMemoryCount;
565 KEVENT MemoryAvailableEvent;
573 // Cache file information
576 HANDLE CacheFileHandle;
578 PFILE_OBJECT CacheFileObject;
580 ULONG CacheBlockSize;
582 UNICODE_STRING CacheFile;
584 LARGE_INTEGER CacheBlockCount; // Total number of cache blocks in the cache file
586 void *CacheBaseAddress;
588 LARGE_INTEGER CacheLength;
593 // Throttles on behavior
597 LARGE_INTEGER MaxDirty;
600 // Maximum RPC length that is issued by the service. We should limit our
601 // data requests such as for extents to thsi length
604 ULONG MaximumRPCLength;
610 AFSTreeHdr VolumeTree;
612 ERESOURCE VolumeTreeLock;
614 struct _AFS_VOLUME_CB *VolumeListHead;
616 struct _AFS_VOLUME_CB *VolumeListTail;
618 ERESOURCE VolumeListLock;
621 // Queued extent release count and event
624 LONG QueuedReleaseExtentCount;
626 KEVENT QueuedReleaseExtentEvent;
629 // Name array related information
632 ULONG NameArrayLength;
637 // Our root cell tree
640 AFSTreeHdr RootCellTree;
642 ERESOURCE RootCellTreeLock;
645 // Cache file object access
648 ERESOURCE CacheFileLock;
651 // NP Connection list information
654 ERESOURCE ProviderListLock;
656 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderConnectionList;
658 struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList;
666 // Worker pool information
671 struct _AFS_WORKER_QUEUE_HDR *PoolHead;
675 struct _AFS_WORK_ITEM *QueueHead;
677 struct _AFS_WORK_ITEM *QueueTail;
679 KEVENT WorkerQueueHasItems;
689 struct _AFS_WORKER_QUEUE_HDR *IOPoolHead;
691 ERESOURCE IOQueueLock;
693 struct _AFS_WORK_ITEM *IOQueueHead;
695 struct _AFS_WORK_ITEM *IOQueueTail;
697 KEVENT IOWorkerQueueHasItems;
699 LONG IOQueueItemCount;
705 } AFSDeviceExt, *PAFSDeviceExt;
708 // Network provider connection cb
710 #pragma pack(push, 1)
711 typedef struct _AFSFSD_PROVIDER_CONNECTION_CB
714 struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink;
716 struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList;
728 LARGE_INTEGER AuthenticationId;
732 UNICODE_STRING RemoteName;
734 UNICODE_STRING ComponentName;
736 UNICODE_STRING Comment;
738 } AFSProviderConnectionCB;
742 // Callbacks defined in the framework
747 (*PAFSProcessRequest)( IN ULONG RequestType,
748 IN ULONG RequestFlags,
750 IN PUNICODE_STRING FileName,
751 IN AFSFileID *FileId,
754 IN OUT void *ResultBuffer,
755 IN OUT PULONG ResultBufferLength);
759 (*PAFSDbgLogMsg)( IN ULONG Subsystem,
766 (*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName,
767 IN ULONG DisplayType,
772 (*PAFSExAllocatePoolWithTag)( IN POOL_TYPE PoolType,
773 IN SIZE_T NumberOfBytes,
778 (*PAFSExFreePool)( IN void *Pointer);
782 (*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId,
783 IN ULONGLONG ThreadId,
784 OUT GUID *AuthGroup);
786 typedef struct _AFS_LIBRARY_INIT_CB
789 PDEVICE_OBJECT AFSControlDeviceObject;
791 PDEVICE_OBJECT AFSRDRDeviceObject;
793 UNICODE_STRING AFSServerName;
797 AFSFileID GlobalRootFid;
799 CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks;
801 void *AFSCacheBaseAddress;
803 LARGE_INTEGER AFSCacheLength;
806 // Callbacks in the framework
809 PAFSProcessRequest AFSProcessRequest;
811 PAFSDbgLogMsg AFSDbgLogMsg;
813 PAFSAddConnectionEx AFSAddConnectionEx;
815 PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag;
817 PAFSExFreePool AFSExFreePool;
819 PAFSDumpTraceFiles AFSDumpTraceFiles;
821 PAFSRetrieveAuthGroup AFSRetrieveAuthGroup;