1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2575e9461SMike Marshall /* 3575e9461SMike Marshall * (C) 2001 Clemson University and The University of Chicago 4575e9461SMike Marshall * 5575e9461SMike Marshall * See COPYING in top-level directory. 6575e9461SMike Marshall */ 7575e9461SMike Marshall 8575e9461SMike Marshall /* 9575e9461SMike Marshall * The ORANGEFS Linux kernel support allows ORANGEFS volumes to be mounted and 10575e9461SMike Marshall * accessed through the Linux VFS (i.e. using standard I/O system calls). 11575e9461SMike Marshall * This support is only needed on clients that wish to mount the file system. 12575e9461SMike Marshall * 13575e9461SMike Marshall */ 14575e9461SMike Marshall 15575e9461SMike Marshall /* 16575e9461SMike Marshall * Declarations and macros for the ORANGEFS Linux kernel support. 17575e9461SMike Marshall */ 18575e9461SMike Marshall 19575e9461SMike Marshall #ifndef __ORANGEFSKERNEL_H 20575e9461SMike Marshall #define __ORANGEFSKERNEL_H 21575e9461SMike Marshall 22575e9461SMike Marshall #include <linux/kernel.h> 23575e9461SMike Marshall #include <linux/moduleparam.h> 24575e9461SMike Marshall #include <linux/statfs.h> 25575e9461SMike Marshall #include <linux/backing-dev.h> 26575e9461SMike Marshall #include <linux/device.h> 27575e9461SMike Marshall #include <linux/mpage.h> 28575e9461SMike Marshall #include <linux/namei.h> 29575e9461SMike Marshall #include <linux/errno.h> 30575e9461SMike Marshall #include <linux/init.h> 31575e9461SMike Marshall #include <linux/module.h> 32575e9461SMike Marshall #include <linux/slab.h> 33575e9461SMike Marshall #include <linux/types.h> 34575e9461SMike Marshall #include <linux/fs.h> 35575e9461SMike Marshall #include <linux/vmalloc.h> 36575e9461SMike Marshall 37575e9461SMike Marshall #include <linux/aio.h> 38575e9461SMike Marshall #include <linux/posix_acl.h> 39575e9461SMike Marshall #include <linux/posix_acl_xattr.h> 40575e9461SMike Marshall #include <linux/compat.h> 41575e9461SMike Marshall #include <linux/mount.h> 42575e9461SMike Marshall #include <linux/uaccess.h> 43575e9461SMike Marshall #include <linux/atomic.h> 44575e9461SMike Marshall #include <linux/uio.h> 45174cd4b1SIngo Molnar #include <linux/sched/signal.h> 46575e9461SMike Marshall #include <linux/mm.h> 47575e9461SMike Marshall #include <linux/wait.h> 48575e9461SMike Marshall #include <linux/dcache.h> 49575e9461SMike Marshall #include <linux/pagemap.h> 50575e9461SMike Marshall #include <linux/poll.h> 51575e9461SMike Marshall #include <linux/rwsem.h> 52575e9461SMike Marshall #include <linux/xattr.h> 53575e9461SMike Marshall #include <linux/exportfs.h> 54fc2e2e9cSMartin Brandenburg #include <linux/hashtable.h> 55575e9461SMike Marshall 56575e9461SMike Marshall #include <asm/unaligned.h> 57575e9461SMike Marshall 58575e9461SMike Marshall #include "orangefs-dev-proto.h" 59575e9461SMike Marshall 60575e9461SMike Marshall #define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS 20 61575e9461SMike Marshall 62575e9461SMike Marshall #define ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS 30 63575e9461SMike Marshall 64575e9461SMike Marshall #define ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS 900 /* 15 minutes */ 65575e9461SMike Marshall 66575e9461SMike Marshall #define ORANGEFS_REQDEVICE_NAME "pvfs2-req" 67575e9461SMike Marshall 68575e9461SMike Marshall #define ORANGEFS_DEVREQ_MAGIC 0x20030529 69575e9461SMike Marshall #define ORANGEFS_PURGE_RETRY_COUNT 0x00000005 70575e9461SMike Marshall 71575e9461SMike Marshall #define MAX_DEV_REQ_UPSIZE (2 * sizeof(__s32) + \ 72575e9461SMike Marshall sizeof(__u64) + sizeof(struct orangefs_upcall_s)) 73575e9461SMike Marshall #define MAX_DEV_REQ_DOWNSIZE (2 * sizeof(__s32) + \ 74575e9461SMike Marshall sizeof(__u64) + sizeof(struct orangefs_downcall_s)) 75575e9461SMike Marshall 76575e9461SMike Marshall /* 77575e9461SMike Marshall * valid orangefs kernel operation states 78575e9461SMike Marshall * 79575e9461SMike Marshall * unknown - op was just initialized 80575e9461SMike Marshall * waiting - op is on request_list (upward bound) 81575e9461SMike Marshall * inprogr - op is in progress (waiting for downcall) 82575e9461SMike Marshall * serviced - op has matching downcall; ok 83575e9461SMike Marshall * purged - op has to start a timer since client-core 84575e9461SMike Marshall * exited uncleanly before servicing op 85ed42fe05SAl Viro * given up - submitter has given up waiting for it 86575e9461SMike Marshall */ 87575e9461SMike Marshall enum orangefs_vfs_op_states { 88575e9461SMike Marshall OP_VFS_STATE_UNKNOWN = 0, 89575e9461SMike Marshall OP_VFS_STATE_WAITING = 1, 90575e9461SMike Marshall OP_VFS_STATE_INPROGR = 2, 91575e9461SMike Marshall OP_VFS_STATE_SERVICED = 4, 92575e9461SMike Marshall OP_VFS_STATE_PURGED = 8, 93ed42fe05SAl Viro OP_VFS_STATE_GIVEN_UP = 16, 94575e9461SMike Marshall }; 95575e9461SMike Marshall 96575e9461SMike Marshall /* 97575e9461SMike Marshall * orangefs kernel memory related flags 98575e9461SMike Marshall */ 99575e9461SMike Marshall 100538e3048SMartin Brandenburg #if (defined CONFIG_DEBUG_SLAB) 101575e9461SMike Marshall #define ORANGEFS_CACHE_CREATE_FLAGS SLAB_RED_ZONE 102575e9461SMike Marshall #else 103575e9461SMike Marshall #define ORANGEFS_CACHE_CREATE_FLAGS 0 104538e3048SMartin Brandenburg #endif 105575e9461SMike Marshall 106575e9461SMike Marshall extern int orangefs_init_acl(struct inode *inode, struct inode *dir); 107575e9461SMike Marshall extern const struct xattr_handler *orangefs_xattr_handlers[]; 108575e9461SMike Marshall 109575e9461SMike Marshall extern struct posix_acl *orangefs_get_acl(struct inode *inode, int type); 110575e9461SMike Marshall extern int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 111575e9461SMike Marshall 112575e9461SMike Marshall /* 113575e9461SMike Marshall * orangefs data structures 114575e9461SMike Marshall */ 115575e9461SMike Marshall struct orangefs_kernel_op_s { 116575e9461SMike Marshall enum orangefs_vfs_op_states op_state; 117575e9461SMike Marshall __u64 tag; 118575e9461SMike Marshall 119575e9461SMike Marshall /* 120d37c0f30SMike Marshall * Set uses_shared_memory to non zero if this operation uses 121d37c0f30SMike Marshall * shared memory. If true, then a retry on the op must also 122d37c0f30SMike Marshall * get a new shared memory buffer and re-populate it. 123d37c0f30SMike Marshall * Cancels don't care - it only matters for service_operation() 124d37c0f30SMike Marshall * retry logics and cancels don't go through it anymore. It 125d37c0f30SMike Marshall * safely stays non-zero when we use it as slot_to_free. 126575e9461SMike Marshall */ 12778699e29SAl Viro union { 128575e9461SMike Marshall int uses_shared_memory; 12978699e29SAl Viro int slot_to_free; 13078699e29SAl Viro }; 131575e9461SMike Marshall 132575e9461SMike Marshall struct orangefs_upcall_s upcall; 133575e9461SMike Marshall struct orangefs_downcall_s downcall; 134575e9461SMike Marshall 135d2d87a3bSAl Viro struct completion waitq; 136575e9461SMike Marshall spinlock_t lock; 137575e9461SMike Marshall 138575e9461SMike Marshall int attempts; 139575e9461SMike Marshall 140575e9461SMike Marshall struct list_head list; 141575e9461SMike Marshall }; 142575e9461SMike Marshall 14360831949SAl Viro #define set_op_state_waiting(op) ((op)->op_state = OP_VFS_STATE_WAITING) 14460831949SAl Viro #define set_op_state_inprogress(op) ((op)->op_state = OP_VFS_STATE_INPROGR) 1452d4cae0dSMike Marshall #define set_op_state_given_up(op) ((op)->op_state = OP_VFS_STATE_GIVEN_UP) 14660831949SAl Viro static inline void set_op_state_serviced(struct orangefs_kernel_op_s *op) 14760831949SAl Viro { 14860831949SAl Viro op->op_state = OP_VFS_STATE_SERVICED; 149d2d87a3bSAl Viro complete(&op->waitq); 15060831949SAl Viro } 15160831949SAl Viro 15260831949SAl Viro #define op_state_waiting(op) ((op)->op_state & OP_VFS_STATE_WAITING) 15360831949SAl Viro #define op_state_in_progress(op) ((op)->op_state & OP_VFS_STATE_INPROGR) 15460831949SAl Viro #define op_state_serviced(op) ((op)->op_state & OP_VFS_STATE_SERVICED) 15560831949SAl Viro #define op_state_purged(op) ((op)->op_state & OP_VFS_STATE_PURGED) 156ed42fe05SAl Viro #define op_state_given_up(op) ((op)->op_state & OP_VFS_STATE_GIVEN_UP) 15778699e29SAl Viro #define op_is_cancel(op) ((op)->upcall.type == ORANGEFS_VFS_OP_CANCEL) 158ed42fe05SAl Viro 159c1223ca4SAl Viro void op_release(struct orangefs_kernel_op_s *op); 16060831949SAl Viro 16178699e29SAl Viro extern void orangefs_bufmap_put(int); 16278699e29SAl Viro static inline void put_cancel(struct orangefs_kernel_op_s *op) 16378699e29SAl Viro { 16478699e29SAl Viro orangefs_bufmap_put(op->slot_to_free); 16578699e29SAl Viro op_release(op); 16678699e29SAl Viro } 16778699e29SAl Viro 16878699e29SAl Viro static inline void set_op_state_purged(struct orangefs_kernel_op_s *op) 16978699e29SAl Viro { 17078699e29SAl Viro spin_lock(&op->lock); 17178699e29SAl Viro if (unlikely(op_is_cancel(op))) { 17205a50a5bSAl Viro list_del_init(&op->list); 17378699e29SAl Viro spin_unlock(&op->lock); 17478699e29SAl Viro put_cancel(op); 17578699e29SAl Viro } else { 17678699e29SAl Viro op->op_state |= OP_VFS_STATE_PURGED; 177d2d87a3bSAl Viro complete(&op->waitq); 17878699e29SAl Viro spin_unlock(&op->lock); 17978699e29SAl Viro } 18078699e29SAl Viro } 18178699e29SAl Viro 182575e9461SMike Marshall /* per inode private orangefs info */ 183575e9461SMike Marshall struct orangefs_inode_s { 184575e9461SMike Marshall struct orangefs_object_kref refn; 185575e9461SMike Marshall char link_target[ORANGEFS_NAME_MAX]; 186575e9461SMike Marshall /* 187575e9461SMike Marshall * Reading/Writing Extended attributes need to acquire the appropriate 188575e9461SMike Marshall * reader/writer semaphore on the orangefs_inode_s structure. 189575e9461SMike Marshall */ 190575e9461SMike Marshall struct rw_semaphore xattr_sem; 191575e9461SMike Marshall 192575e9461SMike Marshall struct inode vfs_inode; 193575e9461SMike Marshall sector_t last_failed_block_index_read; 194575e9461SMike Marshall 19571680c18SMartin Brandenburg unsigned long getattr_time; 196afd9fb2aSMartin Brandenburg int attr_valid; 197afd9fb2aSMartin Brandenburg kuid_t attr_uid; 198afd9fb2aSMartin Brandenburg kgid_t attr_gid; 199fc2e2e9cSMartin Brandenburg 200fc2e2e9cSMartin Brandenburg DECLARE_HASHTABLE(xattr_cache, 4); 201575e9461SMike Marshall }; 202575e9461SMike Marshall 203575e9461SMike Marshall /* per superblock private orangefs info */ 204575e9461SMike Marshall struct orangefs_sb_info_s { 205575e9461SMike Marshall struct orangefs_khandle root_khandle; 206575e9461SMike Marshall __s32 fs_id; 207575e9461SMike Marshall int id; 208575e9461SMike Marshall int flags; 209575e9461SMike Marshall #define ORANGEFS_OPT_INTR 0x01 210575e9461SMike Marshall #define ORANGEFS_OPT_LOCAL_LOCK 0x02 211575e9461SMike Marshall char devname[ORANGEFS_MAX_SERVER_ADDR_LEN]; 212575e9461SMike Marshall struct super_block *sb; 213575e9461SMike Marshall int mount_pending; 2141ec1688cSMartin Brandenburg int no_list; 215575e9461SMike Marshall struct list_head list; 216575e9461SMike Marshall }; 217575e9461SMike Marshall 218575e9461SMike Marshall struct orangefs_stats { 219575e9461SMike Marshall unsigned long cache_hits; 220575e9461SMike Marshall unsigned long cache_misses; 221575e9461SMike Marshall unsigned long reads; 222575e9461SMike Marshall unsigned long writes; 223575e9461SMike Marshall }; 224575e9461SMike Marshall 225fc2e2e9cSMartin Brandenburg struct orangefs_cached_xattr { 226fc2e2e9cSMartin Brandenburg struct hlist_node node; 227fc2e2e9cSMartin Brandenburg char key[ORANGEFS_MAX_XATTR_NAMELEN]; 228fc2e2e9cSMartin Brandenburg char val[ORANGEFS_MAX_XATTR_VALUELEN]; 229fc2e2e9cSMartin Brandenburg ssize_t length; 230fc2e2e9cSMartin Brandenburg unsigned long timeout; 231fc2e2e9cSMartin Brandenburg }; 232fc2e2e9cSMartin Brandenburg 233889d5f1bSMartin Brandenburg extern struct orangefs_stats orangefs_stats; 234575e9461SMike Marshall 235575e9461SMike Marshall /* 236575e9461SMike Marshall * NOTE: See Documentation/filesystems/porting for information 237575e9461SMike Marshall * on implementing FOO_I and properly accessing fs private data 238575e9461SMike Marshall */ 239575e9461SMike Marshall static inline struct orangefs_inode_s *ORANGEFS_I(struct inode *inode) 240575e9461SMike Marshall { 241575e9461SMike Marshall return container_of(inode, struct orangefs_inode_s, vfs_inode); 242575e9461SMike Marshall } 243575e9461SMike Marshall 244575e9461SMike Marshall static inline struct orangefs_sb_info_s *ORANGEFS_SB(struct super_block *sb) 245575e9461SMike Marshall { 246575e9461SMike Marshall return (struct orangefs_sb_info_s *) sb->s_fs_info; 247575e9461SMike Marshall } 248575e9461SMike Marshall 249575e9461SMike Marshall /* ino_t descends from "unsigned long", 8 bytes, 64 bits. */ 250575e9461SMike Marshall static inline ino_t orangefs_khandle_to_ino(struct orangefs_khandle *khandle) 251575e9461SMike Marshall { 252575e9461SMike Marshall union { 253575e9461SMike Marshall unsigned char u[8]; 254575e9461SMike Marshall __u64 ino; 255575e9461SMike Marshall } ihandle; 256575e9461SMike Marshall 257575e9461SMike Marshall ihandle.u[0] = khandle->u[0] ^ khandle->u[4]; 258575e9461SMike Marshall ihandle.u[1] = khandle->u[1] ^ khandle->u[5]; 259575e9461SMike Marshall ihandle.u[2] = khandle->u[2] ^ khandle->u[6]; 260575e9461SMike Marshall ihandle.u[3] = khandle->u[3] ^ khandle->u[7]; 261575e9461SMike Marshall ihandle.u[4] = khandle->u[12] ^ khandle->u[8]; 262575e9461SMike Marshall ihandle.u[5] = khandle->u[13] ^ khandle->u[9]; 263575e9461SMike Marshall ihandle.u[6] = khandle->u[14] ^ khandle->u[10]; 264575e9461SMike Marshall ihandle.u[7] = khandle->u[15] ^ khandle->u[11]; 265575e9461SMike Marshall 266575e9461SMike Marshall return ihandle.ino; 267575e9461SMike Marshall } 268575e9461SMike Marshall 269575e9461SMike Marshall static inline struct orangefs_khandle *get_khandle_from_ino(struct inode *inode) 270575e9461SMike Marshall { 271575e9461SMike Marshall return &(ORANGEFS_I(inode)->refn.khandle); 272575e9461SMike Marshall } 273575e9461SMike Marshall 274575e9461SMike Marshall static inline int is_root_handle(struct inode *inode) 275575e9461SMike Marshall { 276575e9461SMike Marshall gossip_debug(GOSSIP_DCACHE_DEBUG, 277575e9461SMike Marshall "%s: root handle: %pU, this handle: %pU:\n", 278575e9461SMike Marshall __func__, 279575e9461SMike Marshall &ORANGEFS_SB(inode->i_sb)->root_khandle, 280575e9461SMike Marshall get_khandle_from_ino(inode)); 281575e9461SMike Marshall 282575e9461SMike Marshall if (ORANGEFS_khandle_cmp(&(ORANGEFS_SB(inode->i_sb)->root_khandle), 283575e9461SMike Marshall get_khandle_from_ino(inode))) 284575e9461SMike Marshall return 0; 285575e9461SMike Marshall else 286575e9461SMike Marshall return 1; 287575e9461SMike Marshall } 288575e9461SMike Marshall 289575e9461SMike Marshall static inline int match_handle(struct orangefs_khandle resp_handle, 290575e9461SMike Marshall struct inode *inode) 291575e9461SMike Marshall { 292575e9461SMike Marshall gossip_debug(GOSSIP_DCACHE_DEBUG, 293575e9461SMike Marshall "%s: one handle: %pU, another handle:%pU:\n", 294575e9461SMike Marshall __func__, 295575e9461SMike Marshall &resp_handle, 296575e9461SMike Marshall get_khandle_from_ino(inode)); 297575e9461SMike Marshall 298575e9461SMike Marshall if (ORANGEFS_khandle_cmp(&resp_handle, get_khandle_from_ino(inode))) 299575e9461SMike Marshall return 0; 300575e9461SMike Marshall else 301575e9461SMike Marshall return 1; 302575e9461SMike Marshall } 303575e9461SMike Marshall 304575e9461SMike Marshall /* 305575e9461SMike Marshall * defined in orangefs-cache.c 306575e9461SMike Marshall */ 307575e9461SMike Marshall int op_cache_initialize(void); 308575e9461SMike Marshall int op_cache_finalize(void); 309575e9461SMike Marshall struct orangefs_kernel_op_s *op_alloc(__s32 type); 31078699e29SAl Viro void orangefs_new_tag(struct orangefs_kernel_op_s *op); 311575e9461SMike Marshall char *get_opname_string(struct orangefs_kernel_op_s *new_op); 312575e9461SMike Marshall 313575e9461SMike Marshall int orangefs_inode_cache_initialize(void); 314575e9461SMike Marshall int orangefs_inode_cache_finalize(void); 315575e9461SMike Marshall 316575e9461SMike Marshall /* 317575e9461SMike Marshall * defined in orangefs-mod.c 318575e9461SMike Marshall */ 319575e9461SMike Marshall void purge_inprogress_ops(void); 320575e9461SMike Marshall 321575e9461SMike Marshall /* 322575e9461SMike Marshall * defined in waitqueue.c 323575e9461SMike Marshall */ 324575e9461SMike Marshall void purge_waiting_ops(void); 325575e9461SMike Marshall 326575e9461SMike Marshall /* 327575e9461SMike Marshall * defined in super.c 328575e9461SMike Marshall */ 329482664ddSMartin Brandenburg extern uint64_t orangefs_features; 330482664ddSMartin Brandenburg 331575e9461SMike Marshall struct dentry *orangefs_mount(struct file_system_type *fst, 332575e9461SMike Marshall int flags, 333575e9461SMike Marshall const char *devname, 334575e9461SMike Marshall void *data); 335575e9461SMike Marshall 336575e9461SMike Marshall void orangefs_kill_sb(struct super_block *sb); 33745996492SAl Viro int orangefs_remount(struct orangefs_sb_info_s *); 338575e9461SMike Marshall 339575e9461SMike Marshall int fsid_key_table_initialize(void); 340575e9461SMike Marshall void fsid_key_table_finalize(void); 341575e9461SMike Marshall 342575e9461SMike Marshall /* 343575e9461SMike Marshall * defined in inode.c 344575e9461SMike Marshall */ 345575e9461SMike Marshall struct inode *orangefs_new_inode(struct super_block *sb, 346575e9461SMike Marshall struct inode *dir, 347575e9461SMike Marshall int mode, 348575e9461SMike Marshall dev_t dev, 349575e9461SMike Marshall struct orangefs_object_kref *ref); 350575e9461SMike Marshall 351afd9fb2aSMartin Brandenburg int __orangefs_setattr(struct inode *, struct iattr *); 352afd9fb2aSMartin Brandenburg int orangefs_setattr(struct dentry *, struct iattr *); 353575e9461SMike Marshall 354a528d35eSDavid Howells int orangefs_getattr(const struct path *path, struct kstat *stat, 355a528d35eSDavid Howells u32 request_mask, unsigned int flags); 356575e9461SMike Marshall 357933287daSMartin Brandenburg int orangefs_permission(struct inode *inode, int mask); 358933287daSMartin Brandenburg 35995582b00SDeepa Dinamani int orangefs_update_time(struct inode *, struct timespec64 *, int); 360a55f2d86SMartin Brandenburg 361575e9461SMike Marshall /* 362575e9461SMike Marshall * defined in xattr.c 363575e9461SMike Marshall */ 364575e9461SMike Marshall ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size); 365575e9461SMike Marshall 366575e9461SMike Marshall /* 367575e9461SMike Marshall * defined in namei.c 368575e9461SMike Marshall */ 369575e9461SMike Marshall struct inode *orangefs_iget(struct super_block *sb, 370575e9461SMike Marshall struct orangefs_object_kref *ref); 371575e9461SMike Marshall 372575e9461SMike Marshall ssize_t orangefs_inode_read(struct inode *inode, 373575e9461SMike Marshall struct iov_iter *iter, 374575e9461SMike Marshall loff_t *offset, 375575e9461SMike Marshall loff_t readahead_size); 376575e9461SMike Marshall 377575e9461SMike Marshall /* 378575e9461SMike Marshall * defined in devorangefs-req.c 379575e9461SMike Marshall */ 380482664ddSMartin Brandenburg extern uint32_t orangefs_userspace_version; 381f2ee3b75SMartin Brandenburg 382575e9461SMike Marshall int orangefs_dev_init(void); 383575e9461SMike Marshall void orangefs_dev_cleanup(void); 384575e9461SMike Marshall int is_daemon_in_service(void); 38578699e29SAl Viro bool __is_daemon_in_service(void); 386575e9461SMike Marshall 387575e9461SMike Marshall /* 388575e9461SMike Marshall * defined in orangefs-utils.c 389575e9461SMike Marshall */ 390575e9461SMike Marshall __s32 fsid_of_op(struct orangefs_kernel_op_s *op); 391575e9461SMike Marshall 392575e9461SMike Marshall ssize_t orangefs_inode_getxattr(struct inode *inode, 393575e9461SMike Marshall const char *name, 394575e9461SMike Marshall void *buffer, 395575e9461SMike Marshall size_t size); 396575e9461SMike Marshall 397575e9461SMike Marshall int orangefs_inode_setxattr(struct inode *inode, 398575e9461SMike Marshall const char *name, 399575e9461SMike Marshall const void *value, 400575e9461SMike Marshall size_t size, 401575e9461SMike Marshall int flags); 402575e9461SMike Marshall 4038b60785cSMartin Brandenburg #define ORANGEFS_GETATTR_NEW 1 4048b60785cSMartin Brandenburg #define ORANGEFS_GETATTR_SIZE 2 4058b60785cSMartin Brandenburg 4068b60785cSMartin Brandenburg int orangefs_inode_getattr(struct inode *, int); 407575e9461SMike Marshall 4085859d77eSMartin Brandenburg int orangefs_inode_check_changed(struct inode *inode); 4095859d77eSMartin Brandenburg 410afd9fb2aSMartin Brandenburg int orangefs_inode_setattr(struct inode *inode); 411575e9461SMike Marshall 41278699e29SAl Viro bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op); 413575e9461SMike Marshall 414575e9461SMike Marshall int orangefs_normalize_to_errno(__s32 error_code); 415575e9461SMike Marshall 4161d503617SMartin Brandenburg extern struct mutex orangefs_request_mutex; 417575e9461SMike Marshall extern int op_timeout_secs; 418575e9461SMike Marshall extern int slot_timeout_secs; 4191d503617SMartin Brandenburg extern int orangefs_dcache_timeout_msecs; 4201d503617SMartin Brandenburg extern int orangefs_getattr_timeout_msecs; 421575e9461SMike Marshall extern struct list_head orangefs_superblocks; 422575e9461SMike Marshall extern spinlock_t orangefs_superblocks_lock; 423575e9461SMike Marshall extern struct list_head orangefs_request_list; 424575e9461SMike Marshall extern spinlock_t orangefs_request_list_lock; 425575e9461SMike Marshall extern wait_queue_head_t orangefs_request_list_waitq; 4261d503617SMartin Brandenburg extern struct list_head *orangefs_htable_ops_in_progress; 4271d503617SMartin Brandenburg extern spinlock_t orangefs_htable_ops_in_progress_lock; 428575e9461SMike Marshall extern int hash_table_size; 429575e9461SMike Marshall 430575e9461SMike Marshall extern const struct file_operations orangefs_file_operations; 4316f3fc107SAl Viro extern const struct inode_operations orangefs_symlink_inode_operations; 4326f3fc107SAl Viro extern const struct inode_operations orangefs_dir_inode_operations; 433575e9461SMike Marshall extern const struct file_operations orangefs_dir_operations; 434575e9461SMike Marshall extern const struct dentry_operations orangefs_dentry_operations; 435575e9461SMike Marshall 436575e9461SMike Marshall /* 437575e9461SMike Marshall * misc convenience macros 438575e9461SMike Marshall */ 439575e9461SMike Marshall 440575e9461SMike Marshall #define ORANGEFS_OP_INTERRUPTIBLE 1 /* service_operation() is interruptible */ 441575e9461SMike Marshall #define ORANGEFS_OP_PRIORITY 2 /* service_operation() is high priority */ 442575e9461SMike Marshall #define ORANGEFS_OP_CANCELLATION 4 /* this is a cancellation */ 443adcf34a2SMike Marshall #define ORANGEFS_OP_NO_MUTEX 8 /* don't acquire request_mutex */ 444575e9461SMike Marshall #define ORANGEFS_OP_ASYNC 16 /* Queue it, but don't wait */ 445575e9461SMike Marshall 446575e9461SMike Marshall int service_operation(struct orangefs_kernel_op_s *op, 447575e9461SMike Marshall const char *op_name, 448575e9461SMike Marshall int flags); 449575e9461SMike Marshall 450575e9461SMike Marshall #define get_interruptible_flag(inode) \ 451575e9461SMike Marshall ((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \ 452575e9461SMike Marshall ORANGEFS_OP_INTERRUPTIBLE : 0) 453575e9461SMike Marshall 454575e9461SMike Marshall #define fill_default_sys_attrs(sys_attr, type, mode) \ 455575e9461SMike Marshall do { \ 45678fee0b6SJann Horn sys_attr.owner = from_kuid(&init_user_ns, current_fsuid()); \ 45778fee0b6SJann Horn sys_attr.group = from_kgid(&init_user_ns, current_fsgid()); \ 458575e9461SMike Marshall sys_attr.perms = ORANGEFS_util_translate_mode(mode); \ 45969a23de2SMartin Brandenburg sys_attr.mtime = 0; \ 46069a23de2SMartin Brandenburg sys_attr.atime = 0; \ 46169a23de2SMartin Brandenburg sys_attr.ctime = 0; \ 462575e9461SMike Marshall sys_attr.mask = ORANGEFS_ATTR_SYS_ALL_SETABLE; \ 463575e9461SMike Marshall } while (0) 464575e9461SMike Marshall 465804b1737SMiklos Szeredi static inline void orangefs_set_timeout(struct dentry *dentry) 466804b1737SMiklos Szeredi { 467804b1737SMiklos Szeredi unsigned long time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; 468804b1737SMiklos Szeredi 469804b1737SMiklos Szeredi dentry->d_fsdata = (void *) time; 470804b1737SMiklos Szeredi } 471804b1737SMiklos Szeredi 472575e9461SMike Marshall #endif /* __ORANGEFSKERNEL_H */ 473