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