Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * linux/fs/nfs/delegation.h
0004  *
0005  * Copyright (c) Trond Myklebust
0006  *
0007  * Definitions pertaining to NFS delegated files
0008  */
0009 #ifndef FS_NFS_DELEGATION_H
0010 #define FS_NFS_DELEGATION_H
0011 
0012 #if IS_ENABLED(CONFIG_NFS_V4)
0013 /*
0014  * NFSv4 delegation
0015  */
0016 struct nfs_delegation {
0017     struct list_head super_list;
0018     const struct cred *cred;
0019     struct inode *inode;
0020     nfs4_stateid stateid;
0021     fmode_t type;
0022     unsigned long pagemod_limit;
0023     __u64 change_attr;
0024     unsigned long flags;
0025     refcount_t refcount;
0026     spinlock_t lock;
0027     struct rcu_head rcu;
0028 };
0029 
0030 enum {
0031     NFS_DELEGATION_NEED_RECLAIM = 0,
0032     NFS_DELEGATION_RETURN,
0033     NFS_DELEGATION_RETURN_IF_CLOSED,
0034     NFS_DELEGATION_REFERENCED,
0035     NFS_DELEGATION_RETURNING,
0036     NFS_DELEGATION_REVOKED,
0037     NFS_DELEGATION_TEST_EXPIRED,
0038     NFS_DELEGATION_INODE_FREEING,
0039     NFS_DELEGATION_RETURN_DELAYED,
0040 };
0041 
0042 int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,
0043         fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit);
0044 void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred,
0045         fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit);
0046 int nfs4_inode_return_delegation(struct inode *inode);
0047 void nfs4_inode_return_delegation_on_close(struct inode *inode);
0048 int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid);
0049 void nfs_inode_evict_delegation(struct inode *inode);
0050 
0051 struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle);
0052 void nfs_server_return_all_delegations(struct nfs_server *);
0053 void nfs_expire_all_delegations(struct nfs_client *clp);
0054 void nfs_expire_unused_delegation_types(struct nfs_client *clp, fmode_t flags);
0055 void nfs_expire_unreferenced_delegations(struct nfs_client *clp);
0056 int nfs_client_return_marked_delegations(struct nfs_client *clp);
0057 int nfs_delegations_present(struct nfs_client *clp);
0058 void nfs_remove_bad_delegation(struct inode *inode, const nfs4_stateid *stateid);
0059 void nfs_delegation_mark_returned(struct inode *inode, const nfs4_stateid *stateid);
0060 
0061 void nfs_delegation_mark_reclaim(struct nfs_client *clp);
0062 void nfs_delegation_reap_unclaimed(struct nfs_client *clp);
0063 
0064 void nfs_mark_test_expired_all_delegations(struct nfs_client *clp);
0065 void nfs_test_expired_all_delegations(struct nfs_client *clp);
0066 void nfs_reap_expired_delegations(struct nfs_client *clp);
0067 
0068 /* NFSv4 delegation-related procedures */
0069 int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync);
0070 int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid);
0071 int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid *stateid);
0072 bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, const struct cred **cred);
0073 bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode);
0074 
0075 struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode);
0076 void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
0077 int nfs4_have_delegation(struct inode *inode, fmode_t flags);
0078 int nfs4_check_delegation(struct inode *inode, fmode_t flags);
0079 bool nfs4_delegation_flush_on_close(const struct inode *inode);
0080 void nfs_inode_find_delegation_state_and_recover(struct inode *inode,
0081         const nfs4_stateid *stateid);
0082 int nfs4_inode_make_writeable(struct inode *inode);
0083 
0084 #endif
0085 
0086 static inline int nfs_have_delegated_attributes(struct inode *inode)
0087 {
0088     return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ);
0089 }
0090 
0091 #endif