11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * linux/fs/nfs/delegation.h 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (c) Trond Myklebust 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * Definitions pertaining to NFS delegated files 71da177e4SLinus Torvalds */ 81da177e4SLinus Torvalds #ifndef FS_NFS_DELEGATION_H 91da177e4SLinus Torvalds #define FS_NFS_DELEGATION_H 101da177e4SLinus Torvalds 111da177e4SLinus Torvalds #if defined(CONFIG_NFS_V4) 121da177e4SLinus Torvalds /* 131da177e4SLinus Torvalds * NFSv4 delegation 141da177e4SLinus Torvalds */ 151da177e4SLinus Torvalds struct nfs_delegation { 161da177e4SLinus Torvalds struct list_head super_list; 171da177e4SLinus Torvalds struct rpc_cred *cred; 181da177e4SLinus Torvalds struct inode *inode; 191da177e4SLinus Torvalds nfs4_stateid stateid; 201da177e4SLinus Torvalds int type; 211da177e4SLinus Torvalds #define NFS_DELEGATION_NEED_RECLAIM 1 221da177e4SLinus Torvalds long flags; 231da177e4SLinus Torvalds loff_t maxsize; 24beb2a5ecSTrond Myklebust __u64 change_attr; 251da177e4SLinus Torvalds }; 261da177e4SLinus Torvalds 271da177e4SLinus Torvalds int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 281da177e4SLinus Torvalds void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 29cae7a073STrond Myklebust int __nfs_inode_return_delegation(struct inode *inode); 301da177e4SLinus Torvalds int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); 311da177e4SLinus Torvalds 32*adfa6f98SDavid Howells struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle); 331da177e4SLinus Torvalds void nfs_return_all_delegations(struct super_block *sb); 34*adfa6f98SDavid Howells void nfs_expire_all_delegations(struct nfs_client *clp); 35*adfa6f98SDavid Howells void nfs_handle_cb_pathdown(struct nfs_client *clp); 361da177e4SLinus Torvalds 37*adfa6f98SDavid Howells void nfs_delegation_mark_reclaim(struct nfs_client *clp); 38*adfa6f98SDavid Howells void nfs_delegation_reap_unclaimed(struct nfs_client *clp); 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds /* NFSv4 delegation-related procedures */ 411da177e4SLinus Torvalds int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid); 421da177e4SLinus Torvalds int nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state); 43888e694cSTrond Myklebust int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl); 443e4f6290STrond Myklebust int nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode); 451da177e4SLinus Torvalds 461da177e4SLinus Torvalds static inline int nfs_have_delegation(struct inode *inode, int flags) 471da177e4SLinus Torvalds { 481da177e4SLinus Torvalds flags &= FMODE_READ|FMODE_WRITE; 491da177e4SLinus Torvalds smp_rmb(); 501da177e4SLinus Torvalds if ((NFS_I(inode)->delegation_state & flags) == flags) 511da177e4SLinus Torvalds return 1; 521da177e4SLinus Torvalds return 0; 531da177e4SLinus Torvalds } 54cae7a073STrond Myklebust 55cae7a073STrond Myklebust static inline int nfs_inode_return_delegation(struct inode *inode) 56cae7a073STrond Myklebust { 57cae7a073STrond Myklebust int err = 0; 58cae7a073STrond Myklebust 59cae7a073STrond Myklebust if (NFS_I(inode)->delegation != NULL) 60cae7a073STrond Myklebust err = __nfs_inode_return_delegation(inode); 61cae7a073STrond Myklebust return err; 62cae7a073STrond Myklebust } 631da177e4SLinus Torvalds #else 641da177e4SLinus Torvalds static inline int nfs_have_delegation(struct inode *inode, int flags) 651da177e4SLinus Torvalds { 661da177e4SLinus Torvalds return 0; 671da177e4SLinus Torvalds } 68cae7a073STrond Myklebust 69cae7a073STrond Myklebust static inline int nfs_inode_return_delegation(struct inode *inode) 70cae7a073STrond Myklebust { 71cae7a073STrond Myklebust return 0; 72cae7a073STrond Myklebust } 731da177e4SLinus Torvalds #endif 741da177e4SLinus Torvalds 751da177e4SLinus Torvalds #endif 76