nfsd: find_cpntf_state cleanup
authorJ. Bruce Fields <bfields@redhat.com>
Thu, 21 Jan 2021 22:57:42 +0000 (17:57 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 25 Jan 2021 14:36:29 +0000 (09:36 -0500)
I think this unusual use of struct compound_state could cause confusion.

It's not that much more complicated just to open-code this stateid
lookup.

The only change in behavior should be a different error return in the
case the copy is using a source stateid that is a revoked delegation,
but I doubt that matters.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
[ cel: squashed in fix reported by Coverity ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c

index c74bf3b5b0de163abb94e9343b7a8af9f2713bbd..b7a5ac5a81ac1fe53331f2ea863645eeb1ca4910 100644 (file)
@@ -5812,21 +5812,27 @@ static __be32 find_cpntf_state(struct nfsd_net *nn, stateid_t *st,
 {
        __be32 status;
        struct nfs4_cpntf_state *cps = NULL;
-       struct nfsd4_compound_state cstate;
+       struct nfs4_client *found;
 
        status = manage_cpntf_state(nn, st, NULL, &cps);
        if (status)
                return status;
 
        cps->cpntf_time = ktime_get_boottime_seconds();
-       memset(&cstate, 0, sizeof(cstate));
-       status = set_client(&cps->cp_p_clid, &cstate, nn, true);
-       if (status)
+
+       status = nfserr_expired;
+       found = lookup_clientid(&cps->cp_p_clid, true, nn);
+       if (!found)
                goto out;
-       status = nfsd4_lookup_stateid(&cstate, &cps->cp_p_stateid,
-                               NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID,
-                               stid, nn);
-       put_client_renew(cstate.clp);
+
+       *stid = find_stateid_by_type(found, &cps->cp_p_stateid,
+                       NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID);
+       if (*stid)
+               status = nfs_ok;
+       else
+               status = nfserr_bad_stateid;
+
+       put_client_renew(found);
 out:
        nfs4_put_cpntf_state(nn, cps);
        return status;