1*1da177e4SLinus Torvalds /* 2*1da177e4SLinus Torvalds * linux/fs/nfs/delegation.h 3*1da177e4SLinus Torvalds * 4*1da177e4SLinus Torvalds * Copyright (c) Trond Myklebust 5*1da177e4SLinus Torvalds * 6*1da177e4SLinus Torvalds * Definitions pertaining to NFS delegated files 7*1da177e4SLinus Torvalds */ 8*1da177e4SLinus Torvalds #ifndef FS_NFS_DELEGATION_H 9*1da177e4SLinus Torvalds #define FS_NFS_DELEGATION_H 10*1da177e4SLinus Torvalds 11*1da177e4SLinus Torvalds #if defined(CONFIG_NFS_V4) 12*1da177e4SLinus Torvalds /* 13*1da177e4SLinus Torvalds * NFSv4 delegation 14*1da177e4SLinus Torvalds */ 15*1da177e4SLinus Torvalds struct nfs_delegation { 16*1da177e4SLinus Torvalds struct list_head super_list; 17*1da177e4SLinus Torvalds struct rpc_cred *cred; 18*1da177e4SLinus Torvalds struct inode *inode; 19*1da177e4SLinus Torvalds nfs4_stateid stateid; 20*1da177e4SLinus Torvalds int type; 21*1da177e4SLinus Torvalds #define NFS_DELEGATION_NEED_RECLAIM 1 22*1da177e4SLinus Torvalds long flags; 23*1da177e4SLinus Torvalds loff_t maxsize; 24*1da177e4SLinus Torvalds }; 25*1da177e4SLinus Torvalds 26*1da177e4SLinus Torvalds int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 27*1da177e4SLinus Torvalds void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 28*1da177e4SLinus Torvalds int nfs_inode_return_delegation(struct inode *inode); 29*1da177e4SLinus Torvalds int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); 30*1da177e4SLinus Torvalds 31*1da177e4SLinus Torvalds struct inode *nfs_delegation_find_inode(struct nfs4_client *clp, const struct nfs_fh *fhandle); 32*1da177e4SLinus Torvalds void nfs_return_all_delegations(struct super_block *sb); 33*1da177e4SLinus Torvalds void nfs_handle_cb_pathdown(struct nfs4_client *clp); 34*1da177e4SLinus Torvalds 35*1da177e4SLinus Torvalds void nfs_delegation_mark_reclaim(struct nfs4_client *clp); 36*1da177e4SLinus Torvalds void nfs_delegation_reap_unclaimed(struct nfs4_client *clp); 37*1da177e4SLinus Torvalds 38*1da177e4SLinus Torvalds /* NFSv4 delegation-related procedures */ 39*1da177e4SLinus Torvalds int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid); 40*1da177e4SLinus Torvalds int nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state); 41*1da177e4SLinus Torvalds 42*1da177e4SLinus Torvalds static inline int nfs_have_delegation(struct inode *inode, int flags) 43*1da177e4SLinus Torvalds { 44*1da177e4SLinus Torvalds flags &= FMODE_READ|FMODE_WRITE; 45*1da177e4SLinus Torvalds smp_rmb(); 46*1da177e4SLinus Torvalds if ((NFS_I(inode)->delegation_state & flags) == flags) 47*1da177e4SLinus Torvalds return 1; 48*1da177e4SLinus Torvalds return 0; 49*1da177e4SLinus Torvalds } 50*1da177e4SLinus Torvalds #else 51*1da177e4SLinus Torvalds static inline int nfs_have_delegation(struct inode *inode, int flags) 52*1da177e4SLinus Torvalds { 53*1da177e4SLinus Torvalds return 0; 54*1da177e4SLinus Torvalds } 55*1da177e4SLinus Torvalds #endif 56*1da177e4SLinus Torvalds 57*1da177e4SLinus Torvalds #endif 58