@@ -42,8 +42,7 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation)
set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags);
}
-static bool
-nfs4_is_valid_delegation(const struct nfs_delegation *delegation,
+bool nfs4_is_valid_delegation(const struct nfs_delegation *delegation,
fmode_t flags)
{
if (delegation != NULL && (delegation->type & flags) == flags &&
@@ -69,6 +69,7 @@ bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_state
bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode);
void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
+bool nfs4_is_valid_delegation(const struct nfs_delegation *delegation, fmode_t flags);
int nfs4_have_delegation(struct inode *inode, fmode_t flags);
int nfs4_check_delegation(struct inode *inode, fmode_t flags);
bool nfs4_delegation_flush_on_close(const struct inode *inode);
@@ -1436,11 +1436,7 @@ static int can_open_cached(struct nfs4_state *state, fmode_t mode,
static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode,
enum open_claim_type4 claim)
{
- if (delegation == NULL)
- return 0;
- if ((delegation->type & fmode) != fmode)
- return 0;
- if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags))
+ if (!nfs4_is_valid_delegation(delegation, fmode))
return 0;
switch (claim) {
case NFS4_OPEN_CLAIM_NULL:
If the delegation is marked as being revoked, we must not use it for cached opens. Fixes: 869f9dfa4d6d ("NFSv4: Fix races between nfs_remove_bad_delegation() and delegation return") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> --- fs/nfs/delegation.c | 3 +-- fs/nfs/delegation.h | 1 + fs/nfs/nfs4proc.c | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-)