forked from fuse4x/kext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuse_biglock_vnops.h
280 lines (207 loc) · 10.4 KB
/
fuse_biglock_vnops.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*
* Copyright (C) 2006 Google. All Rights Reserved.
* Amit Singh <singh@>
*/
#ifndef _FUSE_BIGLOCK_VNOPS_H_
#define _FUSE_BIGLOCK_VNOPS_H_
#include <fuse_param.h>
#include "fuse.h"
#include "fuse_locking.h"
#if M_FUSE4X_ENABLE_BIGLOCK
#if FUSE_TRACE_LK
#define biglock_log(fmt, ...) log(fmt, ## __VA_ARGS__)
#else
#define biglock_log(fmt, ...) {}
#endif
#define fuse_biglock_lock(lock) fuse_lck_mtx_lock(lock)
#define fuse_biglock_unlock(lock) fuse_lck_mtx_unlock(lock)
#define fuse_nodelock_lock(node, type) \
do { \
int err; \
biglock_log("0: fusefs_lock(%p,%d): %s@%d by %d\n", node, type, __FUNCTION__, __LINE__, proc_selfpid()); \
err = fusefs_lock(node, type); \
biglock_log("1: fusefs_lock(%p,%d): %s@%d by %d\n", node, type, __FUNCTION__, __LINE__, proc_selfpid()); \
if(err) \
return err; \
} while(0)
#define fuse_nodelock_unlock(node) \
do { \
biglock_log("0: fusefs_unlock(%p): %s@%d by %d\n", node, __FUNCTION__, __LINE__, proc_selfpid()); \
fusefs_unlock(node); \
biglock_log("1: fusefs_unlock(%p): %s@%d by %d\n", node, __FUNCTION__, __LINE__, proc_selfpid()); \
} while(0)
#define fuse_nodelock_lock_pair(node1, node2, type) \
do { \
int err; \
biglock_log("0: fusefs_lockpair(%p,%p,%d): %s@%d by %d\n", node1, node2, type, __FUNCTION__, __LINE__, proc_selfpid()); \
err = fusefs_lockpair(node1, node2, type); \
biglock_log("1: fusefs_lockpair(%p,%p,%d): %s@%d by %d\n", node1, node2, type, __FUNCTION__, __LINE__, proc_selfpid()); \
if(err) \
return err; \
} while(0)
#define fuse_nodelock_unlock_pair(node1, node2) \
do { \
biglock_log("0: fusefs_unlockpair(%p,%p): %s@%d by %d\n", node1, node2, __FUNCTION__, __LINE__, proc_selfpid()); \
fusefs_unlockpair(node1, node2); \
biglock_log("1: fusefs_unlockpair(%p,%p): %s@%d by %d\n", node1, node2, __FUNCTION__, __LINE__, proc_selfpid()); \
} while(0)
#define fuse_nodelock_lock_four(node1, node2, node3, node4, type) \
do { \
int err; \
biglock_log("0: fusefs_lockfour(%p,%p,%p,%p,%d): %s@%d by %d\n", node1, node2, node3, node4, type, __FUNCTION__, __LINE__, proc_selfpid()); \
err = fusefs_lockfour(node1, node2, node3, node4, type); \
biglock_log("1: fusefs_lockfour(%p,%p,%p,%p,%d): %s@%d by %d\n", node1, node2, node3, node4, type, __FUNCTION__, __LINE__, proc_selfpid()); \
if(err) \
return err; \
} while(0)
#define fuse_nodelock_unlock_four(node1, node2, node3, node4) \
do { \
biglock_log("0: fusefs_unlockfour(%p,%p,%p,%p): %s@%d by %d\n", node1, node2, node3, node4, __FUNCTION__, __LINE__, proc_selfpid()); \
fusefs_unlockfour(node1, node2, node3, node4); \
biglock_log("1: fusefs_unlockfour(%p,%p,%p,%p): %s@%d by %d\n", node1, node2, node3, node4, __FUNCTION__, __LINE__, proc_selfpid()); \
} while(0)
/** Wrapper that surrounds a vfsop call with biglock locking. */
#define locked_vfsop(mp, vfsop, args...) \
do { \
errno_t res; \
struct fuse_data *data __unused = fuse_get_mpdata((mp)); \
fuse_biglock_lock(data->biglock); \
res = vfsop(mp, ##args); \
fuse_biglock_unlock(data->biglock); \
return res; \
} while(0)
/** Wrapper that surrounds a vnop call with biglock locking. */
#define locked_vnop(vnode, vnop, args) \
do { \
int res; \
vnode_t vp = (vnode); \
struct fuse_data *data __unused = fuse_get_mpdata(vnode_mount(vp)); \
fuse_biglock_lock(data->biglock); \
res = vnop(args); \
fuse_biglock_unlock(data->biglock); \
return res; \
} while(0)
/**
* Wrapper that surrounds a vnop call with biglock locking and single-node
* locking.
*/
#define nodelocked_vnop(vnode, vnop, args) \
do { \
int res; \
vnode_t vp = (vnode); \
struct fuse_data *data __unused = fuse_get_mpdata(vnode_mount(vp)); \
struct fuse_vnode_data *node = VTOFUD(vp); \
fuse_nodelock_lock(node, FUSEFS_EXCLUSIVE_LOCK); \
fuse_biglock_lock(data->biglock); \
res = vnop(args); \
fuse_biglock_unlock(data->biglock); \
fuse_nodelock_unlock(node); \
return res; \
} while(0)
/**
* Wrapper that surrounds a vnop call with biglock locking and dual node
* locking.
*/
#define nodelocked_pair_vnop(vnode1, vnode2, vnop, args) \
do { \
int res; \
vnode_t vp1 = (vnode1), vp2 = (vnode2); \
struct fuse_data *data __unused = fuse_get_mpdata(vnode_mount(vp1)); \
struct fuse_vnode_data *node1 = vp1 ? VTOFUD(vp1) : NULL; \
struct fuse_vnode_data *node2 = vp2 ? VTOFUD(vp2) : NULL; \
fuse_nodelock_lock_pair(node1, node2, FUSEFS_EXCLUSIVE_LOCK); \
fuse_biglock_lock(data->biglock); \
res = vnop(args); \
fuse_biglock_unlock(data->biglock); \
fuse_nodelock_unlock_pair(node1, node2); \
return res; \
} while(0)
/**
* Wrapper that surrounds a vnop call with biglock locking and four-node
* locking.
*/
#define nodelocked_quad_vnop(vnode1, vnode2, vnode3, vnode4, vnop, args) \
do { \
int res; \
vnode_t vp1 = (vnode1), vp2 = (vnode2), vp3 = (vnode3), vp4 = (vnode4); \
struct fuse_data *data __unused = fuse_get_mpdata(vnode_mount(vp1)); \
struct fuse_vnode_data *node1 = vp1 ? VTOFUD(vp1) : NULL; \
struct fuse_vnode_data *node2 = vp2 ? VTOFUD(vp2) : NULL; \
struct fuse_vnode_data *node3 = vp3 ? VTOFUD(vp3) : NULL; \
struct fuse_vnode_data *node4 = vp4 ? VTOFUD(vp4) : NULL; \
fuse_nodelock_lock_four(node1, node2, node3, node4, FUSEFS_EXCLUSIVE_LOCK); \
fuse_biglock_lock(data->biglock); \
res = vnop(args); \
fuse_biglock_unlock(data->biglock); \
fuse_nodelock_unlock_four(node1, node2, node3, node4); \
return res; \
} while(0)
typedef int (*fuse_biglock_vnode_op_t)(void *);
/*
* VNOPs
*/
FUSE_VNOP_EXPORT int fuse_biglock_vnop_access(struct vnop_access_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_advlock(struct vnop_advlock_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_allocate(struct vnop_allocate_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_blktooff(struct vnop_blktooff_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_blockmap(struct vnop_blockmap_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_bwrite(struct vnop_bwrite_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_close(struct vnop_close_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_copyfile(struct vnop_copyfile_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_create(struct vnop_create_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_exchange(struct vnop_exchange_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_fsync(struct vnop_fsync_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_getattr(struct vnop_getattr_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_getattrlist(struct vnop_getattrlist_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_getnamedstream(struct vnop_getnamedstream_args *ap);
#if M_FUSE4X_ENABLE_XATTR
FUSE_VNOP_EXPORT int fuse_biglock_vnop_getxattr(struct vnop_getxattr_args *ap);
#endif
FUSE_VNOP_EXPORT int fuse_biglock_vnop_inactive(struct vnop_inactive_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_ioctl(struct vnop_ioctl_args *ap);
#if M_FUSE4X_ENABLE_KQUEUE
FUSE_VNOP_EXPORT int fuse_biglock_vnop_kqfilt_add(struct vnop_kqfilt_add_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_kqfilt_remove(struct vnop_kqfilt_remove_args *ap);
#endif
FUSE_VNOP_EXPORT int fuse_biglock_vnop_link(struct vnop_link_args *ap);
#if M_FUSE4X_ENABLE_XATTR
FUSE_VNOP_EXPORT int fuse_biglock_vnop_listxattr(struct vnop_listxattr_args *ap);
#endif
FUSE_VNOP_EXPORT int fuse_biglock_vnop_lookup(struct vnop_lookup_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_makenamedstream(struct fuse_makenamedstream_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_mkdir(struct vnop_mkdir_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_mknod(struct vnop_mknod_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_mmap(struct vnop_mmap_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_mnomap(struct vnop_mnomap_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_offtoblk(struct vnop_offtoblk_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_open(struct vnop_open_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_pagein(struct vnop_pagein_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_pageout(struct vnop_pageout_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_pathconf(struct vnop_pathconf_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_read(struct vnop_read_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_readdir(struct vnop_readdir_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_readdirattr(struct vnop_readdirattr_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_readlink(struct vnop_readlink_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_reclaim(struct vnop_reclaim_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_remove(struct vnop_remove_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_readnamedstream(struct vnop_readnamedstream_args *ap);
#if M_FUSE4X_ENABLE_XATTR
FUSE_VNOP_EXPORT int fuse_biglock_vnop_removexattr(struct vnop_removexattr_args *ap);
#endif
FUSE_VNOP_EXPORT int fuse_biglock_vnop_rename(struct vnop_rename_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_revoke(struct vnop_revoke_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_rmdir(struct vnop_rmdir_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_searchfs(struct vnop_searchfs_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_select(struct vnop_select_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_setattr(struct vnop_setattr_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_setlabel(struct vnop_setlabel_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_setattrlist (struct vnop_setattrlist_args *ap);
#if M_FUSE4X_ENABLE_XATTR
FUSE_VNOP_EXPORT int fuse_biglock_vnop_setxattr(struct vnop_setxattr_args *ap);
#endif
FUSE_VNOP_EXPORT int fuse_biglock_vnop_strategy(struct vnop_strategy_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_symlink(struct vnop_symlink_args *ap);
// FUSE_VNOP_EXPORT int fuse_biglock_vnop_whiteout(struct vnop_whiteout_args *ap);
FUSE_VNOP_EXPORT int fuse_biglock_vnop_write(struct vnop_write_args *ap);
#endif /* M_FUSE4X_ENABLE_BIGLOCK */
#endif /* _FUSE_BIGLOCK_VNOPS_H_ */