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; 241da177e4SLinus Torvalds }; 251da177e4SLinus Torvalds 261da177e4SLinus Torvalds int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 271da177e4SLinus Torvalds void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 28cae7a073STrond Myklebust int __nfs_inode_return_delegation(struct inode *inode); 291da177e4SLinus Torvalds int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); 301da177e4SLinus Torvalds 311da177e4SLinus Torvalds struct inode *nfs_delegation_find_inode(struct nfs4_client *clp, const struct nfs_fh *fhandle); 321da177e4SLinus Torvalds void nfs_return_all_delegations(struct super_block *sb); 331da177e4SLinus Torvalds void nfs_handle_cb_pathdown(struct nfs4_client *clp); 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds void nfs_delegation_mark_reclaim(struct nfs4_client *clp); 361da177e4SLinus Torvalds void nfs_delegation_reap_unclaimed(struct nfs4_client *clp); 371da177e4SLinus Torvalds 381da177e4SLinus Torvalds /* NFSv4 delegation-related procedures */ 391da177e4SLinus Torvalds int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid); 401da177e4SLinus Torvalds int nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state); 41*888e694cSTrond Myklebust int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl); 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds static inline int nfs_have_delegation(struct inode *inode, int flags) 441da177e4SLinus Torvalds { 451da177e4SLinus Torvalds flags &= FMODE_READ|FMODE_WRITE; 461da177e4SLinus Torvalds smp_rmb(); 471da177e4SLinus Torvalds if ((NFS_I(inode)->delegation_state & flags) == flags) 481da177e4SLinus Torvalds return 1; 491da177e4SLinus Torvalds return 0; 501da177e4SLinus Torvalds } 51cae7a073STrond Myklebust 52cae7a073STrond Myklebust static inline int nfs_inode_return_delegation(struct inode *inode) 53cae7a073STrond Myklebust { 54cae7a073STrond Myklebust int err = 0; 55cae7a073STrond Myklebust 56cae7a073STrond Myklebust if (NFS_I(inode)->delegation != NULL) 57cae7a073STrond Myklebust err = __nfs_inode_return_delegation(inode); 58cae7a073STrond Myklebust return err; 59cae7a073STrond Myklebust } 601da177e4SLinus Torvalds #else 611da177e4SLinus Torvalds static inline int nfs_have_delegation(struct inode *inode, int flags) 621da177e4SLinus Torvalds { 631da177e4SLinus Torvalds return 0; 641da177e4SLinus Torvalds } 65cae7a073STrond Myklebust 66cae7a073STrond Myklebust static inline int nfs_inode_return_delegation(struct inode *inode) 67cae7a073STrond Myklebust { 68cae7a073STrond Myklebust return 0; 69cae7a073STrond Myklebust } 701da177e4SLinus Torvalds #endif 711da177e4SLinus Torvalds 721da177e4SLinus Torvalds #endif 73