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 | |
f7ab093f | 103 | |
894ac432 MB |
104 | /* PVFS2 error codes are a signed 32-bit integer. Error codes are negative, but |
105 | * the sign is stripped before decoding. */ | |
f7ab093f | 106 | |
894ac432 | 107 | /* Bit 31 is not used since it is the sign. */ |
f7ab093f | 108 | |
894ac432 MB |
109 | /* Bit 30 specifies that this is a PVFS2 error. A PVFS2 error is either an |
110 | * encoded errno value or a PVFS2 protocol error. */ | |
111 | #define PVFS_ERROR_BIT (1 << 30) | |
f7ab093f | 112 | |
894ac432 MB |
113 | /* Bit 29 specifies that this is a PVFS2 protocol error and not an encoded |
114 | * errno value. */ | |
115 | #define PVFS_NON_ERRNO_ERROR_BIT (1 << 29) | |
f7ab093f | 116 | |
894ac432 MB |
117 | /* Bits 9, 8, and 7 specify the error class, which encodes the section of |
118 | * server code the error originated in for logging purposes. It is not used | |
119 | * in the kernel except to be masked out. */ | |
120 | #define PVFS_ERROR_CLASS_BITS 0x380 | |
121 | ||
122 | /* Bits 6 - 0 are reserved for the actual error code. */ | |
123 | #define PVFS_ERROR_NUMBER_BITS 0x7f | |
124 | ||
125 | /* Encoded errno values are decoded by PINT_errno_mapping in pvfs2-utils.c. */ | |
126 | ||
127 | /* Our own PVFS2 protocol error codes. */ | |
128 | #define PVFS_ECANCEL (1|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
129 | #define PVFS_EDEVINIT (2|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
130 | #define PVFS_EDETAIL (3|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
131 | #define PVFS_EHOSTNTFD (4|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
132 | #define PVFS_EADDRNTFD (5|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
133 | #define PVFS_ENORECVR (6|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
134 | #define PVFS_ETRYAGAIN (7|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
135 | #define PVFS_ENOTPVFS (8|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
136 | #define PVFS_ESECURITY (9|PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT) | |
f7ab093f MM |
137 | |
138 | /* permission bits */ | |
139 | #define PVFS_O_EXECUTE (1 << 0) | |
140 | #define PVFS_O_WRITE (1 << 1) | |
141 | #define PVFS_O_READ (1 << 2) | |
142 | #define PVFS_G_EXECUTE (1 << 3) | |
143 | #define PVFS_G_WRITE (1 << 4) | |
144 | #define PVFS_G_READ (1 << 5) | |
145 | #define PVFS_U_EXECUTE (1 << 6) | |
146 | #define PVFS_U_WRITE (1 << 7) | |
147 | #define PVFS_U_READ (1 << 8) | |
148 | /* no PVFS_U_VTX (sticky bit) */ | |
149 | #define PVFS_G_SGID (1 << 10) | |
150 | #define PVFS_U_SUID (1 << 11) | |
151 | ||
152 | /* definition taken from stdint.h */ | |
153 | #define INT32_MAX (2147483647) | |
154 | #define PVFS_ITERATE_START (INT32_MAX - 1) | |
155 | #define PVFS_ITERATE_END (INT32_MAX - 2) | |
88309aae | 156 | #define PVFS_ITERATE_NEXT (INT32_MAX - 3) |
f7ab093f MM |
157 | #define PVFS_READDIR_START PVFS_ITERATE_START |
158 | #define PVFS_READDIR_END PVFS_ITERATE_END | |
159 | #define PVFS_IMMUTABLE_FL FS_IMMUTABLE_FL | |
160 | #define PVFS_APPEND_FL FS_APPEND_FL | |
161 | #define PVFS_NOATIME_FL FS_NOATIME_FL | |
162 | #define PVFS_MIRROR_FL 0x01000000ULL | |
163 | #define PVFS_O_EXECUTE (1 << 0) | |
164 | #define PVFS_FS_ID_NULL ((__s32)0) | |
165 | #define PVFS_ATTR_SYS_UID (1 << 0) | |
166 | #define PVFS_ATTR_SYS_GID (1 << 1) | |
167 | #define PVFS_ATTR_SYS_PERM (1 << 2) | |
168 | #define PVFS_ATTR_SYS_ATIME (1 << 3) | |
169 | #define PVFS_ATTR_SYS_CTIME (1 << 4) | |
170 | #define PVFS_ATTR_SYS_MTIME (1 << 5) | |
171 | #define PVFS_ATTR_SYS_TYPE (1 << 6) | |
172 | #define PVFS_ATTR_SYS_ATIME_SET (1 << 7) | |
173 | #define PVFS_ATTR_SYS_MTIME_SET (1 << 8) | |
174 | #define PVFS_ATTR_SYS_SIZE (1 << 20) | |
175 | #define PVFS_ATTR_SYS_LNK_TARGET (1 << 24) | |
176 | #define PVFS_ATTR_SYS_DFILE_COUNT (1 << 25) | |
177 | #define PVFS_ATTR_SYS_DIRENT_COUNT (1 << 26) | |
178 | #define PVFS_ATTR_SYS_BLKSIZE (1 << 28) | |
179 | #define PVFS_ATTR_SYS_MIRROR_COPIES_COUNT (1 << 29) | |
180 | #define PVFS_ATTR_SYS_COMMON_ALL \ | |
181 | (PVFS_ATTR_SYS_UID | \ | |
182 | PVFS_ATTR_SYS_GID | \ | |
183 | PVFS_ATTR_SYS_PERM | \ | |
184 | PVFS_ATTR_SYS_ATIME | \ | |
185 | PVFS_ATTR_SYS_CTIME | \ | |
186 | PVFS_ATTR_SYS_MTIME | \ | |
187 | PVFS_ATTR_SYS_TYPE) | |
188 | ||
189 | #define PVFS_ATTR_SYS_ALL_SETABLE \ | |
190 | (PVFS_ATTR_SYS_COMMON_ALL-PVFS_ATTR_SYS_TYPE) | |
191 | ||
192 | #define PVFS_ATTR_SYS_ALL_NOHINT \ | |
193 | (PVFS_ATTR_SYS_COMMON_ALL | \ | |
194 | PVFS_ATTR_SYS_SIZE | \ | |
195 | PVFS_ATTR_SYS_LNK_TARGET | \ | |
196 | PVFS_ATTR_SYS_DFILE_COUNT | \ | |
197 | PVFS_ATTR_SYS_MIRROR_COPIES_COUNT | \ | |
198 | PVFS_ATTR_SYS_DIRENT_COUNT | \ | |
199 | PVFS_ATTR_SYS_BLKSIZE) | |
200 | #define PVFS_XATTR_REPLACE 0x2 | |
201 | #define PVFS_XATTR_CREATE 0x1 | |
202 | #define PVFS_MAX_SERVER_ADDR_LEN 256 | |
203 | #define PVFS_NAME_MAX 256 | |
204 | /* | |
205 | * max extended attribute name len as imposed by the VFS and exploited for the | |
206 | * upcall request types. | |
207 | * NOTE: Please retain them as multiples of 8 even if you wish to change them | |
208 | * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit | |
209 | * kernel. Due to implementation within DBPF, this really needs to be | |
210 | * PVFS_NAME_MAX, which it was the same value as, but no reason to let it | |
211 | * break if that changes in the future. | |
212 | */ | |
213 | #define PVFS_MAX_XATTR_NAMELEN PVFS_NAME_MAX /* Not the same as | |
214 | * XATTR_NAME_MAX defined | |
215 | * by <linux/xattr.h> | |
216 | */ | |
217 | #define PVFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX | |
218 | * defined by <linux/xattr.h> | |
219 | */ | |
220 | #define PVFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX | |
221 | * defined by <linux/xattr.h> | |
222 | */ | |
223 | /* | |
224 | * PVFS I/O operation types, used in both system and server interfaces. | |
225 | */ | |
226 | enum PVFS_io_type { | |
227 | PVFS_IO_READ = 1, | |
228 | PVFS_IO_WRITE = 2 | |
229 | }; | |
230 | ||
231 | /* | |
232 | * If this enum is modified the server parameters related to the precreate pool | |
233 | * batch and low threshold sizes may need to be modified to reflect this | |
234 | * change. | |
235 | */ | |
236 | enum pvfs2_ds_type { | |
237 | PVFS_TYPE_NONE = 0, | |
238 | PVFS_TYPE_METAFILE = (1 << 0), | |
239 | PVFS_TYPE_DATAFILE = (1 << 1), | |
240 | PVFS_TYPE_DIRECTORY = (1 << 2), | |
241 | PVFS_TYPE_SYMLINK = (1 << 3), | |
242 | PVFS_TYPE_DIRDATA = (1 << 4), | |
243 | PVFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */ | |
244 | }; | |
245 | ||
246 | /* | |
247 | * PVFS_certificate simply stores a buffer with the buffer size. | |
248 | * The buffer can be converted to an OpenSSL X509 struct for use. | |
249 | */ | |
250 | struct PVFS_certificate { | |
251 | __u32 buf_size; | |
252 | unsigned char *buf; | |
253 | }; | |
254 | ||
255 | /* | |
256 | * A credential identifies a user and is signed by the client/user | |
257 | * private key. | |
258 | */ | |
259 | struct PVFS_credential { | |
260 | __u32 userid; /* user id */ | |
261 | __u32 num_groups; /* length of group_array */ | |
262 | __u32 *group_array; /* groups for which the user is a member */ | |
263 | char *issuer; /* alias of the issuing server */ | |
264 | __u64 timeout; /* seconds after epoch to time out */ | |
265 | __u32 sig_size; /* length of the signature in bytes */ | |
266 | unsigned char *signature; /* digital signature */ | |
267 | struct PVFS_certificate certificate; /* user certificate buffer */ | |
268 | }; | |
269 | #define extra_size_PVFS_credential (PVFS_REQ_LIMIT_GROUPS * \ | |
270 | sizeof(__u32) + \ | |
271 | PVFS_REQ_LIMIT_ISSUER + \ | |
272 | PVFS_REQ_LIMIT_SIGNATURE + \ | |
273 | extra_size_PVFS_certificate) | |
274 | ||
275 | /* This structure is used by the VFS-client interaction alone */ | |
276 | struct PVFS_keyval_pair { | |
277 | char key[PVFS_MAX_XATTR_NAMELEN]; | |
278 | __s32 key_sz; /* __s32 for portable, fixed-size structures */ | |
279 | __s32 val_sz; | |
280 | char val[PVFS_MAX_XATTR_VALUELEN]; | |
281 | }; | |
282 | ||
283 | /* pvfs2-sysint.h ***********************************************************/ | |
284 | /* Describes attributes for a file, directory, or symlink. */ | |
285 | struct PVFS_sys_attr_s { | |
286 | __u32 owner; | |
287 | __u32 group; | |
288 | __u32 perms; | |
289 | __u64 atime; | |
290 | __u64 mtime; | |
291 | __u64 ctime; | |
292 | __s64 size; | |
293 | ||
294 | /* NOTE: caller must free if valid */ | |
295 | char *link_target; | |
296 | ||
297 | /* Changed to __s32 so that size of structure does not change */ | |
298 | __s32 dfile_count; | |
299 | ||
300 | /* Changed to __s32 so that size of structure does not change */ | |
301 | __s32 distr_dir_servers_initial; | |
302 | ||
303 | /* Changed to __s32 so that size of structure does not change */ | |
304 | __s32 distr_dir_servers_max; | |
305 | ||
306 | /* Changed to __s32 so that size of structure does not change */ | |
307 | __s32 distr_dir_split_size; | |
308 | ||
309 | __u32 mirror_copies_count; | |
310 | ||
311 | /* NOTE: caller must free if valid */ | |
312 | char *dist_name; | |
313 | ||
314 | /* NOTE: caller must free if valid */ | |
315 | char *dist_params; | |
316 | ||
317 | __s64 dirent_count; | |
318 | enum pvfs2_ds_type objtype; | |
319 | __u64 flags; | |
320 | __u32 mask; | |
321 | __s64 blksize; | |
322 | }; | |
323 | ||
324 | #define PVFS2_LOOKUP_LINK_NO_FOLLOW 0 | |
325 | #define PVFS2_LOOKUP_LINK_FOLLOW 1 | |
326 | ||
327 | /* pint-dev.h ***************************************************************/ | |
328 | ||
329 | /* parameter structure used in PVFS_DEV_DEBUG ioctl command */ | |
330 | struct dev_mask_info_s { | |
331 | enum { | |
332 | KERNEL_MASK, | |
333 | CLIENT_MASK, | |
334 | } mask_type; | |
335 | __u64 mask_value; | |
336 | }; | |
337 | ||
338 | struct dev_mask2_info_s { | |
339 | __u64 mask1_value; | |
340 | __u64 mask2_value; | |
341 | }; | |
342 | ||
343 | /* pvfs2-util.h *************************************************************/ | |
f7ab093f MM |
344 | __s32 PVFS_util_translate_mode(int mode); |
345 | ||
346 | /* pvfs2-debug.h ************************************************************/ | |
347 | #include "pvfs2-debug.h" | |
348 | ||
349 | /* pvfs2-internal.h *********************************************************/ | |
350 | #define llu(x) (unsigned long long)(x) | |
351 | #define lld(x) (long long)(x) | |
352 | ||
353 | /* pint-dev-shared.h ********************************************************/ | |
354 | #define PVFS_DEV_MAGIC 'k' | |
355 | ||
356 | #define PVFS2_READDIR_DEFAULT_DESC_COUNT 5 | |
357 | ||
358 | #define DEV_GET_MAGIC 0x1 | |
359 | #define DEV_GET_MAX_UPSIZE 0x2 | |
360 | #define DEV_GET_MAX_DOWNSIZE 0x3 | |
361 | #define DEV_MAP 0x4 | |
362 | #define DEV_REMOUNT_ALL 0x5 | |
363 | #define DEV_DEBUG 0x6 | |
364 | #define DEV_UPSTREAM 0x7 | |
365 | #define DEV_CLIENT_MASK 0x8 | |
366 | #define DEV_CLIENT_STRING 0x9 | |
367 | #define DEV_MAX_NR 0xa | |
368 | ||
369 | /* supported ioctls, codes are with respect to user-space */ | |
370 | enum { | |
371 | PVFS_DEV_GET_MAGIC = _IOW(PVFS_DEV_MAGIC, DEV_GET_MAGIC, __s32), | |
372 | PVFS_DEV_GET_MAX_UPSIZE = | |
373 | _IOW(PVFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32), | |
374 | PVFS_DEV_GET_MAX_DOWNSIZE = | |
375 | _IOW(PVFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32), | |
376 | PVFS_DEV_MAP = _IO(PVFS_DEV_MAGIC, DEV_MAP), | |
377 | PVFS_DEV_REMOUNT_ALL = _IO(PVFS_DEV_MAGIC, DEV_REMOUNT_ALL), | |
378 | PVFS_DEV_DEBUG = _IOR(PVFS_DEV_MAGIC, DEV_DEBUG, __s32), | |
379 | PVFS_DEV_UPSTREAM = _IOW(PVFS_DEV_MAGIC, DEV_UPSTREAM, int), | |
380 | PVFS_DEV_CLIENT_MASK = _IOW(PVFS_DEV_MAGIC, | |
381 | DEV_CLIENT_MASK, | |
382 | struct dev_mask2_info_s), | |
383 | PVFS_DEV_CLIENT_STRING = _IOW(PVFS_DEV_MAGIC, | |
384 | DEV_CLIENT_STRING, | |
385 | char *), | |
386 | PVFS_DEV_MAXNR = DEV_MAX_NR, | |
387 | }; | |
388 | ||
389 | /* | |
390 | * version number for use in communicating between kernel space and user | |
391 | * space | |
392 | */ | |
393 | /* | |
394 | #define PVFS_KERNEL_PROTO_VERSION \ | |
395 | ((PVFS2_VERSION_MAJOR * 10000) + \ | |
396 | (PVFS2_VERSION_MINOR * 100) + \ | |
397 | PVFS2_VERSION_SUB) | |
398 | */ | |
399 | #define PVFS_KERNEL_PROTO_VERSION 0 | |
400 | ||
401 | /* | |
402 | * describes memory regions to map in the PVFS_DEV_MAP ioctl. | |
403 | * NOTE: See devpvfs2-req.c for 32 bit compat structure. | |
404 | * Since this structure has a variable-sized layout that is different | |
405 | * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout | |
406 | * on such systems before servicing ioctl calls from user-space binaries | |
407 | * that may be 32 bit! | |
408 | */ | |
409 | struct PVFS_dev_map_desc { | |
410 | void *ptr; | |
411 | __s32 total_size; | |
412 | __s32 size; | |
413 | __s32 count; | |
414 | }; | |
415 | ||
416 | /* gossip.h *****************************************************************/ | |
417 | ||
418 | #ifdef GOSSIP_DISABLE_DEBUG | |
419 | #define gossip_debug(mask, format, f...) do {} while (0) | |
420 | #else | |
421 | extern __u64 gossip_debug_mask; | |
422 | extern struct client_debug_mask client_debug_mask; | |
423 | ||
424 | /* try to avoid function call overhead by checking masks in macro */ | |
425 | #define gossip_debug(mask, format, f...) \ | |
426 | do { \ | |
427 | if (gossip_debug_mask & mask) \ | |
428 | printk(format, ##f); \ | |
429 | } while (0) | |
430 | #endif /* GOSSIP_DISABLE_DEBUG */ | |
431 | ||
432 | /* do file and line number printouts w/ the GNU preprocessor */ | |
433 | #define gossip_ldebug(mask, format, f...) \ | |
434 | gossip_debug(mask, "%s: " format, __func__, ##f) | |
435 | ||
436 | #define gossip_err printk | |
437 | #define gossip_lerr(format, f...) \ | |
438 | gossip_err("%s line %d: " format, \ | |
439 | __FILE__, \ | |
440 | __LINE__, \ | |
441 | ##f) |