11917a693SJoe Perches #include <linux/kernel.h> 2f7ab093fSMike Marshall #include <linux/types.h> 381b784b1SGuenter Roeck #include <linux/spinlock_types.h> 4f7ab093fSMike Marshall #include <linux/slab.h> 52c590d5fSMike Marshall #include <linux/ioctl.h> 6f7ab093fSMike Marshall 7f7ab093fSMike Marshall /* pvfs2-config.h ***********************************************************/ 88bb8aefdSYi Liu #define ORANGEFS_VERSION_MAJOR 2 98bb8aefdSYi Liu #define ORANGEFS_VERSION_MINOR 9 108bb8aefdSYi Liu #define ORANGEFS_VERSION_SUB 0 11f7ab093fSMike Marshall 12f7ab093fSMike Marshall /* khandle stuff ***********************************************************/ 13f7ab093fSMike Marshall 14f7ab093fSMike Marshall /* 15f7ab093fSMike Marshall * The 2.9 core will put 64 bit handles in here like this: 16f7ab093fSMike Marshall * 1234 0000 0000 5678 17f7ab093fSMike Marshall * The 3.0 and beyond cores will put 128 bit handles in here like this: 18f7ab093fSMike Marshall * 1234 5678 90AB CDEF 19f7ab093fSMike Marshall * The kernel module will always use the first four bytes and 20f7ab093fSMike Marshall * the last four bytes as an inum. 21f7ab093fSMike Marshall */ 228bb8aefdSYi Liu struct orangefs_khandle { 23f7ab093fSMike Marshall unsigned char u[16]; 24f7ab093fSMike Marshall } __aligned(8); 25f7ab093fSMike Marshall 26f7ab093fSMike Marshall /* 27f7ab093fSMike Marshall * kernel version of an object ref. 28f7ab093fSMike Marshall */ 298bb8aefdSYi Liu struct orangefs_object_kref { 308bb8aefdSYi Liu struct orangefs_khandle khandle; 31f7ab093fSMike Marshall __s32 fs_id; 32f7ab093fSMike Marshall __s32 __pad1; 33f7ab093fSMike Marshall }; 34f7ab093fSMike Marshall 35f7ab093fSMike Marshall /* 36f7ab093fSMike Marshall * compare 2 khandles assumes little endian thus from large address to 37f7ab093fSMike Marshall * small address 38f7ab093fSMike Marshall */ 398bb8aefdSYi Liu static inline int ORANGEFS_khandle_cmp(const struct orangefs_khandle *kh1, 408bb8aefdSYi Liu const struct orangefs_khandle *kh2) 41f7ab093fSMike Marshall { 42f7ab093fSMike Marshall int i; 43f7ab093fSMike Marshall 44f7ab093fSMike Marshall for (i = 15; i >= 0; i--) { 45f7ab093fSMike Marshall if (kh1->u[i] > kh2->u[i]) 46f7ab093fSMike Marshall return 1; 47f7ab093fSMike Marshall if (kh1->u[i] < kh2->u[i]) 48f7ab093fSMike Marshall return -1; 49f7ab093fSMike Marshall } 50f7ab093fSMike Marshall 51f7ab093fSMike Marshall return 0; 52f7ab093fSMike Marshall } 53f7ab093fSMike Marshall 548bb8aefdSYi Liu static inline void ORANGEFS_khandle_to(const struct orangefs_khandle *kh, 55f7ab093fSMike Marshall void *p, int size) 56f7ab093fSMike Marshall { 57f7ab093fSMike Marshall 5850e01586SMike Marshall memcpy(p, kh->u, 16); 59a9bb3ba8SMike Marshall memset(p + 16, 0, size - 16); 60f7ab093fSMike Marshall 61f7ab093fSMike Marshall } 62f7ab093fSMike Marshall 638bb8aefdSYi Liu static inline void ORANGEFS_khandle_from(struct orangefs_khandle *kh, 64f7ab093fSMike Marshall void *p, int size) 65f7ab093fSMike Marshall { 66f7ab093fSMike Marshall memset(kh, 0, 16); 6750e01586SMike Marshall memcpy(kh->u, p, 16); 68f7ab093fSMike Marshall 69f7ab093fSMike Marshall } 70f7ab093fSMike Marshall 71f7ab093fSMike Marshall /* pvfs2-types.h ************************************************************/ 728bb8aefdSYi Liu typedef __u32 ORANGEFS_uid; 738bb8aefdSYi Liu typedef __u32 ORANGEFS_gid; 748bb8aefdSYi Liu typedef __s32 ORANGEFS_fs_id; 758bb8aefdSYi Liu typedef __u32 ORANGEFS_permissions; 768bb8aefdSYi Liu typedef __u64 ORANGEFS_time; 778bb8aefdSYi Liu typedef __s64 ORANGEFS_size; 788bb8aefdSYi Liu typedef __u64 ORANGEFS_flags; 798bb8aefdSYi Liu typedef __u64 ORANGEFS_ds_position; 808bb8aefdSYi Liu typedef __s32 ORANGEFS_error; 818bb8aefdSYi Liu typedef __s64 ORANGEFS_offset; 82f7ab093fSMike Marshall 838bb8aefdSYi Liu #define ORANGEFS_SUPER_MAGIC 0x20030528 84894ac432SMartin Brandenburg 8554804949SMike Marshall /* 868bb8aefdSYi Liu * ORANGEFS error codes are a signed 32-bit integer. Error codes are negative, but 8754804949SMike Marshall * the sign is stripped before decoding. 8854804949SMike Marshall */ 89894ac432SMartin Brandenburg 90894ac432SMartin Brandenburg /* Bit 31 is not used since it is the sign. */ 91894ac432SMartin Brandenburg 9254804949SMike Marshall /* 938bb8aefdSYi Liu * Bit 30 specifies that this is a ORANGEFS error. A ORANGEFS error is either an 948bb8aefdSYi Liu * encoded errno value or a ORANGEFS protocol error. 9554804949SMike Marshall */ 968bb8aefdSYi Liu #define ORANGEFS_ERROR_BIT (1 << 30) 97894ac432SMartin Brandenburg 9854804949SMike Marshall /* 998bb8aefdSYi Liu * Bit 29 specifies that this is a ORANGEFS protocol error and not an encoded 10054804949SMike Marshall * errno value. 10154804949SMike Marshall */ 1028bb8aefdSYi Liu #define ORANGEFS_NON_ERRNO_ERROR_BIT (1 << 29) 103f7ab093fSMike Marshall 10454804949SMike Marshall /* 10554804949SMike Marshall * Bits 9, 8, and 7 specify the error class, which encodes the section of 106894ac432SMartin Brandenburg * server code the error originated in for logging purposes. It is not used 10754804949SMike Marshall * in the kernel except to be masked out. 10854804949SMike Marshall */ 1098bb8aefdSYi Liu #define ORANGEFS_ERROR_CLASS_BITS 0x380 110f7ab093fSMike Marshall 111894ac432SMartin Brandenburg /* Bits 6 - 0 are reserved for the actual error code. */ 1128bb8aefdSYi Liu #define ORANGEFS_ERROR_NUMBER_BITS 0x7f 113f7ab093fSMike Marshall 114575e9461SMike Marshall /* Encoded errno values decoded by PINT_errno_mapping in orangefs-utils.c. */ 115f7ab093fSMike Marshall 1168bb8aefdSYi Liu /* Our own ORANGEFS protocol error codes. */ 1178bb8aefdSYi Liu #define ORANGEFS_ECANCEL (1|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 1188bb8aefdSYi Liu #define ORANGEFS_EDEVINIT (2|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 1198bb8aefdSYi Liu #define ORANGEFS_EDETAIL (3|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 1208bb8aefdSYi Liu #define ORANGEFS_EHOSTNTFD (4|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 1218bb8aefdSYi Liu #define ORANGEFS_EADDRNTFD (5|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 1228bb8aefdSYi Liu #define ORANGEFS_ENORECVR (6|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 1238bb8aefdSYi Liu #define ORANGEFS_ETRYAGAIN (7|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 1248bb8aefdSYi Liu #define ORANGEFS_ENOTPVFS (8|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 1258bb8aefdSYi Liu #define ORANGEFS_ESECURITY (9|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) 126f7ab093fSMike Marshall 127f7ab093fSMike Marshall /* permission bits */ 1288bb8aefdSYi Liu #define ORANGEFS_O_EXECUTE (1 << 0) 1298bb8aefdSYi Liu #define ORANGEFS_O_WRITE (1 << 1) 1308bb8aefdSYi Liu #define ORANGEFS_O_READ (1 << 2) 1318bb8aefdSYi Liu #define ORANGEFS_G_EXECUTE (1 << 3) 1328bb8aefdSYi Liu #define ORANGEFS_G_WRITE (1 << 4) 1338bb8aefdSYi Liu #define ORANGEFS_G_READ (1 << 5) 1348bb8aefdSYi Liu #define ORANGEFS_U_EXECUTE (1 << 6) 1358bb8aefdSYi Liu #define ORANGEFS_U_WRITE (1 << 7) 1368bb8aefdSYi Liu #define ORANGEFS_U_READ (1 << 8) 1378bb8aefdSYi Liu /* no ORANGEFS_U_VTX (sticky bit) */ 1388bb8aefdSYi Liu #define ORANGEFS_G_SGID (1 << 10) 1398bb8aefdSYi Liu #define ORANGEFS_U_SUID (1 << 11) 140f7ab093fSMike Marshall 141*7b796ae3SMartin Brandenburg #define ORANGEFS_ITERATE_START 2147483646 142*7b796ae3SMartin Brandenburg #define ORANGEFS_ITERATE_END 2147483645 1438bb8aefdSYi Liu #define ORANGEFS_IMMUTABLE_FL FS_IMMUTABLE_FL 1448bb8aefdSYi Liu #define ORANGEFS_APPEND_FL FS_APPEND_FL 1458bb8aefdSYi Liu #define ORANGEFS_NOATIME_FL FS_NOATIME_FL 1468bb8aefdSYi Liu #define ORANGEFS_MIRROR_FL 0x01000000ULL 1478bb8aefdSYi Liu #define ORANGEFS_O_EXECUTE (1 << 0) 1488bb8aefdSYi Liu #define ORANGEFS_FS_ID_NULL ((__s32)0) 1498bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_UID (1 << 0) 1508bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_GID (1 << 1) 1518bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_PERM (1 << 2) 1528bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_ATIME (1 << 3) 1538bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_CTIME (1 << 4) 1548bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_MTIME (1 << 5) 1558bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_TYPE (1 << 6) 1568bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_ATIME_SET (1 << 7) 1578bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_MTIME_SET (1 << 8) 1588bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_SIZE (1 << 20) 1598bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_LNK_TARGET (1 << 24) 1608bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_DFILE_COUNT (1 << 25) 1618bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_DIRENT_COUNT (1 << 26) 1628bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_BLKSIZE (1 << 28) 1638bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT (1 << 29) 1648bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_COMMON_ALL \ 1658bb8aefdSYi Liu (ORANGEFS_ATTR_SYS_UID | \ 1668bb8aefdSYi Liu ORANGEFS_ATTR_SYS_GID | \ 1678bb8aefdSYi Liu ORANGEFS_ATTR_SYS_PERM | \ 1688bb8aefdSYi Liu ORANGEFS_ATTR_SYS_ATIME | \ 1698bb8aefdSYi Liu ORANGEFS_ATTR_SYS_CTIME | \ 1708bb8aefdSYi Liu ORANGEFS_ATTR_SYS_MTIME | \ 1718bb8aefdSYi Liu ORANGEFS_ATTR_SYS_TYPE) 172f7ab093fSMike Marshall 1738bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_ALL_SETABLE \ 1748bb8aefdSYi Liu (ORANGEFS_ATTR_SYS_COMMON_ALL-ORANGEFS_ATTR_SYS_TYPE) 175f7ab093fSMike Marshall 1768bb8aefdSYi Liu #define ORANGEFS_ATTR_SYS_ALL_NOHINT \ 1778bb8aefdSYi Liu (ORANGEFS_ATTR_SYS_COMMON_ALL | \ 1788bb8aefdSYi Liu ORANGEFS_ATTR_SYS_SIZE | \ 1798bb8aefdSYi Liu ORANGEFS_ATTR_SYS_LNK_TARGET | \ 1808bb8aefdSYi Liu ORANGEFS_ATTR_SYS_DFILE_COUNT | \ 1818bb8aefdSYi Liu ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT | \ 1828bb8aefdSYi Liu ORANGEFS_ATTR_SYS_DIRENT_COUNT | \ 1838bb8aefdSYi Liu ORANGEFS_ATTR_SYS_BLKSIZE) 184933287daSMartin Brandenburg 1858bb8aefdSYi Liu #define ORANGEFS_XATTR_REPLACE 0x2 1868bb8aefdSYi Liu #define ORANGEFS_XATTR_CREATE 0x1 1878bb8aefdSYi Liu #define ORANGEFS_MAX_SERVER_ADDR_LEN 256 1888bb8aefdSYi Liu #define ORANGEFS_NAME_MAX 256 189f7ab093fSMike Marshall /* 190f7ab093fSMike Marshall * max extended attribute name len as imposed by the VFS and exploited for the 191f7ab093fSMike Marshall * upcall request types. 192f7ab093fSMike Marshall * NOTE: Please retain them as multiples of 8 even if you wish to change them 193f7ab093fSMike Marshall * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit 194f7ab093fSMike Marshall * kernel. Due to implementation within DBPF, this really needs to be 1958bb8aefdSYi Liu * ORANGEFS_NAME_MAX, which it was the same value as, but no reason to let it 196f7ab093fSMike Marshall * break if that changes in the future. 197f7ab093fSMike Marshall */ 1988bb8aefdSYi Liu #define ORANGEFS_MAX_XATTR_NAMELEN ORANGEFS_NAME_MAX /* Not the same as 199f7ab093fSMike Marshall * XATTR_NAME_MAX defined 200f7ab093fSMike Marshall * by <linux/xattr.h> 201f7ab093fSMike Marshall */ 2028bb8aefdSYi Liu #define ORANGEFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX 203f7ab093fSMike Marshall * defined by <linux/xattr.h> 204f7ab093fSMike Marshall */ 2058bb8aefdSYi Liu #define ORANGEFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX 206f7ab093fSMike Marshall * defined by <linux/xattr.h> 207f7ab093fSMike Marshall */ 208f7ab093fSMike Marshall /* 2098bb8aefdSYi Liu * ORANGEFS I/O operation types, used in both system and server interfaces. 210f7ab093fSMike Marshall */ 2118bb8aefdSYi Liu enum ORANGEFS_io_type { 2128bb8aefdSYi Liu ORANGEFS_IO_READ = 1, 2138bb8aefdSYi Liu ORANGEFS_IO_WRITE = 2 214f7ab093fSMike Marshall }; 215f7ab093fSMike Marshall 216f7ab093fSMike Marshall /* 217f7ab093fSMike Marshall * If this enum is modified the server parameters related to the precreate pool 218f7ab093fSMike Marshall * batch and low threshold sizes may need to be modified to reflect this 219f7ab093fSMike Marshall * change. 220f7ab093fSMike Marshall */ 2218bb8aefdSYi Liu enum orangefs_ds_type { 2228bb8aefdSYi Liu ORANGEFS_TYPE_NONE = 0, 2238bb8aefdSYi Liu ORANGEFS_TYPE_METAFILE = (1 << 0), 2248bb8aefdSYi Liu ORANGEFS_TYPE_DATAFILE = (1 << 1), 2258bb8aefdSYi Liu ORANGEFS_TYPE_DIRECTORY = (1 << 2), 2268bb8aefdSYi Liu ORANGEFS_TYPE_SYMLINK = (1 << 3), 2278bb8aefdSYi Liu ORANGEFS_TYPE_DIRDATA = (1 << 4), 2288bb8aefdSYi Liu ORANGEFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */ 229f7ab093fSMike Marshall }; 230f7ab093fSMike Marshall 231f7ab093fSMike Marshall /* 2328bb8aefdSYi Liu * ORANGEFS_certificate simply stores a buffer with the buffer size. 233f7ab093fSMike Marshall * The buffer can be converted to an OpenSSL X509 struct for use. 234f7ab093fSMike Marshall */ 2358bb8aefdSYi Liu struct ORANGEFS_certificate { 236f7ab093fSMike Marshall __u32 buf_size; 237f7ab093fSMike Marshall unsigned char *buf; 238f7ab093fSMike Marshall }; 239f7ab093fSMike Marshall 240f7ab093fSMike Marshall /* 241f7ab093fSMike Marshall * A credential identifies a user and is signed by the client/user 242f7ab093fSMike Marshall * private key. 243f7ab093fSMike Marshall */ 2448bb8aefdSYi Liu struct ORANGEFS_credential { 245f7ab093fSMike Marshall __u32 userid; /* user id */ 246f7ab093fSMike Marshall __u32 num_groups; /* length of group_array */ 247f7ab093fSMike Marshall __u32 *group_array; /* groups for which the user is a member */ 248f7ab093fSMike Marshall char *issuer; /* alias of the issuing server */ 249f7ab093fSMike Marshall __u64 timeout; /* seconds after epoch to time out */ 250f7ab093fSMike Marshall __u32 sig_size; /* length of the signature in bytes */ 251f7ab093fSMike Marshall unsigned char *signature; /* digital signature */ 2528bb8aefdSYi Liu struct ORANGEFS_certificate certificate; /* user certificate buffer */ 253f7ab093fSMike Marshall }; 2548bb8aefdSYi Liu #define extra_size_ORANGEFS_credential (ORANGEFS_REQ_LIMIT_GROUPS * \ 255f7ab093fSMike Marshall sizeof(__u32) + \ 2568bb8aefdSYi Liu ORANGEFS_REQ_LIMIT_ISSUER + \ 2578bb8aefdSYi Liu ORANGEFS_REQ_LIMIT_SIGNATURE + \ 2588bb8aefdSYi Liu extra_size_ORANGEFS_certificate) 259f7ab093fSMike Marshall 260f7ab093fSMike Marshall /* This structure is used by the VFS-client interaction alone */ 2618bb8aefdSYi Liu struct ORANGEFS_keyval_pair { 2628bb8aefdSYi Liu char key[ORANGEFS_MAX_XATTR_NAMELEN]; 263f7ab093fSMike Marshall __s32 key_sz; /* __s32 for portable, fixed-size structures */ 264f7ab093fSMike Marshall __s32 val_sz; 2658bb8aefdSYi Liu char val[ORANGEFS_MAX_XATTR_VALUELEN]; 266f7ab093fSMike Marshall }; 267f7ab093fSMike Marshall 268f7ab093fSMike Marshall /* pvfs2-sysint.h ***********************************************************/ 269f7ab093fSMike Marshall /* Describes attributes for a file, directory, or symlink. */ 2708bb8aefdSYi Liu struct ORANGEFS_sys_attr_s { 271f7ab093fSMike Marshall __u32 owner; 272f7ab093fSMike Marshall __u32 group; 273f7ab093fSMike Marshall __u32 perms; 274f7ab093fSMike Marshall __u64 atime; 275f7ab093fSMike Marshall __u64 mtime; 276f7ab093fSMike Marshall __u64 ctime; 277f7ab093fSMike Marshall __s64 size; 278f7ab093fSMike Marshall 279f7ab093fSMike Marshall /* NOTE: caller must free if valid */ 280f7ab093fSMike Marshall char *link_target; 281f7ab093fSMike Marshall 282f7ab093fSMike Marshall /* Changed to __s32 so that size of structure does not change */ 283f7ab093fSMike Marshall __s32 dfile_count; 284f7ab093fSMike Marshall 285f7ab093fSMike Marshall /* Changed to __s32 so that size of structure does not change */ 286f7ab093fSMike Marshall __s32 distr_dir_servers_initial; 287f7ab093fSMike Marshall 288f7ab093fSMike Marshall /* Changed to __s32 so that size of structure does not change */ 289f7ab093fSMike Marshall __s32 distr_dir_servers_max; 290f7ab093fSMike Marshall 291f7ab093fSMike Marshall /* Changed to __s32 so that size of structure does not change */ 292f7ab093fSMike Marshall __s32 distr_dir_split_size; 293f7ab093fSMike Marshall 294f7ab093fSMike Marshall __u32 mirror_copies_count; 295f7ab093fSMike Marshall 296f7ab093fSMike Marshall /* NOTE: caller must free if valid */ 297f7ab093fSMike Marshall char *dist_name; 298f7ab093fSMike Marshall 299f7ab093fSMike Marshall /* NOTE: caller must free if valid */ 300f7ab093fSMike Marshall char *dist_params; 301f7ab093fSMike Marshall 302f7ab093fSMike Marshall __s64 dirent_count; 3038bb8aefdSYi Liu enum orangefs_ds_type objtype; 304f7ab093fSMike Marshall __u64 flags; 305f7ab093fSMike Marshall __u32 mask; 306f7ab093fSMike Marshall __s64 blksize; 307f7ab093fSMike Marshall }; 308f7ab093fSMike Marshall 3098bb8aefdSYi Liu #define ORANGEFS_LOOKUP_LINK_NO_FOLLOW 0 310f7ab093fSMike Marshall 311f7ab093fSMike Marshall /* pint-dev.h ***************************************************************/ 312f7ab093fSMike Marshall 3138bb8aefdSYi Liu /* parameter structure used in ORANGEFS_DEV_DEBUG ioctl command */ 314f7ab093fSMike Marshall struct dev_mask_info_s { 315f7ab093fSMike Marshall enum { 316f7ab093fSMike Marshall KERNEL_MASK, 317f7ab093fSMike Marshall CLIENT_MASK, 318f7ab093fSMike Marshall } mask_type; 319f7ab093fSMike Marshall __u64 mask_value; 320f7ab093fSMike Marshall }; 321f7ab093fSMike Marshall 322f7ab093fSMike Marshall struct dev_mask2_info_s { 323f7ab093fSMike Marshall __u64 mask1_value; 324f7ab093fSMike Marshall __u64 mask2_value; 325f7ab093fSMike Marshall }; 326f7ab093fSMike Marshall 327f7ab093fSMike Marshall /* pvfs2-util.h *************************************************************/ 3288bb8aefdSYi Liu __s32 ORANGEFS_util_translate_mode(int mode); 329f7ab093fSMike Marshall 330f7ab093fSMike Marshall /* pvfs2-debug.h ************************************************************/ 331575e9461SMike Marshall #include "orangefs-debug.h" 332f7ab093fSMike Marshall 333f7ab093fSMike Marshall /* pvfs2-internal.h *********************************************************/ 334f7ab093fSMike Marshall #define llu(x) (unsigned long long)(x) 335f7ab093fSMike Marshall #define lld(x) (long long)(x) 336f7ab093fSMike Marshall 337f7ab093fSMike Marshall /* pint-dev-shared.h ********************************************************/ 3388bb8aefdSYi Liu #define ORANGEFS_DEV_MAGIC 'k' 339f7ab093fSMike Marshall 3408bb8aefdSYi Liu #define ORANGEFS_READDIR_DEFAULT_DESC_COUNT 5 341f7ab093fSMike Marshall 342f7ab093fSMike Marshall #define DEV_GET_MAGIC 0x1 343f7ab093fSMike Marshall #define DEV_GET_MAX_UPSIZE 0x2 344f7ab093fSMike Marshall #define DEV_GET_MAX_DOWNSIZE 0x3 345f7ab093fSMike Marshall #define DEV_MAP 0x4 346f7ab093fSMike Marshall #define DEV_REMOUNT_ALL 0x5 347f7ab093fSMike Marshall #define DEV_DEBUG 0x6 348f7ab093fSMike Marshall #define DEV_UPSTREAM 0x7 349f7ab093fSMike Marshall #define DEV_CLIENT_MASK 0x8 350f7ab093fSMike Marshall #define DEV_CLIENT_STRING 0x9 351f7ab093fSMike Marshall #define DEV_MAX_NR 0xa 352f7ab093fSMike Marshall 353f7ab093fSMike Marshall /* supported ioctls, codes are with respect to user-space */ 354f7ab093fSMike Marshall enum { 3558bb8aefdSYi Liu ORANGEFS_DEV_GET_MAGIC = _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAGIC, __s32), 3568bb8aefdSYi Liu ORANGEFS_DEV_GET_MAX_UPSIZE = 3578bb8aefdSYi Liu _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32), 3588bb8aefdSYi Liu ORANGEFS_DEV_GET_MAX_DOWNSIZE = 3598bb8aefdSYi Liu _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32), 3608bb8aefdSYi Liu ORANGEFS_DEV_MAP = _IO(ORANGEFS_DEV_MAGIC, DEV_MAP), 3618bb8aefdSYi Liu ORANGEFS_DEV_REMOUNT_ALL = _IO(ORANGEFS_DEV_MAGIC, DEV_REMOUNT_ALL), 3628bb8aefdSYi Liu ORANGEFS_DEV_DEBUG = _IOR(ORANGEFS_DEV_MAGIC, DEV_DEBUG, __s32), 3638bb8aefdSYi Liu ORANGEFS_DEV_UPSTREAM = _IOW(ORANGEFS_DEV_MAGIC, DEV_UPSTREAM, int), 3648bb8aefdSYi Liu ORANGEFS_DEV_CLIENT_MASK = _IOW(ORANGEFS_DEV_MAGIC, 365f7ab093fSMike Marshall DEV_CLIENT_MASK, 366f7ab093fSMike Marshall struct dev_mask2_info_s), 3678bb8aefdSYi Liu ORANGEFS_DEV_CLIENT_STRING = _IOW(ORANGEFS_DEV_MAGIC, 368f7ab093fSMike Marshall DEV_CLIENT_STRING, 369f7ab093fSMike Marshall char *), 3708bb8aefdSYi Liu ORANGEFS_DEV_MAXNR = DEV_MAX_NR, 371f7ab093fSMike Marshall }; 372f7ab093fSMike Marshall 373f7ab093fSMike Marshall /* 374f7ab093fSMike Marshall * version number for use in communicating between kernel space and user 37554804949SMike Marshall * space. Zero signifies the upstream version of the kernel module. 376f7ab093fSMike Marshall */ 3778bb8aefdSYi Liu #define ORANGEFS_KERNEL_PROTO_VERSION 0 378878dfd32SMartin Brandenburg #define ORANGEFS_MINIMUM_USERSPACE_VERSION 20903 379f7ab093fSMike Marshall 380f7ab093fSMike Marshall /* 3818bb8aefdSYi Liu * describes memory regions to map in the ORANGEFS_DEV_MAP ioctl. 382575e9461SMike Marshall * NOTE: See devorangefs-req.c for 32 bit compat structure. 383f7ab093fSMike Marshall * Since this structure has a variable-sized layout that is different 384f7ab093fSMike Marshall * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout 385f7ab093fSMike Marshall * on such systems before servicing ioctl calls from user-space binaries 386f7ab093fSMike Marshall * that may be 32 bit! 387f7ab093fSMike Marshall */ 3888bb8aefdSYi Liu struct ORANGEFS_dev_map_desc { 389f7ab093fSMike Marshall void *ptr; 390f7ab093fSMike Marshall __s32 total_size; 391f7ab093fSMike Marshall __s32 size; 392f7ab093fSMike Marshall __s32 count; 393f7ab093fSMike Marshall }; 394f7ab093fSMike Marshall 395f7ab093fSMike Marshall /* gossip.h *****************************************************************/ 396f7ab093fSMike Marshall 397f7ab093fSMike Marshall #ifdef GOSSIP_DISABLE_DEBUG 3981917a693SJoe Perches #define gossip_debug(mask, fmt, ...) \ 3991917a693SJoe Perches do { \ 4001917a693SJoe Perches if (0) \ 4011917a693SJoe Perches printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ 4021917a693SJoe Perches } while (0) 403f7ab093fSMike Marshall #else 40444f46410SMartin Brandenburg extern __u64 orangefs_gossip_debug_mask; 405f7ab093fSMike Marshall 406f7ab093fSMike Marshall /* try to avoid function call overhead by checking masks in macro */ 4071917a693SJoe Perches #define gossip_debug(mask, fmt, ...) \ 408f7ab093fSMike Marshall do { \ 40944f46410SMartin Brandenburg if (orangefs_gossip_debug_mask & (mask)) \ 4101917a693SJoe Perches printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ 411f7ab093fSMike Marshall } while (0) 412f7ab093fSMike Marshall #endif /* GOSSIP_DISABLE_DEBUG */ 413f7ab093fSMike Marshall 414f7ab093fSMike Marshall /* do file and line number printouts w/ the GNU preprocessor */ 4151917a693SJoe Perches #define gossip_ldebug(mask, fmt, ...) \ 4161917a693SJoe Perches gossip_debug(mask, "%s: " fmt, __func__, ##__VA_ARGS__) 417f7ab093fSMike Marshall 4181917a693SJoe Perches #define gossip_err pr_err 4191917a693SJoe Perches #define gossip_lerr(fmt, ...) \ 4201917a693SJoe Perches gossip_err("%s line %d: " fmt, \ 4211917a693SJoe Perches __FILE__, __LINE__, ##__VA_ARGS__) 422