blob: 1efc6f8a5224cb0cd1ebb84b793cb68042e70442 [file] [log] [blame]
Joe Perches1917a692016-03-27 14:34:52 -07001#include <linux/kernel.h>
Mike Marshallf7ab0932015-07-17 10:38:11 -04002#include <linux/types.h>
Guenter Roeck81b784b2015-08-01 18:29:37 -07003#include <linux/spinlock_types.h>
Mike Marshallf7ab0932015-07-17 10:38:11 -04004#include <linux/slab.h>
Mike Marshall2c590d52015-07-24 10:37:15 -04005#include <linux/ioctl.h>
Mike Marshallf7ab0932015-07-17 10:38:11 -04006
7extern struct client_debug_mask *cdm_array;
8extern char *debug_help_string;
9extern int help_string_initialized;
10extern struct dentry *debug_dir;
11extern struct dentry *help_file_dentry;
12extern struct dentry *client_debug_dentry;
13extern const struct file_operations debug_help_fops;
14extern int client_all_index;
15extern int client_verbose_index;
16extern int cdm_element_count;
17#define DEBUG_HELP_STRING_SIZE 4096
18#define HELP_STRING_UNINITIALIZED \
19 "Client Debug Keywords are unknown until the first time\n" \
20 "the client is started after boot.\n"
21#define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help"
22#define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug"
23#define ORANGEFS_CLIENT_DEBUG_FILE "client-debug"
Yi Liu8bb8aef2015-11-24 15:12:14 -050024#define ORANGEFS_VERBOSE "verbose"
25#define ORANGEFS_ALL "all"
Mike Marshallf7ab0932015-07-17 10:38:11 -040026
27/* pvfs2-config.h ***********************************************************/
Yi Liu8bb8aef2015-11-24 15:12:14 -050028#define ORANGEFS_VERSION_MAJOR 2
29#define ORANGEFS_VERSION_MINOR 9
30#define ORANGEFS_VERSION_SUB 0
Mike Marshallf7ab0932015-07-17 10:38:11 -040031
32/* khandle stuff ***********************************************************/
33
34/*
35 * The 2.9 core will put 64 bit handles in here like this:
36 * 1234 0000 0000 5678
37 * The 3.0 and beyond cores will put 128 bit handles in here like this:
38 * 1234 5678 90AB CDEF
39 * The kernel module will always use the first four bytes and
40 * the last four bytes as an inum.
41 */
Yi Liu8bb8aef2015-11-24 15:12:14 -050042struct orangefs_khandle {
Mike Marshallf7ab0932015-07-17 10:38:11 -040043 unsigned char u[16];
44} __aligned(8);
45
46/*
47 * kernel version of an object ref.
48 */
Yi Liu8bb8aef2015-11-24 15:12:14 -050049struct orangefs_object_kref {
50 struct orangefs_khandle khandle;
Mike Marshallf7ab0932015-07-17 10:38:11 -040051 __s32 fs_id;
52 __s32 __pad1;
53};
54
55/*
56 * compare 2 khandles assumes little endian thus from large address to
57 * small address
58 */
Yi Liu8bb8aef2015-11-24 15:12:14 -050059static inline int ORANGEFS_khandle_cmp(const struct orangefs_khandle *kh1,
60 const struct orangefs_khandle *kh2)
Mike Marshallf7ab0932015-07-17 10:38:11 -040061{
62 int i;
63
64 for (i = 15; i >= 0; i--) {
65 if (kh1->u[i] > kh2->u[i])
66 return 1;
67 if (kh1->u[i] < kh2->u[i])
68 return -1;
69 }
70
71 return 0;
72}
73
Yi Liu8bb8aef2015-11-24 15:12:14 -050074static inline void ORANGEFS_khandle_to(const struct orangefs_khandle *kh,
Mike Marshallf7ab0932015-07-17 10:38:11 -040075 void *p, int size)
76{
Mike Marshallf7ab0932015-07-17 10:38:11 -040077
Mike Marshall50e01582015-09-29 11:17:26 -040078 memcpy(p, kh->u, 16);
Mike Marshalla9bb3ba2016-04-06 11:19:37 -040079 memset(p + 16, 0, size - 16);
Mike Marshallf7ab0932015-07-17 10:38:11 -040080
Mike Marshallf7ab0932015-07-17 10:38:11 -040081}
82
Yi Liu8bb8aef2015-11-24 15:12:14 -050083static inline void ORANGEFS_khandle_from(struct orangefs_khandle *kh,
Mike Marshallf7ab0932015-07-17 10:38:11 -040084 void *p, int size)
85{
Mike Marshallf7ab0932015-07-17 10:38:11 -040086 memset(kh, 0, 16);
Mike Marshall50e01582015-09-29 11:17:26 -040087 memcpy(kh->u, p, 16);
Mike Marshallf7ab0932015-07-17 10:38:11 -040088
Mike Marshallf7ab0932015-07-17 10:38:11 -040089}
90
91/* pvfs2-types.h ************************************************************/
Yi Liu8bb8aef2015-11-24 15:12:14 -050092typedef __u32 ORANGEFS_uid;
93typedef __u32 ORANGEFS_gid;
94typedef __s32 ORANGEFS_fs_id;
95typedef __u32 ORANGEFS_permissions;
96typedef __u64 ORANGEFS_time;
97typedef __s64 ORANGEFS_size;
98typedef __u64 ORANGEFS_flags;
99typedef __u64 ORANGEFS_ds_position;
100typedef __s32 ORANGEFS_error;
101typedef __s64 ORANGEFS_offset;
Mike Marshallf7ab0932015-07-17 10:38:11 -0400102
Yi Liu8bb8aef2015-11-24 15:12:14 -0500103#define ORANGEFS_SUPER_MAGIC 0x20030528
Martin Brandenburg894ac432015-10-02 12:11:19 -0400104
Mike Marshall54804942015-10-05 13:44:24 -0400105/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500106 * ORANGEFS error codes are a signed 32-bit integer. Error codes are negative, but
Mike Marshall54804942015-10-05 13:44:24 -0400107 * the sign is stripped before decoding.
108 */
Martin Brandenburg894ac432015-10-02 12:11:19 -0400109
110/* Bit 31 is not used since it is the sign. */
111
Mike Marshall54804942015-10-05 13:44:24 -0400112/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500113 * Bit 30 specifies that this is a ORANGEFS error. A ORANGEFS error is either an
114 * encoded errno value or a ORANGEFS protocol error.
Mike Marshall54804942015-10-05 13:44:24 -0400115 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500116#define ORANGEFS_ERROR_BIT (1 << 30)
Martin Brandenburg894ac432015-10-02 12:11:19 -0400117
Mike Marshall54804942015-10-05 13:44:24 -0400118/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500119 * Bit 29 specifies that this is a ORANGEFS protocol error and not an encoded
Mike Marshall54804942015-10-05 13:44:24 -0400120 * errno value.
121 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500122#define ORANGEFS_NON_ERRNO_ERROR_BIT (1 << 29)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400123
Mike Marshall54804942015-10-05 13:44:24 -0400124/*
125 * Bits 9, 8, and 7 specify the error class, which encodes the section of
Martin Brandenburg894ac432015-10-02 12:11:19 -0400126 * server code the error originated in for logging purposes. It is not used
Mike Marshall54804942015-10-05 13:44:24 -0400127 * in the kernel except to be masked out.
128 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500129#define ORANGEFS_ERROR_CLASS_BITS 0x380
Mike Marshallf7ab0932015-07-17 10:38:11 -0400130
Martin Brandenburg894ac432015-10-02 12:11:19 -0400131/* Bits 6 - 0 are reserved for the actual error code. */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500132#define ORANGEFS_ERROR_NUMBER_BITS 0x7f
Mike Marshallf7ab0932015-07-17 10:38:11 -0400133
Mike Marshall575e9462015-12-04 12:56:14 -0500134/* Encoded errno values decoded by PINT_errno_mapping in orangefs-utils.c. */
Mike Marshallf7ab0932015-07-17 10:38:11 -0400135
Yi Liu8bb8aef2015-11-24 15:12:14 -0500136/* Our own ORANGEFS protocol error codes. */
137#define ORANGEFS_ECANCEL (1|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
138#define ORANGEFS_EDEVINIT (2|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
139#define ORANGEFS_EDETAIL (3|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
140#define ORANGEFS_EHOSTNTFD (4|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
141#define ORANGEFS_EADDRNTFD (5|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
142#define ORANGEFS_ENORECVR (6|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
143#define ORANGEFS_ETRYAGAIN (7|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
144#define ORANGEFS_ENOTPVFS (8|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
145#define ORANGEFS_ESECURITY (9|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400146
147/* permission bits */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500148#define ORANGEFS_O_EXECUTE (1 << 0)
149#define ORANGEFS_O_WRITE (1 << 1)
150#define ORANGEFS_O_READ (1 << 2)
151#define ORANGEFS_G_EXECUTE (1 << 3)
152#define ORANGEFS_G_WRITE (1 << 4)
153#define ORANGEFS_G_READ (1 << 5)
154#define ORANGEFS_U_EXECUTE (1 << 6)
155#define ORANGEFS_U_WRITE (1 << 7)
156#define ORANGEFS_U_READ (1 << 8)
157/* no ORANGEFS_U_VTX (sticky bit) */
158#define ORANGEFS_G_SGID (1 << 10)
159#define ORANGEFS_U_SUID (1 << 11)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400160
161/* definition taken from stdint.h */
162#define INT32_MAX (2147483647)
Yi Liu8bb8aef2015-11-24 15:12:14 -0500163#define ORANGEFS_ITERATE_START (INT32_MAX - 1)
164#define ORANGEFS_ITERATE_END (INT32_MAX - 2)
165#define ORANGEFS_ITERATE_NEXT (INT32_MAX - 3)
166#define ORANGEFS_READDIR_START ORANGEFS_ITERATE_START
167#define ORANGEFS_READDIR_END ORANGEFS_ITERATE_END
168#define ORANGEFS_IMMUTABLE_FL FS_IMMUTABLE_FL
169#define ORANGEFS_APPEND_FL FS_APPEND_FL
170#define ORANGEFS_NOATIME_FL FS_NOATIME_FL
171#define ORANGEFS_MIRROR_FL 0x01000000ULL
172#define ORANGEFS_O_EXECUTE (1 << 0)
173#define ORANGEFS_FS_ID_NULL ((__s32)0)
174#define ORANGEFS_ATTR_SYS_UID (1 << 0)
175#define ORANGEFS_ATTR_SYS_GID (1 << 1)
176#define ORANGEFS_ATTR_SYS_PERM (1 << 2)
177#define ORANGEFS_ATTR_SYS_ATIME (1 << 3)
178#define ORANGEFS_ATTR_SYS_CTIME (1 << 4)
179#define ORANGEFS_ATTR_SYS_MTIME (1 << 5)
180#define ORANGEFS_ATTR_SYS_TYPE (1 << 6)
181#define ORANGEFS_ATTR_SYS_ATIME_SET (1 << 7)
182#define ORANGEFS_ATTR_SYS_MTIME_SET (1 << 8)
183#define ORANGEFS_ATTR_SYS_SIZE (1 << 20)
184#define ORANGEFS_ATTR_SYS_LNK_TARGET (1 << 24)
185#define ORANGEFS_ATTR_SYS_DFILE_COUNT (1 << 25)
186#define ORANGEFS_ATTR_SYS_DIRENT_COUNT (1 << 26)
187#define ORANGEFS_ATTR_SYS_BLKSIZE (1 << 28)
188#define ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT (1 << 29)
189#define ORANGEFS_ATTR_SYS_COMMON_ALL \
190 (ORANGEFS_ATTR_SYS_UID | \
191 ORANGEFS_ATTR_SYS_GID | \
192 ORANGEFS_ATTR_SYS_PERM | \
193 ORANGEFS_ATTR_SYS_ATIME | \
194 ORANGEFS_ATTR_SYS_CTIME | \
195 ORANGEFS_ATTR_SYS_MTIME | \
196 ORANGEFS_ATTR_SYS_TYPE)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400197
Yi Liu8bb8aef2015-11-24 15:12:14 -0500198#define ORANGEFS_ATTR_SYS_ALL_SETABLE \
199(ORANGEFS_ATTR_SYS_COMMON_ALL-ORANGEFS_ATTR_SYS_TYPE)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400200
Yi Liu8bb8aef2015-11-24 15:12:14 -0500201#define ORANGEFS_ATTR_SYS_ALL_NOHINT \
202 (ORANGEFS_ATTR_SYS_COMMON_ALL | \
203 ORANGEFS_ATTR_SYS_SIZE | \
204 ORANGEFS_ATTR_SYS_LNK_TARGET | \
205 ORANGEFS_ATTR_SYS_DFILE_COUNT | \
206 ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT | \
207 ORANGEFS_ATTR_SYS_DIRENT_COUNT | \
208 ORANGEFS_ATTR_SYS_BLKSIZE)
Martin Brandenburg933287d2016-01-30 13:46:54 -0500209
210#define ORANGEFS_ATTR_SYS_ALL_NOHINT_NOSIZE \
211 (ORANGEFS_ATTR_SYS_COMMON_ALL | \
212 ORANGEFS_ATTR_SYS_LNK_TARGET | \
213 ORANGEFS_ATTR_SYS_DFILE_COUNT | \
214 ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT | \
215 ORANGEFS_ATTR_SYS_DIRENT_COUNT | \
216 ORANGEFS_ATTR_SYS_BLKSIZE)
217
Yi Liu8bb8aef2015-11-24 15:12:14 -0500218#define ORANGEFS_XATTR_REPLACE 0x2
219#define ORANGEFS_XATTR_CREATE 0x1
220#define ORANGEFS_MAX_SERVER_ADDR_LEN 256
221#define ORANGEFS_NAME_MAX 256
Mike Marshallf7ab0932015-07-17 10:38:11 -0400222/*
223 * max extended attribute name len as imposed by the VFS and exploited for the
224 * upcall request types.
225 * NOTE: Please retain them as multiples of 8 even if you wish to change them
226 * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit
227 * kernel. Due to implementation within DBPF, this really needs to be
Yi Liu8bb8aef2015-11-24 15:12:14 -0500228 * ORANGEFS_NAME_MAX, which it was the same value as, but no reason to let it
Mike Marshallf7ab0932015-07-17 10:38:11 -0400229 * break if that changes in the future.
230 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500231#define ORANGEFS_MAX_XATTR_NAMELEN ORANGEFS_NAME_MAX /* Not the same as
Mike Marshallf7ab0932015-07-17 10:38:11 -0400232 * XATTR_NAME_MAX defined
233 * by <linux/xattr.h>
234 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500235#define ORANGEFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX
Mike Marshallf7ab0932015-07-17 10:38:11 -0400236 * defined by <linux/xattr.h>
237 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500238#define ORANGEFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX
Mike Marshallf7ab0932015-07-17 10:38:11 -0400239 * defined by <linux/xattr.h>
240 */
241/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500242 * ORANGEFS I/O operation types, used in both system and server interfaces.
Mike Marshallf7ab0932015-07-17 10:38:11 -0400243 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500244enum ORANGEFS_io_type {
245 ORANGEFS_IO_READ = 1,
246 ORANGEFS_IO_WRITE = 2
Mike Marshallf7ab0932015-07-17 10:38:11 -0400247};
248
249/*
250 * If this enum is modified the server parameters related to the precreate pool
251 * batch and low threshold sizes may need to be modified to reflect this
252 * change.
253 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500254enum orangefs_ds_type {
255 ORANGEFS_TYPE_NONE = 0,
256 ORANGEFS_TYPE_METAFILE = (1 << 0),
257 ORANGEFS_TYPE_DATAFILE = (1 << 1),
258 ORANGEFS_TYPE_DIRECTORY = (1 << 2),
259 ORANGEFS_TYPE_SYMLINK = (1 << 3),
260 ORANGEFS_TYPE_DIRDATA = (1 << 4),
261 ORANGEFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */
Mike Marshallf7ab0932015-07-17 10:38:11 -0400262};
263
264/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500265 * ORANGEFS_certificate simply stores a buffer with the buffer size.
Mike Marshallf7ab0932015-07-17 10:38:11 -0400266 * The buffer can be converted to an OpenSSL X509 struct for use.
267 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500268struct ORANGEFS_certificate {
Mike Marshallf7ab0932015-07-17 10:38:11 -0400269 __u32 buf_size;
270 unsigned char *buf;
271};
272
273/*
274 * A credential identifies a user and is signed by the client/user
275 * private key.
276 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500277struct ORANGEFS_credential {
Mike Marshallf7ab0932015-07-17 10:38:11 -0400278 __u32 userid; /* user id */
279 __u32 num_groups; /* length of group_array */
280 __u32 *group_array; /* groups for which the user is a member */
281 char *issuer; /* alias of the issuing server */
282 __u64 timeout; /* seconds after epoch to time out */
283 __u32 sig_size; /* length of the signature in bytes */
284 unsigned char *signature; /* digital signature */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500285 struct ORANGEFS_certificate certificate; /* user certificate buffer */
Mike Marshallf7ab0932015-07-17 10:38:11 -0400286};
Yi Liu8bb8aef2015-11-24 15:12:14 -0500287#define extra_size_ORANGEFS_credential (ORANGEFS_REQ_LIMIT_GROUPS * \
Mike Marshallf7ab0932015-07-17 10:38:11 -0400288 sizeof(__u32) + \
Yi Liu8bb8aef2015-11-24 15:12:14 -0500289 ORANGEFS_REQ_LIMIT_ISSUER + \
290 ORANGEFS_REQ_LIMIT_SIGNATURE + \
291 extra_size_ORANGEFS_certificate)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400292
293/* This structure is used by the VFS-client interaction alone */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500294struct ORANGEFS_keyval_pair {
295 char key[ORANGEFS_MAX_XATTR_NAMELEN];
Mike Marshallf7ab0932015-07-17 10:38:11 -0400296 __s32 key_sz; /* __s32 for portable, fixed-size structures */
297 __s32 val_sz;
Yi Liu8bb8aef2015-11-24 15:12:14 -0500298 char val[ORANGEFS_MAX_XATTR_VALUELEN];
Mike Marshallf7ab0932015-07-17 10:38:11 -0400299};
300
301/* pvfs2-sysint.h ***********************************************************/
302/* Describes attributes for a file, directory, or symlink. */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500303struct ORANGEFS_sys_attr_s {
Mike Marshallf7ab0932015-07-17 10:38:11 -0400304 __u32 owner;
305 __u32 group;
306 __u32 perms;
307 __u64 atime;
308 __u64 mtime;
309 __u64 ctime;
310 __s64 size;
311
312 /* NOTE: caller must free if valid */
313 char *link_target;
314
315 /* Changed to __s32 so that size of structure does not change */
316 __s32 dfile_count;
317
318 /* Changed to __s32 so that size of structure does not change */
319 __s32 distr_dir_servers_initial;
320
321 /* Changed to __s32 so that size of structure does not change */
322 __s32 distr_dir_servers_max;
323
324 /* Changed to __s32 so that size of structure does not change */
325 __s32 distr_dir_split_size;
326
327 __u32 mirror_copies_count;
328
329 /* NOTE: caller must free if valid */
330 char *dist_name;
331
332 /* NOTE: caller must free if valid */
333 char *dist_params;
334
335 __s64 dirent_count;
Yi Liu8bb8aef2015-11-24 15:12:14 -0500336 enum orangefs_ds_type objtype;
Mike Marshallf7ab0932015-07-17 10:38:11 -0400337 __u64 flags;
338 __u32 mask;
339 __s64 blksize;
340};
341
Yi Liu8bb8aef2015-11-24 15:12:14 -0500342#define ORANGEFS_LOOKUP_LINK_NO_FOLLOW 0
Mike Marshallf7ab0932015-07-17 10:38:11 -0400343
344/* pint-dev.h ***************************************************************/
345
Yi Liu8bb8aef2015-11-24 15:12:14 -0500346/* parameter structure used in ORANGEFS_DEV_DEBUG ioctl command */
Mike Marshallf7ab0932015-07-17 10:38:11 -0400347struct dev_mask_info_s {
348 enum {
349 KERNEL_MASK,
350 CLIENT_MASK,
351 } mask_type;
352 __u64 mask_value;
353};
354
355struct dev_mask2_info_s {
356 __u64 mask1_value;
357 __u64 mask2_value;
358};
359
360/* pvfs2-util.h *************************************************************/
Yi Liu8bb8aef2015-11-24 15:12:14 -0500361__s32 ORANGEFS_util_translate_mode(int mode);
Mike Marshallf7ab0932015-07-17 10:38:11 -0400362
363/* pvfs2-debug.h ************************************************************/
Mike Marshall575e9462015-12-04 12:56:14 -0500364#include "orangefs-debug.h"
Mike Marshallf7ab0932015-07-17 10:38:11 -0400365
366/* pvfs2-internal.h *********************************************************/
367#define llu(x) (unsigned long long)(x)
368#define lld(x) (long long)(x)
369
370/* pint-dev-shared.h ********************************************************/
Yi Liu8bb8aef2015-11-24 15:12:14 -0500371#define ORANGEFS_DEV_MAGIC 'k'
Mike Marshallf7ab0932015-07-17 10:38:11 -0400372
Yi Liu8bb8aef2015-11-24 15:12:14 -0500373#define ORANGEFS_READDIR_DEFAULT_DESC_COUNT 5
Mike Marshallf7ab0932015-07-17 10:38:11 -0400374
375#define DEV_GET_MAGIC 0x1
376#define DEV_GET_MAX_UPSIZE 0x2
377#define DEV_GET_MAX_DOWNSIZE 0x3
378#define DEV_MAP 0x4
379#define DEV_REMOUNT_ALL 0x5
380#define DEV_DEBUG 0x6
381#define DEV_UPSTREAM 0x7
382#define DEV_CLIENT_MASK 0x8
383#define DEV_CLIENT_STRING 0x9
384#define DEV_MAX_NR 0xa
385
386/* supported ioctls, codes are with respect to user-space */
387enum {
Yi Liu8bb8aef2015-11-24 15:12:14 -0500388 ORANGEFS_DEV_GET_MAGIC = _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAGIC, __s32),
389 ORANGEFS_DEV_GET_MAX_UPSIZE =
390 _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32),
391 ORANGEFS_DEV_GET_MAX_DOWNSIZE =
392 _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32),
393 ORANGEFS_DEV_MAP = _IO(ORANGEFS_DEV_MAGIC, DEV_MAP),
394 ORANGEFS_DEV_REMOUNT_ALL = _IO(ORANGEFS_DEV_MAGIC, DEV_REMOUNT_ALL),
395 ORANGEFS_DEV_DEBUG = _IOR(ORANGEFS_DEV_MAGIC, DEV_DEBUG, __s32),
396 ORANGEFS_DEV_UPSTREAM = _IOW(ORANGEFS_DEV_MAGIC, DEV_UPSTREAM, int),
397 ORANGEFS_DEV_CLIENT_MASK = _IOW(ORANGEFS_DEV_MAGIC,
Mike Marshallf7ab0932015-07-17 10:38:11 -0400398 DEV_CLIENT_MASK,
399 struct dev_mask2_info_s),
Yi Liu8bb8aef2015-11-24 15:12:14 -0500400 ORANGEFS_DEV_CLIENT_STRING = _IOW(ORANGEFS_DEV_MAGIC,
Mike Marshallf7ab0932015-07-17 10:38:11 -0400401 DEV_CLIENT_STRING,
402 char *),
Yi Liu8bb8aef2015-11-24 15:12:14 -0500403 ORANGEFS_DEV_MAXNR = DEV_MAX_NR,
Mike Marshallf7ab0932015-07-17 10:38:11 -0400404};
405
406/*
407 * version number for use in communicating between kernel space and user
Mike Marshall54804942015-10-05 13:44:24 -0400408 * space. Zero signifies the upstream version of the kernel module.
Mike Marshallf7ab0932015-07-17 10:38:11 -0400409 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500410#define ORANGEFS_KERNEL_PROTO_VERSION 0
Martin Brandenburg878dfd32016-03-30 16:18:43 -0400411#define ORANGEFS_MINIMUM_USERSPACE_VERSION 20903
Mike Marshallf7ab0932015-07-17 10:38:11 -0400412
413/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500414 * describes memory regions to map in the ORANGEFS_DEV_MAP ioctl.
Mike Marshall575e9462015-12-04 12:56:14 -0500415 * NOTE: See devorangefs-req.c for 32 bit compat structure.
Mike Marshallf7ab0932015-07-17 10:38:11 -0400416 * Since this structure has a variable-sized layout that is different
417 * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout
418 * on such systems before servicing ioctl calls from user-space binaries
419 * that may be 32 bit!
420 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500421struct ORANGEFS_dev_map_desc {
Mike Marshallf7ab0932015-07-17 10:38:11 -0400422 void *ptr;
423 __s32 total_size;
424 __s32 size;
425 __s32 count;
426};
427
428/* gossip.h *****************************************************************/
429
430#ifdef GOSSIP_DISABLE_DEBUG
Joe Perches1917a692016-03-27 14:34:52 -0700431#define gossip_debug(mask, fmt, ...) \
432do { \
433 if (0) \
434 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
435} while (0)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400436#else
437extern __u64 gossip_debug_mask;
438extern struct client_debug_mask client_debug_mask;
439
440/* try to avoid function call overhead by checking masks in macro */
Joe Perches1917a692016-03-27 14:34:52 -0700441#define gossip_debug(mask, fmt, ...) \
442do { \
443 if (gossip_debug_mask & (mask)) \
444 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
Mike Marshallf7ab0932015-07-17 10:38:11 -0400445} while (0)
446#endif /* GOSSIP_DISABLE_DEBUG */
447
448/* do file and line number printouts w/ the GNU preprocessor */
Joe Perches1917a692016-03-27 14:34:52 -0700449#define gossip_ldebug(mask, fmt, ...) \
450 gossip_debug(mask, "%s: " fmt, __func__, ##__VA_ARGS__)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400451
Joe Perches1917a692016-03-27 14:34:52 -0700452#define gossip_err pr_err
453#define gossip_lerr(fmt, ...) \
454 gossip_err("%s line %d: " fmt, \
455 __FILE__, __LINE__, ##__VA_ARGS__)