Joe Perches | 1917a69 | 2016-03-27 14:34:52 -0700 | [diff] [blame] | 1 | #include <linux/kernel.h> |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 2 | #include <linux/types.h> |
Guenter Roeck | 81b784b | 2015-08-01 18:29:37 -0700 | [diff] [blame] | 3 | #include <linux/spinlock_types.h> |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 4 | #include <linux/slab.h> |
Mike Marshall | 2c590d5 | 2015-07-24 10:37:15 -0400 | [diff] [blame] | 5 | #include <linux/ioctl.h> |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 6 | |
| 7 | extern struct client_debug_mask *cdm_array; |
| 8 | extern char *debug_help_string; |
| 9 | extern int help_string_initialized; |
| 10 | extern struct dentry *debug_dir; |
| 11 | extern struct dentry *help_file_dentry; |
| 12 | extern struct dentry *client_debug_dentry; |
| 13 | extern const struct file_operations debug_help_fops; |
| 14 | extern int client_all_index; |
| 15 | extern int client_verbose_index; |
| 16 | extern 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 Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 24 | #define ORANGEFS_VERBOSE "verbose" |
| 25 | #define ORANGEFS_ALL "all" |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 26 | |
| 27 | /* pvfs2-config.h ***********************************************************/ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 28 | #define ORANGEFS_VERSION_MAJOR 2 |
| 29 | #define ORANGEFS_VERSION_MINOR 9 |
| 30 | #define ORANGEFS_VERSION_SUB 0 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 31 | |
| 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 Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 42 | struct orangefs_khandle { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 43 | unsigned char u[16]; |
| 44 | } __aligned(8); |
| 45 | |
| 46 | /* |
| 47 | * kernel version of an object ref. |
| 48 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 49 | struct orangefs_object_kref { |
| 50 | struct orangefs_khandle khandle; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 51 | __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 Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 59 | static inline int ORANGEFS_khandle_cmp(const struct orangefs_khandle *kh1, |
| 60 | const struct orangefs_khandle *kh2) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 61 | { |
| 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 Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 74 | static inline void ORANGEFS_khandle_to(const struct orangefs_khandle *kh, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 75 | void *p, int size) |
| 76 | { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 77 | |
Mike Marshall | 50e0158 | 2015-09-29 11:17:26 -0400 | [diff] [blame] | 78 | memcpy(p, kh->u, 16); |
Mike Marshall | a9bb3ba | 2016-04-06 11:19:37 -0400 | [diff] [blame] | 79 | memset(p + 16, 0, size - 16); |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 80 | |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 81 | } |
| 82 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 83 | static inline void ORANGEFS_khandle_from(struct orangefs_khandle *kh, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 84 | void *p, int size) |
| 85 | { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 86 | memset(kh, 0, 16); |
Mike Marshall | 50e0158 | 2015-09-29 11:17:26 -0400 | [diff] [blame] | 87 | memcpy(kh->u, p, 16); |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 88 | |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /* pvfs2-types.h ************************************************************/ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 92 | typedef __u32 ORANGEFS_uid; |
| 93 | typedef __u32 ORANGEFS_gid; |
| 94 | typedef __s32 ORANGEFS_fs_id; |
| 95 | typedef __u32 ORANGEFS_permissions; |
| 96 | typedef __u64 ORANGEFS_time; |
| 97 | typedef __s64 ORANGEFS_size; |
| 98 | typedef __u64 ORANGEFS_flags; |
| 99 | typedef __u64 ORANGEFS_ds_position; |
| 100 | typedef __s32 ORANGEFS_error; |
| 101 | typedef __s64 ORANGEFS_offset; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 102 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 103 | #define ORANGEFS_SUPER_MAGIC 0x20030528 |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 104 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 105 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 106 | * ORANGEFS error codes are a signed 32-bit integer. Error codes are negative, but |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 107 | * the sign is stripped before decoding. |
| 108 | */ |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 109 | |
| 110 | /* Bit 31 is not used since it is the sign. */ |
| 111 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 112 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 113 | * 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 Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 115 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 116 | #define ORANGEFS_ERROR_BIT (1 << 30) |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 117 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 118 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 119 | * Bit 29 specifies that this is a ORANGEFS protocol error and not an encoded |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 120 | * errno value. |
| 121 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 122 | #define ORANGEFS_NON_ERRNO_ERROR_BIT (1 << 29) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 123 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 124 | /* |
| 125 | * Bits 9, 8, and 7 specify the error class, which encodes the section of |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 126 | * server code the error originated in for logging purposes. It is not used |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 127 | * in the kernel except to be masked out. |
| 128 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 129 | #define ORANGEFS_ERROR_CLASS_BITS 0x380 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 130 | |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 131 | /* Bits 6 - 0 are reserved for the actual error code. */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 132 | #define ORANGEFS_ERROR_NUMBER_BITS 0x7f |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 133 | |
Mike Marshall | 575e946 | 2015-12-04 12:56:14 -0500 | [diff] [blame] | 134 | /* Encoded errno values decoded by PINT_errno_mapping in orangefs-utils.c. */ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 135 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 136 | /* 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 Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 146 | |
| 147 | /* permission bits */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 148 | #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 Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 160 | |
| 161 | /* definition taken from stdint.h */ |
| 162 | #define INT32_MAX (2147483647) |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 163 | #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 Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 197 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 198 | #define ORANGEFS_ATTR_SYS_ALL_SETABLE \ |
| 199 | (ORANGEFS_ATTR_SYS_COMMON_ALL-ORANGEFS_ATTR_SYS_TYPE) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 200 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 201 | #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 Brandenburg | 933287d | 2016-01-30 13:46:54 -0500 | [diff] [blame] | 209 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 210 | #define ORANGEFS_XATTR_REPLACE 0x2 |
| 211 | #define ORANGEFS_XATTR_CREATE 0x1 |
| 212 | #define ORANGEFS_MAX_SERVER_ADDR_LEN 256 |
| 213 | #define ORANGEFS_NAME_MAX 256 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 214 | /* |
| 215 | * max extended attribute name len as imposed by the VFS and exploited for the |
| 216 | * upcall request types. |
| 217 | * NOTE: Please retain them as multiples of 8 even if you wish to change them |
| 218 | * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit |
| 219 | * kernel. Due to implementation within DBPF, this really needs to be |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 220 | * ORANGEFS_NAME_MAX, which it was the same value as, but no reason to let it |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 221 | * break if that changes in the future. |
| 222 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 223 | #define ORANGEFS_MAX_XATTR_NAMELEN ORANGEFS_NAME_MAX /* Not the same as |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 224 | * XATTR_NAME_MAX defined |
| 225 | * by <linux/xattr.h> |
| 226 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 227 | #define ORANGEFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 228 | * defined by <linux/xattr.h> |
| 229 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 230 | #define ORANGEFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 231 | * defined by <linux/xattr.h> |
| 232 | */ |
| 233 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 234 | * ORANGEFS I/O operation types, used in both system and server interfaces. |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 235 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 236 | enum ORANGEFS_io_type { |
| 237 | ORANGEFS_IO_READ = 1, |
| 238 | ORANGEFS_IO_WRITE = 2 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | /* |
| 242 | * If this enum is modified the server parameters related to the precreate pool |
| 243 | * batch and low threshold sizes may need to be modified to reflect this |
| 244 | * change. |
| 245 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 246 | enum orangefs_ds_type { |
| 247 | ORANGEFS_TYPE_NONE = 0, |
| 248 | ORANGEFS_TYPE_METAFILE = (1 << 0), |
| 249 | ORANGEFS_TYPE_DATAFILE = (1 << 1), |
| 250 | ORANGEFS_TYPE_DIRECTORY = (1 << 2), |
| 251 | ORANGEFS_TYPE_SYMLINK = (1 << 3), |
| 252 | ORANGEFS_TYPE_DIRDATA = (1 << 4), |
| 253 | ORANGEFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 254 | }; |
| 255 | |
| 256 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 257 | * ORANGEFS_certificate simply stores a buffer with the buffer size. |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 258 | * The buffer can be converted to an OpenSSL X509 struct for use. |
| 259 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 260 | struct ORANGEFS_certificate { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 261 | __u32 buf_size; |
| 262 | unsigned char *buf; |
| 263 | }; |
| 264 | |
| 265 | /* |
| 266 | * A credential identifies a user and is signed by the client/user |
| 267 | * private key. |
| 268 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 269 | struct ORANGEFS_credential { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 270 | __u32 userid; /* user id */ |
| 271 | __u32 num_groups; /* length of group_array */ |
| 272 | __u32 *group_array; /* groups for which the user is a member */ |
| 273 | char *issuer; /* alias of the issuing server */ |
| 274 | __u64 timeout; /* seconds after epoch to time out */ |
| 275 | __u32 sig_size; /* length of the signature in bytes */ |
| 276 | unsigned char *signature; /* digital signature */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 277 | struct ORANGEFS_certificate certificate; /* user certificate buffer */ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 278 | }; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 279 | #define extra_size_ORANGEFS_credential (ORANGEFS_REQ_LIMIT_GROUPS * \ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 280 | sizeof(__u32) + \ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 281 | ORANGEFS_REQ_LIMIT_ISSUER + \ |
| 282 | ORANGEFS_REQ_LIMIT_SIGNATURE + \ |
| 283 | extra_size_ORANGEFS_certificate) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 284 | |
| 285 | /* This structure is used by the VFS-client interaction alone */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 286 | struct ORANGEFS_keyval_pair { |
| 287 | char key[ORANGEFS_MAX_XATTR_NAMELEN]; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 288 | __s32 key_sz; /* __s32 for portable, fixed-size structures */ |
| 289 | __s32 val_sz; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 290 | char val[ORANGEFS_MAX_XATTR_VALUELEN]; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | /* pvfs2-sysint.h ***********************************************************/ |
| 294 | /* Describes attributes for a file, directory, or symlink. */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 295 | struct ORANGEFS_sys_attr_s { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 296 | __u32 owner; |
| 297 | __u32 group; |
| 298 | __u32 perms; |
| 299 | __u64 atime; |
| 300 | __u64 mtime; |
| 301 | __u64 ctime; |
| 302 | __s64 size; |
| 303 | |
| 304 | /* NOTE: caller must free if valid */ |
| 305 | char *link_target; |
| 306 | |
| 307 | /* Changed to __s32 so that size of structure does not change */ |
| 308 | __s32 dfile_count; |
| 309 | |
| 310 | /* Changed to __s32 so that size of structure does not change */ |
| 311 | __s32 distr_dir_servers_initial; |
| 312 | |
| 313 | /* Changed to __s32 so that size of structure does not change */ |
| 314 | __s32 distr_dir_servers_max; |
| 315 | |
| 316 | /* Changed to __s32 so that size of structure does not change */ |
| 317 | __s32 distr_dir_split_size; |
| 318 | |
| 319 | __u32 mirror_copies_count; |
| 320 | |
| 321 | /* NOTE: caller must free if valid */ |
| 322 | char *dist_name; |
| 323 | |
| 324 | /* NOTE: caller must free if valid */ |
| 325 | char *dist_params; |
| 326 | |
| 327 | __s64 dirent_count; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 328 | enum orangefs_ds_type objtype; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 329 | __u64 flags; |
| 330 | __u32 mask; |
| 331 | __s64 blksize; |
| 332 | }; |
| 333 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 334 | #define ORANGEFS_LOOKUP_LINK_NO_FOLLOW 0 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 335 | |
| 336 | /* pint-dev.h ***************************************************************/ |
| 337 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 338 | /* parameter structure used in ORANGEFS_DEV_DEBUG ioctl command */ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 339 | struct dev_mask_info_s { |
| 340 | enum { |
| 341 | KERNEL_MASK, |
| 342 | CLIENT_MASK, |
| 343 | } mask_type; |
| 344 | __u64 mask_value; |
| 345 | }; |
| 346 | |
| 347 | struct dev_mask2_info_s { |
| 348 | __u64 mask1_value; |
| 349 | __u64 mask2_value; |
| 350 | }; |
| 351 | |
| 352 | /* pvfs2-util.h *************************************************************/ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 353 | __s32 ORANGEFS_util_translate_mode(int mode); |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 354 | |
| 355 | /* pvfs2-debug.h ************************************************************/ |
Mike Marshall | 575e946 | 2015-12-04 12:56:14 -0500 | [diff] [blame] | 356 | #include "orangefs-debug.h" |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 357 | |
| 358 | /* pvfs2-internal.h *********************************************************/ |
| 359 | #define llu(x) (unsigned long long)(x) |
| 360 | #define lld(x) (long long)(x) |
| 361 | |
| 362 | /* pint-dev-shared.h ********************************************************/ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 363 | #define ORANGEFS_DEV_MAGIC 'k' |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 364 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 365 | #define ORANGEFS_READDIR_DEFAULT_DESC_COUNT 5 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 366 | |
| 367 | #define DEV_GET_MAGIC 0x1 |
| 368 | #define DEV_GET_MAX_UPSIZE 0x2 |
| 369 | #define DEV_GET_MAX_DOWNSIZE 0x3 |
| 370 | #define DEV_MAP 0x4 |
| 371 | #define DEV_REMOUNT_ALL 0x5 |
| 372 | #define DEV_DEBUG 0x6 |
| 373 | #define DEV_UPSTREAM 0x7 |
| 374 | #define DEV_CLIENT_MASK 0x8 |
| 375 | #define DEV_CLIENT_STRING 0x9 |
| 376 | #define DEV_MAX_NR 0xa |
| 377 | |
| 378 | /* supported ioctls, codes are with respect to user-space */ |
| 379 | enum { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 380 | ORANGEFS_DEV_GET_MAGIC = _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAGIC, __s32), |
| 381 | ORANGEFS_DEV_GET_MAX_UPSIZE = |
| 382 | _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32), |
| 383 | ORANGEFS_DEV_GET_MAX_DOWNSIZE = |
| 384 | _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32), |
| 385 | ORANGEFS_DEV_MAP = _IO(ORANGEFS_DEV_MAGIC, DEV_MAP), |
| 386 | ORANGEFS_DEV_REMOUNT_ALL = _IO(ORANGEFS_DEV_MAGIC, DEV_REMOUNT_ALL), |
| 387 | ORANGEFS_DEV_DEBUG = _IOR(ORANGEFS_DEV_MAGIC, DEV_DEBUG, __s32), |
| 388 | ORANGEFS_DEV_UPSTREAM = _IOW(ORANGEFS_DEV_MAGIC, DEV_UPSTREAM, int), |
| 389 | ORANGEFS_DEV_CLIENT_MASK = _IOW(ORANGEFS_DEV_MAGIC, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 390 | DEV_CLIENT_MASK, |
| 391 | struct dev_mask2_info_s), |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 392 | ORANGEFS_DEV_CLIENT_STRING = _IOW(ORANGEFS_DEV_MAGIC, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 393 | DEV_CLIENT_STRING, |
| 394 | char *), |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 395 | ORANGEFS_DEV_MAXNR = DEV_MAX_NR, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 396 | }; |
| 397 | |
| 398 | /* |
| 399 | * version number for use in communicating between kernel space and user |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 400 | * space. Zero signifies the upstream version of the kernel module. |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 401 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 402 | #define ORANGEFS_KERNEL_PROTO_VERSION 0 |
Martin Brandenburg | 878dfd3 | 2016-03-30 16:18:43 -0400 | [diff] [blame] | 403 | #define ORANGEFS_MINIMUM_USERSPACE_VERSION 20903 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 404 | |
| 405 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 406 | * describes memory regions to map in the ORANGEFS_DEV_MAP ioctl. |
Mike Marshall | 575e946 | 2015-12-04 12:56:14 -0500 | [diff] [blame] | 407 | * NOTE: See devorangefs-req.c for 32 bit compat structure. |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 408 | * Since this structure has a variable-sized layout that is different |
| 409 | * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout |
| 410 | * on such systems before servicing ioctl calls from user-space binaries |
| 411 | * that may be 32 bit! |
| 412 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 413 | struct ORANGEFS_dev_map_desc { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 414 | void *ptr; |
| 415 | __s32 total_size; |
| 416 | __s32 size; |
| 417 | __s32 count; |
| 418 | }; |
| 419 | |
| 420 | /* gossip.h *****************************************************************/ |
| 421 | |
| 422 | #ifdef GOSSIP_DISABLE_DEBUG |
Joe Perches | 1917a69 | 2016-03-27 14:34:52 -0700 | [diff] [blame] | 423 | #define gossip_debug(mask, fmt, ...) \ |
| 424 | do { \ |
| 425 | if (0) \ |
| 426 | printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ |
| 427 | } while (0) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 428 | #else |
| 429 | extern __u64 gossip_debug_mask; |
| 430 | extern struct client_debug_mask client_debug_mask; |
| 431 | |
| 432 | /* try to avoid function call overhead by checking masks in macro */ |
Joe Perches | 1917a69 | 2016-03-27 14:34:52 -0700 | [diff] [blame] | 433 | #define gossip_debug(mask, fmt, ...) \ |
| 434 | do { \ |
| 435 | if (gossip_debug_mask & (mask)) \ |
| 436 | printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 437 | } while (0) |
| 438 | #endif /* GOSSIP_DISABLE_DEBUG */ |
| 439 | |
| 440 | /* do file and line number printouts w/ the GNU preprocessor */ |
Joe Perches | 1917a69 | 2016-03-27 14:34:52 -0700 | [diff] [blame] | 441 | #define gossip_ldebug(mask, fmt, ...) \ |
| 442 | gossip_debug(mask, "%s: " fmt, __func__, ##__VA_ARGS__) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 443 | |
Joe Perches | 1917a69 | 2016-03-27 14:34:52 -0700 | [diff] [blame] | 444 | #define gossip_err pr_err |
| 445 | #define gossip_lerr(fmt, ...) \ |
| 446 | gossip_err("%s line %d: " fmt, \ |
| 447 | __FILE__, __LINE__, ##__VA_ARGS__) |