test: fsrtllks.h Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# fsrtllks.h

Go to the documentation of this file.

    00001
    00002 typedef struct _LOCKTREE_NODE {
    00003
    00004     //
    00005     //  List of locks under this node
    00006     //
    00007
    00008     SINGLE_LIST_ENTRY Locks;
    00009
    00010     //
    00011     //  Flag whether this node is holey as a result of a failed allocation
    00012     //  during a node split.  During deletion of shared locks, we may
    00013     //  discover that the locks in the node no longer have total overlap
    00014     //  but cannot allocate resources to create the new nodes in the tree.
    00015     //
    00016     //  Any insert into the region occupied by a holey node will finish by
    00017     //  trying to split a holey node up.  Any split or access check in a
    00018     //  holey node must completely traverse the locks at the node.
    00019     //
    00020
    00021     BOOLEAN HoleyNode;
    00022
    00023     //
    00024     //  Maximum byte offset affected by locks in this node.
    00025     //  Note: minimum offset is the starting offset of the
    00026     //  first lock at this node.
    00027     //
    00028
    00029     ULONGLONG Extent;
    00030
    00031     //
    00032     //  Splay tree links to parent, lock groups strictly less than
    00033     //  and lock groups strictly greater than locks in this node.
    00034     //
    00035
    00036     RTL_SPLAY_LINKS Links;
    00037
    00038     //
    00039     //  Last lock in the list (useful for node collapse under insert)
    00040     //
    00041
    00042     SINGLE_LIST_ENTRY Tail;
    00043
    00044 } LOCKTREE_NODE, *PLOCKTREE_NODE;
    00045
    00046 //
    00047 //  Define the threading wrappers for lock information
    00048 //
    00049
    00050 //
    00051 //  Each shared lock record corresponds to a current granted lock and is
    00052 //  maintained in a queue off of a LOCKTREE_NODE's Locks list.  The list
    00053 //  of current locks is ordered according to the starting byte of the lock.
    00054 //
    00055
    00056 typedef struct _SH_LOCK {
    00057
    00058     //
    00059     //  The link structures for the list of shared locks.
    00060     //
    00061
    00062     SINGLE_LIST_ENTRY   Link;
    00063
    00064     //
    00065     //  The actual locked range
    00066     //
    00067
    00068     FILE_LOCK_INFO LockInfo;
    00069
    00070 } SH_LOCK, *PSH_LOCK;
    00071
    00072 //
    00073 //  Each exclusive lock record corresponds to a current granted lock and is
    00074 //  threaded into the exclusive lock tree.
    00075 //
    00076
    00077 typedef struct _EX_LOCK {
    00078
    00079     //
    00080     //  The link structures for the list of current locks.
    00081     //
    00082
    00083     RTL_SPLAY_LINKS     Links;
    00084
    00085     //
    00086     //  The actual locked range
    00087     //
    00088
    00089     FILE_LOCK_INFO LockInfo;
    00090
    00091 } EX_LOCK, *PEX_LOCK;
    00092
    00093 //
    00094 //  Each Waiting lock record corresponds to a IRP that is waiting for a
    00095 //  lock to be granted and is maintained in a queue off of the FILE_LOCK's
    00096 //  WaitingLockQueue list.
    00097 //
    00098
    00099 typedef struct _WAITING_LOCK {
    00100
    00101     //
    00102     //  The link structures for the list of waiting locks
    00103     //
    00104
    00105     SINGLE_LIST_ENTRY   Link;
    00106
    00107     //
    00108     //  The context field to use when completing the irp via the alternate
    00109     //  routine
    00110     //
    00111
    00112     PVOID Context;
    00113
    00114     //
    00115     //  A pointer to the IRP that is waiting for a lock
    00116     //
    00117
    00118     PIRP Irp;
    00119
    00120 } WAITING_LOCK, *PWAITING_LOCK;
    00121
    00122
    00123 //
    00124 //  Each lock or waiting onto some lock queue.
    00125 //
    00126
    00127 typedef struct _LOCK_QUEUE {
    00128
    00129     //
    00130     // SpinLock to guard queue access
    00131     //
    00132
    00133     KSPIN_LOCK  QueueSpinLock;
    00134
    00135     //
    00136     //  The items contain locktrees of the current granted
    00137     //  locks and a list of the waiting locks
    00138     //
    00139
    00140     PRTL_SPLAY_LINKS SharedLockTree;
    00141     PRTL_SPLAY_LINKS ExclusiveLockTree;
    00142     SINGLE_LIST_ENTRY WaitingLocks;
    00143     SINGLE_LIST_ENTRY WaitingLocksTail;
    00144
    00145 } LOCK_QUEUE, *PLOCK_QUEUE;
    00146
    00147
    00148 //
    00149 //  Any file_lock which has had a lock applied gets a non-paged pool
    00150 //  structure which tracks the current locks applied to the file
    00151 //
    00152
    00153 typedef struct _LOCK_INFO {
    00154
    00155     //
    00156     //  LowestLockOffset retains the offset of the lowest existing
    00157     //  lock.  This facilitates a quick check to see if a read or
    00158     //  write can proceed without locking the lock database.  This is
    00159     //  helpful for applications that use mirrored locks -- all locks
    00160     //  are higher than file data.
    00161     //
    00162     //  If the lowest lock has an offset > 0xffffffff, LowestLockOffset
    00163     //  is set to 0xffffffff.
    00164     //
    00165
    00166     ULONG LowestLockOffset;
    00167
    00168     //
    00169     //  The optional procedure to call to complete a request
    00170     //
    00171
    00172     PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine;
    00173
    00174     //
    00175     //  The optional procedure to call when unlocking a byte range
    00176     //
    00177
    00178     PUNLOCK_ROUTINE UnlockRoutine;
    00179
    00180     //
    00181     // The locked ranges
    00182     //
    00183
    00184     LOCK_QUEUE  LockQueue;
    00185
    00186 } LOCK_INFO, *PLOCK_INFO;
    00187
    00188
    00190
    00191 //
    00192 //  The oplock state is now just a ULONG.
    00193 //
    00194
    00195 typedef ULONG OPLOCK_STATE;
    00196
    00197 //
    00198 //  The non-opaque definition of an OPLOCK is a pointer to a privately
    00199 //  defined structure.
    00200 //
    00201
    00202 typedef struct _NONOPAQUE_OPLOCK {
    00203
    00204     //
    00205     //  This is the Irp used to successfully request a level I oplock or
    00206     //  batch oplock.  It is completed to initiate the Oplock I break
    00207     //  procedure.
    00208     //
    00209
    00210     PIRP IrpExclusiveOplock;
    00211
    00212     //
    00213     //  This is a pointer to the original file object used when granting
    00214     //  an Oplock I or batch oplock.
    00215     //
    00216
    00217     PFILE_OBJECT FileObject;
    00218
    00219     //
    00220     //  The start of a linked list of Irps used to successfully request
    00221     //  a level II oplock.
    00222     //
    00223
    00224     LIST_ENTRY IrpOplocksII;
    00225
    00226     //
    00227     //  The following links the Irps waiting to be completed on a queue
    00228     //  of Irps.
    00229     //
    00230
    00231     LIST_ENTRY WaitingIrps;
    00232
    00233     //
    00234     //  Oplock state.  This indicates the current oplock state.
    00235     //
    00236
    00237     OPLOCK_STATE OplockState;
    00238
    00239     //
    00240     //  This FastMutex is used to control access to this structure.
    00241     //
    00242
    00243     PFAST_MUTEX FastMutex;
    00244
    00245     //
    00246     //  This is the timer package to process an OpFilter break.
    00247     //
    00248
    00249     struct _OPFILTER_TIMER *OpFilter;
    00250
    00251     //
    00252     //  Count of outstanding timers.
    00253     //
    00254
    00255     ULONG TimerCount;
    00256
    00257 } NONOPAQUE_OPLOCK, *PNONOPAQUE_OPLOCK;
    00258
    00259 //
    00260 //  Each Waiting Irp record corresponds to an Irp that is waiting for an
    00261 //  oplock break to be acknowledged and is maintained in a queue off of the
    00262 //  Oplock's WaitingIrps list.
    00263 //
    00264
    00265 typedef struct _WAITING_IRP {
    00266
    00267     //
    00268     //  The link structures for the list of waiting irps.
    00269     //
    00270
    00271     LIST_ENTRY Links;
    00272
    00273     //
    00274     //  This is the Irp attached to this structure.
    00275     //
    00276
    00277     PIRP Irp;
    00278
    00279     //
    00280     //  This is the routine to call when we are done with an Irp we
    00281     //  held on a waiting queue.  (We originally returned STATUS_PENDING).
    00282     //
    00283
    00284     POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine;
    00285
    00286     //
    00287     //  The context field to use when we are done with the Irp.
    00288     //
    00289
    00290     PVOID Context;
    00291
    00292     //
    00293     //  This points to an event object used when we do not want to
    00294     //  give up this thread.
    00295     //
    00296
    00297     PKEVENT Event;
    00298
    00299     //
    00300     //  This field contains a copy of the Irp Iosb.Information field.
    00301     //  We copy it here so that we can store the Oplock address in the
    00302     //  Irp.
    00303     //
    00304
    00305     ULONG Information;
    00306
    00307 } WAITING_IRP, *PWAITING_IRP;
    00308
    00309 //
    00310 //  The following structure is used when timing out the OpFilter oplocks.
    00311 //
    00312
    00313 typedef struct _OPFILTER_TIMER {
    00314
    00315     KDPC OpFilterDpc;
    00316     KTIMER OpFilterTimer;
    00317     WORK_QUEUE_ITEM OpFilterItem;
    00318     PNONOPAQUE_OPLOCK Oplock;
    00319
    00320 } OPFILTER_TIMER, *POPFILTER_TIMER;
    00321