nfsd4: fix test_stateid for delegation stateid's
authorJ. Bruce Fields <bfields@redhat.com>
Fri, 9 Sep 2011 15:26:58 +0000 (11:26 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 13 Sep 2011 22:30:35 +0000 (18:30 -0400)
Test_stateid should handle delegation stateid's as well.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c

index 24685a02690f2f48b889a5005299846533fbaa9d..30387f3d988100b4f1292d32dba357eb538b7eb3 100644 (file)
@@ -3261,28 +3261,26 @@ static int is_delegation_stateid(stateid_t *stateid)
 
 __be32 nfs4_validate_stateid(stateid_t *stateid, bool has_session)
 {
-       struct nfs4_ol_stateid *stp = NULL;
-       __be32 status = nfserr_stale_stateid;
+       struct nfs4_stid *s;
+       struct nfs4_ol_stateid *ols;
+       __be32 status;
 
        if (STALE_STATEID(stateid))
-               goto out;
-
-       status = nfserr_expired;
-       stp = find_ol_stateid(stateid);
-       if (!stp)
-               goto out;
-       status = nfserr_bad_stateid;
-       if (stp->st_stateowner->so_is_open_owner
-           && !openowner(stp->st_stateowner)->oo_confirmed)
-               goto out;
+               return nfserr_stale_stateid;
 
-       status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, has_session);
+       s = find_stateid(stateid);
+       if (!s)
+                return nfserr_stale_stateid;
+       status = check_stateid_generation(stateid, &s->sc_stateid, has_session);
        if (status)
-               goto out;
-
-       status = nfs_ok;
-out:
-       return status;
+               return status;
+       if (!(s->sc_type & (NFS4_OPEN_STID | NFS4_LOCK_STID)))
+               return nfs_ok;
+       ols = openlockstateid(s);
+       if (ols->st_stateowner->so_is_open_owner
+           && !openowner(ols->st_stateowner)->oo_confirmed)
+               return nfserr_bad_stateid;
+       return nfs_ok;
 }
 
 /*