Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 1 | #include <linux/types.h> |
Guenter Roeck | 81b784b | 2015-08-01 18:29:37 -0700 | [diff] [blame] | 2 | #include <linux/spinlock_types.h> |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 3 | #include <linux/slab.h> |
Mike Marshall | 2c590d5 | 2015-07-24 10:37:15 -0400 | [diff] [blame] | 4 | #include <linux/ioctl.h> |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 5 | |
| 6 | extern struct client_debug_mask *cdm_array; |
| 7 | extern char *debug_help_string; |
| 8 | extern int help_string_initialized; |
| 9 | extern struct dentry *debug_dir; |
| 10 | extern struct dentry *help_file_dentry; |
| 11 | extern struct dentry *client_debug_dentry; |
| 12 | extern const struct file_operations debug_help_fops; |
| 13 | extern int client_all_index; |
| 14 | extern int client_verbose_index; |
| 15 | extern int cdm_element_count; |
| 16 | #define DEBUG_HELP_STRING_SIZE 4096 |
| 17 | #define HELP_STRING_UNINITIALIZED \ |
| 18 | "Client Debug Keywords are unknown until the first time\n" \ |
| 19 | "the client is started after boot.\n" |
| 20 | #define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help" |
| 21 | #define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug" |
| 22 | #define ORANGEFS_CLIENT_DEBUG_FILE "client-debug" |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 23 | #define ORANGEFS_VERBOSE "verbose" |
| 24 | #define ORANGEFS_ALL "all" |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 25 | |
| 26 | /* pvfs2-config.h ***********************************************************/ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 27 | #define ORANGEFS_VERSION_MAJOR 2 |
| 28 | #define ORANGEFS_VERSION_MINOR 9 |
| 29 | #define ORANGEFS_VERSION_SUB 0 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 30 | |
| 31 | /* khandle stuff ***********************************************************/ |
| 32 | |
| 33 | /* |
| 34 | * The 2.9 core will put 64 bit handles in here like this: |
| 35 | * 1234 0000 0000 5678 |
| 36 | * The 3.0 and beyond cores will put 128 bit handles in here like this: |
| 37 | * 1234 5678 90AB CDEF |
| 38 | * The kernel module will always use the first four bytes and |
| 39 | * the last four bytes as an inum. |
| 40 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 41 | struct orangefs_khandle { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 42 | unsigned char u[16]; |
| 43 | } __aligned(8); |
| 44 | |
| 45 | /* |
| 46 | * kernel version of an object ref. |
| 47 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 48 | struct orangefs_object_kref { |
| 49 | struct orangefs_khandle khandle; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 50 | __s32 fs_id; |
| 51 | __s32 __pad1; |
| 52 | }; |
| 53 | |
| 54 | /* |
| 55 | * compare 2 khandles assumes little endian thus from large address to |
| 56 | * small address |
| 57 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 58 | static inline int ORANGEFS_khandle_cmp(const struct orangefs_khandle *kh1, |
| 59 | const struct orangefs_khandle *kh2) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 60 | { |
| 61 | int i; |
| 62 | |
| 63 | for (i = 15; i >= 0; i--) { |
| 64 | if (kh1->u[i] > kh2->u[i]) |
| 65 | return 1; |
| 66 | if (kh1->u[i] < kh2->u[i]) |
| 67 | return -1; |
| 68 | } |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 73 | static inline void ORANGEFS_khandle_to(const struct orangefs_khandle *kh, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 74 | void *p, int size) |
| 75 | { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 76 | |
| 77 | memset(p, 0, size); |
Mike Marshall | 50e0158 | 2015-09-29 11:17:26 -0400 | [diff] [blame] | 78 | memcpy(p, kh->u, 16); |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 79 | |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 80 | } |
| 81 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 82 | static inline void ORANGEFS_khandle_from(struct orangefs_khandle *kh, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 83 | void *p, int size) |
| 84 | { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 85 | memset(kh, 0, 16); |
Mike Marshall | 50e0158 | 2015-09-29 11:17:26 -0400 | [diff] [blame] | 86 | memcpy(kh->u, p, 16); |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 87 | |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /* pvfs2-types.h ************************************************************/ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 91 | typedef __u32 ORANGEFS_uid; |
| 92 | typedef __u32 ORANGEFS_gid; |
| 93 | typedef __s32 ORANGEFS_fs_id; |
| 94 | typedef __u32 ORANGEFS_permissions; |
| 95 | typedef __u64 ORANGEFS_time; |
| 96 | typedef __s64 ORANGEFS_size; |
| 97 | typedef __u64 ORANGEFS_flags; |
| 98 | typedef __u64 ORANGEFS_ds_position; |
| 99 | typedef __s32 ORANGEFS_error; |
| 100 | typedef __s64 ORANGEFS_offset; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 101 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 102 | #define ORANGEFS_SUPER_MAGIC 0x20030528 |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 103 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 104 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 105 | * 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] | 106 | * the sign is stripped before decoding. |
| 107 | */ |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 108 | |
| 109 | /* Bit 31 is not used since it is the sign. */ |
| 110 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 111 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 112 | * Bit 30 specifies that this is a ORANGEFS error. A ORANGEFS error is either an |
| 113 | * encoded errno value or a ORANGEFS protocol error. |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 114 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 115 | #define ORANGEFS_ERROR_BIT (1 << 30) |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 116 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 117 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 118 | * 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] | 119 | * errno value. |
| 120 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 121 | #define ORANGEFS_NON_ERRNO_ERROR_BIT (1 << 29) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 122 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 123 | /* |
| 124 | * 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] | 125 | * 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] | 126 | * in the kernel except to be masked out. |
| 127 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 128 | #define ORANGEFS_ERROR_CLASS_BITS 0x380 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 129 | |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 130 | /* Bits 6 - 0 are reserved for the actual error code. */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 131 | #define ORANGEFS_ERROR_NUMBER_BITS 0x7f |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 132 | |
Mike Marshall | 575e946 | 2015-12-04 12:56:14 -0500 | [diff] [blame] | 133 | /* Encoded errno values decoded by PINT_errno_mapping in orangefs-utils.c. */ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 134 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 135 | /* Our own ORANGEFS protocol error codes. */ |
| 136 | #define ORANGEFS_ECANCEL (1|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
| 137 | #define ORANGEFS_EDEVINIT (2|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
| 138 | #define ORANGEFS_EDETAIL (3|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
| 139 | #define ORANGEFS_EHOSTNTFD (4|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
| 140 | #define ORANGEFS_EADDRNTFD (5|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
| 141 | #define ORANGEFS_ENORECVR (6|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
| 142 | #define ORANGEFS_ETRYAGAIN (7|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
| 143 | #define ORANGEFS_ENOTPVFS (8|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
| 144 | #define ORANGEFS_ESECURITY (9|ORANGEFS_NON_ERRNO_ERROR_BIT|ORANGEFS_ERROR_BIT) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 145 | |
| 146 | /* permission bits */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 147 | #define ORANGEFS_O_EXECUTE (1 << 0) |
| 148 | #define ORANGEFS_O_WRITE (1 << 1) |
| 149 | #define ORANGEFS_O_READ (1 << 2) |
| 150 | #define ORANGEFS_G_EXECUTE (1 << 3) |
| 151 | #define ORANGEFS_G_WRITE (1 << 4) |
| 152 | #define ORANGEFS_G_READ (1 << 5) |
| 153 | #define ORANGEFS_U_EXECUTE (1 << 6) |
| 154 | #define ORANGEFS_U_WRITE (1 << 7) |
| 155 | #define ORANGEFS_U_READ (1 << 8) |
| 156 | /* no ORANGEFS_U_VTX (sticky bit) */ |
| 157 | #define ORANGEFS_G_SGID (1 << 10) |
| 158 | #define ORANGEFS_U_SUID (1 << 11) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 159 | |
| 160 | /* definition taken from stdint.h */ |
| 161 | #define INT32_MAX (2147483647) |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 162 | #define ORANGEFS_ITERATE_START (INT32_MAX - 1) |
| 163 | #define ORANGEFS_ITERATE_END (INT32_MAX - 2) |
| 164 | #define ORANGEFS_ITERATE_NEXT (INT32_MAX - 3) |
| 165 | #define ORANGEFS_READDIR_START ORANGEFS_ITERATE_START |
| 166 | #define ORANGEFS_READDIR_END ORANGEFS_ITERATE_END |
| 167 | #define ORANGEFS_IMMUTABLE_FL FS_IMMUTABLE_FL |
| 168 | #define ORANGEFS_APPEND_FL FS_APPEND_FL |
| 169 | #define ORANGEFS_NOATIME_FL FS_NOATIME_FL |
| 170 | #define ORANGEFS_MIRROR_FL 0x01000000ULL |
| 171 | #define ORANGEFS_O_EXECUTE (1 << 0) |
| 172 | #define ORANGEFS_FS_ID_NULL ((__s32)0) |
| 173 | #define ORANGEFS_ATTR_SYS_UID (1 << 0) |
| 174 | #define ORANGEFS_ATTR_SYS_GID (1 << 1) |
| 175 | #define ORANGEFS_ATTR_SYS_PERM (1 << 2) |
| 176 | #define ORANGEFS_ATTR_SYS_ATIME (1 << 3) |
| 177 | #define ORANGEFS_ATTR_SYS_CTIME (1 << 4) |
| 178 | #define ORANGEFS_ATTR_SYS_MTIME (1 << 5) |
| 179 | #define ORANGEFS_ATTR_SYS_TYPE (1 << 6) |
| 180 | #define ORANGEFS_ATTR_SYS_ATIME_SET (1 << 7) |
| 181 | #define ORANGEFS_ATTR_SYS_MTIME_SET (1 << 8) |
| 182 | #define ORANGEFS_ATTR_SYS_SIZE (1 << 20) |
| 183 | #define ORANGEFS_ATTR_SYS_LNK_TARGET (1 << 24) |
| 184 | #define ORANGEFS_ATTR_SYS_DFILE_COUNT (1 << 25) |
| 185 | #define ORANGEFS_ATTR_SYS_DIRENT_COUNT (1 << 26) |
| 186 | #define ORANGEFS_ATTR_SYS_BLKSIZE (1 << 28) |
| 187 | #define ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT (1 << 29) |
| 188 | #define ORANGEFS_ATTR_SYS_COMMON_ALL \ |
| 189 | (ORANGEFS_ATTR_SYS_UID | \ |
| 190 | ORANGEFS_ATTR_SYS_GID | \ |
| 191 | ORANGEFS_ATTR_SYS_PERM | \ |
| 192 | ORANGEFS_ATTR_SYS_ATIME | \ |
| 193 | ORANGEFS_ATTR_SYS_CTIME | \ |
| 194 | ORANGEFS_ATTR_SYS_MTIME | \ |
| 195 | ORANGEFS_ATTR_SYS_TYPE) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 196 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 197 | #define ORANGEFS_ATTR_SYS_ALL_SETABLE \ |
| 198 | (ORANGEFS_ATTR_SYS_COMMON_ALL-ORANGEFS_ATTR_SYS_TYPE) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 199 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 200 | #define ORANGEFS_ATTR_SYS_ALL_NOHINT \ |
| 201 | (ORANGEFS_ATTR_SYS_COMMON_ALL | \ |
| 202 | ORANGEFS_ATTR_SYS_SIZE | \ |
| 203 | ORANGEFS_ATTR_SYS_LNK_TARGET | \ |
| 204 | ORANGEFS_ATTR_SYS_DFILE_COUNT | \ |
| 205 | ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT | \ |
| 206 | ORANGEFS_ATTR_SYS_DIRENT_COUNT | \ |
| 207 | ORANGEFS_ATTR_SYS_BLKSIZE) |
Martin Brandenburg | 933287d | 2016-01-30 13:46:54 -0500 | [diff] [blame] | 208 | |
| 209 | #define ORANGEFS_ATTR_SYS_ALL_NOHINT_NOSIZE \ |
| 210 | (ORANGEFS_ATTR_SYS_COMMON_ALL | \ |
| 211 | ORANGEFS_ATTR_SYS_LNK_TARGET | \ |
| 212 | ORANGEFS_ATTR_SYS_DFILE_COUNT | \ |
| 213 | ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT | \ |
| 214 | ORANGEFS_ATTR_SYS_DIRENT_COUNT | \ |
| 215 | ORANGEFS_ATTR_SYS_BLKSIZE) |
| 216 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 217 | #define ORANGEFS_XATTR_REPLACE 0x2 |
| 218 | #define ORANGEFS_XATTR_CREATE 0x1 |
| 219 | #define ORANGEFS_MAX_SERVER_ADDR_LEN 256 |
| 220 | #define ORANGEFS_NAME_MAX 256 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 221 | /* |
| 222 | * max extended attribute name len as imposed by the VFS and exploited for the |
| 223 | * upcall request types. |
| 224 | * NOTE: Please retain them as multiples of 8 even if you wish to change them |
| 225 | * This is *NECESSARY* for supporting 32 bit user-space binaries on a 64-bit |
| 226 | * kernel. Due to implementation within DBPF, this really needs to be |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 227 | * 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] | 228 | * break if that changes in the future. |
| 229 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 230 | #define ORANGEFS_MAX_XATTR_NAMELEN ORANGEFS_NAME_MAX /* Not the same as |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 231 | * XATTR_NAME_MAX defined |
| 232 | * by <linux/xattr.h> |
| 233 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 234 | #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] | 235 | * defined by <linux/xattr.h> |
| 236 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 237 | #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] | 238 | * defined by <linux/xattr.h> |
| 239 | */ |
| 240 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 241 | * ORANGEFS I/O operation types, used in both system and server interfaces. |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 242 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 243 | enum ORANGEFS_io_type { |
| 244 | ORANGEFS_IO_READ = 1, |
| 245 | ORANGEFS_IO_WRITE = 2 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | /* |
| 249 | * If this enum is modified the server parameters related to the precreate pool |
| 250 | * batch and low threshold sizes may need to be modified to reflect this |
| 251 | * change. |
| 252 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 253 | enum orangefs_ds_type { |
| 254 | ORANGEFS_TYPE_NONE = 0, |
| 255 | ORANGEFS_TYPE_METAFILE = (1 << 0), |
| 256 | ORANGEFS_TYPE_DATAFILE = (1 << 1), |
| 257 | ORANGEFS_TYPE_DIRECTORY = (1 << 2), |
| 258 | ORANGEFS_TYPE_SYMLINK = (1 << 3), |
| 259 | ORANGEFS_TYPE_DIRDATA = (1 << 4), |
| 260 | ORANGEFS_TYPE_INTERNAL = (1 << 5) /* for the server's private use */ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 264 | * ORANGEFS_certificate simply stores a buffer with the buffer size. |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 265 | * The buffer can be converted to an OpenSSL X509 struct for use. |
| 266 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 267 | struct ORANGEFS_certificate { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 268 | __u32 buf_size; |
| 269 | unsigned char *buf; |
| 270 | }; |
| 271 | |
| 272 | /* |
| 273 | * A credential identifies a user and is signed by the client/user |
| 274 | * private key. |
| 275 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 276 | struct ORANGEFS_credential { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 277 | __u32 userid; /* user id */ |
| 278 | __u32 num_groups; /* length of group_array */ |
| 279 | __u32 *group_array; /* groups for which the user is a member */ |
| 280 | char *issuer; /* alias of the issuing server */ |
| 281 | __u64 timeout; /* seconds after epoch to time out */ |
| 282 | __u32 sig_size; /* length of the signature in bytes */ |
| 283 | unsigned char *signature; /* digital signature */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 284 | struct ORANGEFS_certificate certificate; /* user certificate buffer */ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 285 | }; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 286 | #define extra_size_ORANGEFS_credential (ORANGEFS_REQ_LIMIT_GROUPS * \ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 287 | sizeof(__u32) + \ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 288 | ORANGEFS_REQ_LIMIT_ISSUER + \ |
| 289 | ORANGEFS_REQ_LIMIT_SIGNATURE + \ |
| 290 | extra_size_ORANGEFS_certificate) |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 291 | |
| 292 | /* This structure is used by the VFS-client interaction alone */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 293 | struct ORANGEFS_keyval_pair { |
| 294 | char key[ORANGEFS_MAX_XATTR_NAMELEN]; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 295 | __s32 key_sz; /* __s32 for portable, fixed-size structures */ |
| 296 | __s32 val_sz; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 297 | char val[ORANGEFS_MAX_XATTR_VALUELEN]; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 298 | }; |
| 299 | |
| 300 | /* pvfs2-sysint.h ***********************************************************/ |
| 301 | /* Describes attributes for a file, directory, or symlink. */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 302 | struct ORANGEFS_sys_attr_s { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 303 | __u32 owner; |
| 304 | __u32 group; |
| 305 | __u32 perms; |
| 306 | __u64 atime; |
| 307 | __u64 mtime; |
| 308 | __u64 ctime; |
| 309 | __s64 size; |
| 310 | |
| 311 | /* NOTE: caller must free if valid */ |
| 312 | char *link_target; |
| 313 | |
| 314 | /* Changed to __s32 so that size of structure does not change */ |
| 315 | __s32 dfile_count; |
| 316 | |
| 317 | /* Changed to __s32 so that size of structure does not change */ |
| 318 | __s32 distr_dir_servers_initial; |
| 319 | |
| 320 | /* Changed to __s32 so that size of structure does not change */ |
| 321 | __s32 distr_dir_servers_max; |
| 322 | |
| 323 | /* Changed to __s32 so that size of structure does not change */ |
| 324 | __s32 distr_dir_split_size; |
| 325 | |
| 326 | __u32 mirror_copies_count; |
| 327 | |
| 328 | /* NOTE: caller must free if valid */ |
| 329 | char *dist_name; |
| 330 | |
| 331 | /* NOTE: caller must free if valid */ |
| 332 | char *dist_params; |
| 333 | |
| 334 | __s64 dirent_count; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 335 | enum orangefs_ds_type objtype; |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 336 | __u64 flags; |
| 337 | __u32 mask; |
| 338 | __s64 blksize; |
| 339 | }; |
| 340 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 341 | #define ORANGEFS_LOOKUP_LINK_NO_FOLLOW 0 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 342 | |
| 343 | /* pint-dev.h ***************************************************************/ |
| 344 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 345 | /* parameter structure used in ORANGEFS_DEV_DEBUG ioctl command */ |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 346 | struct dev_mask_info_s { |
| 347 | enum { |
| 348 | KERNEL_MASK, |
| 349 | CLIENT_MASK, |
| 350 | } mask_type; |
| 351 | __u64 mask_value; |
| 352 | }; |
| 353 | |
| 354 | struct dev_mask2_info_s { |
| 355 | __u64 mask1_value; |
| 356 | __u64 mask2_value; |
| 357 | }; |
| 358 | |
| 359 | /* pvfs2-util.h *************************************************************/ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 360 | __s32 ORANGEFS_util_translate_mode(int mode); |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 361 | |
| 362 | /* pvfs2-debug.h ************************************************************/ |
Mike Marshall | 575e946 | 2015-12-04 12:56:14 -0500 | [diff] [blame] | 363 | #include "orangefs-debug.h" |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 364 | |
| 365 | /* pvfs2-internal.h *********************************************************/ |
| 366 | #define llu(x) (unsigned long long)(x) |
| 367 | #define lld(x) (long long)(x) |
| 368 | |
| 369 | /* pint-dev-shared.h ********************************************************/ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 370 | #define ORANGEFS_DEV_MAGIC 'k' |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 371 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 372 | #define ORANGEFS_READDIR_DEFAULT_DESC_COUNT 5 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 373 | |
| 374 | #define DEV_GET_MAGIC 0x1 |
| 375 | #define DEV_GET_MAX_UPSIZE 0x2 |
| 376 | #define DEV_GET_MAX_DOWNSIZE 0x3 |
| 377 | #define DEV_MAP 0x4 |
| 378 | #define DEV_REMOUNT_ALL 0x5 |
| 379 | #define DEV_DEBUG 0x6 |
| 380 | #define DEV_UPSTREAM 0x7 |
| 381 | #define DEV_CLIENT_MASK 0x8 |
| 382 | #define DEV_CLIENT_STRING 0x9 |
| 383 | #define DEV_MAX_NR 0xa |
| 384 | |
| 385 | /* supported ioctls, codes are with respect to user-space */ |
| 386 | enum { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 387 | ORANGEFS_DEV_GET_MAGIC = _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAGIC, __s32), |
| 388 | ORANGEFS_DEV_GET_MAX_UPSIZE = |
| 389 | _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_UPSIZE, __s32), |
| 390 | ORANGEFS_DEV_GET_MAX_DOWNSIZE = |
| 391 | _IOW(ORANGEFS_DEV_MAGIC, DEV_GET_MAX_DOWNSIZE, __s32), |
| 392 | ORANGEFS_DEV_MAP = _IO(ORANGEFS_DEV_MAGIC, DEV_MAP), |
| 393 | ORANGEFS_DEV_REMOUNT_ALL = _IO(ORANGEFS_DEV_MAGIC, DEV_REMOUNT_ALL), |
| 394 | ORANGEFS_DEV_DEBUG = _IOR(ORANGEFS_DEV_MAGIC, DEV_DEBUG, __s32), |
| 395 | ORANGEFS_DEV_UPSTREAM = _IOW(ORANGEFS_DEV_MAGIC, DEV_UPSTREAM, int), |
| 396 | ORANGEFS_DEV_CLIENT_MASK = _IOW(ORANGEFS_DEV_MAGIC, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 397 | DEV_CLIENT_MASK, |
| 398 | struct dev_mask2_info_s), |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 399 | ORANGEFS_DEV_CLIENT_STRING = _IOW(ORANGEFS_DEV_MAGIC, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 400 | DEV_CLIENT_STRING, |
| 401 | char *), |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 402 | ORANGEFS_DEV_MAXNR = DEV_MAX_NR, |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 403 | }; |
| 404 | |
| 405 | /* |
| 406 | * version number for use in communicating between kernel space and user |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 407 | * space. Zero signifies the upstream version of the kernel module. |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 408 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 409 | #define ORANGEFS_KERNEL_PROTO_VERSION 0 |
Mike Marshall | 569dbfc | 2016-01-13 11:36:25 -0500 | [diff] [blame] | 410 | #define ORANGEFS_MINIMUM_USERSPACE_VERSION 20904 |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 411 | |
| 412 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 413 | * describes memory regions to map in the ORANGEFS_DEV_MAP ioctl. |
Mike Marshall | 575e946 | 2015-12-04 12:56:14 -0500 | [diff] [blame] | 414 | * NOTE: See devorangefs-req.c for 32 bit compat structure. |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 415 | * Since this structure has a variable-sized layout that is different |
| 416 | * on 32 and 64 bit platforms, we need to normalize to a 64 bit layout |
| 417 | * on such systems before servicing ioctl calls from user-space binaries |
| 418 | * that may be 32 bit! |
| 419 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 420 | struct ORANGEFS_dev_map_desc { |
Mike Marshall | f7ab093 | 2015-07-17 10:38:11 -0400 | [diff] [blame] | 421 | void *ptr; |
| 422 | __s32 total_size; |
| 423 | __s32 size; |
| 424 | __s32 count; |
| 425 | }; |
| 426 | |
| 427 | /* gossip.h *****************************************************************/ |
| 428 | |
| 429 | #ifdef GOSSIP_DISABLE_DEBUG |
| 430 | #define gossip_debug(mask, format, f...) do {} while (0) |
| 431 | #else |
| 432 | extern __u64 gossip_debug_mask; |
| 433 | extern struct client_debug_mask client_debug_mask; |
| 434 | |
| 435 | /* try to avoid function call overhead by checking masks in macro */ |
| 436 | #define gossip_debug(mask, format, f...) \ |
| 437 | do { \ |
| 438 | if (gossip_debug_mask & mask) \ |
| 439 | printk(format, ##f); \ |
| 440 | } while (0) |
| 441 | #endif /* GOSSIP_DISABLE_DEBUG */ |
| 442 | |
| 443 | /* do file and line number printouts w/ the GNU preprocessor */ |
| 444 | #define gossip_ldebug(mask, format, f...) \ |
| 445 | gossip_debug(mask, "%s: " format, __func__, ##f) |
| 446 | |
| 447 | #define gossip_err printk |
| 448 | #define gossip_lerr(format, f...) \ |
| 449 | gossip_err("%s line %d: " format, \ |
| 450 | __FILE__, \ |
| 451 | __LINE__, \ |
| 452 | ##f) |