OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/WINNT/afsrdr/common/AFSRedirCommonStructs.h
00001 /*
00002  * Copyright (c) 2008-2011 Kernel Drivers, LLC.
00003  * Copyright (c) 2009-2011 Your File System, Inc.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * - Redistributions of source code must retain the above copyright notice,
00011  *   this list of conditions and the following disclaimer.
00012  * - Redistributions in binary form must reproduce the above copyright
00013  *   notice,
00014  *   this list of conditions and the following disclaimer in the
00015  *   documentation
00016  *   and/or other materials provided with the distribution.
00017  * - Neither the name of Kernel Drivers, LLC nor the names of its
00018  *   contributors may be
00019  *   used to endorse or promote products derived from this software without
00020  *   specific prior written permission from Kernel Drivers, LLC
00021  *   and Your File System, Inc.
00022  *
00023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00025  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00026  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00027  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00028  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00029  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00030  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00031  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00032  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  */
00035 
00036 #ifndef _AFS_REDIR_COMMON_STRUCTS_H
00037 #define _AFS_REDIR_COMMON_STRUCTS_H
00038 
00039 //
00040 // BTree Entry
00041 //
00042 
00043 typedef struct AFS_BTREE_ENTRY
00044 {
00045 
00046     void    *parentLink;
00047 
00048     void    *leftLink;
00049 
00050     void    *rightLink;
00051 
00052     ULONGLONG HashIndex;
00053 
00054 } AFSBTreeEntry, *PAFSBTreeEntry;
00055 
00056 typedef struct AFS_LIST_ENTRY
00057 {
00058 
00059     void    *fLink;
00060 
00061     void    *bLink;
00062 
00063 } AFSListEntry;
00064 
00065 typedef struct _AFS_TREE_HDR
00066 {
00067 
00068     AFSBTreeEntry *TreeHead;
00069 
00070     ERESOURCE     *TreeLock;
00071 
00072 } AFSTreeHdr;
00073 
00074 //
00075 // Sys Name Information CB
00076 //
00077 
00078 typedef struct _AFS_SYS_NAME_CB
00079 {
00080 
00081     struct _AFS_SYS_NAME_CB     *fLink;
00082 
00083     UNICODE_STRING      SysName;
00084 
00085 } AFSSysNameCB;
00086 
00087 //
00088 // Communication service control structures
00089 //
00090 
00091 typedef struct _AFSFSD_SRVC_CONTROL_BLOCK
00092 {
00093 
00094     ULONG                       IrpPoolRequestIndex;
00095 
00096     struct _POOL_ENTRY          *RequestPoolHead;
00097 
00098     struct _POOL_ENTRY          *RequestPoolTail;
00099 
00100     ERESOURCE                   IrpPoolLock;
00101 
00102     struct _POOL_ENTRY          *ResultPoolHead;
00103 
00104     struct _POOL_ENTRY          *ResultPoolTail;
00105 
00106     ERESOURCE                   ResultPoolLock;
00107 
00108     KEVENT                      IrpPoolHasEntries;
00109 
00110     KEVENT                      IrpPoolHasReleaseEntries;
00111 
00112     ULONG                       IrpPoolControlFlag;
00113 
00114     LONG                        QueueCount;
00115 
00116 } AFSCommSrvcCB, *PAFSCommSrvcCB;
00117 
00118 //
00119 // Irp Pool entry
00120 //
00121 
00122 typedef struct _POOL_ENTRY
00123 {
00124 
00125     struct _POOL_ENTRY    *fLink;
00126 
00127     struct _POOL_ENTRY    *bLink;
00128 
00129     KEVENT      Event;
00130 
00131     GUID        AuthGroup;
00132 
00133     AFSFileID    FileId;
00134 
00135     UNICODE_STRING  FileName;
00136 
00137     ULONG       RequestType;
00138 
00139     ULONG       RequestIndex;
00140 
00141     ULONG       RequestFlags;
00142 
00143     ULONG       DataLength;
00144 
00145     void       *Data;
00146 
00147     ULONG       ResultStatus;
00148 
00149     void       *ResultBuffer;
00150 
00151     ULONG      *ResultBufferLength;
00152 
00153 } AFSPoolEntry;
00154 
00155 //
00156 // The first portion is the non-paged section of the Fcb
00157 //
00158 
00159 typedef struct _AFS_NONPAGED_FCB
00160 {
00161 
00162     USHORT          Size;
00163     USHORT          Type;
00164 
00165     //
00166     // Ranking - File Resource first, then Paging Resource
00167     //
00168 
00169     ERESOURCE       Resource;
00170 
00171     ERESOURCE       PagingResource;
00172 
00173     //
00174     // The section object pointer
00175     //
00176 
00177     SECTION_OBJECT_POINTERS        SectionObjectPointers;
00178 
00179     FAST_MUTEX      AdvancedHdrMutex;
00180 
00181     ERESOURCE       CcbListLock;
00182 
00183     union
00184     {
00185 
00186         struct
00187         {
00188 
00189             ERESOURCE       ExtentsResource;
00190 
00191             //
00192             // This is set when an Extents Request completes.  Do not wait for this
00193             // with the Extents resource held!
00194             //
00195             KEVENT          ExtentsRequestComplete;
00196 
00197             NTSTATUS        ExtentsRequestStatus;
00198 
00199             GUID            ExtentsRequestAuthGroup;
00200 
00201             struct _AFS_FSD_EXTENT  *DirtyListHead;
00202 
00203             struct _AFS_FSD_EXTENT  *DirtyListTail;
00204 
00205             ERESOURCE       DirtyExtentsListLock;
00206 
00207             KEVENT          FlushEvent;
00208 
00209             //
00210             // Queued Flush event. This event is set when the queued flush count
00211             // is zero, cleared otherwise.
00212 
00213             KEVENT          QueuedFlushEvent;
00214 
00215         } File;
00216 
00217         struct
00218         {
00219 
00220             LONG            DirectoryEnumCount;
00221 
00222         } Directory;
00223 
00224     } Specific;
00225 
00226 } AFSNonPagedFcb, *PAFSNonPagedFcb;
00227 
00228 typedef struct _AFS_FSD_EXTENT
00229 {
00230     //
00231     // Linked list first - the extents and then the skip list
00232     //
00233 
00234     LIST_ENTRY          Lists[AFS_NUM_EXTENT_LISTS];
00235 
00236     AFSListEntry        DirtyList;
00237 
00238     //
00239     // And the extent itself
00240     //
00241 
00242     LARGE_INTEGER       FileOffset;
00243 
00244     LARGE_INTEGER       CacheOffset;
00245 
00246     ULONG               Size;
00247 
00248     ULONG               Flags;
00249 
00250     LONG                ActiveCount;
00251 
00252 #if GEN_MD5
00253     UCHAR               MD5[16];
00254 #endif
00255 
00256 } AFSExtent, *PAFSExtent;
00257 
00258 typedef struct AFS_FCB
00259 {
00260 
00261     FSRTL_ADVANCED_FCB_HEADER Header;
00262 
00263     //
00264     // This is the linked list of nodes processed asynchronously by the respective worker thread
00265     //
00266 
00267     AFSListEntry        ListEntry;
00268 
00269     //
00270     // The NP portion of the Fcb
00271     //
00272 
00273     AFSNonPagedFcb    *NPFcb;
00274 
00275     //
00276     // Fcb flags
00277     //
00278 
00279     ULONG               Flags;
00280 
00281     //
00282     // Share access mapping
00283     //
00284 
00285     SHARE_ACCESS        ShareAccess;
00286 
00287     //
00288     // Open pointer count on this file
00289     //
00290 
00291     LONG                OpenReferenceCount;
00292 
00293     //
00294     // Open handle count on this file
00295     //
00296 
00297     LONG                OpenHandleCount;
00298 
00299     //
00300     // Object info block
00301     //
00302 
00303     struct _AFS_OBJECT_INFORMATION_CB   *ObjectInformation;
00304 
00305     //
00306     // Ccb list pointers
00307     //
00308 
00309     struct _AFS_CCB    *CcbListHead;
00310 
00311     struct _AFS_CCB    *CcbListTail;
00312 
00313     //
00314     // Union for node type specific information
00315     //
00316 
00317     union
00318     {
00319 
00320         struct
00321         {
00322             //
00323             // We set this when a flush has been sent to the
00324             // server sucessfully.  We use this to influence when we
00325             // write the flush.
00326             //
00327             LARGE_INTEGER       LastServerFlush;
00328 
00329             //
00330             // We set this when the extent ref count goes to zero.
00331             // we use this to influence which files to purge
00332             //
00333             LARGE_INTEGER       LastExtentAccess;
00334 
00335             //
00336             // If there has been a RELEASE_FILE_EXTENTS - this is
00337             // where we stopped last time this stops us from
00338             // constantly refreeing the same extents and then grabbing
00339             // them again.
00340             //
00341             LARGE_INTEGER       LastPurgePoint;
00342 
00343             //
00344             // File lock
00345             //
00346 
00347             FILE_LOCK           FileLock;
00348 
00349             //
00350             // The extents
00351             //
00352 
00353             LIST_ENTRY          ExtentsLists[AFS_NUM_EXTENT_LISTS];
00354 
00355             //
00356             // There is only ever one request active, so we embed it
00357             //
00358 
00359             AFSRequestExtentsCB ExtentsRequest;
00360 
00361             //
00362             // Last PID that requested extents, NOT the system process
00363             //
00364 
00365             ULONGLONG           ExtentRequestProcessId;
00366 
00367             //
00368             // Dirty extent count
00369             //
00370 
00371             LONG                ExtentsDirtyCount;
00372 
00373             //
00374             // Extent count for this file
00375             //
00376 
00377             LONG                ExtentCount;
00378 
00379             //
00380             // The Lazy writer thread
00381             //
00382 
00383             PETHREAD            LazyWriterThread;
00384 
00385             //
00386             // Current count of queued flush items for the file
00387             //
00388 
00389             LONG                QueuedFlushCount;
00390 
00391             //
00392             // Cache space currently held by extents for the file
00393             //
00394 
00395             LONG                ExtentLength; // in KBs
00396 
00397         } File;
00398 
00399         struct
00400         {
00401 
00402             ULONG       Reserved;
00403 
00404         } Directory;
00405 
00406     } Specific;
00407 
00408 } AFSFcb, *PAFSFcb;
00409 
00410 typedef struct _AFS_DEVICE_EXTENSION
00411 {
00412 
00413     //
00414     // Self pointer
00415     //
00416 
00417     PDEVICE_OBJECT  Self;
00418 
00419     //
00420     // List of device isntances
00421     //
00422 
00423     struct _AFS_DEVICE_EXTENSION *DeviceLink;
00424 
00425     //
00426     // Device flags
00427     //
00428 
00429     ULONG           DeviceFlags;
00430 
00431     AFSFcb*         Fcb;
00432 
00433     union
00434     {
00435 
00436         struct
00437         {
00438 
00439             //
00440             // Volume worker tracking information
00441             //
00442 
00443             KEVENT           VolumeWorkerCloseEvent;
00444 
00445             LONG             VolumeWorkerThreadCount;
00446 
00447             //
00448             // Fcb lifetime & flush time tickcount. This is calculated
00449             // in DriverEntry() for the control device.
00450             //
00451 
00452             LARGE_INTEGER           ObjectLifeTimeCount;
00453             LARGE_INTEGER           FcbFlushTimeCount;
00454             LARGE_INTEGER           FcbPurgeTimeCount;
00455             LARGE_INTEGER           ExtentRequestTimeCount;
00456 
00457             //
00458             // Comm interface
00459             //
00460 
00461             AFSCommSrvcCB    CommServiceCB;
00462 
00463             //
00464             // Extent Release Interface
00465             //
00466 
00467             ERESOURCE        ExtentReleaseResource;
00468 
00469             KEVENT           ExtentReleaseEvent;
00470 
00471             ULONG            ExtentReleaseSequence;
00472 
00473             PKPROCESS        ServiceProcess;
00474 
00475             //
00476             // SysName information control block
00477             //
00478 
00479             ERESOURCE       SysName32ListLock;
00480 
00481             AFSSysNameCB    *SysName32ListHead;
00482 
00483             AFSSysNameCB    *SysName32ListTail;
00484 
00485             ERESOURCE       SysName64ListLock;
00486 
00487             AFSSysNameCB    *SysName64ListHead;
00488 
00489             AFSSysNameCB    *SysName64ListTail;
00490 
00491             //
00492             // Our process tree information
00493             //
00494 
00495             AFSTreeHdr          ProcessTree;
00496 
00497             ERESOURCE           ProcessTreeLock;
00498 
00499             //
00500             // SID Entry tree
00501             //
00502 
00503             AFSTreeHdr          AuthGroupTree;
00504 
00505             ERESOURCE           AuthGroupTreeLock;
00506 
00507             //
00508             // Notificaiton information. This is used for change notification
00509             //
00510 
00511             LIST_ENTRY          DirNotifyList;
00512 
00513             PNOTIFY_SYNC        NotifySync;
00514 
00515             //
00516             // Library load information
00517             //
00518 
00519             KEVENT              LoadLibraryEvent;
00520 
00521             ULONG               LibraryState;
00522 
00523             ERESOURCE           LibraryStateLock;
00524 
00525             LONG                InflightLibraryRequests;
00526 
00527             KEVENT              InflightLibraryEvent;
00528 
00529             ERESOURCE           LibraryQueueLock;
00530 
00531             struct _AFS_LIBRARY_QUEUE_REQUEST_CB    *LibraryQueueHead;
00532 
00533             struct _AFS_LIBRARY_QUEUE_REQUEST_CB    *LibraryQueueTail;
00534 
00535             UNICODE_STRING      LibraryServicePath;
00536 
00537             DEVICE_OBJECT      *LibraryDeviceObject;
00538 
00539             FILE_OBJECT        *LibraryFileObject;
00540 
00541             //
00542             // Extent processing information within the library
00543             //
00544 
00545             LONG                ExtentCount;
00546 
00547             LONG                ExtentsHeldLength;
00548 
00549             KEVENT              ExtentsHeldEvent;
00550 
00551             //
00552             // Outstanding service request information
00553             //
00554 
00555             LONG                OutstandingServiceRequestCount;
00556 
00557             KEVENT              OutstandingServiceRequestEvent;
00558 
00559             //
00560             // Out of memory signalling
00561             //
00562 
00563             LONG                WaitingForMemoryCount;
00564 
00565             KEVENT              MemoryAvailableEvent;
00566 
00567         } Control;
00568 
00569         struct
00570         {
00571 
00572             //
00573             // Cache file information
00574             //
00575 
00576             HANDLE              CacheFileHandle;
00577 
00578             PFILE_OBJECT        CacheFileObject;
00579 
00580             ULONG               CacheBlockSize;
00581 
00582             UNICODE_STRING      CacheFile;
00583 
00584             LARGE_INTEGER       CacheBlockCount; // Total number of cache blocks in the cache file
00585 
00586             void               *CacheBaseAddress;
00587 
00588             LARGE_INTEGER       CacheLength;
00589 
00590             PMDL                CacheMdl;
00591 
00592             //
00593             // Throttles on behavior
00594             //
00595             LARGE_INTEGER       MaxIo;
00596 
00597             LARGE_INTEGER       MaxDirty;
00598 
00599             //
00600             // Maximum RPC length that is issued by the service. We should limit our
00601             // data requests such as for extents to this length
00602             //
00603 
00604             ULONG               MaximumRPCLength;
00605 
00606             //
00607             // Volume tree
00608             //
00609 
00610             AFSTreeHdr          VolumeTree;
00611 
00612             ERESOURCE           VolumeTreeLock;
00613 
00614             struct _AFS_VOLUME_CB        *VolumeListHead;
00615 
00616             struct _AFS_VOLUME_CB        *VolumeListTail;
00617 
00618             ERESOURCE           VolumeListLock;
00619 
00620             //
00621             // Queued extent release count and event
00622             //
00623 
00624             LONG                QueuedReleaseExtentCount;
00625 
00626             KEVENT              QueuedReleaseExtentEvent;
00627 
00628             //
00629             // Name array related information
00630             //
00631 
00632             ULONG               NameArrayLength;
00633 
00634             ULONG               MaxLinkCount;
00635 
00636             //
00637             // Our root cell tree
00638             //
00639 
00640             AFSTreeHdr          RootCellTree;
00641 
00642             ERESOURCE           RootCellTreeLock;
00643 
00644             //
00645             // Cache file object access
00646             //
00647 
00648             ERESOURCE           CacheFileLock;
00649 
00650             //
00651             // NP Connection list information
00652             //
00653 
00654             ERESOURCE                 ProviderListLock;
00655 
00656             struct _AFSFSD_PROVIDER_CONNECTION_CB   *ProviderConnectionList;
00657 
00658             struct _AFSFSD_PROVIDER_CONNECTION_CB   *ProviderEnumerationList;
00659 
00660         } RDR;
00661 
00662         struct
00663         {
00664 
00665             //
00666             // Worker pool information
00667             //
00668 
00669             ULONG            WorkerCount;
00670 
00671             struct _AFS_WORKER_QUEUE_HDR *PoolHead;
00672 
00673             ERESOURCE        QueueLock;
00674 
00675             struct _AFS_WORK_ITEM     *QueueHead;
00676 
00677             struct _AFS_WORK_ITEM     *QueueTail;
00678 
00679             KEVENT           WorkerQueueHasItems;
00680 
00681             LONG             QueueItemCount;
00682 
00683             //
00684             // IO Worker queue
00685             //
00686 
00687             ULONG            IOWorkerCount;
00688 
00689             struct _AFS_WORKER_QUEUE_HDR *IOPoolHead;
00690 
00691             ERESOURCE        IOQueueLock;
00692 
00693             struct _AFS_WORK_ITEM     *IOQueueHead;
00694 
00695             struct _AFS_WORK_ITEM     *IOQueueTail;
00696 
00697             KEVENT           IOWorkerQueueHasItems;
00698 
00699             LONG             IOQueueItemCount;
00700 
00701         } Library;
00702 
00703     } Specific;
00704 
00705 } AFSDeviceExt, *PAFSDeviceExt;
00706 
00707 //
00708 // Network provider connection cb
00709 //
00710 #pragma pack(push, 1)
00711 typedef struct _AFSFSD_PROVIDER_CONNECTION_CB
00712 {
00713 
00714     struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink;
00715 
00716     struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList;
00717 
00718     ULONG       Flags;
00719 
00720     ULONG       Type;
00721 
00722     ULONG       Scope;
00723 
00724     ULONG       DisplayType;
00725 
00726     ULONG       Usage;
00727 
00728     LARGE_INTEGER AuthenticationId;
00729 
00730     WCHAR       LocalName;
00731 
00732     UNICODE_STRING RemoteName;
00733 
00734     UNICODE_STRING ComponentName;
00735 
00736     UNICODE_STRING Comment;
00737 
00738 } AFSProviderConnectionCB;
00739 #pragma pack(pop)
00740 
00741 //
00742 // Callbacks defined in the framework
00743 //
00744 
00745 typedef
00746 NTSTATUS
00747 (*PAFSProcessRequest)( IN ULONG RequestType,
00748                        IN ULONG RequestFlags,
00749                        IN GUID *AuthGroup,
00750                        IN PUNICODE_STRING FileName,
00751                        IN AFSFileID *FileId,
00752                        IN void  *Data,
00753                        IN ULONG DataLength,
00754                        IN OUT void *ResultBuffer,
00755                        IN OUT PULONG ResultBufferLength);
00756 
00757 typedef
00758 NTSTATUS
00759 (*PAFSDbgLogMsg)( IN ULONG Subsystem,
00760                   IN ULONG Level,
00761                   IN PCCH Format,
00762                   ...);
00763 
00764 typedef
00765 NTSTATUS
00766 (*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName,
00767                         IN ULONG DisplayType,
00768                         IN ULONG Flags);
00769 
00770 typedef
00771 void *
00772 (*PAFSExAllocatePoolWithTag)( IN POOL_TYPE  PoolType,
00773                               IN SIZE_T  NumberOfBytes,
00774                               IN ULONG  Tag);
00775 
00776 typedef
00777 void
00778 (*PAFSExFreePoolWithTag)( IN void *Pointer, IN ULONG Tag);
00779 
00780 typedef
00781 void
00782 (*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId,
00783                           IN ULONGLONG ThreadId,
00784                           OUT GUID *AuthGroup);
00785 
00786 typedef struct _AFS_LIBRARY_INIT_CB
00787 {
00788 
00789     PDEVICE_OBJECT      AFSControlDeviceObject;
00790 
00791     PDEVICE_OBJECT      AFSRDRDeviceObject;
00792 
00793     UNICODE_STRING      AFSServerName;
00794 
00795     ULONG               AFSDebugFlags;
00796 
00797     AFSFileID           GlobalRootFid;
00798 
00799     CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks;
00800 
00801     void               *AFSCacheBaseAddress;
00802 
00803     LARGE_INTEGER       AFSCacheLength;
00804 
00805     //
00806     // Callbacks in the framework
00807     //
00808 
00809     PAFSProcessRequest  AFSProcessRequest;
00810 
00811     PAFSDbgLogMsg       AFSDbgLogMsg;
00812 
00813     PAFSAddConnectionEx AFSAddConnectionEx;
00814 
00815     PAFSExAllocatePoolWithTag   AFSExAllocatePoolWithTag;
00816 
00817     PAFSExFreePoolWithTag      AFSExFreePoolWithTag;
00818 
00819     PAFSDumpTraceFiles  AFSDumpTraceFiles;
00820 
00821     PAFSRetrieveAuthGroup AFSRetrieveAuthGroup;
00822 
00823 } AFSLibraryInitCB;
00824 
00825 
00826 #endif
00827 
 All Data Structures Files Functions Variables