ReactOS  0.4.15-dev-5649-gd5999c6
fastio.c File Reference
#include "btrfs_drv.h"
Include dependency graph for fastio.c:

Go to the source code of this file.

Functions

 _Function_class_ (FAST_IO_QUERY_BASIC_INFO)
 
 _Function_class_ (FAST_IO_QUERY_STANDARD_INFO)
 
 _Function_class_ (FAST_IO_CHECK_IF_POSSIBLE)
 
 _Function_class_ (FAST_IO_QUERY_NETWORK_OPEN_INFO)
 
 _Function_class_ (FAST_IO_ACQUIRE_FOR_MOD_WRITE)
 
 _Function_class_ (FAST_IO_RELEASE_FOR_MOD_WRITE)
 
 _Function_class_ (FAST_IO_ACQUIRE_FOR_CCFLUSH)
 
 _Function_class_ (FAST_IO_RELEASE_FOR_CCFLUSH)
 
 _Function_class_ (FAST_IO_WRITE)
 
 _Function_class_ (FAST_IO_LOCK)
 
 _Function_class_ (FAST_IO_UNLOCK_SINGLE)
 
 _Function_class_ (FAST_IO_UNLOCK_ALL)
 
 _Function_class_ (FAST_IO_UNLOCK_ALL_BY_KEY)
 
static void __stdcall fast_io_acquire_for_create_section (_In_ PFILE_OBJECT FileObject)
 
static void __stdcall fast_io_release_for_create_section (_In_ PFILE_OBJECT FileObject)
 
void init_fast_io_dispatch (FAST_IO_DISPATCH **fiod)
 

Variables

FAST_IO_DISPATCH FastIoDispatch
 

Function Documentation

◆ _Function_class_() [1/13]

_Function_class_ ( FAST_IO_QUERY_BASIC_INFO  )

Definition at line 22 of file fastio.c.

24  {
25  fcb* fcb;
26  ccb* ccb;
27 
29 
31 
32  TRACE("(%p, %u, %p, %p, %p)\n", FileObject, wait, fbi, IoStatus, DeviceObject);
33 
34  if (!FileObject) {
36  return false;
37  }
38 
39  fcb = FileObject->FsContext;
40 
41  if (!fcb) {
43  return false;
44  }
45 
46  ccb = FileObject->FsContext2;
47 
48  if (!ccb) {
50  return false;
51  }
52 
55  return false;
56  }
57 
58  if (fcb->ads) {
59  if (!ccb->fileref || !ccb->fileref->parent || !ccb->fileref->parent->fcb) {
61  return false;
62  }
63 
64  fcb = ccb->fileref->parent->fcb;
65  }
66 
67  if (!ExAcquireResourceSharedLite(fcb->Header.Resource, wait)) {
69  return false;
70  }
71 
72  if (fcb == fcb->Vcb->dummy_fcb) {
74 
76  fbi->CreationTime = fbi->LastAccessTime = fbi->LastWriteTime = fbi->ChangeTime = time;
77  } else {
78  fbi->CreationTime.QuadPart = unix_time_to_win(&fcb->inode_item.otime);
79  fbi->LastAccessTime.QuadPart = unix_time_to_win(&fcb->inode_item.st_atime);
80  fbi->LastWriteTime.QuadPart = unix_time_to_win(&fcb->inode_item.st_mtime);
81  fbi->ChangeTime.QuadPart = unix_time_to_win(&fcb->inode_item.st_ctime);
82  }
83 
84  fbi->FileAttributes = fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fcb->atts;
85 
86  IoStatus->Status = STATUS_SUCCESS;
87  IoStatus->Information = sizeof(FILE_BASIC_INFORMATION);
88 
89  ExReleaseResourceLite(fcb->Header.Resource);
90 
92 
93  return true;
94 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct _file_ref * parent
Definition: btrfs_drv.h:352
#define FsRtlEnterFileSystem
BTRFS_TIME otime
Definition: btrfs.h:304
#define FsRtlExitFileSystem
__u16 time
Definition: mkdosfs.c:366
ACCESS_MASK access
Definition: btrfs_drv.h:382
BTRFS_TIME st_ctime
Definition: btrfs.h:302
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNUSED(x)
Definition: btrfs_drv.h:82
BTRFS_TIME st_mtime
Definition: btrfs.h:303
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1067
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1364
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
BTRFS_TIME st_atime
Definition: btrfs.h:301
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
ULONG atts
Definition: btrfs_drv.h:297
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
bool ads
Definition: btrfs_drv.h:330
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _ccb ccb
file_ref * fileref
Definition: btrfs_drv.h:383
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
#define FILE_BASIC_INFORMATION
Definition: disk.h:53

◆ _Function_class_() [2/13]

_Function_class_ ( FAST_IO_QUERY_STANDARD_INFO  )

Definition at line 96 of file fastio.c.

98  {
99  fcb* fcb;
100  ccb* ccb;
101  bool ads;
102  ULONG adssize;
103 
105 
107 
108  TRACE("(%p, %u, %p, %p, %p)\n", FileObject, wait, fsi, IoStatus, DeviceObject);
109 
110  if (!FileObject) {
112  return false;
113  }
114 
115  fcb = FileObject->FsContext;
116  ccb = FileObject->FsContext2;
117 
118  if (!fcb) {
120  return false;
121  }
122 
123  if (!ExAcquireResourceSharedLite(fcb->Header.Resource, wait)) {
125  return false;
126  }
127 
128  ads = fcb->ads;
129 
130  if (ads) {
131  struct _fcb* fcb2;
132 
133  if (!ccb || !ccb->fileref || !ccb->fileref->parent || !ccb->fileref->parent->fcb) {
134  ExReleaseResourceLite(fcb->Header.Resource);
136  return false;
137  }
138 
139  adssize = fcb->adsdata.Length;
140 
141  fcb2 = ccb->fileref->parent->fcb;
142 
143  ExReleaseResourceLite(fcb->Header.Resource);
144 
145  fcb = fcb2;
146 
147  if (!ExAcquireResourceSharedLite(fcb->Header.Resource, wait)) {
149  return false;
150  }
151 
152  fsi->AllocationSize.QuadPart = fsi->EndOfFile.QuadPart = adssize;
153  fsi->NumberOfLinks = fcb->inode_item.st_nlink;
154  fsi->Directory = false;
155  } else {
156  fsi->AllocationSize.QuadPart = fcb_alloc_size(fcb);
157  fsi->EndOfFile.QuadPart = S_ISDIR(fcb->inode_item.st_mode) ? 0 : fcb->inode_item.st_size;
158  fsi->NumberOfLinks = fcb->inode_item.st_nlink;
159  fsi->Directory = S_ISDIR(fcb->inode_item.st_mode);
160  }
161 
162  fsi->DeletePending = ccb->fileref ? ccb->fileref->delete_on_close : false;
163 
164  IoStatus->Status = STATUS_SUCCESS;
165  IoStatus->Information = sizeof(FILE_STANDARD_INFORMATION);
166 
167  ExReleaseResourceLite(fcb->Header.Resource);
168 
170 
171  return true;
172 }
struct _file_ref * parent
Definition: btrfs_drv.h:352
#define FsRtlEnterFileSystem
adns_state ads
Definition: adh-query.c:35
#define FsRtlExitFileSystem
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
uint32_t st_nlink
Definition: btrfs.h:292
#define UNUSED(x)
Definition: btrfs_drv.h:82
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
uint64_t st_size
Definition: btrfs.h:289
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1364
#define S_ISDIR(mode)
Definition: various.h:18
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1824
ANSI_STRING adsdata
Definition: btrfs_drv.h:334
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
bool ads
Definition: btrfs_drv.h:330
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _ccb ccb
file_ref * fileref
Definition: btrfs_drv.h:383
uint32_t st_mode
Definition: btrfs.h:295
bool delete_on_close
Definition: btrfs_drv.h:345

◆ _Function_class_() [3/13]

_Function_class_ ( FAST_IO_CHECK_IF_POSSIBLE  )

Definition at line 174 of file fastio.c.

177  {
178  fcb* fcb = FileObject->FsContext;
179  LARGE_INTEGER len2;
180 
181  UNUSED(Wait);
182  UNUSED(IoStatus);
184 
185  len2.QuadPart = Length;
186 
187  if (CheckForReadOperation) {
189  return true;
190  } else {
192  return true;
193  }
194 
195  return false;
196 }
BOOLEAN NTAPI FsRtlFastCheckLockForRead(IN PFILE_LOCK FileLock, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN ULONG Key, IN PFILE_OBJECT FileObject, IN PVOID Process)
Definition: filelock.c:748
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN CheckForReadOperation
Definition: fatprocs.h:2662
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
static __inline bool is_subvol_readonly(root *r, PIRP Irp)
Definition: btrfs_drv.h:1033
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define UNUSED(x)
Definition: btrfs_drv.h:82
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FILE_LOCK lock
Definition: btrfs_drv.h:294
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2662
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
struct _root * subvol
Definition: btrfs_drv.h:288
#define NULL
Definition: types.h:112
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
BOOLEAN NTAPI FsRtlFastCheckLockForWrite(IN PFILE_LOCK FileLock, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN ULONG Key, IN PFILE_OBJECT FileObject, IN PVOID Process)
Definition: filelock.c:782
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
LONGLONG QuadPart
Definition: typedefs.h:114

◆ _Function_class_() [4/13]

_Function_class_ ( FAST_IO_QUERY_NETWORK_OPEN_INFO  )

Definition at line 198 of file fastio.c.

200  {
201  fcb* fcb;
202  ccb* ccb;
203  file_ref* fileref;
204 
205  UNUSED(Wait);
206  UNUSED(IoStatus); // FIXME - really? What about IoStatus->Information?
208 
210 
211  TRACE("(%p, %u, %p, %p, %p)\n", FileObject, Wait, fnoi, IoStatus, DeviceObject);
212 
214 
215  fcb = FileObject->FsContext;
216 
217  if (!fcb || fcb == fcb->Vcb->volume_fcb) {
219  return false;
220  }
221 
222  ccb = FileObject->FsContext2;
223 
224  if (!ccb) {
226  return false;
227  }
228 
229  fileref = ccb->fileref;
230 
231  if (fcb == fcb->Vcb->dummy_fcb) {
233 
235  fnoi->CreationTime = fnoi->LastAccessTime = fnoi->LastWriteTime = fnoi->ChangeTime = time;
236  } else {
237  INODE_ITEM* ii;
238 
239  if (fcb->ads) {
240  if (!fileref || !fileref->parent) {
241  ERR("no fileref for stream\n");
243  return false;
244  }
245 
246  ii = &fileref->parent->fcb->inode_item;
247  } else
248  ii = &fcb->inode_item;
249 
250  fnoi->CreationTime.QuadPart = unix_time_to_win(&ii->otime);
251  fnoi->LastAccessTime.QuadPart = unix_time_to_win(&ii->st_atime);
252  fnoi->LastWriteTime.QuadPart = unix_time_to_win(&ii->st_mtime);
253  fnoi->ChangeTime.QuadPart = unix_time_to_win(&ii->st_ctime);
254  }
255 
256  if (fcb->ads) {
257  fnoi->AllocationSize.QuadPart = fnoi->EndOfFile.QuadPart = fcb->adsdata.Length;
258  fnoi->FileAttributes = fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fileref->parent->fcb->atts;
259  } else {
260  fnoi->AllocationSize.QuadPart = fcb_alloc_size(fcb);
261  fnoi->EndOfFile.QuadPart = S_ISDIR(fcb->inode_item.st_mode) ? 0 : fcb->inode_item.st_size;
262  fnoi->FileAttributes = fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fcb->atts;
263  }
264 
266 
267  return true;
268 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define FsRtlEnterFileSystem
BTRFS_TIME otime
Definition: btrfs.h:304
#define FsRtlExitFileSystem
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
__u16 time
Definition: mkdosfs.c:366
BTRFS_TIME st_ctime
Definition: btrfs.h:302
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNUSED(x)
Definition: btrfs_drv.h:82
BTRFS_TIME st_mtime
Definition: btrfs.h:303
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1067
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
uint64_t st_size
Definition: btrfs.h:289
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1364
#define S_ISDIR(mode)
Definition: various.h:18
struct _file_ref * fileref
Definition: btrfs_drv.h:305
BTRFS_TIME st_atime
Definition: btrfs.h:301
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
#define ERR(fmt,...)
Definition: debug.h:110
ULONG atts
Definition: btrfs_drv.h:297
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1824
ANSI_STRING adsdata
Definition: btrfs_drv.h:334
bool ads
Definition: btrfs_drv.h:330
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
struct _ccb ccb
file_ref * fileref
Definition: btrfs_drv.h:383
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
uint32_t st_mode
Definition: btrfs.h:295

◆ _Function_class_() [5/13]

_Function_class_ ( FAST_IO_ACQUIRE_FOR_MOD_WRITE  )

Definition at line 270 of file fastio.c.

272  {
273  fcb* fcb;
274 
276 
279 
280  fcb = FileObject->FsContext;
281 
282  if (!fcb)
284 
285  // Make sure we don't get interrupted by the flush thread, which can cause a deadlock
286 
287  if (!ExAcquireResourceSharedLite(&fcb->Vcb->tree_lock, false))
288  return STATUS_CANT_WAIT;
289 
290  if (!ExAcquireResourceExclusiveLite(fcb->Header.Resource, false)) {
291  ExReleaseResourceLite(&fcb->Vcb->tree_lock);
292  TRACE("returning STATUS_CANT_WAIT\n");
293  return STATUS_CANT_WAIT;
294  }
295 
296  // Ideally this would be PagingIoResource, but that doesn't play well with copy-on-write,
297  // as we can't guarantee that we won't need to do any reallocations.
298 
299  *ResourceToRelease = fcb->Header.Resource;
300 
301  TRACE("returning STATUS_SUCCESS\n");
302 
303  return STATUS_SUCCESS;
304 }
_In_ PLARGE_INTEGER EndingOffset
Definition: iotypes.h:1597
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PLARGE_INTEGER _Out_ struct _ERESOURCE ** ResourceToRelease
Definition: iotypes.h:1598
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNUSED(x)
Definition: btrfs_drv.h:82
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1364
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
LONGLONG QuadPart
Definition: typedefs.h:114
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452

◆ _Function_class_() [6/13]

_Function_class_ ( FAST_IO_RELEASE_FOR_MOD_WRITE  )

Definition at line 306 of file fastio.c.

308  {
309  fcb* fcb;
310 
311  TRACE("(%p, %p, %p)\n", FileObject, ResourceToRelease, DeviceObject);
312 
314 
315  fcb = FileObject->FsContext;
316 
318 
319  ExReleaseResourceLite(&fcb->Vcb->tree_lock);
320 
321  return STATUS_SUCCESS;
322 }
_In_ PLARGE_INTEGER _Out_ struct _ERESOURCE ** ResourceToRelease
Definition: iotypes.h:1598
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNUSED(x)
Definition: btrfs_drv.h:82
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1364
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _device_extension * Vcb
Definition: btrfs_drv.h:287

◆ _Function_class_() [7/13]

_Function_class_ ( FAST_IO_ACQUIRE_FOR_CCFLUSH  )

Definition at line 324 of file fastio.c.

325  {
328 
330 
331  return STATUS_SUCCESS;
332 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNUSED(x)
Definition: btrfs_drv.h:82
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define STATUS_SUCCESS
Definition: shellext.h:65
#define FSRTL_CACHE_TOP_LEVEL_IRP
Definition: fsrtltypes.h:60

◆ _Function_class_() [8/13]

_Function_class_ ( FAST_IO_RELEASE_FOR_CCFLUSH  )

Definition at line 334 of file fastio.c.

335  {
338 
341 
342  return STATUS_SUCCESS;
343 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNUSED(x)
Definition: btrfs_drv.h:82
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
#define FSRTL_CACHE_TOP_LEVEL_IRP
Definition: fsrtltypes.h:60

◆ _Function_class_() [9/13]

_Function_class_ ( FAST_IO_WRITE  )

Definition at line 345 of file fastio.c.

346  {
347  fcb* fcb = FileObject->FsContext;
348  bool ret;
349 
351 
352  if (!ExAcquireResourceSharedLite(&fcb->Vcb->tree_lock, Wait)) {
354  return false;
355  }
356 
358 
359  if (ret)
360  fcb->inode_item.st_size = fcb->Header.FileSize.QuadPart;
361 
362  ExReleaseResourceLite(&fcb->Vcb->tree_lock);
363 
365 
366  return ret;
367 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
Definition: bufpool.h:45
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2662
uint64_t st_size
Definition: btrfs.h:289
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
int ret
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
BOOLEAN NTAPI FsRtlCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:264
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
struct _device_extension * Vcb
Definition: btrfs_drv.h:287

◆ _Function_class_() [10/13]

_Function_class_ ( FAST_IO_LOCK  )

Definition at line 369 of file fastio.c.

372  {
373  BOOLEAN ret;
374  fcb* fcb = FileObject->FsContext;
375 
377 
378  TRACE("(%p, %I64x, %I64x, %p, %lx, %u, %u, %p, %p)\n", FileObject, FileOffset ? FileOffset->QuadPart : 0, Length ? Length->QuadPart : 0,
380 
381  if (fcb->type != BTRFS_TYPE_FILE) {
382  WARN("can only lock files\n");
384  IoStatus->Information = 0;
385  return true;
386  }
387 
389  ExAcquireResourceSharedLite(fcb->Header.Resource, true);
390 
392  ExclusiveLock, IoStatus, NULL, false);
393 
394  if (ret)
395  fcb->Header.IsFastIoPossible = fast_io_possible(fcb);
396 
397  ExReleaseResourceLite(fcb->Header.Resource);
399 
400  return ret;
401 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WARN(fmt,...)
Definition: debug.h:112
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN FailImmediately
Definition: fatprocs.h:2709
unsigned char BOOLEAN
#define UNUSED(x)
Definition: btrfs_drv.h:82
uint8_t type
Definition: btrfs_drv.h:291
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FILE_LOCK lock
Definition: btrfs_drv.h:294
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
int ret
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1684
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
#define NULL
Definition: types.h:112
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN BOOLEAN ExclusiveLock
Definition: fatprocs.h:2709
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define BTRFS_TYPE_FILE
Definition: shellext.h:85
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)
Definition: fsrtlfuncs.h:1581

◆ _Function_class_() [11/13]

_Function_class_ ( FAST_IO_UNLOCK_SINGLE  )

Definition at line 403 of file fastio.c.

405  {
406  fcb* fcb = FileObject->FsContext;
407 
409 
410  TRACE("(%p, %I64x, %I64x, %p, %lx, %p, %p)\n", FileObject, FileOffset ? FileOffset->QuadPart : 0, Length ? Length->QuadPart : 0,
412 
413  IoStatus->Information = 0;
414 
415  if (fcb->type != BTRFS_TYPE_FILE) {
416  WARN("can only lock files\n");
418  return true;
419  }
420 
422 
424 
425  fcb->Header.IsFastIoPossible = fast_io_possible(fcb);
426 
428 
429  return true;
430 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WARN(fmt,...)
Definition: debug.h:112
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS NTAPI FsRtlFastUnlockSingle(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN PEPROCESS Process, IN ULONG Key, IN PVOID Context OPTIONAL, IN BOOLEAN AlreadySynchronized)
Definition: filelock.c:825
#define UNUSED(x)
Definition: btrfs_drv.h:82
uint8_t type
Definition: btrfs_drv.h:291
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FILE_LOCK lock
Definition: btrfs_drv.h:294
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define TRACE(s)
Definition: solgame.cpp:4
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1684
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
#define NULL
Definition: types.h:112
#define BTRFS_TYPE_FILE
Definition: shellext.h:85
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155

◆ _Function_class_() [12/13]

_Function_class_ ( FAST_IO_UNLOCK_ALL  )

Definition at line 432 of file fastio.c.

433  {
434  fcb* fcb = FileObject->FsContext;
435 
437 
438  TRACE("(%p, %p, %p, %p)\n", FileObject, ProcessId, IoStatus, DeviceObject);
439 
440  IoStatus->Information = 0;
441 
442  if (fcb->type != BTRFS_TYPE_FILE) {
443  WARN("can only lock files\n");
445  return true;
446  }
447 
449 
450  ExAcquireResourceSharedLite(fcb->Header.Resource, true);
451 
453 
454  fcb->Header.IsFastIoPossible = fast_io_possible(fcb);
455 
456  ExReleaseResourceLite(fcb->Header.Resource);
457 
459 
460  return true;
461 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WARN(fmt,...)
Definition: debug.h:112
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNUSED(x)
Definition: btrfs_drv.h:82
uint8_t type
Definition: btrfs_drv.h:291
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FILE_LOCK lock
Definition: btrfs_drv.h:294
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
NTSTATUS NTAPI FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN PVOID Context OPTIONAL)
Definition: filelock.c:1025
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1684
#define NULL
Definition: types.h:112
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define BTRFS_TYPE_FILE
Definition: shellext.h:85
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155

◆ _Function_class_() [13/13]

_Function_class_ ( FAST_IO_UNLOCK_ALL_BY_KEY  )

Definition at line 463 of file fastio.c.

465  {
466  fcb* fcb = FileObject->FsContext;
467 
469 
470  TRACE("(%p, %p, %lx, %p, %p)\n", FileObject, ProcessId, Key, IoStatus, DeviceObject);
471 
472  IoStatus->Information = 0;
473 
474  if (fcb->type != BTRFS_TYPE_FILE) {
475  WARN("can only lock files\n");
477  return true;
478  }
479 
481 
482  ExAcquireResourceSharedLite(fcb->Header.Resource, true);
483 
485 
486  fcb->Header.IsFastIoPossible = fast_io_possible(fcb);
487 
488  ExReleaseResourceLite(fcb->Header.Resource);
489 
491 
492  return true;
493 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WARN(fmt,...)
Definition: debug.h:112
NTSTATUS NTAPI FsRtlFastUnlockAllByKey(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN ULONG Key, IN PVOID Context OPTIONAL)
Definition: filelock.c:1086
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNUSED(x)
Definition: btrfs_drv.h:82
uint8_t type
Definition: btrfs_drv.h:291
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FILE_LOCK lock
Definition: btrfs_drv.h:294
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1684
#define NULL
Definition: types.h:112
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define BTRFS_TYPE_FILE
Definition: shellext.h:85
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155

◆ fast_io_acquire_for_create_section()

static void __stdcall fast_io_acquire_for_create_section ( _In_ PFILE_OBJECT  FileObject)
static

Definition at line 498 of file fastio.c.

498  {
499  fcb* fcb;
500 
501  TRACE("(%p)\n", FileObject);
502 
503  if (!FileObject)
504  return;
505 
506  fcb = FileObject->FsContext;
507 
508  if (!fcb)
509  return;
510 
511  ExAcquireResourceSharedLite(&fcb->Vcb->tree_lock, true);
512  ExAcquireResourceExclusiveLite(fcb->Header.Resource, true);
513 }
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1364
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
struct _device_extension * Vcb
Definition: btrfs_drv.h:287

Referenced by init_fast_io_dispatch().

◆ fast_io_release_for_create_section()

static void __stdcall fast_io_release_for_create_section ( _In_ PFILE_OBJECT  FileObject)
static

Definition at line 518 of file fastio.c.

518  {
519  fcb* fcb;
520 
521  TRACE("(%p)\n", FileObject);
522 
523  if (!FileObject)
524  return;
525 
526  fcb = FileObject->FsContext;
527 
528  if (!fcb)
529  return;
530 
531  ExReleaseResourceLite(fcb->Header.Resource);
532  ExReleaseResourceLite(&fcb->Vcb->tree_lock);
533 }
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1364
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
struct _device_extension * Vcb
Definition: btrfs_drv.h:287

Referenced by init_fast_io_dispatch().

◆ init_fast_io_dispatch()

void init_fast_io_dispatch ( FAST_IO_DISPATCH **  fiod)

Definition at line 535 of file fastio.c.

535  {
537 
539 
540  FastIoDispatch.FastIoCheckIfPossible = fast_io_check_if_possible;
542  FastIoDispatch.FastIoWrite = fast_io_write;
543  FastIoDispatch.FastIoQueryBasicInfo = fast_query_basic_info;
544  FastIoDispatch.FastIoQueryStandardInfo = fast_query_standard_info;
545  FastIoDispatch.FastIoLock = fast_io_lock;
546  FastIoDispatch.FastIoUnlockSingle = fast_io_unlock_single;
547  FastIoDispatch.FastIoUnlockAll = fast_io_unlock_all;
548  FastIoDispatch.FastIoUnlockAllByKey = fast_io_unlock_all_by_key;
551  FastIoDispatch.FastIoQueryNetworkOpenInfo = fast_io_query_network_open_info;
552  FastIoDispatch.AcquireForModWrite = fast_io_acquire_for_mod_write;
557  FastIoDispatch.ReleaseForModWrite = fast_io_release_for_mod_write;
558  FastIoDispatch.AcquireForCcFlush = fast_io_acquire_for_ccflush;
559  FastIoDispatch.ReleaseForCcFlush = fast_io_release_for_ccflush;
560 
561  *fiod = &FastIoDispatch;
562 }
PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle
Definition: iotypes.h:1740
BOOLEAN NTAPI FsRtlMdlReadCompleteDev(IN PFILE_OBJECT FileObject, IN PMDL MemoryDescriptorList, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1011
BOOLEAN NTAPI FsRtlMdlWriteCompleteDev(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1198
PFAST_IO_MDL_READ MdlRead
Definition: iotypes.h:1749
PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite
Definition: iotypes.h:1751
PFAST_IO_UNLOCK_ALL FastIoUnlockAll
Definition: iotypes.h:1741
PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection
Definition: iotypes.h:1745
PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo
Definition: iotypes.h:1747
BOOLEAN NTAPI FsRtlPrepareMdlWriteDev(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1272
PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite
Definition: iotypes.h:1758
static void __stdcall fast_io_release_for_create_section(_In_ PFILE_OBJECT FileObject)
Definition: fastio.c:518
PFAST_IO_MDL_READ_COMPLETE MdlReadComplete
Definition: iotypes.h:1750
PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo
Definition: iotypes.h:1737
struct _FAST_IO_DISPATCH FAST_IO_DISPATCH
BOOLEAN NTAPI FsRtlMdlReadDev(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1025
PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey
Definition: iotypes.h:1742
PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush
Definition: iotypes.h:1759
PFAST_IO_LOCK FastIoLock
Definition: iotypes.h:1739
static void __stdcall fast_io_acquire_for_create_section(_In_ PFILE_OBJECT FileObject)
Definition: fastio.c:498
PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite
Definition: iotypes.h:1748
FAST_IO_DISPATCH FastIoDispatch
Definition: fastio.c:20
PFAST_IO_READ FastIoRead
Definition: iotypes.h:1735
PFAST_IO_WRITE FastIoWrite
Definition: iotypes.h:1736
PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo
Definition: iotypes.h:1738
BOOLEAN NTAPI FsRtlCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:64
PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete
Definition: iotypes.h:1752
PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible
Definition: iotypes.h:1734
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection
Definition: iotypes.h:1744
PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush
Definition: iotypes.h:1760
ULONG SizeOfFastIoDispatch
Definition: iotypes.h:1733

Referenced by _Function_class_().

Variable Documentation

◆ FastIoDispatch