blob: e0bf5e4dce0da164ed046fc7aa3915ecef58a1e3 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Joe Perches1917a692016-03-27 14:34:52 -07002#include <linux/kernel.h>
Mike Marshallf7ab0932015-07-17 10:38:11 -04003#include <linux/types.h>
Guenter Roeck81b784b2015-08-01 18:29:37 -07004#include <linux/spinlock_types.h>
Mike Marshallf7ab0932015-07-17 10:38:11 -04005#include <linux/slab.h>
Mike Marshall2c590d52015-07-24 10:37:15 -04006#include <linux/ioctl.h>
Mike Marshallf7ab0932015-07-17 10:38:11 -04007
Mike Marshallf7ab0932015-07-17 10:38:11 -04008/* pvfs2-config.h ***********************************************************/
Yi Liu8bb8aef2015-11-24 15:12:14 -05009#define ORANGEFS_VERSION_MAJOR 2
10#define ORANGEFS_VERSION_MINOR 9
11#define ORANGEFS_VERSION_SUB 0
Mike Marshallf7ab0932015-07-17 10:38:11 -040012
13/* khandle stuff ***********************************************************/
14
15/*
16 * The 2.9 core will put 64 bit handles in here like this:
17 * 1234 0000 0000 5678
18 * The 3.0 and beyond cores will put 128 bit handles in here like this:
19 * 1234 5678 90AB CDEF
20 * The kernel module will always use the first four bytes and
21 * the last four bytes as an inum.
22 */
Yi Liu8bb8aef2015-11-24 15:12:14 -050023struct orangefs_khandle {
Mike Marshallf7ab0932015-07-17 10:38:11 -040024 unsigned char u[16];
25} __aligned(8);
26
27/*
28 * kernel version of an object ref.
29 */
Yi Liu8bb8aef2015-11-24 15:12:14 -050030struct orangefs_object_kref {
31 struct orangefs_khandle khandle;
Mike Marshallf7ab0932015-07-17 10:38:11 -040032 __s32 fs_id;
33 __s32 __pad1;
34};
35
36/*
37 * compare 2 khandles assumes little endian thus from large address to
38 * small address
39 */
Yi Liu8bb8aef2015-11-24 15:12:14 -050040static inline int ORANGEFS_khandle_cmp(const struct orangefs_khandle *kh1,
41 const struct orangefs_khandle *kh2)
Mike Marshallf7ab0932015-07-17 10:38:11 -040042{
43 int i;
44
45 for (i = 15; i >= 0; i--) {
46 if (kh1->u[i] > kh2->u[i])
47 return 1;
48 if (kh1->u[i] < kh2->u[i])
49 return -1;
50 }
51
52 return 0;
53}
54
Yi Liu8bb8aef2015-11-24 15:12:14 -050055static inline void ORANGEFS_khandle_to(const struct orangefs_khandle *kh,
Mike Marshallf7ab0932015-07-17 10:38:11 -040056 void *p, int size)
57{
Mike Marshallf7ab0932015-07-17 10:38:11 -040058
Mike Marshall50e01582015-09-29 11:17:26 -040059 memcpy(p, kh->u, 16);
Mike Marshalla9bb3ba2016-04-06 11:19:37 -040060 memset(p + 16, 0, size - 16);
Mike Marshallf7ab0932015-07-17 10:38:11 -040061
Mike Marshallf7ab0932015-07-17 10:38:11 -040062}
63
Yi Liu8bb8aef2015-11-24 15:12:14 -050064static inline void ORANGEFS_khandle_from(struct orangefs_khandle *kh,
Mike Marshallf7ab0932015-07-17 10:38:11 -040065 void *p, int size)
66{
Mike Marshallf7ab0932015-07-17 10:38:11 -040067 memset(kh, 0, 16);
Mike Marshall50e01582015-09-29 11:17:26 -040068 memcpy(kh->u, p, 16);
Mike Marshallf7ab0932015-07-17 10:38:11 -040069
Mike Marshallf7ab0932015-07-17 10:38:11 -040070}
71
72/* pvfs2-types.h ************************************************************/
Yi Liu8bb8aef2015-11-24 15:12:14 -050073typedef __u32 ORANGEFS_uid;
74typedef __u32 ORANGEFS_gid;
75typedef __s32 ORANGEFS_fs_id;
76typedef __u32 ORANGEFS_permissions;
77typedef __u64 ORANGEFS_time;
78typedef __s64 ORANGEFS_size;
79typedef __u64 ORANGEFS_flags;
80typedef __u64 ORANGEFS_ds_position;
81typedef __s32 ORANGEFS_error;
82typedef __s64 ORANGEFS_offset;
Mike Marshallf7ab0932015-07-17 10:38:11 -040083
Yi Liu8bb8aef2015-11-24 15:12:14 -050084#define ORANGEFS_SUPER_MAGIC 0x20030528
Martin Brandenburg894ac432015-10-02 12:11:19 -040085
Mike Marshall54804942015-10-05 13:44:24 -040086/*
Yi Liu8bb8aef2015-11-24 15:12:14 -050087 * ORANGEFS error codes are a signed 32-bit integer. Error codes are negative, but
Mike Marshall54804942015-10-05 13:44:24 -040088 * the sign is stripped before decoding.
89 */
Martin Brandenburg894ac432015-10-02 12:11:19 -040090
91/* Bit 31 is not used since it is the sign. */
92
Mike Marshall54804942015-10-05 13:44:24 -040093/*
Yi Liu8bb8aef2015-11-24 15:12:14 -050094 * Bit 30 specifies that this is a ORANGEFS error. A ORANGEFS error is either an
95 * encoded errno value or a ORANGEFS protocol error.
Mike Marshall54804942015-10-05 13:44:24 -040096 */
Yi Liu8bb8aef2015-11-24 15:12:14 -050097#define ORANGEFS_ERROR_BIT (1 << 30)
Martin Brandenburg894ac432015-10-02 12:11:19 -040098
Mike Marshall54804942015-10-05 13:44:24 -040099/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500100 * Bit 29 specifies that this is a ORANGEFS protocol error and not an encoded
Mike Marshall54804942015-10-05 13:44:24 -0400101 * errno value.
102 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500103#define ORANGEFS_NON_ERRNO_ERROR_BIT (1 << 29)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400104
Mike Marshall54804942015-10-05 13:44:24 -0400105/*
106 * Bits 9, 8, and 7 specify the error class, which encodes the section of
Martin Brandenburg894ac432015-10-02 12:11:19 -0400107 * server code the error originated in for logging purposes. It is not used
Mike Marshall54804942015-10-05 13:44:24 -0400108 * in the kernel except to be masked out.
109 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500110#define ORANGEFS_ERROR_CLASS_BITS 0x380
Mike Marshallf7ab0932015-07-17 10:38:11 -0400111
Martin Brandenburg894ac432015-10-02 12:11:19 -0400112/* Bits 6 - 0 are reserved for the actual error code. */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500113#define ORANGEFS_ERROR_NUMBER_BITS 0x7f
Mike Marshallf7ab0932015-07-17 10:38:11 -0400114
Mike Marshall575e9462015-12-04 12:56:14 -0500115/* Encoded errno values decoded by PINT_errno_mapping in orangefs-utils.c. */
Mike Marshallf7ab0932015-07-17 10:38:11 -0400116
Yi Liu8bb8aef2015-11-24 15:12:14 -0500117/* Our own ORANGEFS protocol error codes. */
118#define ORANGEFS_ECANCEL (1|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
119#define ORANGEFS_EDEVINIT (2|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
120#define ORANGEFS_EDETAIL (3|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
121#define ORANGEFS_EHOSTNTFD (4|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
122#define ORANGEFS_EADDRNTFD (5|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
123#define ORANGEFS_ENORECVR (6|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
124#define ORANGEFS_ETRYAGAIN (7|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
125#define ORANGEFS_ENOTPVFS (8|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
126#define ORANGEFS_ESECURITY (9|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400127
128/* permission bits */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500129#define ORANGEFS_O_EXECUTE (1 << 0)
130#define ORANGEFS_O_WRITE (1 << 1)
131#define ORANGEFS_O_READ (1 << 2)
132#define ORANGEFS_G_EXECUTE (1 << 3)
133#define ORANGEFS_G_WRITE (1 << 4)
134#define ORANGEFS_G_READ (1 << 5)
135#define ORANGEFS_U_EXECUTE (1 << 6)
136#define ORANGEFS_U_WRITE (1 << 7)
137#define ORANGEFS_U_READ (1 << 8)
138/* no ORANGEFS_U_VTX (sticky bit) */
139#define ORANGEFS_G_SGID (1 << 10)
140#define ORANGEFS_U_SUID (1 << 11)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400141
Martin Brandenburg7b796ae2017-04-25 15:38:02 -0400142#define ORANGEFS_ITERATE_START 2147483646
143#define ORANGEFS_ITERATE_END 2147483645
Yi Liu8bb8aef2015-11-24 15:12:14 -0500144#define ORANGEFS_IMMUTABLE_FL FS_IMMUTABLE_FL
145#define ORANGEFS_APPEND_FL FS_APPEND_FL
146#define ORANGEFS_NOATIME_FL FS_NOATIME_FL
147#define ORANGEFS_MIRROR_FL 0x01000000ULL
148#define ORANGEFS_O_EXECUTE (1 << 0)
149#define ORANGEFS_FS_ID_NULL ((__s32)0)
150#define ORANGEFS_ATTR_SYS_UID (1 << 0)
151#define ORANGEFS_ATTR_SYS_GID (1 << 1)
152#define ORANGEFS_ATTR_SYS_PERM (1 << 2)
153#define ORANGEFS_ATTR_SYS_ATIME (1 << 3)
154#define ORANGEFS_ATTR_SYS_CTIME (1 << 4)
155#define ORANGEFS_ATTR_SYS_MTIME (1 << 5)
156#define ORANGEFS_ATTR_SYS_TYPE (1 << 6)
157#define ORANGEFS_ATTR_SYS_ATIME_SET (1 << 7)
158#define ORANGEFS_ATTR_SYS_MTIME_SET (1 << 8)
159#define ORANGEFS_ATTR_SYS_SIZE (1 << 20)
160#define ORANGEFS_ATTR_SYS_LNK_TARGET (1 << 24)
161#define ORANGEFS_ATTR_SYS_DFILE_COUNT (1 << 25)
162#define ORANGEFS_ATTR_SYS_DIRENT_COUNT (1 << 26)
163#define ORANGEFS_ATTR_SYS_BLKSIZE (1 << 28)
164#define ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT (1 << 29)
165#define ORANGEFS_ATTR_SYS_COMMON_ALL \
166 (ORANGEFS_ATTR_SYS_UID | \
167 ORANGEFS_ATTR_SYS_GID | \
168 ORANGEFS_ATTR_SYS_PERM | \
169 ORANGEFS_ATTR_SYS_ATIME | \
170 ORANGEFS_ATTR_SYS_CTIME | \
171 ORANGEFS_ATTR_SYS_MTIME | \
172 ORANGEFS_ATTR_SYS_TYPE)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400173
Yi Liu8bb8aef2015-11-24 15:12:14 -0500174#define ORANGEFS_ATTR_SYS_ALL_SETABLE \
175(ORANGEFS_ATTR_SYS_COMMON_ALL-ORANGEFS_ATTR_SYS_TYPE)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400176
Yi Liu8bb8aef2015-11-24 15:12:14 -0500177#define ORANGEFS_ATTR_SYS_ALL_NOHINT \
178 (ORANGEFS_ATTR_SYS_COMMON_ALL | \
179 ORANGEFS_ATTR_SYS_SIZE | \
180 ORANGEFS_ATTR_SYS_LNK_TARGET | \
181 ORANGEFS_ATTR_SYS_DFILE_COUNT | \
182 ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT | \
183 ORANGEFS_ATTR_SYS_DIRENT_COUNT | \
184 ORANGEFS_ATTR_SYS_BLKSIZE)
Martin Brandenburg933287d2016-01-30 13:46:54 -0500185
Yi Liu8bb8aef2015-11-24 15:12:14 -0500186#define ORANGEFS_XATTR_REPLACE 0x2
187#define ORANGEFS_XATTR_CREATE 0x1
188#define ORANGEFS_MAX_SERVER_ADDR_LEN 256
189#define ORANGEFS_NAME_MAX 256
Mike Marshallf7ab0932015-07-17 10:38:11 -0400190/*
191 * max extended attribute name len as imposed by the VFS and exploited for the
192 * upcall request types.
193 * NOTE: Please retain them as multiples of 8 even if you wish to change them
194 * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit
195 * kernel. Due to implementation within DBPF, this really needs to be
Yi Liu8bb8aef2015-11-24 15:12:14 -0500196 * ORANGEFS_NAME_MAX, which it was the same value as, but no reason to let it
Mike Marshallf7ab0932015-07-17 10:38:11 -0400197 * break if that changes in the future.
198 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500199#define ORANGEFS_MAX_XATTR_NAMELEN ORANGEFS_NAME_MAX /* Not the same as
Mike Marshallf7ab0932015-07-17 10:38:11 -0400200 * XATTR_NAME_MAX defined
201 * by <linux/xattr.h>
202 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500203#define ORANGEFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX
Mike Marshallf7ab0932015-07-17 10:38:11 -0400204 * defined by <linux/xattr.h>
205 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500206#define ORANGEFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX
Mike Marshallf7ab0932015-07-17 10:38:11 -0400207 * defined by <linux/xattr.h>
208 */
209/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500210 * ORANGEFS I/O operation types, used in both system and server interfaces.
Mike Marshallf7ab0932015-07-17 10:38:11 -0400211 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500212enum ORANGEFS_io_type {
213 ORANGEFS_IO_READ = 1,
214 ORANGEFS_IO_WRITE = 2
Mike Marshallf7ab0932015-07-17 10:38:11 -0400215};
216
217/*
218 * If this enum is modified the server parameters related to the precreate pool
219 * batch and low threshold sizes may need to be modified to reflect this
220 * change.
221 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500222enum orangefs_ds_type {
223 ORANGEFS_TYPE_NONE = 0,
224 ORANGEFS_TYPE_METAFILE = (1 << 0),
225 ORANGEFS_TYPE_DATAFILE = (1 << 1),
226 ORANGEFS_TYPE_DIRECTORY = (1 << 2),
227 ORANGEFS_TYPE_SYMLINK = (1 << 3),
228 ORANGEFS_TYPE_DIRDATA = (1 << 4),
229 ORANGEFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */
Mike Marshallf7ab0932015-07-17 10:38:11 -0400230};
231
232/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500233 * ORANGEFS_certificate simply stores a buffer with the buffer size.
Mike Marshallf7ab0932015-07-17 10:38:11 -0400234 * The buffer can be converted to an OpenSSL X509 struct for use.
235 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500236struct ORANGEFS_certificate {
Mike Marshallf7ab0932015-07-17 10:38:11 -0400237 __u32 buf_size;
238 unsigned char *buf;
239};
240
241/*
242 * A credential identifies a user and is signed by the client/user
243 * private key.
244 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500245struct ORANGEFS_credential {
Mike Marshallf7ab0932015-07-17 10:38:11 -0400246 __u32 userid; /* user id */
247 __u32 num_groups; /* length of group_array */
248 __u32 *group_array; /* groups for which the user is a member */
249 char *issuer; /* alias of the issuing server */
250 __u64 timeout; /* seconds after epoch to time out */
251 __u32 sig_size; /* length of the signature in bytes */
252 unsigned char *signature; /* digital signature */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500253 struct ORANGEFS_certificate certificate; /* user certificate buffer */
Mike Marshallf7ab0932015-07-17 10:38:11 -0400254};
Yi Liu8bb8aef2015-11-24 15:12:14 -0500255#define extra_size_ORANGEFS_credential (ORANGEFS_REQ_LIMIT_GROUPS * \
Mike Marshallf7ab0932015-07-17 10:38:11 -0400256 sizeof(__u32) + \
Yi Liu8bb8aef2015-11-24 15:12:14 -0500257 ORANGEFS_REQ_LIMIT_ISSUER + \
258 ORANGEFS_REQ_LIMIT_SIGNATURE + \
259 extra_size_ORANGEFS_certificate)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400260
261/* This structure is used by the VFS-client interaction alone */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500262struct ORANGEFS_keyval_pair {
263 char key[ORANGEFS_MAX_XATTR_NAMELEN];
Mike Marshallf7ab0932015-07-17 10:38:11 -0400264 __s32 key_sz; /* __s32 for portable, fixed-size structures */
265 __s32 val_sz;
Yi Liu8bb8aef2015-11-24 15:12:14 -0500266 char val[ORANGEFS_MAX_XATTR_VALUELEN];
Mike Marshallf7ab0932015-07-17 10:38:11 -0400267};
268
269/* pvfs2-sysint.h ***********************************************************/
270/* Describes attributes for a file, directory, or symlink. */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500271struct ORANGEFS_sys_attr_s {
Mike Marshallf7ab0932015-07-17 10:38:11 -0400272 __u32 owner;
273 __u32 group;
274 __u32 perms;
275 __u64 atime;
276 __u64 mtime;
277 __u64 ctime;
278 __s64 size;
279
280 /* NOTE: caller must free if valid */
281 char *link_target;
282
283 /* Changed to __s32 so that size of structure does not change */
284 __s32 dfile_count;
285
286 /* Changed to __s32 so that size of structure does not change */
287 __s32 distr_dir_servers_initial;
288
289 /* Changed to __s32 so that size of structure does not change */
290 __s32 distr_dir_servers_max;
291
292 /* Changed to __s32 so that size of structure does not change */
293 __s32 distr_dir_split_size;
294
295 __u32 mirror_copies_count;
296
297 /* NOTE: caller must free if valid */
298 char *dist_name;
299
300 /* NOTE: caller must free if valid */
301 char *dist_params;
302
303 __s64 dirent_count;
Yi Liu8bb8aef2015-11-24 15:12:14 -0500304 enum orangefs_ds_type objtype;
Mike Marshallf7ab0932015-07-17 10:38:11 -0400305 __u64 flags;
306 __u32 mask;
307 __s64 blksize;
308};
309
Yi Liu8bb8aef2015-11-24 15:12:14 -0500310#define ORANGEFS_LOOKUP_LINK_NO_FOLLOW 0
Mike Marshallf7ab0932015-07-17 10:38:11 -0400311
312/* pint-dev.h ***************************************************************/
313
Yi Liu8bb8aef2015-11-24 15:12:14 -0500314/* parameter structure used in ORANGEFS_DEV_DEBUG ioctl command */
Mike Marshallf7ab0932015-07-17 10:38:11 -0400315struct dev_mask_info_s {
316 enum {
317 KERNEL_MASK,
318 CLIENT_MASK,
319 } mask_type;
320 __u64 mask_value;
321};
322
323struct dev_mask2_info_s {
324 __u64 mask1_value;
325 __u64 mask2_value;
326};
327
328/* pvfs2-util.h *************************************************************/
Yi Liu8bb8aef2015-11-24 15:12:14 -0500329__s32 ORANGEFS_util_translate_mode(int mode);
Mike Marshallf7ab0932015-07-17 10:38:11 -0400330
331/* pvfs2-debug.h ************************************************************/
Mike Marshall575e9462015-12-04 12:56:14 -0500332#include "orangefs-debug.h"
Mike Marshallf7ab0932015-07-17 10:38:11 -0400333
334/* pvfs2-internal.h *********************************************************/
335#define llu(x) (unsigned long long)(x)
336#define lld(x) (long long)(x)
337
338/* pint-dev-shared.h ********************************************************/
Yi Liu8bb8aef2015-11-24 15:12:14 -0500339#define ORANGEFS_DEV_MAGIC 'k'
Mike Marshallf7ab0932015-07-17 10:38:11 -0400340
Yi Liu8bb8aef2015-11-24 15:12:14 -0500341#define ORANGEFS_READDIR_DEFAULT_DESC_COUNT 5
Mike Marshallf7ab0932015-07-17 10:38:11 -0400342
343#define DEV_GET_MAGIC 0x1
344#define DEV_GET_MAX_UPSIZE 0x2
345#define DEV_GET_MAX_DOWNSIZE 0x3
346#define DEV_MAP 0x4
347#define DEV_REMOUNT_ALL 0x5
348#define DEV_DEBUG 0x6
349#define DEV_UPSTREAM 0x7
350#define DEV_CLIENT_MASK 0x8
351#define DEV_CLIENT_STRING 0x9
352#define DEV_MAX_NR 0xa
353
354/* supported ioctls, codes are with respect to user-space */
355enum {
Yi Liu8bb8aef2015-11-24 15:12:14 -0500356 ORANGEFS_DEV_GET_MAGIC = _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAGIC, __s32),
357 ORANGEFS_DEV_GET_MAX_UPSIZE =
358 _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32),
359 ORANGEFS_DEV_GET_MAX_DOWNSIZE =
360 _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32),
361 ORANGEFS_DEV_MAP = _IO(ORANGEFS_DEV_MAGIC, DEV_MAP),
362 ORANGEFS_DEV_REMOUNT_ALL = _IO(ORANGEFS_DEV_MAGIC, DEV_REMOUNT_ALL),
363 ORANGEFS_DEV_DEBUG = _IOR(ORANGEFS_DEV_MAGIC, DEV_DEBUG, __s32),
364 ORANGEFS_DEV_UPSTREAM = _IOW(ORANGEFS_DEV_MAGIC, DEV_UPSTREAM, int),
365 ORANGEFS_DEV_CLIENT_MASK = _IOW(ORANGEFS_DEV_MAGIC,
Mike Marshallf7ab0932015-07-17 10:38:11 -0400366 DEV_CLIENT_MASK,
367 struct dev_mask2_info_s),
Yi Liu8bb8aef2015-11-24 15:12:14 -0500368 ORANGEFS_DEV_CLIENT_STRING = _IOW(ORANGEFS_DEV_MAGIC,
Mike Marshallf7ab0932015-07-17 10:38:11 -0400369 DEV_CLIENT_STRING,
370 char *),
Yi Liu8bb8aef2015-11-24 15:12:14 -0500371 ORANGEFS_DEV_MAXNR = DEV_MAX_NR,
Mike Marshallf7ab0932015-07-17 10:38:11 -0400372};
373
374/*
375 * version number for use in communicating between kernel space and user
Mike Marshall54804942015-10-05 13:44:24 -0400376 * space. Zero signifies the upstream version of the kernel module.
Mike Marshallf7ab0932015-07-17 10:38:11 -0400377 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500378#define ORANGEFS_KERNEL_PROTO_VERSION 0
Martin Brandenburg878dfd32016-03-30 16:18:43 -0400379#define ORANGEFS_MINIMUM_USERSPACE_VERSION 20903
Mike Marshallf7ab0932015-07-17 10:38:11 -0400380
381/*
Yi Liu8bb8aef2015-11-24 15:12:14 -0500382 * describes memory regions to map in the ORANGEFS_DEV_MAP ioctl.
Mike Marshall575e9462015-12-04 12:56:14 -0500383 * NOTE: See devorangefs-req.c for 32 bit compat structure.
Mike Marshallf7ab0932015-07-17 10:38:11 -0400384 * Since this structure has a variable-sized layout that is different
385 * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout
386 * on such systems before servicing ioctl calls from user-space binaries
387 * that may be 32 bit!
388 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500389struct ORANGEFS_dev_map_desc {
Mike Marshallf7ab0932015-07-17 10:38:11 -0400390 void *ptr;
391 __s32 total_size;
392 __s32 size;
393 __s32 count;
394};
395
396/* gossip.h *****************************************************************/
397
398#ifdef GOSSIP_DISABLE_DEBUG
Joe Perches1917a692016-03-27 14:34:52 -0700399#define gossip_debug(mask, fmt, ...) \
400do { \
401 if (0) \
402 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
403} while (0)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400404#else
Martin Brandenburg44f46412016-08-15 11:38:36 -0400405extern __u64 orangefs_gossip_debug_mask;
Mike Marshallf7ab0932015-07-17 10:38:11 -0400406
407/* try to avoid function call overhead by checking masks in macro */
Joe Perches1917a692016-03-27 14:34:52 -0700408#define gossip_debug(mask, fmt, ...) \
409do { \
Martin Brandenburg44f46412016-08-15 11:38:36 -0400410 if (orangefs_gossip_debug_mask & (mask)) \
Joe Perches1917a692016-03-27 14:34:52 -0700411 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
Mike Marshallf7ab0932015-07-17 10:38:11 -0400412} while (0)
413#endif /* GOSSIP_DISABLE_DEBUG */
414
415/* do file and line number printouts w/ the GNU preprocessor */
Joe Perches1917a692016-03-27 14:34:52 -0700416#define gossip_ldebug(mask, fmt, ...) \
417 gossip_debug(mask, "%s: " fmt, __func__, ##__VA_ARGS__)
Mike Marshallf7ab0932015-07-17 10:38:11 -0400418
Joe Perches1917a692016-03-27 14:34:52 -0700419#define gossip_err pr_err
420#define gossip_lerr(fmt, ...) \
421 gossip_err("%s line %d: " fmt, \
422 __FILE__, __LINE__, ##__VA_ARGS__)