162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#include <linux/kernel.h>
362306a36Sopenharmony_ci#include <linux/types.h>
462306a36Sopenharmony_ci#include <linux/spinlock_types.h>
562306a36Sopenharmony_ci#include <linux/slab.h>
662306a36Sopenharmony_ci#include <linux/ioctl.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci/* khandle stuff  ***********************************************************/
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/*
1162306a36Sopenharmony_ci * The 2.9 core will put 64 bit handles in here like this:
1262306a36Sopenharmony_ci *    1234 0000 0000 5678
1362306a36Sopenharmony_ci * The 3.0 and beyond cores will put 128 bit handles in here like this:
1462306a36Sopenharmony_ci *    1234 5678 90AB CDEF
1562306a36Sopenharmony_ci * The kernel module will always use the first four bytes and
1662306a36Sopenharmony_ci * the last four bytes as an inum.
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_cistruct orangefs_khandle {
1962306a36Sopenharmony_ci	unsigned char u[16];
2062306a36Sopenharmony_ci}  __aligned(8);
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/*
2362306a36Sopenharmony_ci * kernel version of an object ref.
2462306a36Sopenharmony_ci */
2562306a36Sopenharmony_cistruct orangefs_object_kref {
2662306a36Sopenharmony_ci	struct orangefs_khandle khandle;
2762306a36Sopenharmony_ci	__s32 fs_id;
2862306a36Sopenharmony_ci	__s32 __pad1;
2962306a36Sopenharmony_ci};
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/*
3262306a36Sopenharmony_ci * compare 2 khandles assumes little endian thus from large address to
3362306a36Sopenharmony_ci * small address
3462306a36Sopenharmony_ci */
3562306a36Sopenharmony_cistatic inline int ORANGEFS_khandle_cmp(const struct orangefs_khandle *kh1,
3662306a36Sopenharmony_ci				   const struct orangefs_khandle *kh2)
3762306a36Sopenharmony_ci{
3862306a36Sopenharmony_ci	int i;
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci	for (i = 15; i >= 0; i--) {
4162306a36Sopenharmony_ci		if (kh1->u[i] > kh2->u[i])
4262306a36Sopenharmony_ci			return 1;
4362306a36Sopenharmony_ci		if (kh1->u[i] < kh2->u[i])
4462306a36Sopenharmony_ci			return -1;
4562306a36Sopenharmony_ci	}
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci	return 0;
4862306a36Sopenharmony_ci}
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_cistatic inline void ORANGEFS_khandle_to(const struct orangefs_khandle *kh,
5162306a36Sopenharmony_ci				   void *p, int size)
5262306a36Sopenharmony_ci{
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci	memcpy(p, kh->u, 16);
5562306a36Sopenharmony_ci	memset(p + 16, 0, size - 16);
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci}
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_cistatic inline void ORANGEFS_khandle_from(struct orangefs_khandle *kh,
6062306a36Sopenharmony_ci				     void *p, int size)
6162306a36Sopenharmony_ci{
6262306a36Sopenharmony_ci	memset(kh, 0, 16);
6362306a36Sopenharmony_ci	memcpy(kh->u, p, 16);
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci}
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/* pvfs2-types.h ************************************************************/
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#define ORANGEFS_SUPER_MAGIC 0x20030528
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/*
7262306a36Sopenharmony_ci * ORANGEFS error codes are a signed 32-bit integer. Error codes are negative, but
7362306a36Sopenharmony_ci * the sign is stripped before decoding.
7462306a36Sopenharmony_ci */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* Bit 31 is not used since it is the sign. */
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci/*
7962306a36Sopenharmony_ci * Bit 30 specifies that this is a ORANGEFS error. A ORANGEFS error is either an
8062306a36Sopenharmony_ci * encoded errno value or a ORANGEFS protocol error.
8162306a36Sopenharmony_ci */
8262306a36Sopenharmony_ci#define ORANGEFS_ERROR_BIT (1 << 30)
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/*
8562306a36Sopenharmony_ci * Bit 29 specifies that this is a ORANGEFS protocol error and not an encoded
8662306a36Sopenharmony_ci * errno value.
8762306a36Sopenharmony_ci */
8862306a36Sopenharmony_ci#define ORANGEFS_NON_ERRNO_ERROR_BIT (1 << 29)
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci/*
9162306a36Sopenharmony_ci * Bits 9, 8, and 7 specify the error class, which encodes the section of
9262306a36Sopenharmony_ci * server code the error originated in for logging purposes. It is not used
9362306a36Sopenharmony_ci * in the kernel except to be masked out.
9462306a36Sopenharmony_ci */
9562306a36Sopenharmony_ci#define ORANGEFS_ERROR_CLASS_BITS 0x380
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci/* Bits 6 - 0 are reserved for the actual error code. */
9862306a36Sopenharmony_ci#define ORANGEFS_ERROR_NUMBER_BITS 0x7f
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci/* Encoded errno values decoded by PINT_errno_mapping in orangefs-utils.c. */
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci/* Our own ORANGEFS protocol error codes. */
10362306a36Sopenharmony_ci#define ORANGEFS_ECANCEL    (1|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
10462306a36Sopenharmony_ci#define ORANGEFS_EDEVINIT   (2|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
10562306a36Sopenharmony_ci#define ORANGEFS_EDETAIL    (3|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
10662306a36Sopenharmony_ci#define ORANGEFS_EHOSTNTFD  (4|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
10762306a36Sopenharmony_ci#define ORANGEFS_EADDRNTFD  (5|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
10862306a36Sopenharmony_ci#define ORANGEFS_ENORECVR   (6|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
10962306a36Sopenharmony_ci#define ORANGEFS_ETRYAGAIN  (7|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
11062306a36Sopenharmony_ci#define ORANGEFS_ENOTPVFS   (8|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
11162306a36Sopenharmony_ci#define ORANGEFS_ESECURITY  (9|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT)
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci/* permission bits */
11462306a36Sopenharmony_ci#define ORANGEFS_O_EXECUTE (1 << 0)
11562306a36Sopenharmony_ci#define ORANGEFS_O_WRITE   (1 << 1)
11662306a36Sopenharmony_ci#define ORANGEFS_O_READ    (1 << 2)
11762306a36Sopenharmony_ci#define ORANGEFS_G_EXECUTE (1 << 3)
11862306a36Sopenharmony_ci#define ORANGEFS_G_WRITE   (1 << 4)
11962306a36Sopenharmony_ci#define ORANGEFS_G_READ    (1 << 5)
12062306a36Sopenharmony_ci#define ORANGEFS_U_EXECUTE (1 << 6)
12162306a36Sopenharmony_ci#define ORANGEFS_U_WRITE   (1 << 7)
12262306a36Sopenharmony_ci#define ORANGEFS_U_READ    (1 << 8)
12362306a36Sopenharmony_ci/* no ORANGEFS_U_VTX (sticky bit) */
12462306a36Sopenharmony_ci#define ORANGEFS_G_SGID    (1 << 10)
12562306a36Sopenharmony_ci#define ORANGEFS_U_SUID    (1 << 11)
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci#define ORANGEFS_ITERATE_START    2147483646
12862306a36Sopenharmony_ci#define ORANGEFS_ITERATE_END      2147483645
12962306a36Sopenharmony_ci#define ORANGEFS_IMMUTABLE_FL FS_IMMUTABLE_FL
13062306a36Sopenharmony_ci#define ORANGEFS_APPEND_FL    FS_APPEND_FL
13162306a36Sopenharmony_ci#define ORANGEFS_NOATIME_FL   FS_NOATIME_FL
13262306a36Sopenharmony_ci#define ORANGEFS_MIRROR_FL    0x01000000ULL
13362306a36Sopenharmony_ci#define ORANGEFS_FS_ID_NULL       ((__s32)0)
13462306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_UID                   (1 << 0)
13562306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_GID                   (1 << 1)
13662306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_PERM                  (1 << 2)
13762306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_ATIME                 (1 << 3)
13862306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_CTIME                 (1 << 4)
13962306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_MTIME                 (1 << 5)
14062306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_TYPE                  (1 << 6)
14162306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_ATIME_SET             (1 << 7)
14262306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_MTIME_SET             (1 << 8)
14362306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_SIZE                  (1 << 20)
14462306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_LNK_TARGET            (1 << 24)
14562306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_DFILE_COUNT           (1 << 25)
14662306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_DIRENT_COUNT          (1 << 26)
14762306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_BLKSIZE               (1 << 28)
14862306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT   (1 << 29)
14962306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_COMMON_ALL	\
15062306a36Sopenharmony_ci	(ORANGEFS_ATTR_SYS_UID	|	\
15162306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_GID	|	\
15262306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_PERM	|	\
15362306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_ATIME	|	\
15462306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_CTIME	|	\
15562306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_MTIME	|	\
15662306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_TYPE)
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_ALL_SETABLE		\
15962306a36Sopenharmony_ci(ORANGEFS_ATTR_SYS_COMMON_ALL-ORANGEFS_ATTR_SYS_TYPE)
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci#define ORANGEFS_ATTR_SYS_ALL_NOHINT			\
16262306a36Sopenharmony_ci	(ORANGEFS_ATTR_SYS_COMMON_ALL		|	\
16362306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_SIZE			|	\
16462306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_LNK_TARGET		|	\
16562306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_DFILE_COUNT		|	\
16662306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT	|	\
16762306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_DIRENT_COUNT		|	\
16862306a36Sopenharmony_ci	 ORANGEFS_ATTR_SYS_BLKSIZE)
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci#define ORANGEFS_XATTR_REPLACE 0x2
17162306a36Sopenharmony_ci#define ORANGEFS_XATTR_CREATE  0x1
17262306a36Sopenharmony_ci#define ORANGEFS_MAX_SERVER_ADDR_LEN 256
17362306a36Sopenharmony_ci#define ORANGEFS_NAME_MAX                256
17462306a36Sopenharmony_ci/*
17562306a36Sopenharmony_ci * max extended attribute name len as imposed by the VFS and exploited for the
17662306a36Sopenharmony_ci * upcall request types.
17762306a36Sopenharmony_ci * NOTE: Please retain them as multiples of 8 even if you wish to change them
17862306a36Sopenharmony_ci * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit
17962306a36Sopenharmony_ci * kernel. Due to implementation within DBPF, this really needs to be
18062306a36Sopenharmony_ci * ORANGEFS_NAME_MAX, which it was the same value as, but no reason to let it
18162306a36Sopenharmony_ci * break if that changes in the future.
18262306a36Sopenharmony_ci */
18362306a36Sopenharmony_ci#define ORANGEFS_MAX_XATTR_NAMELEN   ORANGEFS_NAME_MAX	/* Not the same as
18462306a36Sopenharmony_ci						 * XATTR_NAME_MAX defined
18562306a36Sopenharmony_ci						 * by <linux/xattr.h>
18662306a36Sopenharmony_ci						 */
18762306a36Sopenharmony_ci#define ORANGEFS_MAX_XATTR_VALUELEN  8192	/* Not the same as XATTR_SIZE_MAX
18862306a36Sopenharmony_ci					 * defined by <linux/xattr.h>
18962306a36Sopenharmony_ci					 */
19062306a36Sopenharmony_ci#define ORANGEFS_MAX_XATTR_LISTLEN   16	/* Not the same as XATTR_LIST_MAX
19162306a36Sopenharmony_ci					 * defined by <linux/xattr.h>
19262306a36Sopenharmony_ci					 */
19362306a36Sopenharmony_ci/*
19462306a36Sopenharmony_ci * ORANGEFS I/O operation types, used in both system and server interfaces.
19562306a36Sopenharmony_ci */
19662306a36Sopenharmony_cienum ORANGEFS_io_type {
19762306a36Sopenharmony_ci	ORANGEFS_IO_READ = 1,
19862306a36Sopenharmony_ci	ORANGEFS_IO_WRITE = 2
19962306a36Sopenharmony_ci};
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci/*
20262306a36Sopenharmony_ci * If this enum is modified the server parameters related to the precreate pool
20362306a36Sopenharmony_ci * batch and low threshold sizes may need to be modified  to reflect this
20462306a36Sopenharmony_ci * change.
20562306a36Sopenharmony_ci */
20662306a36Sopenharmony_cienum orangefs_ds_type {
20762306a36Sopenharmony_ci	ORANGEFS_TYPE_NONE = 0,
20862306a36Sopenharmony_ci	ORANGEFS_TYPE_METAFILE = (1 << 0),
20962306a36Sopenharmony_ci	ORANGEFS_TYPE_DATAFILE = (1 << 1),
21062306a36Sopenharmony_ci	ORANGEFS_TYPE_DIRECTORY = (1 << 2),
21162306a36Sopenharmony_ci	ORANGEFS_TYPE_SYMLINK = (1 << 3),
21262306a36Sopenharmony_ci	ORANGEFS_TYPE_DIRDATA = (1 << 4),
21362306a36Sopenharmony_ci	ORANGEFS_TYPE_INTERNAL = (1 << 5)	/* for the server's private use */
21462306a36Sopenharmony_ci};
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci/* This structure is used by the VFS-client interaction alone */
21762306a36Sopenharmony_cistruct ORANGEFS_keyval_pair {
21862306a36Sopenharmony_ci	char key[ORANGEFS_MAX_XATTR_NAMELEN];
21962306a36Sopenharmony_ci	__s32 key_sz;	/* __s32 for portable, fixed-size structures */
22062306a36Sopenharmony_ci	__s32 val_sz;
22162306a36Sopenharmony_ci	char val[ORANGEFS_MAX_XATTR_VALUELEN];
22262306a36Sopenharmony_ci};
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci/* pvfs2-sysint.h ***********************************************************/
22562306a36Sopenharmony_ci/* Describes attributes for a file, directory, or symlink. */
22662306a36Sopenharmony_cistruct ORANGEFS_sys_attr_s {
22762306a36Sopenharmony_ci	__u32 owner;
22862306a36Sopenharmony_ci	__u32 group;
22962306a36Sopenharmony_ci	__u32 perms;
23062306a36Sopenharmony_ci	__u64 atime;
23162306a36Sopenharmony_ci	__u64 mtime;
23262306a36Sopenharmony_ci	__u64 ctime;
23362306a36Sopenharmony_ci	__s64 size;
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci	/* NOTE: caller must free if valid */
23662306a36Sopenharmony_ci	char *link_target;
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci	/* Changed to __s32 so that size of structure does not change */
23962306a36Sopenharmony_ci	__s32 dfile_count;
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci	/* Changed to __s32 so that size of structure does not change */
24262306a36Sopenharmony_ci	__s32 distr_dir_servers_initial;
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci	/* Changed to __s32 so that size of structure does not change */
24562306a36Sopenharmony_ci	__s32 distr_dir_servers_max;
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci	/* Changed to __s32 so that size of structure does not change */
24862306a36Sopenharmony_ci	__s32 distr_dir_split_size;
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci	__u32 mirror_copies_count;
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_ci	/* NOTE: caller must free if valid */
25362306a36Sopenharmony_ci	char *dist_name;
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci	/* NOTE: caller must free if valid */
25662306a36Sopenharmony_ci	char *dist_params;
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ci	__s64 dirent_count;
25962306a36Sopenharmony_ci	enum orangefs_ds_type objtype;
26062306a36Sopenharmony_ci	__u64 flags;
26162306a36Sopenharmony_ci	__u32 mask;
26262306a36Sopenharmony_ci	__s64 blksize;
26362306a36Sopenharmony_ci};
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci#define ORANGEFS_LOOKUP_LINK_NO_FOLLOW 0
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci/* pint-dev.h ***************************************************************/
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_ci/* parameter structure used in ORANGEFS_DEV_DEBUG ioctl command */
27062306a36Sopenharmony_cistruct dev_mask_info_s {
27162306a36Sopenharmony_ci	enum {
27262306a36Sopenharmony_ci		KERNEL_MASK,
27362306a36Sopenharmony_ci		CLIENT_MASK,
27462306a36Sopenharmony_ci	} mask_type;
27562306a36Sopenharmony_ci	__u64 mask_value;
27662306a36Sopenharmony_ci};
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_cistruct dev_mask2_info_s {
27962306a36Sopenharmony_ci	__u64 mask1_value;
28062306a36Sopenharmony_ci	__u64 mask2_value;
28162306a36Sopenharmony_ci};
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci/* pvfs2-util.h *************************************************************/
28462306a36Sopenharmony_ci__s32 ORANGEFS_util_translate_mode(int mode);
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci/* pvfs2-debug.h ************************************************************/
28762306a36Sopenharmony_ci#include "orangefs-debug.h"
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci/* pvfs2-internal.h *********************************************************/
29062306a36Sopenharmony_ci#define llu(x) (unsigned long long)(x)
29162306a36Sopenharmony_ci#define lld(x) (long long)(x)
29262306a36Sopenharmony_ci
29362306a36Sopenharmony_ci/* pint-dev-shared.h ********************************************************/
29462306a36Sopenharmony_ci#define ORANGEFS_DEV_MAGIC 'k'
29562306a36Sopenharmony_ci
29662306a36Sopenharmony_ci#define ORANGEFS_READDIR_DEFAULT_DESC_COUNT  5
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ci#define DEV_GET_MAGIC           0x1
29962306a36Sopenharmony_ci#define DEV_GET_MAX_UPSIZE      0x2
30062306a36Sopenharmony_ci#define DEV_GET_MAX_DOWNSIZE    0x3
30162306a36Sopenharmony_ci#define DEV_MAP                 0x4
30262306a36Sopenharmony_ci#define DEV_REMOUNT_ALL         0x5
30362306a36Sopenharmony_ci#define DEV_DEBUG               0x6
30462306a36Sopenharmony_ci#define DEV_UPSTREAM            0x7
30562306a36Sopenharmony_ci#define DEV_CLIENT_MASK         0x8
30662306a36Sopenharmony_ci#define DEV_CLIENT_STRING       0x9
30762306a36Sopenharmony_ci#define DEV_MAX_NR              0xa
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci/* supported ioctls, codes are with respect to user-space */
31062306a36Sopenharmony_cienum {
31162306a36Sopenharmony_ci	ORANGEFS_DEV_GET_MAGIC = _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAGIC, __s32),
31262306a36Sopenharmony_ci	ORANGEFS_DEV_GET_MAX_UPSIZE =
31362306a36Sopenharmony_ci	    _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32),
31462306a36Sopenharmony_ci	ORANGEFS_DEV_GET_MAX_DOWNSIZE =
31562306a36Sopenharmony_ci	    _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32),
31662306a36Sopenharmony_ci	ORANGEFS_DEV_MAP = _IO(ORANGEFS_DEV_MAGIC, DEV_MAP),
31762306a36Sopenharmony_ci	ORANGEFS_DEV_REMOUNT_ALL = _IO(ORANGEFS_DEV_MAGIC, DEV_REMOUNT_ALL),
31862306a36Sopenharmony_ci	ORANGEFS_DEV_DEBUG = _IOR(ORANGEFS_DEV_MAGIC, DEV_DEBUG, __s32),
31962306a36Sopenharmony_ci	ORANGEFS_DEV_UPSTREAM = _IOW(ORANGEFS_DEV_MAGIC, DEV_UPSTREAM, int),
32062306a36Sopenharmony_ci	ORANGEFS_DEV_CLIENT_MASK = _IOW(ORANGEFS_DEV_MAGIC,
32162306a36Sopenharmony_ci				    DEV_CLIENT_MASK,
32262306a36Sopenharmony_ci				    struct dev_mask2_info_s),
32362306a36Sopenharmony_ci	ORANGEFS_DEV_CLIENT_STRING = _IOW(ORANGEFS_DEV_MAGIC,
32462306a36Sopenharmony_ci				      DEV_CLIENT_STRING,
32562306a36Sopenharmony_ci				      char *),
32662306a36Sopenharmony_ci	ORANGEFS_DEV_MAXNR = DEV_MAX_NR,
32762306a36Sopenharmony_ci};
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci/*
33062306a36Sopenharmony_ci * version number for use in communicating between kernel space and user
33162306a36Sopenharmony_ci * space. Zero signifies the upstream version of the kernel module.
33262306a36Sopenharmony_ci */
33362306a36Sopenharmony_ci#define ORANGEFS_KERNEL_PROTO_VERSION 0
33462306a36Sopenharmony_ci#define ORANGEFS_MINIMUM_USERSPACE_VERSION 20903
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_ci/*
33762306a36Sopenharmony_ci * describes memory regions to map in the ORANGEFS_DEV_MAP ioctl.
33862306a36Sopenharmony_ci * NOTE: See devorangefs-req.c for 32 bit compat structure.
33962306a36Sopenharmony_ci * Since this structure has a variable-sized layout that is different
34062306a36Sopenharmony_ci * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout
34162306a36Sopenharmony_ci * on such systems before servicing ioctl calls from user-space binaries
34262306a36Sopenharmony_ci * that may be 32 bit!
34362306a36Sopenharmony_ci */
34462306a36Sopenharmony_cistruct ORANGEFS_dev_map_desc {
34562306a36Sopenharmony_ci	void __user *ptr;
34662306a36Sopenharmony_ci	__s32 total_size;
34762306a36Sopenharmony_ci	__s32 size;
34862306a36Sopenharmony_ci	__s32 count;
34962306a36Sopenharmony_ci};
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_ci/* gossip.h *****************************************************************/
35262306a36Sopenharmony_ci
35362306a36Sopenharmony_ciextern __u64 orangefs_gossip_debug_mask;
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ci/* try to avoid function call overhead by checking masks in macro */
35662306a36Sopenharmony_ci#define gossip_debug(mask, fmt, ...)					\
35762306a36Sopenharmony_cido {									\
35862306a36Sopenharmony_ci	if (orangefs_gossip_debug_mask & (mask))			\
35962306a36Sopenharmony_ci		printk(KERN_DEBUG fmt, ##__VA_ARGS__);			\
36062306a36Sopenharmony_ci} while (0)
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ci#define gossip_err pr_err
363