Commit | Line | Data |
---|---|---|
f7ab093f | 1 | #include <linux/types.h> |
81b784b1 | 2 | #include <linux/spinlock_types.h> |
f7ab093f | 3 | #include <linux/slab.h> |
2c590d5f | 4 | #include <linux/ioctl.h> |
f7ab093f MM |
5 | |
6 | extern struct client_debug_mask *cdm_array; | |
7 | extern char *debug_help_string; | |
8 | extern int help_string_initialized; | |
9 | extern struct dentry *debug_dir; | |
10 | extern struct dentry *help_file_dentry; | |
11 | extern struct dentry *client_debug_dentry; | |
12 | extern const struct file_operations debug_help_fops; | |
13 | extern int client_all_index; | |
14 | extern int client_verbose_index; | |
15 | extern int cdm_element_count; | |
16 | #define DEBUG_HELP_STRING_SIZE 4096 | |
17 | #define HELP_STRING_UNINITIALIZED \ | |
18 | "Client Debug Keywords are unknown until the first time\n" \ | |
19 | "the client is started after boot.\n" | |
20 | #define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help" | |
21 | #define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug" | |
22 | #define ORANGEFS_CLIENT_DEBUG_FILE "client-debug" | |
23 | #define PVFS2_VERBOSE "verbose" | |
24 | #define PVFS2_ALL "all" | |
25 | ||
26 | /* pvfs2-config.h ***********************************************************/ | |
27 | #define PVFS2_VERSION_MAJOR 2 | |
28 | #define PVFS2_VERSION_MINOR 9 | |
29 | #define PVFS2_VERSION_SUB 0 | |
30 | ||
31 | /* khandle stuff ***********************************************************/ | |
32 | ||
33 | /* | |
34 | * The 2.9 core will put 64 bit handles in here like this: | |
35 | * 1234 0000 0000 5678 | |
36 | * The 3.0 and beyond cores will put 128 bit handles in here like this: | |
37 | * 1234 5678 90AB CDEF | |
38 | * The kernel module will always use the first four bytes and | |
39 | * the last four bytes as an inum. | |
40 | */ | |
41 | struct pvfs2_khandle { | |
42 | unsigned char u[16]; | |
43 | } __aligned(8); | |
44 | ||
45 | /* | |
46 | * kernel version of an object ref. | |
47 | */ | |
48 | struct pvfs2_object_kref { | |
49 | struct pvfs2_khandle khandle; | |
50 | __s32 fs_id; | |
51 | __s32 __pad1; | |
52 | }; | |
53 | ||
54 | /* | |
55 | * compare 2 khandles assumes little endian thus from large address to | |
56 | * small address | |
57 | */ | |
58 | static inline int PVFS_khandle_cmp(const struct pvfs2_khandle *kh1, | |
59 | const struct pvfs2_khandle *kh2) | |
60 | { | |
61 | int i; | |
62 | ||
63 | for (i = 15; i >= 0; i--) { | |
64 | if (kh1->u[i] > kh2->u[i]) | |
65 | return 1; | |
66 | if (kh1->u[i] < kh2->u[i]) | |
67 | return -1; | |
68 | } | |
69 | ||
70 | return 0; | |
71 | } | |
72 | ||
f7ab093f MM |
73 | static inline void PVFS_khandle_to(const struct pvfs2_khandle *kh, |
74 | void *p, int size) | |
75 | { | |
f7ab093f MM |
76 | |
77 | memset(p, 0, size); | |
50e01586 | 78 | memcpy(p, kh->u, 16); |
f7ab093f | 79 | |
f7ab093f MM |
80 | } |
81 | ||
f7ab093f MM |
82 | static inline void PVFS_khandle_from(struct pvfs2_khandle *kh, |
83 | void *p, int size) | |
84 | { | |
f7ab093f | 85 | memset(kh, 0, 16); |
50e01586 | 86 | memcpy(kh->u, p, 16); |
f7ab093f | 87 | |
f7ab093f MM |
88 | } |
89 | ||
90 | /* pvfs2-types.h ************************************************************/ | |
91 | typedef __u32 PVFS_uid; | |
92 | typedef __u32 PVFS_gid; | |
93 | typedef __s32 PVFS_fs_id; | |
94 | typedef __u32 PVFS_permissions; | |
95 | typedef __u64 PVFS_time; | |
96 | typedef __s64 PVFS_size; | |
97 | typedef __u64 PVFS_flags; | |
98 | typedef __u64 PVFS_ds_position; | |
99 | typedef __s32 PVFS_error; | |
100 | typedef __s64 PVFS_offset; | |
101 | ||
102 | #define PVFS2_SUPER_MAGIC 0x20030528 | |
103 | #define PVFS_ERROR_BIT (1 << 30) | |
104 | #define PVFS_NON_ERRNO_ERROR_BIT (1 << 29) | |
105 | #define IS_PVFS_ERROR(__error) ((__error)&(PVFS_ERROR_BIT)) | |
106 | #define IS_PVFS_NON_ERRNO_ERROR(__error) \ | |
107 | (((__error)&(PVFS_NON_ERRNO_ERROR_BIT)) && IS_PVFS_ERROR(__error)) | |
108 | #define PVFS_ERROR_TO_ERRNO(__error) PVFS_get_errno_mapping(__error) | |
109 | ||
110 | /* 7 bits are used for the errno mapped error codes */ | |
111 | #define PVFS_ERROR_CODE(__error) \ | |
112 | ((__error) & (__s32)(0x7f|PVFS_ERROR_BIT)) | |
113 | #define PVFS_ERROR_CLASS(__error) \ | |
114 | ((__error) & ~((__s32)(0x7f|PVFS_ERROR_BIT|PVFS_NON_ERRNO_ERROR_BIT))) | |
115 | #define PVFS_NON_ERRNO_ERROR_CODE(__error) \ | |
116 | ((__error) & (__s32)(127|PVFS_ERROR_BIT|PVFS_NON_ERRNO_ERROR_BIT)) | |
117 | ||
118 | /* PVFS2 error codes, compliments of asm/errno.h */ | |
119 | #define PVFS_EPERM E(1) /* Operation not permitted */ | |
120 | #define PVFS_ENOENT E(2) /* No such file or directory */ | |
121 | #define PVFS_EINTR E(3) /* Interrupted system call */ | |
122 | #define PVFS_EIO E(4) /* I/O error */ | |
123 | #define PVFS_ENXIO E(5) /* No such device or address */ | |
124 | #define PVFS_EBADF E(6) /* Bad file number */ | |
125 | #define PVFS_EAGAIN E(7) /* Try again */ | |
126 | #define PVFS_ENOMEM E(8) /* Out of memory */ | |
127 | #define PVFS_EFAULT E(9) /* Bad address */ | |
128 | #define PVFS_EBUSY E(10) /* Device or resource busy */ | |
129 | #define PVFS_EEXIST E(11) /* File exists */ | |
130 | #define PVFS_ENODEV E(12) /* No such device */ | |
131 | #define PVFS_ENOTDIR E(13) /* Not a directory */ | |
132 | #define PVFS_EISDIR E(14) /* Is a directory */ | |
133 | #define PVFS_EINVAL E(15) /* Invalid argument */ | |
134 | #define PVFS_EMFILE E(16) /* Too many open files */ | |
135 | #define PVFS_EFBIG E(17) /* File too large */ | |
136 | #define PVFS_ENOSPC E(18) /* No space left on device */ | |
137 | #define PVFS_EROFS E(19) /* Read-only file system */ | |
138 | #define PVFS_EMLINK E(20) /* Too many links */ | |
139 | #define PVFS_EPIPE E(21) /* Broken pipe */ | |
140 | #define PVFS_EDEADLK E(22) /* Resource deadlock would occur */ | |
141 | #define PVFS_ENAMETOOLONG E(23) /* File name too long */ | |
142 | #define PVFS_ENOLCK E(24) /* No record locks available */ | |
143 | #define PVFS_ENOSYS E(25) /* Function not implemented */ | |
144 | #define PVFS_ENOTEMPTY E(26) /* Directory not empty */ | |
145 | /* | |
146 | #define PVFS_ELOOP E(27) * Too many symbolic links encountered | |
147 | */ | |
148 | #define PVFS_EWOULDBLOCK E(28) /* Operation would block */ | |
149 | #define PVFS_ENOMSG E(29) /* No message of desired type */ | |
150 | #define PVFS_EUNATCH E(30) /* Protocol driver not attached */ | |
151 | #define PVFS_EBADR E(31) /* Invalid request descriptor */ | |
152 | #define PVFS_EDEADLOCK E(32) | |
153 | #define PVFS_ENODATA E(33) /* No data available */ | |
154 | #define PVFS_ETIME E(34) /* Timer expired */ | |
155 | #define PVFS_ENONET E(35) /* Machine is not on the network */ | |
156 | #define PVFS_EREMOTE E(36) /* Object is remote */ | |
157 | #define PVFS_ECOMM E(37) /* Communication error on send */ | |
158 | #define PVFS_EPROTO E(38) /* Protocol error */ | |
159 | #define PVFS_EBADMSG E(39) /* Not a data message */ | |
160 | /* | |
161 | #define PVFS_EOVERFLOW E(40) * Value too large for defined data | |
162 | * type | |
163 | */ | |
164 | /* | |
165 | #define PVFS_ERESTART E(41) * Interrupted system call should be | |
166 | * restarted | |
167 | */ | |
168 | #define PVFS_EMSGSIZE E(42) /* Message too long */ | |
169 | #define PVFS_EPROTOTYPE E(43) /* Protocol wrong type for socket */ | |
170 | #define PVFS_ENOPROTOOPT E(44) /* Protocol not available */ | |
171 | #define PVFS_EPROTONOSUPPORT E(45) /* Protocol not supported */ | |
172 | /* | |
173 | #define PVFS_EOPNOTSUPP E(46) * Operation not supported on transport | |
174 | * endpoint | |
175 | */ | |
176 | #define PVFS_EADDRINUSE E(47) /* Address already in use */ | |
177 | #define PVFS_EADDRNOTAVAIL E(48) /* Cannot assign requested address */ | |
178 | #define PVFS_ENETDOWN E(49) /* Network is down */ | |
179 | #define PVFS_ENETUNREACH E(50) /* Network is unreachable */ | |
180 | /* | |
181 | #define PVFS_ENETRESET E(51) * Network dropped connection because | |
182 | * of reset | |
183 | */ | |
184 | #define PVFS_ENOBUFS E(52) /* No buffer space available */ | |
185 | #define PVFS_ETIMEDOUT E(53) /* Connection timed out */ | |
186 | #define PVFS_ECONNREFUSED E(54) /* Connection refused */ | |
187 | #define PVFS_EHOSTDOWN E(55) /* Host is down */ | |
188 | #define PVFS_EHOSTUNREACH E(56) /* No route to host */ | |
189 | #define PVFS_EALREADY E(57) /* Operation already in progress */ | |
190 | #define PVFS_EACCES E(58) /* Access not allowed */ | |
191 | #define PVFS_ECONNRESET E(59) /* Connection reset by peer */ | |
192 | #define PVFS_ERANGE E(60) /* Math out of range or buf too small */ | |
193 | ||
194 | /***************** non-errno/pvfs2 specific error codes *****************/ | |
195 | #define PVFS_ECANCEL (1|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
196 | #define PVFS_EDEVINIT (2|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
197 | #define PVFS_EDETAIL (3|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
198 | #define PVFS_EHOSTNTFD (4|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
199 | #define PVFS_EADDRNTFD (5|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
200 | #define PVFS_ENORECVR (6|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
201 | #define PVFS_ETRYAGAIN (7|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
202 | #define PVFS_ENOTPVFS (8|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
203 | #define PVFS_ESECURITY (9|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) | |
204 | ||
205 | /* | |
206 | * NOTE: PLEASE DO NOT ARBITRARILY ADD NEW ERRNO ERROR CODES! | |
207 | * | |
208 | * IF YOU CHOOSE TO ADD A NEW ERROR CODE (DESPITE OUR PLEA), YOU ALSO | |
209 | * NEED TO INCREMENT PVFS_ERRNO MAX (BELOW) AND ADD A MAPPING TO A | |
210 | * UNIX ERRNO VALUE IN THE MACROS BELOW (USED IN | |
211 | * src/common/misc/errno-mapping.c and the kernel module) | |
212 | */ | |
213 | #define PVFS_ERRNO_MAX 61 | |
214 | ||
215 | #define PVFS_ERROR_BMI (1 << 7) /* BMI-specific error */ | |
216 | #define PVFS_ERROR_TROVE (2 << 7) /* Trove-specific error */ | |
217 | #define PVFS_ERROR_FLOW (3 << 7) | |
218 | #define PVFS_ERROR_SM (4 << 7) /* state machine specific error */ | |
219 | #define PVFS_ERROR_SCHED (5 << 7) | |
220 | #define PVFS_ERROR_CLIENT (6 << 7) | |
221 | #define PVFS_ERROR_DEV (7 << 7) /* device file interaction */ | |
222 | ||
223 | #define PVFS_ERROR_CLASS_BITS \ | |
224 | (PVFS_ERROR_BMI | \ | |
225 | PVFS_ERROR_TROVE | \ | |
226 | PVFS_ERROR_FLOW | \ | |
227 | PVFS_ERROR_SM | \ | |
228 | PVFS_ERROR_SCHED | \ | |
229 | PVFS_ERROR_CLIENT | \ | |
230 | PVFS_ERROR_DEV) | |
231 | ||
232 | #define DECLARE_ERRNO_MAPPING() \ | |
233 | __s32 PINT_errno_mapping[PVFS_ERRNO_MAX + 1] = { \ | |
234 | 0, /* leave this one empty */ \ | |
235 | EPERM, /* 1 */ \ | |
236 | ENOENT, \ | |
237 | EINTR, \ | |
238 | EIO, \ | |
239 | ENXIO, \ | |
240 | EBADF, \ | |
241 | EAGAIN, \ | |
242 | ENOMEM, \ | |
243 | EFAULT, \ | |
244 | EBUSY, /* 10 */ \ | |
245 | EEXIST, \ | |
246 | ENODEV, \ | |
247 | ENOTDIR, \ | |
248 | EISDIR, \ | |
249 | EINVAL, \ | |
250 | EMFILE, \ | |
251 | EFBIG, \ | |
252 | ENOSPC, \ | |
253 | EROFS, \ | |
254 | EMLINK, /* 20 */ \ | |
255 | EPIPE, \ | |
256 | EDEADLK, \ | |
257 | ENAMETOOLONG, \ | |
258 | ENOLCK, \ | |
259 | ENOSYS, \ | |
260 | ENOTEMPTY, \ | |
261 | ELOOP, \ | |
262 | EWOULDBLOCK, \ | |
263 | ENOMSG, \ | |
264 | EUNATCH, /* 30 */ \ | |
265 | EBADR, \ | |
266 | EDEADLOCK, \ | |
267 | ENODATA, \ | |
268 | ETIME, \ | |
269 | ENONET, \ | |
270 | EREMOTE, \ | |
271 | ECOMM, \ | |
272 | EPROTO, \ | |
273 | EBADMSG, \ | |
274 | EOVERFLOW, /* 40 */ \ | |
275 | ERESTART, \ | |
276 | EMSGSIZE, \ | |
277 | EPROTOTYPE, \ | |
278 | ENOPROTOOPT, \ | |
279 | EPROTONOSUPPORT, \ | |
280 | EOPNOTSUPP, \ | |
281 | EADDRINUSE, \ | |
282 | EADDRNOTAVAIL, \ | |
283 | ENETDOWN, \ | |
284 | ENETUNREACH, /* 50 */ \ | |
285 | ENETRESET, \ | |
286 | ENOBUFS, \ | |
287 | ETIMEDOUT, \ | |
288 | ECONNREFUSED, \ | |
289 | EHOSTDOWN, \ | |
290 | EHOSTUNREACH, \ | |
291 | EALREADY, \ | |
292 | EACCES, \ | |
293 | ECONNRESET, /* 59 */ \ | |
294 | ERANGE, \ | |
295 | 0 /* PVFS_ERRNO_MAX */ \ | |
296 | }; \ | |
297 | const char *PINT_non_errno_strerror_mapping[] = { \ | |
298 | "Success", /* 0 */ \ | |
299 | "Operation cancelled (possibly due to timeout)", \ | |
300 | "Device initialization failed", \ | |
301 | "Detailed per-server errors are available", \ | |
302 | "Unknown host", \ | |
303 | "No address associated with name", \ | |
304 | "Unknown server error", \ | |
305 | "Host name lookup failure", \ | |
306 | "Path contains non-PVFS elements", \ | |
307 | "Security error", \ | |
308 | }; \ | |
309 | __s32 PINT_non_errno_mapping[] = { \ | |
310 | 0, /* leave this one empty */ \ | |
311 | PVFS_ECANCEL, /* 1 */ \ | |
312 | PVFS_EDEVINIT, /* 2 */ \ | |
313 | PVFS_EDETAIL, /* 3 */ \ | |
314 | PVFS_EHOSTNTFD, /* 4 */ \ | |
315 | PVFS_EADDRNTFD, /* 5 */ \ | |
316 | PVFS_ENORECVR, /* 6 */ \ | |
317 | PVFS_ETRYAGAIN, /* 7 */ \ | |
318 | PVFS_ENOTPVFS, /* 8 */ \ | |
319 | PVFS_ESECURITY, /* 9 */ \ | |
320 | } | |
321 | ||
322 | /* | |
323 | * NOTE: PVFS_get_errno_mapping will convert a PVFS_ERROR_CODE to an | |
324 | * errno value. If the error code is a pvfs2 specific error code | |
325 | * (i.e. a PVFS_NON_ERRNO_ERROR_CODE), PVFS_get_errno_mapping will | |
326 | * return an index into the PINT_non_errno_strerror_mapping array which | |
327 | * can be used for getting the pvfs2 specific strerror message given | |
328 | * the error code. if the value is not a recognized error code, the | |
329 | * passed in value will be returned unchanged. | |
330 | */ | |
331 | #define DECLARE_ERRNO_MAPPING_AND_FN() \ | |
332 | extern __s32 PINT_errno_mapping[]; \ | |
333 | extern __s32 PINT_non_errno_mapping[]; \ | |
334 | extern const char *PINT_non_errno_strerror_mapping[]; \ | |
84d02150 | 335 | static __s32 PVFS_get_errno_mapping(__s32 error) \ |
f7ab093f MM |
336 | { \ |
337 | __s32 ret = error, mask = 0; \ | |
338 | __s32 positive = ((error > -1) ? 1 : 0); \ | |
339 | if (IS_PVFS_NON_ERRNO_ERROR((positive ? error : -error))) { \ | |
340 | mask = (PVFS_NON_ERRNO_ERROR_BIT | \ | |
341 | PVFS_ERROR_BIT | \ | |
342 | PVFS_ERROR_CLASS_BITS); \ | |
343 | ret = PVFS_NON_ERRNO_ERROR_CODE(((positive ? \ | |
344 | error : \ | |
345 | abs(error))) & \ | |
346 | ~mask); \ | |
347 | } \ | |
348 | else if (IS_PVFS_ERROR((positive ? error : -error))) { \ | |
349 | mask = (PVFS_ERROR_BIT | \ | |
350 | PVFS_ERROR_CLASS_BITS); \ | |
351 | ret = PINT_errno_mapping[PVFS_ERROR_CODE(((positive ? \ | |
352 | error : \ | |
353 | abs(error))) & \ | |
354 | ~mask)]; \ | |
355 | } \ | |
356 | return ret; \ | |
357 | } \ | |
f7ab093f MM |
358 | DECLARE_ERRNO_MAPPING() |
359 | ||
360 | /* permission bits */ | |
361 | #define PVFS_O_EXECUTE (1 << 0) | |
362 | #define PVFS_O_WRITE (1 << 1) | |
363 | #define PVFS_O_READ (1 << 2) | |
364 | #define PVFS_G_EXECUTE (1 << 3) | |
365 | #define PVFS_G_WRITE (1 << 4) | |
366 | #define PVFS_G_READ (1 << 5) | |
367 | #define PVFS_U_EXECUTE (1 << 6) | |
368 | #define PVFS_U_WRITE (1 << 7) | |
369 | #define PVFS_U_READ (1 << 8) | |
370 | /* no PVFS_U_VTX (sticky bit) */ | |
371 | #define PVFS_G_SGID (1 << 10) | |
372 | #define PVFS_U_SUID (1 << 11) | |
373 | ||
374 | /* definition taken from stdint.h */ | |
375 | #define INT32_MAX (2147483647) | |
376 | #define PVFS_ITERATE_START (INT32_MAX - 1) | |
377 | #define PVFS_ITERATE_END (INT32_MAX - 2) | |
88309aae | 378 | #define PVFS_ITERATE_NEXT (INT32_MAX - 3) |
f7ab093f MM |
379 | #define PVFS_READDIR_START PVFS_ITERATE_START |
380 | #define PVFS_READDIR_END PVFS_ITERATE_END | |
381 | #define PVFS_IMMUTABLE_FL FS_IMMUTABLE_FL | |
382 | #define PVFS_APPEND_FL FS_APPEND_FL | |
383 | #define PVFS_NOATIME_FL FS_NOATIME_FL | |
384 | #define PVFS_MIRROR_FL 0x01000000ULL | |
385 | #define PVFS_O_EXECUTE (1 << 0) | |
386 | #define PVFS_FS_ID_NULL ((__s32)0) | |
387 | #define PVFS_ATTR_SYS_UID (1 << 0) | |
388 | #define PVFS_ATTR_SYS_GID (1 << 1) | |
389 | #define PVFS_ATTR_SYS_PERM (1 << 2) | |
390 | #define PVFS_ATTR_SYS_ATIME (1 << 3) | |
391 | #define PVFS_ATTR_SYS_CTIME (1 << 4) | |
392 | #define PVFS_ATTR_SYS_MTIME (1 << 5) | |
393 | #define PVFS_ATTR_SYS_TYPE (1 << 6) | |
394 | #define PVFS_ATTR_SYS_ATIME_SET (1 << 7) | |
395 | #define PVFS_ATTR_SYS_MTIME_SET (1 << 8) | |
396 | #define PVFS_ATTR_SYS_SIZE (1 << 20) | |
397 | #define PVFS_ATTR_SYS_LNK_TARGET (1 << 24) | |
398 | #define PVFS_ATTR_SYS_DFILE_COUNT (1 << 25) | |
399 | #define PVFS_ATTR_SYS_DIRENT_COUNT (1 << 26) | |
400 | #define PVFS_ATTR_SYS_BLKSIZE (1 << 28) | |
401 | #define PVFS_ATTR_SYS_MIRROR_COPIES_COUNT (1 << 29) | |
402 | #define PVFS_ATTR_SYS_COMMON_ALL \ | |
403 | (PVFS_ATTR_SYS_UID | \ | |
404 | PVFS_ATTR_SYS_GID | \ | |
405 | PVFS_ATTR_SYS_PERM | \ | |
406 | PVFS_ATTR_SYS_ATIME | \ | |
407 | PVFS_ATTR_SYS_CTIME | \ | |
408 | PVFS_ATTR_SYS_MTIME | \ | |
409 | PVFS_ATTR_SYS_TYPE) | |
410 | ||
411 | #define PVFS_ATTR_SYS_ALL_SETABLE \ | |
412 | (PVFS_ATTR_SYS_COMMON_ALL-PVFS_ATTR_SYS_TYPE) | |
413 | ||
414 | #define PVFS_ATTR_SYS_ALL_NOHINT \ | |
415 | (PVFS_ATTR_SYS_COMMON_ALL | \ | |
416 | PVFS_ATTR_SYS_SIZE | \ | |
417 | PVFS_ATTR_SYS_LNK_TARGET | \ | |
418 | PVFS_ATTR_SYS_DFILE_COUNT | \ | |
419 | PVFS_ATTR_SYS_MIRROR_COPIES_COUNT | \ | |
420 | PVFS_ATTR_SYS_DIRENT_COUNT | \ | |
421 | PVFS_ATTR_SYS_BLKSIZE) | |
422 | #define PVFS_XATTR_REPLACE 0x2 | |
423 | #define PVFS_XATTR_CREATE 0x1 | |
424 | #define PVFS_MAX_SERVER_ADDR_LEN 256 | |
425 | #define PVFS_NAME_MAX 256 | |
426 | /* | |
427 | * max extended attribute name len as imposed by the VFS and exploited for the | |
428 | * upcall request types. | |
429 | * NOTE: Please retain them as multiples of 8 even if you wish to change them | |
430 | * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit | |
431 | * kernel. Due to implementation within DBPF, this really needs to be | |
432 | * PVFS_NAME_MAX, which it was the same value as, but no reason to let it | |
433 | * break if that changes in the future. | |
434 | */ | |
435 | #define PVFS_MAX_XATTR_NAMELEN PVFS_NAME_MAX /* Not the same as | |
436 | * XATTR_NAME_MAX defined | |
437 | * by <linux/xattr.h> | |
438 | */ | |
439 | #define PVFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX | |
440 | * defined by <linux/xattr.h> | |
441 | */ | |
442 | #define PVFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX | |
443 | * defined by <linux/xattr.h> | |
444 | */ | |
445 | /* | |
446 | * PVFS I/O operation types, used in both system and server interfaces. | |
447 | */ | |
448 | enum PVFS_io_type { | |
449 | PVFS_IO_READ = 1, | |
450 | PVFS_IO_WRITE = 2 | |
451 | }; | |
452 | ||
453 | /* | |
454 | * If this enum is modified the server parameters related to the precreate pool | |
455 | * batch and low threshold sizes may need to be modified to reflect this | |
456 | * change. | |
457 | */ | |
458 | enum pvfs2_ds_type { | |
459 | PVFS_TYPE_NONE = 0, | |
460 | PVFS_TYPE_METAFILE = (1 << 0), | |
461 | PVFS_TYPE_DATAFILE = (1 << 1), | |
462 | PVFS_TYPE_DIRECTORY = (1 << 2), | |
463 | PVFS_TYPE_SYMLINK = (1 << 3), | |
464 | PVFS_TYPE_DIRDATA = (1 << 4), | |
465 | PVFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */ | |
466 | }; | |
467 | ||
468 | /* | |
469 | * PVFS_certificate simply stores a buffer with the buffer size. | |
470 | * The buffer can be converted to an OpenSSL X509 struct for use. | |
471 | */ | |
472 | struct PVFS_certificate { | |
473 | __u32 buf_size; | |
474 | unsigned char *buf; | |
475 | }; | |
476 | ||
477 | /* | |
478 | * A credential identifies a user and is signed by the client/user | |
479 | * private key. | |
480 | */ | |
481 | struct PVFS_credential { | |
482 | __u32 userid; /* user id */ | |
483 | __u32 num_groups; /* length of group_array */ | |
484 | __u32 *group_array; /* groups for which the user is a member */ | |
485 | char *issuer; /* alias of the issuing server */ | |
486 | __u64 timeout; /* seconds after epoch to time out */ | |
487 | __u32 sig_size; /* length of the signature in bytes */ | |
488 | unsigned char *signature; /* digital signature */ | |
489 | struct PVFS_certificate certificate; /* user certificate buffer */ | |
490 | }; | |
491 | #define extra_size_PVFS_credential (PVFS_REQ_LIMIT_GROUPS * \ | |
492 | sizeof(__u32) + \ | |
493 | PVFS_REQ_LIMIT_ISSUER + \ | |
494 | PVFS_REQ_LIMIT_SIGNATURE + \ | |
495 | extra_size_PVFS_certificate) | |
496 | ||
497 | /* This structure is used by the VFS-client interaction alone */ | |
498 | struct PVFS_keyval_pair { | |
499 | char key[PVFS_MAX_XATTR_NAMELEN]; | |
500 | __s32 key_sz; /* __s32 for portable, fixed-size structures */ | |
501 | __s32 val_sz; | |
502 | char val[PVFS_MAX_XATTR_VALUELEN]; | |
503 | }; | |
504 | ||
505 | /* pvfs2-sysint.h ***********************************************************/ | |
506 | /* Describes attributes for a file, directory, or symlink. */ | |
507 | struct PVFS_sys_attr_s { | |
508 | __u32 owner; | |
509 | __u32 group; | |
510 | __u32 perms; | |
511 | __u64 atime; | |
512 | __u64 mtime; | |
513 | __u64 ctime; | |
514 | __s64 size; | |
515 | ||
516 | /* NOTE: caller must free if valid */ | |
517 | char *link_target; | |
518 | ||
519 | /* Changed to __s32 so that size of structure does not change */ | |
520 | __s32 dfile_count; | |
521 | ||
522 | /* Changed to __s32 so that size of structure does not change */ | |
523 | __s32 distr_dir_servers_initial; | |
524 | ||
525 | /* Changed to __s32 so that size of structure does not change */ | |
526 | __s32 distr_dir_servers_max; | |
527 | ||
528 | /* Changed to __s32 so that size of structure does not change */ | |
529 | __s32 distr_dir_split_size; | |
530 | ||
531 | __u32 mirror_copies_count; | |
532 | ||
533 | /* NOTE: caller must free if valid */ | |
534 | char *dist_name; | |
535 | ||
536 | /* NOTE: caller must free if valid */ | |
537 | char *dist_params; | |
538 | ||
539 | __s64 dirent_count; | |
540 | enum pvfs2_ds_type objtype; | |
541 | __u64 flags; | |
542 | __u32 mask; | |
543 | __s64 blksize; | |
544 | }; | |
545 | ||
546 | #define PVFS2_LOOKUP_LINK_NO_FOLLOW 0 | |
547 | #define PVFS2_LOOKUP_LINK_FOLLOW 1 | |
548 | ||
549 | /* pint-dev.h ***************************************************************/ | |
550 | ||
551 | /* parameter structure used in PVFS_DEV_DEBUG ioctl command */ | |
552 | struct dev_mask_info_s { | |
553 | enum { | |
554 | KERNEL_MASK, | |
555 | CLIENT_MASK, | |
556 | } mask_type; | |
557 | __u64 mask_value; | |
558 | }; | |
559 | ||
560 | struct dev_mask2_info_s { | |
561 | __u64 mask1_value; | |
562 | __u64 mask2_value; | |
563 | }; | |
564 | ||
565 | /* pvfs2-util.h *************************************************************/ | |
f7ab093f MM |
566 | __s32 PVFS_util_translate_mode(int mode); |
567 | ||
568 | /* pvfs2-debug.h ************************************************************/ | |
569 | #include "pvfs2-debug.h" | |
570 | ||
571 | /* pvfs2-internal.h *********************************************************/ | |
572 | #define llu(x) (unsigned long long)(x) | |
573 | #define lld(x) (long long)(x) | |
574 | ||
575 | /* pint-dev-shared.h ********************************************************/ | |
576 | #define PVFS_DEV_MAGIC 'k' | |
577 | ||
578 | #define PVFS2_READDIR_DEFAULT_DESC_COUNT 5 | |
579 | ||
580 | #define DEV_GET_MAGIC 0x1 | |
581 | #define DEV_GET_MAX_UPSIZE 0x2 | |
582 | #define DEV_GET_MAX_DOWNSIZE 0x3 | |
583 | #define DEV_MAP 0x4 | |
584 | #define DEV_REMOUNT_ALL 0x5 | |
585 | #define DEV_DEBUG 0x6 | |
586 | #define DEV_UPSTREAM 0x7 | |
587 | #define DEV_CLIENT_MASK 0x8 | |
588 | #define DEV_CLIENT_STRING 0x9 | |
589 | #define DEV_MAX_NR 0xa | |
590 | ||
591 | /* supported ioctls, codes are with respect to user-space */ | |
592 | enum { | |
593 | PVFS_DEV_GET_MAGIC = _IOW(PVFS_DEV_MAGIC, DEV_GET_MAGIC, __s32), | |
594 | PVFS_DEV_GET_MAX_UPSIZE = | |
595 | _IOW(PVFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32), | |
596 | PVFS_DEV_GET_MAX_DOWNSIZE = | |
597 | _IOW(PVFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32), | |
598 | PVFS_DEV_MAP = _IO(PVFS_DEV_MAGIC, DEV_MAP), | |
599 | PVFS_DEV_REMOUNT_ALL = _IO(PVFS_DEV_MAGIC, DEV_REMOUNT_ALL), | |
600 | PVFS_DEV_DEBUG = _IOR(PVFS_DEV_MAGIC, DEV_DEBUG, __s32), | |
601 | PVFS_DEV_UPSTREAM = _IOW(PVFS_DEV_MAGIC, DEV_UPSTREAM, int), | |
602 | PVFS_DEV_CLIENT_MASK = _IOW(PVFS_DEV_MAGIC, | |
603 | DEV_CLIENT_MASK, | |
604 | struct dev_mask2_info_s), | |
605 | PVFS_DEV_CLIENT_STRING = _IOW(PVFS_DEV_MAGIC, | |
606 | DEV_CLIENT_STRING, | |
607 | char *), | |
608 | PVFS_DEV_MAXNR = DEV_MAX_NR, | |
609 | }; | |
610 | ||
611 | /* | |
612 | * version number for use in communicating between kernel space and user | |
613 | * space | |
614 | */ | |
615 | /* | |
616 | #define PVFS_KERNEL_PROTO_VERSION \ | |
617 | ((PVFS2_VERSION_MAJOR * 10000) + \ | |
618 | (PVFS2_VERSION_MINOR * 100) + \ | |
619 | PVFS2_VERSION_SUB) | |
620 | */ | |
621 | #define PVFS_KERNEL_PROTO_VERSION 0 | |
622 | ||
623 | /* | |
624 | * describes memory regions to map in the PVFS_DEV_MAP ioctl. | |
625 | * NOTE: See devpvfs2-req.c for 32 bit compat structure. | |
626 | * Since this structure has a variable-sized layout that is different | |
627 | * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout | |
628 | * on such systems before servicing ioctl calls from user-space binaries | |
629 | * that may be 32 bit! | |
630 | */ | |
631 | struct PVFS_dev_map_desc { | |
632 | void *ptr; | |
633 | __s32 total_size; | |
634 | __s32 size; | |
635 | __s32 count; | |
636 | }; | |
637 | ||
638 | /* gossip.h *****************************************************************/ | |
639 | ||
640 | #ifdef GOSSIP_DISABLE_DEBUG | |
641 | #define gossip_debug(mask, format, f...) do {} while (0) | |
642 | #else | |
643 | extern __u64 gossip_debug_mask; | |
644 | extern struct client_debug_mask client_debug_mask; | |
645 | ||
646 | /* try to avoid function call overhead by checking masks in macro */ | |
647 | #define gossip_debug(mask, format, f...) \ | |
648 | do { \ | |
649 | if (gossip_debug_mask & mask) \ | |
650 | printk(format, ##f); \ | |
651 | } while (0) | |
652 | #endif /* GOSSIP_DISABLE_DEBUG */ | |
653 | ||
654 | /* do file and line number printouts w/ the GNU preprocessor */ | |
655 | #define gossip_ldebug(mask, format, f...) \ | |
656 | gossip_debug(mask, "%s: " format, __func__, ##f) | |
657 | ||
658 | #define gossip_err printk | |
659 | #define gossip_lerr(format, f...) \ | |
660 | gossip_err("%s line %d: " format, \ | |
661 | __FILE__, \ | |
662 | __LINE__, \ | |
663 | ##f) |