^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * (C) 2001 Clemson University and The University of Chicago
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * See COPYING in top-level directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * The ORANGEFS Linux kernel support allows ORANGEFS volumes to be mounted and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * accessed through the Linux VFS (i.e. using standard I/O system calls).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * This support is only needed on clients that wish to mount the file system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Declarations and macros for the ORANGEFS Linux kernel support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifndef __ORANGEFSKERNEL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define __ORANGEFSKERNEL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/statfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/backing-dev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/mpage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/namei.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/aio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/posix_acl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/posix_acl_xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/uio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <linux/dcache.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include <linux/rwsem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include <linux/exportfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #include <linux/hashtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #include "orangefs-dev-proto.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS 20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS 30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS 900 /* 15 minutes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define ORANGEFS_REQDEVICE_NAME "pvfs2-req"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define ORANGEFS_DEVREQ_MAGIC 0x20030529
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define ORANGEFS_PURGE_RETRY_COUNT 0x00000005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define MAX_DEV_REQ_UPSIZE (2 * sizeof(__s32) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) sizeof(__u64) + sizeof(struct orangefs_upcall_s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define MAX_DEV_REQ_DOWNSIZE (2 * sizeof(__s32) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) sizeof(__u64) + sizeof(struct orangefs_downcall_s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * valid orangefs kernel operation states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * unknown - op was just initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * waiting - op is on request_list (upward bound)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * inprogr - op is in progress (waiting for downcall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * serviced - op has matching downcall; ok
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * purged - op has to start a timer since client-core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * exited uncleanly before servicing op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * given up - submitter has given up waiting for it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) enum orangefs_vfs_op_states {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) OP_VFS_STATE_UNKNOWN = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) OP_VFS_STATE_WAITING = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) OP_VFS_STATE_INPROGR = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) OP_VFS_STATE_SERVICED = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) OP_VFS_STATE_PURGED = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) OP_VFS_STATE_GIVEN_UP = 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * orangefs kernel memory related flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #if (defined CONFIG_DEBUG_SLAB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define ORANGEFS_CACHE_CREATE_FLAGS SLAB_RED_ZONE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define ORANGEFS_CACHE_CREATE_FLAGS 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) extern int orangefs_init_acl(struct inode *inode, struct inode *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) extern const struct xattr_handler *orangefs_xattr_handlers[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) extern struct posix_acl *orangefs_get_acl(struct inode *inode, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) extern int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * orangefs data structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct orangefs_kernel_op_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) enum orangefs_vfs_op_states op_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) __u64 tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * Set uses_shared_memory to non zero if this operation uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * shared memory. If true, then a retry on the op must also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * get a new shared memory buffer and re-populate it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * Cancels don't care - it only matters for service_operation()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * retry logics and cancels don't go through it anymore. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * safely stays non-zero when we use it as slot_to_free.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int uses_shared_memory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) int slot_to_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct orangefs_upcall_s upcall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct orangefs_downcall_s downcall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct completion waitq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int attempts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define set_op_state_waiting(op) ((op)->op_state = OP_VFS_STATE_WAITING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #define set_op_state_inprogress(op) ((op)->op_state = OP_VFS_STATE_INPROGR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #define set_op_state_given_up(op) ((op)->op_state = OP_VFS_STATE_GIVEN_UP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static inline void set_op_state_serviced(struct orangefs_kernel_op_s *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) op->op_state = OP_VFS_STATE_SERVICED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) complete(&op->waitq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define op_state_waiting(op) ((op)->op_state & OP_VFS_STATE_WAITING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define op_state_in_progress(op) ((op)->op_state & OP_VFS_STATE_INPROGR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define op_state_serviced(op) ((op)->op_state & OP_VFS_STATE_SERVICED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define op_state_purged(op) ((op)->op_state & OP_VFS_STATE_PURGED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #define op_state_given_up(op) ((op)->op_state & OP_VFS_STATE_GIVEN_UP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define op_is_cancel(op) ((op)->upcall.type == ORANGEFS_VFS_OP_CANCEL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) void op_release(struct orangefs_kernel_op_s *op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) extern void orangefs_bufmap_put(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static inline void put_cancel(struct orangefs_kernel_op_s *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) orangefs_bufmap_put(op->slot_to_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) op_release(op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static inline void set_op_state_purged(struct orangefs_kernel_op_s *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) spin_lock(&op->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (unlikely(op_is_cancel(op))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) list_del_init(&op->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) spin_unlock(&op->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) put_cancel(op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) op->op_state |= OP_VFS_STATE_PURGED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) complete(&op->waitq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) spin_unlock(&op->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* per inode private orangefs info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct orangefs_inode_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct orangefs_object_kref refn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) char link_target[ORANGEFS_NAME_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * Reading/Writing Extended attributes need to acquire the appropriate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * reader/writer semaphore on the orangefs_inode_s structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct rw_semaphore xattr_sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) sector_t last_failed_block_index_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) unsigned long getattr_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) unsigned long mapping_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) int attr_valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) kuid_t attr_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) kgid_t attr_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) unsigned long bitlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) DECLARE_HASHTABLE(xattr_cache, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /* per superblock private orangefs info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct orangefs_sb_info_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct orangefs_khandle root_khandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) __s32 fs_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #define ORANGEFS_OPT_INTR 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) #define ORANGEFS_OPT_LOCAL_LOCK 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) char devname[ORANGEFS_MAX_SERVER_ADDR_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct super_block *sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int mount_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) int no_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct orangefs_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) unsigned long cache_hits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) unsigned long cache_misses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) unsigned long reads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) unsigned long writes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct orangefs_cached_xattr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct hlist_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) char key[ORANGEFS_MAX_XATTR_NAMELEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) char val[ORANGEFS_MAX_XATTR_VALUELEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) ssize_t length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) unsigned long timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct orangefs_write_range {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) loff_t pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) kuid_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) kgid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) extern struct orangefs_stats orangefs_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * NOTE: See Documentation/filesystems/porting.rst for information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * on implementing FOO_I and properly accessing fs private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static inline struct orangefs_inode_s *ORANGEFS_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return container_of(inode, struct orangefs_inode_s, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) static inline struct orangefs_sb_info_s *ORANGEFS_SB(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) return (struct orangefs_sb_info_s *) sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* ino_t descends from "unsigned long", 8 bytes, 64 bits. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static inline ino_t orangefs_khandle_to_ino(struct orangefs_khandle *khandle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) unsigned char u[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) __u64 ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) } ihandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) ihandle.u[0] = khandle->u[0] ^ khandle->u[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ihandle.u[1] = khandle->u[1] ^ khandle->u[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) ihandle.u[2] = khandle->u[2] ^ khandle->u[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) ihandle.u[3] = khandle->u[3] ^ khandle->u[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) ihandle.u[4] = khandle->u[12] ^ khandle->u[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ihandle.u[5] = khandle->u[13] ^ khandle->u[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) ihandle.u[6] = khandle->u[14] ^ khandle->u[10];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) ihandle.u[7] = khandle->u[15] ^ khandle->u[11];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return ihandle.ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static inline struct orangefs_khandle *get_khandle_from_ino(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return &(ORANGEFS_I(inode)->refn.khandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) static inline int is_root_handle(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) gossip_debug(GOSSIP_DCACHE_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) "%s: root handle: %pU, this handle: %pU:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) &ORANGEFS_SB(inode->i_sb)->root_khandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) get_khandle_from_ino(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) if (ORANGEFS_khandle_cmp(&(ORANGEFS_SB(inode->i_sb)->root_khandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) get_khandle_from_ino(inode)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static inline int match_handle(struct orangefs_khandle resp_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) gossip_debug(GOSSIP_DCACHE_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) "%s: one handle: %pU, another handle:%pU:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) &resp_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) get_khandle_from_ino(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (ORANGEFS_khandle_cmp(&resp_handle, get_khandle_from_ino(inode)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * defined in orangefs-cache.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) int op_cache_initialize(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) int op_cache_finalize(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) struct orangefs_kernel_op_s *op_alloc(__s32 type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) void orangefs_new_tag(struct orangefs_kernel_op_s *op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) char *get_opname_string(struct orangefs_kernel_op_s *new_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) int orangefs_inode_cache_initialize(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) int orangefs_inode_cache_finalize(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * defined in orangefs-mod.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) void purge_inprogress_ops(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * defined in waitqueue.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) void purge_waiting_ops(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) * defined in super.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) extern uint64_t orangefs_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) struct dentry *orangefs_mount(struct file_system_type *fst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) const char *devname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) void orangefs_kill_sb(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) int orangefs_remount(struct orangefs_sb_info_s *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) int fsid_key_table_initialize(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) void fsid_key_table_finalize(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * defined in inode.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) vm_fault_t orangefs_page_mkwrite(struct vm_fault *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) struct inode *orangefs_new_inode(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) int mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) dev_t dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct orangefs_object_kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) int __orangefs_setattr(struct inode *, struct iattr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) int orangefs_setattr(struct dentry *, struct iattr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) int orangefs_getattr(const struct path *path, struct kstat *stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) u32 request_mask, unsigned int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) int orangefs_permission(struct inode *inode, int mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) int orangefs_update_time(struct inode *, struct timespec64 *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * defined in xattr.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * defined in namei.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) struct inode *orangefs_iget(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct orangefs_object_kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * defined in devorangefs-req.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) extern uint32_t orangefs_userspace_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) int orangefs_dev_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) void orangefs_dev_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) int is_daemon_in_service(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) bool __is_daemon_in_service(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * defined in file.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) int orangefs_revalidate_mapping(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) ssize_t wait_for_direct_io(enum ORANGEFS_io_type, struct inode *, loff_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) struct iov_iter *, size_t, loff_t, struct orangefs_write_range *, int *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) struct file *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ssize_t do_readv_writev(enum ORANGEFS_io_type, struct file *, loff_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) struct iov_iter *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) * defined in orangefs-utils.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) __s32 fsid_of_op(struct orangefs_kernel_op_s *op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) ssize_t orangefs_inode_getxattr(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) void *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) int orangefs_inode_setxattr(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) const void *value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) #define ORANGEFS_GETATTR_NEW 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) #define ORANGEFS_GETATTR_SIZE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) int orangefs_inode_getattr(struct inode *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) int orangefs_inode_check_changed(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) int orangefs_inode_setattr(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) int orangefs_normalize_to_errno(__s32 error_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) extern struct mutex orangefs_request_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) extern int op_timeout_secs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) extern int slot_timeout_secs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) extern int orangefs_cache_timeout_msecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) extern int orangefs_dcache_timeout_msecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) extern int orangefs_getattr_timeout_msecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) extern struct list_head orangefs_superblocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) extern spinlock_t orangefs_superblocks_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) extern struct list_head orangefs_request_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) extern spinlock_t orangefs_request_list_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) extern wait_queue_head_t orangefs_request_list_waitq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) extern struct list_head *orangefs_htable_ops_in_progress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) extern spinlock_t orangefs_htable_ops_in_progress_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) extern int hash_table_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) extern const struct file_operations orangefs_file_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) extern const struct inode_operations orangefs_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) extern const struct inode_operations orangefs_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) extern const struct file_operations orangefs_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) extern const struct dentry_operations orangefs_dentry_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * misc convenience macros
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) #define ORANGEFS_OP_INTERRUPTIBLE 1 /* service_operation() is interruptible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) #define ORANGEFS_OP_PRIORITY 2 /* service_operation() is high priority */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) #define ORANGEFS_OP_CANCELLATION 4 /* this is a cancellation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) #define ORANGEFS_OP_NO_MUTEX 8 /* don't acquire request_mutex */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) #define ORANGEFS_OP_ASYNC 16 /* Queue it, but don't wait */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) #define ORANGEFS_OP_WRITEBACK 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) int service_operation(struct orangefs_kernel_op_s *op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) const char *op_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) #define get_interruptible_flag(inode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) ((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) ORANGEFS_OP_INTERRUPTIBLE : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) #define fill_default_sys_attrs(sys_attr, type, mode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) sys_attr.owner = from_kuid(&init_user_ns, current_fsuid()); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) sys_attr.group = from_kgid(&init_user_ns, current_fsgid()); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) sys_attr.perms = ORANGEFS_util_translate_mode(mode); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) sys_attr.mtime = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) sys_attr.atime = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) sys_attr.ctime = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) sys_attr.mask = ORANGEFS_ATTR_SYS_ALL_SETABLE; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) static inline void orangefs_set_timeout(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) unsigned long time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) dentry->d_fsdata = (void *) time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) #endif /* __ORANGEFSKERNEL_H */