18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * (C) 2001 Clemson University and The University of Chicago 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * See COPYING in top-level directory. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* 98c2ecf20Sopenharmony_ci * The ORANGEFS Linux kernel support allows ORANGEFS volumes to be mounted and 108c2ecf20Sopenharmony_ci * accessed through the Linux VFS (i.e. using standard I/O system calls). 118c2ecf20Sopenharmony_ci * This support is only needed on clients that wish to mount the file system. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci * Declarations and macros for the ORANGEFS Linux kernel support. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#ifndef __ORANGEFSKERNEL_H 208c2ecf20Sopenharmony_ci#define __ORANGEFSKERNEL_H 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <linux/kernel.h> 238c2ecf20Sopenharmony_ci#include <linux/moduleparam.h> 248c2ecf20Sopenharmony_ci#include <linux/statfs.h> 258c2ecf20Sopenharmony_ci#include <linux/backing-dev.h> 268c2ecf20Sopenharmony_ci#include <linux/device.h> 278c2ecf20Sopenharmony_ci#include <linux/mpage.h> 288c2ecf20Sopenharmony_ci#include <linux/namei.h> 298c2ecf20Sopenharmony_ci#include <linux/errno.h> 308c2ecf20Sopenharmony_ci#include <linux/init.h> 318c2ecf20Sopenharmony_ci#include <linux/module.h> 328c2ecf20Sopenharmony_ci#include <linux/slab.h> 338c2ecf20Sopenharmony_ci#include <linux/types.h> 348c2ecf20Sopenharmony_ci#include <linux/fs.h> 358c2ecf20Sopenharmony_ci#include <linux/vmalloc.h> 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#include <linux/aio.h> 388c2ecf20Sopenharmony_ci#include <linux/posix_acl.h> 398c2ecf20Sopenharmony_ci#include <linux/posix_acl_xattr.h> 408c2ecf20Sopenharmony_ci#include <linux/compat.h> 418c2ecf20Sopenharmony_ci#include <linux/mount.h> 428c2ecf20Sopenharmony_ci#include <linux/uaccess.h> 438c2ecf20Sopenharmony_ci#include <linux/atomic.h> 448c2ecf20Sopenharmony_ci#include <linux/uio.h> 458c2ecf20Sopenharmony_ci#include <linux/sched/signal.h> 468c2ecf20Sopenharmony_ci#include <linux/mm.h> 478c2ecf20Sopenharmony_ci#include <linux/wait.h> 488c2ecf20Sopenharmony_ci#include <linux/dcache.h> 498c2ecf20Sopenharmony_ci#include <linux/pagemap.h> 508c2ecf20Sopenharmony_ci#include <linux/poll.h> 518c2ecf20Sopenharmony_ci#include <linux/rwsem.h> 528c2ecf20Sopenharmony_ci#include <linux/xattr.h> 538c2ecf20Sopenharmony_ci#include <linux/exportfs.h> 548c2ecf20Sopenharmony_ci#include <linux/hashtable.h> 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#include <asm/unaligned.h> 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#include "orangefs-dev-proto.h" 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS 20 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS 30 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS 900 /* 15 minutes */ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define ORANGEFS_REQDEVICE_NAME "pvfs2-req" 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define ORANGEFS_DEVREQ_MAGIC 0x20030529 698c2ecf20Sopenharmony_ci#define ORANGEFS_PURGE_RETRY_COUNT 0x00000005 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define MAX_DEV_REQ_UPSIZE (2 * sizeof(__s32) + \ 728c2ecf20Sopenharmony_cisizeof(__u64) + sizeof(struct orangefs_upcall_s)) 738c2ecf20Sopenharmony_ci#define MAX_DEV_REQ_DOWNSIZE (2 * sizeof(__s32) + \ 748c2ecf20Sopenharmony_cisizeof(__u64) + sizeof(struct orangefs_downcall_s)) 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* 778c2ecf20Sopenharmony_ci * valid orangefs kernel operation states 788c2ecf20Sopenharmony_ci * 798c2ecf20Sopenharmony_ci * unknown - op was just initialized 808c2ecf20Sopenharmony_ci * waiting - op is on request_list (upward bound) 818c2ecf20Sopenharmony_ci * inprogr - op is in progress (waiting for downcall) 828c2ecf20Sopenharmony_ci * serviced - op has matching downcall; ok 838c2ecf20Sopenharmony_ci * purged - op has to start a timer since client-core 848c2ecf20Sopenharmony_ci * exited uncleanly before servicing op 858c2ecf20Sopenharmony_ci * given up - submitter has given up waiting for it 868c2ecf20Sopenharmony_ci */ 878c2ecf20Sopenharmony_cienum orangefs_vfs_op_states { 888c2ecf20Sopenharmony_ci OP_VFS_STATE_UNKNOWN = 0, 898c2ecf20Sopenharmony_ci OP_VFS_STATE_WAITING = 1, 908c2ecf20Sopenharmony_ci OP_VFS_STATE_INPROGR = 2, 918c2ecf20Sopenharmony_ci OP_VFS_STATE_SERVICED = 4, 928c2ecf20Sopenharmony_ci OP_VFS_STATE_PURGED = 8, 938c2ecf20Sopenharmony_ci OP_VFS_STATE_GIVEN_UP = 16, 948c2ecf20Sopenharmony_ci}; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* 978c2ecf20Sopenharmony_ci * orangefs kernel memory related flags 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#if (defined CONFIG_DEBUG_SLAB) 1018c2ecf20Sopenharmony_ci#define ORANGEFS_CACHE_CREATE_FLAGS SLAB_RED_ZONE 1028c2ecf20Sopenharmony_ci#else 1038c2ecf20Sopenharmony_ci#define ORANGEFS_CACHE_CREATE_FLAGS 0 1048c2ecf20Sopenharmony_ci#endif 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ciextern int orangefs_init_acl(struct inode *inode, struct inode *dir); 1078c2ecf20Sopenharmony_ciextern const struct xattr_handler *orangefs_xattr_handlers[]; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ciextern struct posix_acl *orangefs_get_acl(struct inode *inode, int type); 1108c2ecf20Sopenharmony_ciextern int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* 1138c2ecf20Sopenharmony_ci * orangefs data structures 1148c2ecf20Sopenharmony_ci */ 1158c2ecf20Sopenharmony_cistruct orangefs_kernel_op_s { 1168c2ecf20Sopenharmony_ci enum orangefs_vfs_op_states op_state; 1178c2ecf20Sopenharmony_ci __u64 tag; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci /* 1208c2ecf20Sopenharmony_ci * Set uses_shared_memory to non zero if this operation uses 1218c2ecf20Sopenharmony_ci * shared memory. If true, then a retry on the op must also 1228c2ecf20Sopenharmony_ci * get a new shared memory buffer and re-populate it. 1238c2ecf20Sopenharmony_ci * Cancels don't care - it only matters for service_operation() 1248c2ecf20Sopenharmony_ci * retry logics and cancels don't go through it anymore. It 1258c2ecf20Sopenharmony_ci * safely stays non-zero when we use it as slot_to_free. 1268c2ecf20Sopenharmony_ci */ 1278c2ecf20Sopenharmony_ci union { 1288c2ecf20Sopenharmony_ci int uses_shared_memory; 1298c2ecf20Sopenharmony_ci int slot_to_free; 1308c2ecf20Sopenharmony_ci }; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci struct orangefs_upcall_s upcall; 1338c2ecf20Sopenharmony_ci struct orangefs_downcall_s downcall; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci struct completion waitq; 1368c2ecf20Sopenharmony_ci spinlock_t lock; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci int attempts; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci struct list_head list; 1418c2ecf20Sopenharmony_ci}; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define set_op_state_waiting(op) ((op)->op_state = OP_VFS_STATE_WAITING) 1448c2ecf20Sopenharmony_ci#define set_op_state_inprogress(op) ((op)->op_state = OP_VFS_STATE_INPROGR) 1458c2ecf20Sopenharmony_ci#define set_op_state_given_up(op) ((op)->op_state = OP_VFS_STATE_GIVEN_UP) 1468c2ecf20Sopenharmony_cistatic inline void set_op_state_serviced(struct orangefs_kernel_op_s *op) 1478c2ecf20Sopenharmony_ci{ 1488c2ecf20Sopenharmony_ci op->op_state = OP_VFS_STATE_SERVICED; 1498c2ecf20Sopenharmony_ci complete(&op->waitq); 1508c2ecf20Sopenharmony_ci} 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci#define op_state_waiting(op) ((op)->op_state & OP_VFS_STATE_WAITING) 1538c2ecf20Sopenharmony_ci#define op_state_in_progress(op) ((op)->op_state & OP_VFS_STATE_INPROGR) 1548c2ecf20Sopenharmony_ci#define op_state_serviced(op) ((op)->op_state & OP_VFS_STATE_SERVICED) 1558c2ecf20Sopenharmony_ci#define op_state_purged(op) ((op)->op_state & OP_VFS_STATE_PURGED) 1568c2ecf20Sopenharmony_ci#define op_state_given_up(op) ((op)->op_state & OP_VFS_STATE_GIVEN_UP) 1578c2ecf20Sopenharmony_ci#define op_is_cancel(op) ((op)->upcall.type == ORANGEFS_VFS_OP_CANCEL) 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_civoid op_release(struct orangefs_kernel_op_s *op); 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ciextern void orangefs_bufmap_put(int); 1628c2ecf20Sopenharmony_cistatic inline void put_cancel(struct orangefs_kernel_op_s *op) 1638c2ecf20Sopenharmony_ci{ 1648c2ecf20Sopenharmony_ci orangefs_bufmap_put(op->slot_to_free); 1658c2ecf20Sopenharmony_ci op_release(op); 1668c2ecf20Sopenharmony_ci} 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_cistatic inline void set_op_state_purged(struct orangefs_kernel_op_s *op) 1698c2ecf20Sopenharmony_ci{ 1708c2ecf20Sopenharmony_ci spin_lock(&op->lock); 1718c2ecf20Sopenharmony_ci if (unlikely(op_is_cancel(op))) { 1728c2ecf20Sopenharmony_ci list_del_init(&op->list); 1738c2ecf20Sopenharmony_ci spin_unlock(&op->lock); 1748c2ecf20Sopenharmony_ci put_cancel(op); 1758c2ecf20Sopenharmony_ci } else { 1768c2ecf20Sopenharmony_ci op->op_state |= OP_VFS_STATE_PURGED; 1778c2ecf20Sopenharmony_ci complete(&op->waitq); 1788c2ecf20Sopenharmony_ci spin_unlock(&op->lock); 1798c2ecf20Sopenharmony_ci } 1808c2ecf20Sopenharmony_ci} 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/* per inode private orangefs info */ 1838c2ecf20Sopenharmony_cistruct orangefs_inode_s { 1848c2ecf20Sopenharmony_ci struct orangefs_object_kref refn; 1858c2ecf20Sopenharmony_ci char link_target[ORANGEFS_NAME_MAX]; 1868c2ecf20Sopenharmony_ci /* 1878c2ecf20Sopenharmony_ci * Reading/Writing Extended attributes need to acquire the appropriate 1888c2ecf20Sopenharmony_ci * reader/writer semaphore on the orangefs_inode_s structure. 1898c2ecf20Sopenharmony_ci */ 1908c2ecf20Sopenharmony_ci struct rw_semaphore xattr_sem; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci struct inode vfs_inode; 1938c2ecf20Sopenharmony_ci sector_t last_failed_block_index_read; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci unsigned long getattr_time; 1968c2ecf20Sopenharmony_ci unsigned long mapping_time; 1978c2ecf20Sopenharmony_ci int attr_valid; 1988c2ecf20Sopenharmony_ci kuid_t attr_uid; 1998c2ecf20Sopenharmony_ci kgid_t attr_gid; 2008c2ecf20Sopenharmony_ci unsigned long bitlock; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci DECLARE_HASHTABLE(xattr_cache, 4); 2038c2ecf20Sopenharmony_ci}; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci/* per superblock private orangefs info */ 2068c2ecf20Sopenharmony_cistruct orangefs_sb_info_s { 2078c2ecf20Sopenharmony_ci struct orangefs_khandle root_khandle; 2088c2ecf20Sopenharmony_ci __s32 fs_id; 2098c2ecf20Sopenharmony_ci int id; 2108c2ecf20Sopenharmony_ci int flags; 2118c2ecf20Sopenharmony_ci#define ORANGEFS_OPT_INTR 0x01 2128c2ecf20Sopenharmony_ci#define ORANGEFS_OPT_LOCAL_LOCK 0x02 2138c2ecf20Sopenharmony_ci char devname[ORANGEFS_MAX_SERVER_ADDR_LEN]; 2148c2ecf20Sopenharmony_ci struct super_block *sb; 2158c2ecf20Sopenharmony_ci int mount_pending; 2168c2ecf20Sopenharmony_ci int no_list; 2178c2ecf20Sopenharmony_ci struct list_head list; 2188c2ecf20Sopenharmony_ci}; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_cistruct orangefs_stats { 2218c2ecf20Sopenharmony_ci unsigned long cache_hits; 2228c2ecf20Sopenharmony_ci unsigned long cache_misses; 2238c2ecf20Sopenharmony_ci unsigned long reads; 2248c2ecf20Sopenharmony_ci unsigned long writes; 2258c2ecf20Sopenharmony_ci}; 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_cistruct orangefs_cached_xattr { 2288c2ecf20Sopenharmony_ci struct hlist_node node; 2298c2ecf20Sopenharmony_ci char key[ORANGEFS_MAX_XATTR_NAMELEN]; 2308c2ecf20Sopenharmony_ci char val[ORANGEFS_MAX_XATTR_VALUELEN]; 2318c2ecf20Sopenharmony_ci ssize_t length; 2328c2ecf20Sopenharmony_ci unsigned long timeout; 2338c2ecf20Sopenharmony_ci}; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_cistruct orangefs_write_range { 2368c2ecf20Sopenharmony_ci loff_t pos; 2378c2ecf20Sopenharmony_ci size_t len; 2388c2ecf20Sopenharmony_ci kuid_t uid; 2398c2ecf20Sopenharmony_ci kgid_t gid; 2408c2ecf20Sopenharmony_ci}; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ciextern struct orangefs_stats orangefs_stats; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci/* 2458c2ecf20Sopenharmony_ci * NOTE: See Documentation/filesystems/porting.rst for information 2468c2ecf20Sopenharmony_ci * on implementing FOO_I and properly accessing fs private data 2478c2ecf20Sopenharmony_ci */ 2488c2ecf20Sopenharmony_cistatic inline struct orangefs_inode_s *ORANGEFS_I(struct inode *inode) 2498c2ecf20Sopenharmony_ci{ 2508c2ecf20Sopenharmony_ci return container_of(inode, struct orangefs_inode_s, vfs_inode); 2518c2ecf20Sopenharmony_ci} 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_cistatic inline struct orangefs_sb_info_s *ORANGEFS_SB(struct super_block *sb) 2548c2ecf20Sopenharmony_ci{ 2558c2ecf20Sopenharmony_ci return (struct orangefs_sb_info_s *) sb->s_fs_info; 2568c2ecf20Sopenharmony_ci} 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci/* ino_t descends from "unsigned long", 8 bytes, 64 bits. */ 2598c2ecf20Sopenharmony_cistatic inline ino_t orangefs_khandle_to_ino(struct orangefs_khandle *khandle) 2608c2ecf20Sopenharmony_ci{ 2618c2ecf20Sopenharmony_ci union { 2628c2ecf20Sopenharmony_ci unsigned char u[8]; 2638c2ecf20Sopenharmony_ci __u64 ino; 2648c2ecf20Sopenharmony_ci } ihandle; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci ihandle.u[0] = khandle->u[0] ^ khandle->u[4]; 2678c2ecf20Sopenharmony_ci ihandle.u[1] = khandle->u[1] ^ khandle->u[5]; 2688c2ecf20Sopenharmony_ci ihandle.u[2] = khandle->u[2] ^ khandle->u[6]; 2698c2ecf20Sopenharmony_ci ihandle.u[3] = khandle->u[3] ^ khandle->u[7]; 2708c2ecf20Sopenharmony_ci ihandle.u[4] = khandle->u[12] ^ khandle->u[8]; 2718c2ecf20Sopenharmony_ci ihandle.u[5] = khandle->u[13] ^ khandle->u[9]; 2728c2ecf20Sopenharmony_ci ihandle.u[6] = khandle->u[14] ^ khandle->u[10]; 2738c2ecf20Sopenharmony_ci ihandle.u[7] = khandle->u[15] ^ khandle->u[11]; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci return ihandle.ino; 2768c2ecf20Sopenharmony_ci} 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_cistatic inline struct orangefs_khandle *get_khandle_from_ino(struct inode *inode) 2798c2ecf20Sopenharmony_ci{ 2808c2ecf20Sopenharmony_ci return &(ORANGEFS_I(inode)->refn.khandle); 2818c2ecf20Sopenharmony_ci} 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_cistatic inline int is_root_handle(struct inode *inode) 2848c2ecf20Sopenharmony_ci{ 2858c2ecf20Sopenharmony_ci gossip_debug(GOSSIP_DCACHE_DEBUG, 2868c2ecf20Sopenharmony_ci "%s: root handle: %pU, this handle: %pU:\n", 2878c2ecf20Sopenharmony_ci __func__, 2888c2ecf20Sopenharmony_ci &ORANGEFS_SB(inode->i_sb)->root_khandle, 2898c2ecf20Sopenharmony_ci get_khandle_from_ino(inode)); 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci if (ORANGEFS_khandle_cmp(&(ORANGEFS_SB(inode->i_sb)->root_khandle), 2928c2ecf20Sopenharmony_ci get_khandle_from_ino(inode))) 2938c2ecf20Sopenharmony_ci return 0; 2948c2ecf20Sopenharmony_ci else 2958c2ecf20Sopenharmony_ci return 1; 2968c2ecf20Sopenharmony_ci} 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_cistatic inline int match_handle(struct orangefs_khandle resp_handle, 2998c2ecf20Sopenharmony_ci struct inode *inode) 3008c2ecf20Sopenharmony_ci{ 3018c2ecf20Sopenharmony_ci gossip_debug(GOSSIP_DCACHE_DEBUG, 3028c2ecf20Sopenharmony_ci "%s: one handle: %pU, another handle:%pU:\n", 3038c2ecf20Sopenharmony_ci __func__, 3048c2ecf20Sopenharmony_ci &resp_handle, 3058c2ecf20Sopenharmony_ci get_khandle_from_ino(inode)); 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci if (ORANGEFS_khandle_cmp(&resp_handle, get_khandle_from_ino(inode))) 3088c2ecf20Sopenharmony_ci return 0; 3098c2ecf20Sopenharmony_ci else 3108c2ecf20Sopenharmony_ci return 1; 3118c2ecf20Sopenharmony_ci} 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci/* 3148c2ecf20Sopenharmony_ci * defined in orangefs-cache.c 3158c2ecf20Sopenharmony_ci */ 3168c2ecf20Sopenharmony_ciint op_cache_initialize(void); 3178c2ecf20Sopenharmony_ciint op_cache_finalize(void); 3188c2ecf20Sopenharmony_cistruct orangefs_kernel_op_s *op_alloc(__s32 type); 3198c2ecf20Sopenharmony_civoid orangefs_new_tag(struct orangefs_kernel_op_s *op); 3208c2ecf20Sopenharmony_cichar *get_opname_string(struct orangefs_kernel_op_s *new_op); 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ciint orangefs_inode_cache_initialize(void); 3238c2ecf20Sopenharmony_ciint orangefs_inode_cache_finalize(void); 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci/* 3268c2ecf20Sopenharmony_ci * defined in orangefs-mod.c 3278c2ecf20Sopenharmony_ci */ 3288c2ecf20Sopenharmony_civoid purge_inprogress_ops(void); 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci/* 3318c2ecf20Sopenharmony_ci * defined in waitqueue.c 3328c2ecf20Sopenharmony_ci */ 3338c2ecf20Sopenharmony_civoid purge_waiting_ops(void); 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci/* 3368c2ecf20Sopenharmony_ci * defined in super.c 3378c2ecf20Sopenharmony_ci */ 3388c2ecf20Sopenharmony_ciextern uint64_t orangefs_features; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_cistruct dentry *orangefs_mount(struct file_system_type *fst, 3418c2ecf20Sopenharmony_ci int flags, 3428c2ecf20Sopenharmony_ci const char *devname, 3438c2ecf20Sopenharmony_ci void *data); 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_civoid orangefs_kill_sb(struct super_block *sb); 3468c2ecf20Sopenharmony_ciint orangefs_remount(struct orangefs_sb_info_s *); 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_ciint fsid_key_table_initialize(void); 3498c2ecf20Sopenharmony_civoid fsid_key_table_finalize(void); 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci/* 3528c2ecf20Sopenharmony_ci * defined in inode.c 3538c2ecf20Sopenharmony_ci */ 3548c2ecf20Sopenharmony_civm_fault_t orangefs_page_mkwrite(struct vm_fault *); 3558c2ecf20Sopenharmony_cistruct inode *orangefs_new_inode(struct super_block *sb, 3568c2ecf20Sopenharmony_ci struct inode *dir, 3578c2ecf20Sopenharmony_ci int mode, 3588c2ecf20Sopenharmony_ci dev_t dev, 3598c2ecf20Sopenharmony_ci struct orangefs_object_kref *ref); 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ciint __orangefs_setattr(struct inode *, struct iattr *); 3628c2ecf20Sopenharmony_ciint orangefs_setattr(struct dentry *, struct iattr *); 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ciint orangefs_getattr(const struct path *path, struct kstat *stat, 3658c2ecf20Sopenharmony_ci u32 request_mask, unsigned int flags); 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ciint orangefs_permission(struct inode *inode, int mask); 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ciint orangefs_update_time(struct inode *, struct timespec64 *, int); 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci/* 3728c2ecf20Sopenharmony_ci * defined in xattr.c 3738c2ecf20Sopenharmony_ci */ 3748c2ecf20Sopenharmony_cissize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size); 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci/* 3778c2ecf20Sopenharmony_ci * defined in namei.c 3788c2ecf20Sopenharmony_ci */ 3798c2ecf20Sopenharmony_cistruct inode *orangefs_iget(struct super_block *sb, 3808c2ecf20Sopenharmony_ci struct orangefs_object_kref *ref); 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci/* 3838c2ecf20Sopenharmony_ci * defined in devorangefs-req.c 3848c2ecf20Sopenharmony_ci */ 3858c2ecf20Sopenharmony_ciextern uint32_t orangefs_userspace_version; 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ciint orangefs_dev_init(void); 3888c2ecf20Sopenharmony_civoid orangefs_dev_cleanup(void); 3898c2ecf20Sopenharmony_ciint is_daemon_in_service(void); 3908c2ecf20Sopenharmony_cibool __is_daemon_in_service(void); 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ci/* 3938c2ecf20Sopenharmony_ci * defined in file.c 3948c2ecf20Sopenharmony_ci */ 3958c2ecf20Sopenharmony_ciint orangefs_revalidate_mapping(struct inode *); 3968c2ecf20Sopenharmony_cissize_t wait_for_direct_io(enum ORANGEFS_io_type, struct inode *, loff_t *, 3978c2ecf20Sopenharmony_ci struct iov_iter *, size_t, loff_t, struct orangefs_write_range *, int *, 3988c2ecf20Sopenharmony_ci struct file *); 3998c2ecf20Sopenharmony_cissize_t do_readv_writev(enum ORANGEFS_io_type, struct file *, loff_t *, 4008c2ecf20Sopenharmony_ci struct iov_iter *); 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci/* 4038c2ecf20Sopenharmony_ci * defined in orangefs-utils.c 4048c2ecf20Sopenharmony_ci */ 4058c2ecf20Sopenharmony_ci__s32 fsid_of_op(struct orangefs_kernel_op_s *op); 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_cissize_t orangefs_inode_getxattr(struct inode *inode, 4088c2ecf20Sopenharmony_ci const char *name, 4098c2ecf20Sopenharmony_ci void *buffer, 4108c2ecf20Sopenharmony_ci size_t size); 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ciint orangefs_inode_setxattr(struct inode *inode, 4138c2ecf20Sopenharmony_ci const char *name, 4148c2ecf20Sopenharmony_ci const void *value, 4158c2ecf20Sopenharmony_ci size_t size, 4168c2ecf20Sopenharmony_ci int flags); 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci#define ORANGEFS_GETATTR_NEW 1 4198c2ecf20Sopenharmony_ci#define ORANGEFS_GETATTR_SIZE 2 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ciint orangefs_inode_getattr(struct inode *, int); 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ciint orangefs_inode_check_changed(struct inode *inode); 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ciint orangefs_inode_setattr(struct inode *inode); 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_cibool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op); 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ciint orangefs_normalize_to_errno(__s32 error_code); 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ciextern struct mutex orangefs_request_mutex; 4328c2ecf20Sopenharmony_ciextern int op_timeout_secs; 4338c2ecf20Sopenharmony_ciextern int slot_timeout_secs; 4348c2ecf20Sopenharmony_ciextern int orangefs_cache_timeout_msecs; 4358c2ecf20Sopenharmony_ciextern int orangefs_dcache_timeout_msecs; 4368c2ecf20Sopenharmony_ciextern int orangefs_getattr_timeout_msecs; 4378c2ecf20Sopenharmony_ciextern struct list_head orangefs_superblocks; 4388c2ecf20Sopenharmony_ciextern spinlock_t orangefs_superblocks_lock; 4398c2ecf20Sopenharmony_ciextern struct list_head orangefs_request_list; 4408c2ecf20Sopenharmony_ciextern spinlock_t orangefs_request_list_lock; 4418c2ecf20Sopenharmony_ciextern wait_queue_head_t orangefs_request_list_waitq; 4428c2ecf20Sopenharmony_ciextern struct list_head *orangefs_htable_ops_in_progress; 4438c2ecf20Sopenharmony_ciextern spinlock_t orangefs_htable_ops_in_progress_lock; 4448c2ecf20Sopenharmony_ciextern int hash_table_size; 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ciextern const struct file_operations orangefs_file_operations; 4478c2ecf20Sopenharmony_ciextern const struct inode_operations orangefs_symlink_inode_operations; 4488c2ecf20Sopenharmony_ciextern const struct inode_operations orangefs_dir_inode_operations; 4498c2ecf20Sopenharmony_ciextern const struct file_operations orangefs_dir_operations; 4508c2ecf20Sopenharmony_ciextern const struct dentry_operations orangefs_dentry_operations; 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci/* 4538c2ecf20Sopenharmony_ci * misc convenience macros 4548c2ecf20Sopenharmony_ci */ 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci#define ORANGEFS_OP_INTERRUPTIBLE 1 /* service_operation() is interruptible */ 4578c2ecf20Sopenharmony_ci#define ORANGEFS_OP_PRIORITY 2 /* service_operation() is high priority */ 4588c2ecf20Sopenharmony_ci#define ORANGEFS_OP_CANCELLATION 4 /* this is a cancellation */ 4598c2ecf20Sopenharmony_ci#define ORANGEFS_OP_NO_MUTEX 8 /* don't acquire request_mutex */ 4608c2ecf20Sopenharmony_ci#define ORANGEFS_OP_ASYNC 16 /* Queue it, but don't wait */ 4618c2ecf20Sopenharmony_ci#define ORANGEFS_OP_WRITEBACK 32 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ciint service_operation(struct orangefs_kernel_op_s *op, 4648c2ecf20Sopenharmony_ci const char *op_name, 4658c2ecf20Sopenharmony_ci int flags); 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci#define get_interruptible_flag(inode) \ 4688c2ecf20Sopenharmony_ci ((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \ 4698c2ecf20Sopenharmony_ci ORANGEFS_OP_INTERRUPTIBLE : 0) 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci#define fill_default_sys_attrs(sys_attr, type, mode) \ 4728c2ecf20Sopenharmony_cido { \ 4738c2ecf20Sopenharmony_ci sys_attr.owner = from_kuid(&init_user_ns, current_fsuid()); \ 4748c2ecf20Sopenharmony_ci sys_attr.group = from_kgid(&init_user_ns, current_fsgid()); \ 4758c2ecf20Sopenharmony_ci sys_attr.perms = ORANGEFS_util_translate_mode(mode); \ 4768c2ecf20Sopenharmony_ci sys_attr.mtime = 0; \ 4778c2ecf20Sopenharmony_ci sys_attr.atime = 0; \ 4788c2ecf20Sopenharmony_ci sys_attr.ctime = 0; \ 4798c2ecf20Sopenharmony_ci sys_attr.mask = ORANGEFS_ATTR_SYS_ALL_SETABLE; \ 4808c2ecf20Sopenharmony_ci} while (0) 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_cistatic inline void orangefs_set_timeout(struct dentry *dentry) 4838c2ecf20Sopenharmony_ci{ 4848c2ecf20Sopenharmony_ci unsigned long time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci dentry->d_fsdata = (void *) time; 4878c2ecf20Sopenharmony_ci} 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci#endif /* __ORANGEFSKERNEL_H */ 490