ReactOS  0.4.14-dev-358-gbef841c
cache.c
Go to the documentation of this file.
1 /* Copyright (c) Mark Harmstone 2016-17
2  *
3  * This file is part of WinBtrfs.
4  *
5  * WinBtrfs is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public Licence as published by
7  * the Free Software Foundation, either version 3 of the Licence, or
8  * (at your option) any later version.
9  *
10  * WinBtrfs is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public Licence for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public Licence
16  * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #include "btrfs_drv.h"
19 
21 
24  fcb* fcb = FileObject->FsContext;
25 
26  TRACE("(%p, %u)\n", Context, Wait);
27 
28  if (!ExAcquireResourceSharedLite(&fcb->Vcb->tree_lock, Wait))
29  return false;
30 
31  if (!ExAcquireResourceExclusiveLite(fcb->Header.Resource, Wait)) {
32  ExReleaseResourceLite(&fcb->Vcb->tree_lock);
33  return false;
34  }
35 
37 
39 
40  return true;
41 }
42 
45  fcb* fcb = FileObject->FsContext;
46 
47  TRACE("(%p)\n", Context);
48 
50 
51  ExReleaseResourceLite(fcb->Header.Resource);
52 
53  ExReleaseResourceLite(&fcb->Vcb->tree_lock);
54 
57 }
58 
61  fcb* fcb = FileObject->FsContext;
62 
63  TRACE("(%p, %u)\n", Context, Wait);
64 
65  if (!ExAcquireResourceSharedLite(fcb->Header.Resource, Wait))
66  return false;
67 
69 
70  return true;
71 }
72 
75  fcb* fcb = FileObject->FsContext;
76 
77  TRACE("(%p)\n", Context);
78 
79  ExReleaseResourceLite(fcb->Header.Resource);
80 
83 }
84 
85 void init_cache() {
90 }
static void __stdcall release_from_lazy_write(PVOID Context)
Definition: cache.c:43
static BOOLEAN __stdcall acquire_for_lazy_write(PVOID Context, BOOLEAN Wait)
Definition: cache.c:22
PKTHREAD lazy_writer_thread
Definition: btrfs_drv.h:292
CACHE_MANAGER_CALLBACKS cache_callbacks
Definition: cache.c:20
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
static BOOLEAN __stdcall acquire_for_read_ahead(PVOID Context, BOOLEAN Wait)
Definition: cache.c:59
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:279
#define TRACE(s)
Definition: solgame.cpp:4
void init_cache()
Definition: cache.c:85
PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite
Definition: cctypes.h:39
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define __stdcall
Definition: typedefs.h:25
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1955
PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead
Definition: cctypes.h:41
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
static void __stdcall release_from_read_ahead(PVOID Context)
Definition: cache.c:73
PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead
Definition: cctypes.h:42
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite
Definition: cctypes.h:40
struct tagContext Context
Definition: acpixf.h:1030
#define KeGetCurrentThread
Definition: hal.h:44
#define FSRTL_CACHE_TOP_LEVEL_IRP
Definition: fsrtltypes.h:60
struct _device_extension * Vcb
Definition: btrfs_drv.h:283
IN BOOLEAN Wait
Definition: fatprocs.h:1529