Skip to content

Commit

Permalink
nfsd: make nfs4_get_existing_delegation less confusing
Browse files Browse the repository at this point in the history
This doesn't "get" anything.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
  • Loading branch information
J. Bruce Fields committed Mar 20, 2018
1 parent 0c911f5 commit 68b18f5
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,20 +900,16 @@ void nfs4_unhash_stid(struct nfs4_stid *s)
}

/**
* nfs4_get_existing_delegation - Discover if this delegation already exists
* nfs4_delegation_exists - Discover if this delegation already exists
* @clp: a pointer to the nfs4_client we're granting a delegation to
* @fp: a pointer to the nfs4_file we're granting a delegation on
*
* Return:
* On success: NULL if an existing delegation was not found.
*
* On error: -EAGAIN if one was previously granted to this nfs4_client
* for this nfs4_file.
*
* On success: true iff an existing delegation is found
*/

static int
nfs4_get_existing_delegation(struct nfs4_client *clp, struct nfs4_file *fp)
static bool
nfs4_delegation_exists(struct nfs4_client *clp, struct nfs4_file *fp)
{
struct nfs4_delegation *searchdp = NULL;
struct nfs4_client *searchclp = NULL;
Expand Down Expand Up @@ -946,15 +942,13 @@ nfs4_get_existing_delegation(struct nfs4_client *clp, struct nfs4_file *fp)
static int
hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp)
{
int status;
struct nfs4_client *clp = dp->dl_stid.sc_client;

lockdep_assert_held(&state_lock);
lockdep_assert_held(&fp->fi_lock);

status = nfs4_get_existing_delegation(clp, fp);
if (status)
return status;
if (nfs4_delegation_exists(clp, fp))
return -EAGAIN;
++fp->fi_delegees;
refcount_inc(&dp->dl_stid.sc_count);
dp->dl_stid.sc_type = NFS4_DELEG_STID;
Expand Down Expand Up @@ -4391,15 +4385,16 @@ static struct nfs4_delegation *
nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
struct nfs4_file *fp, struct nfs4_clnt_odstate *odstate)
{
int status;
int status = 0;
struct nfs4_delegation *dp;

if (fp->fi_had_conflict)
return ERR_PTR(-EAGAIN);

spin_lock(&state_lock);
spin_lock(&fp->fi_lock);
status = nfs4_get_existing_delegation(clp, fp);
if (nfs4_delegation_exists(clp, fp))
status = -EAGAIN;
spin_unlock(&fp->fi_lock);
spin_unlock(&state_lock);

Expand Down

0 comments on commit 68b18f5

Please sign in to comment.