162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * linux/fs/nfs/delegation.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) Trond Myklebust 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Definitions pertaining to NFS delegated files 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci#ifndef FS_NFS_DELEGATION_H 1062306a36Sopenharmony_ci#define FS_NFS_DELEGATION_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_NFS_V4) 1362306a36Sopenharmony_ci/* 1462306a36Sopenharmony_ci * NFSv4 delegation 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_cistruct nfs_delegation { 1762306a36Sopenharmony_ci struct list_head super_list; 1862306a36Sopenharmony_ci const struct cred *cred; 1962306a36Sopenharmony_ci struct inode *inode; 2062306a36Sopenharmony_ci nfs4_stateid stateid; 2162306a36Sopenharmony_ci fmode_t type; 2262306a36Sopenharmony_ci unsigned long pagemod_limit; 2362306a36Sopenharmony_ci __u64 change_attr; 2462306a36Sopenharmony_ci unsigned long flags; 2562306a36Sopenharmony_ci refcount_t refcount; 2662306a36Sopenharmony_ci spinlock_t lock; 2762306a36Sopenharmony_ci struct rcu_head rcu; 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_cienum { 3162306a36Sopenharmony_ci NFS_DELEGATION_NEED_RECLAIM = 0, 3262306a36Sopenharmony_ci NFS_DELEGATION_RETURN, 3362306a36Sopenharmony_ci NFS_DELEGATION_RETURN_IF_CLOSED, 3462306a36Sopenharmony_ci NFS_DELEGATION_REFERENCED, 3562306a36Sopenharmony_ci NFS_DELEGATION_RETURNING, 3662306a36Sopenharmony_ci NFS_DELEGATION_REVOKED, 3762306a36Sopenharmony_ci NFS_DELEGATION_TEST_EXPIRED, 3862306a36Sopenharmony_ci NFS_DELEGATION_INODE_FREEING, 3962306a36Sopenharmony_ci NFS_DELEGATION_RETURN_DELAYED, 4062306a36Sopenharmony_ci}; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciint nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, 4362306a36Sopenharmony_ci fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit); 4462306a36Sopenharmony_civoid nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, 4562306a36Sopenharmony_ci fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit); 4662306a36Sopenharmony_ciint nfs4_inode_return_delegation(struct inode *inode); 4762306a36Sopenharmony_civoid nfs4_inode_return_delegation_on_close(struct inode *inode); 4862306a36Sopenharmony_ciint nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); 4962306a36Sopenharmony_civoid nfs_inode_evict_delegation(struct inode *inode); 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_cistruct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle); 5262306a36Sopenharmony_civoid nfs_server_return_all_delegations(struct nfs_server *); 5362306a36Sopenharmony_civoid nfs_expire_all_delegations(struct nfs_client *clp); 5462306a36Sopenharmony_civoid nfs_expire_unused_delegation_types(struct nfs_client *clp, fmode_t flags); 5562306a36Sopenharmony_civoid nfs_expire_unreferenced_delegations(struct nfs_client *clp); 5662306a36Sopenharmony_ciint nfs_client_return_marked_delegations(struct nfs_client *clp); 5762306a36Sopenharmony_ciint nfs_delegations_present(struct nfs_client *clp); 5862306a36Sopenharmony_civoid nfs_remove_bad_delegation(struct inode *inode, const nfs4_stateid *stateid); 5962306a36Sopenharmony_civoid nfs_delegation_mark_returned(struct inode *inode, const nfs4_stateid *stateid); 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_civoid nfs_delegation_mark_reclaim(struct nfs_client *clp); 6262306a36Sopenharmony_civoid nfs_delegation_reap_unclaimed(struct nfs_client *clp); 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_civoid nfs_mark_test_expired_all_delegations(struct nfs_client *clp); 6562306a36Sopenharmony_civoid nfs_test_expired_all_delegations(struct nfs_client *clp); 6662306a36Sopenharmony_civoid nfs_reap_expired_delegations(struct nfs_client *clp); 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci/* NFSv4 delegation-related procedures */ 6962306a36Sopenharmony_ciint nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync); 7062306a36Sopenharmony_ciint nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid); 7162306a36Sopenharmony_ciint nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid *stateid); 7262306a36Sopenharmony_cibool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, const struct cred **cred); 7362306a36Sopenharmony_cibool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_cistruct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode); 7662306a36Sopenharmony_civoid nfs_mark_delegation_referenced(struct nfs_delegation *delegation); 7762306a36Sopenharmony_ciint nfs4_have_delegation(struct inode *inode, fmode_t flags); 7862306a36Sopenharmony_ciint nfs4_check_delegation(struct inode *inode, fmode_t flags); 7962306a36Sopenharmony_cibool nfs4_delegation_flush_on_close(const struct inode *inode); 8062306a36Sopenharmony_civoid nfs_inode_find_delegation_state_and_recover(struct inode *inode, 8162306a36Sopenharmony_ci const nfs4_stateid *stateid); 8262306a36Sopenharmony_ciint nfs4_inode_make_writeable(struct inode *inode); 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#endif 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_cistatic inline int nfs_have_delegated_attributes(struct inode *inode) 8762306a36Sopenharmony_ci{ 8862306a36Sopenharmony_ci return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ); 8962306a36Sopenharmony_ci} 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#endif 92