NFSD: Remove the ex_pathname field from struct svc_export
[deliverable/linux.git] / fs / nfsd / nfs4state.c
index 24685a02690f2f48b889a5005299846533fbaa9d..0cd346477f29ce511e7f8b5579090fbba797c52c 100644 (file)
@@ -168,9 +168,9 @@ static unsigned int file_hashval(struct inode *ino)
        return hash_ptr(ino, FILE_HASH_BITS);
 }
 
-static unsigned int stateid_hashval(u32 owner_id, u32 file_id)
+static unsigned int stateid_hashval(stateid_t *s)
 {
-       return (owner_id + file_id) & STATEID_HASH_MASK;
+       return opaque_hashval(&s->si_opaque, sizeof(stateid_opaque_t)) & STATEID_HASH_MASK;
 }
 
 static struct list_head file_hashtbl[FILE_HASH_SIZE];
@@ -221,7 +221,7 @@ static inline void hash_stid(struct nfs4_stid *stid)
        stateid_t *s = &stid->sc_stateid;
        unsigned int hashval;
 
-       hashval = stateid_hashval(s->si_stateownerid, s->si_fileid);
+       hashval = stateid_hashval(s);
        list_add(&stid->sc_hash, &stateid_hashtbl[hashval]);
 }
 
@@ -1083,7 +1083,7 @@ static struct nfs4_stid *find_stateid(stateid_t *t)
        struct nfs4_stid *s;
        unsigned int hashval;
 
-       hashval = stateid_hashval(t->si_stateownerid, t->si_fileid);
+       hashval = stateid_hashval(t);
        list_for_each_entry(s, &stateid_hashtbl[hashval], sc_hash)
                if (same_stateid(&s->sc_stateid, t))
                        return s;
@@ -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;
 }
 
 /*
@@ -3292,6 +3290,7 @@ __be32
 nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
                           stateid_t *stateid, int flags, struct file **filpp)
 {
+       struct nfs4_stid *s;
        struct nfs4_ol_stateid *stp = NULL;
        struct nfs4_delegation *dp = NULL;
        struct svc_fh *current_fh = &cstate->current_fh;
@@ -3316,13 +3315,14 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
         * but that we can't find, is expired:
         */
        status = nfserr_expired;
-       if (is_delegation_stateid(stateid)) {
-               dp = find_deleg_stateid(stateid);
-               if (!dp)
-                       goto out;
-               status = check_stateid_generation(stateid, &dp->dl_stid.sc_stateid, nfsd4_has_session(cstate));
-               if (status)
-                       goto out;
+       s = find_stateid(stateid);
+       if (!s)
+               goto out;
+       status = check_stateid_generation(stateid, &s->sc_stateid, nfsd4_has_session(cstate));
+       if (status)
+               goto out;
+       if (s->sc_type == NFS4_DELEG_STID) {
+               dp = delegstateid(s);
                status = nfs4_check_delegmode(dp, flags);
                if (status)
                        goto out;
@@ -3332,19 +3332,13 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
                        BUG_ON(!*filpp);
                }
        } else { /* open or lock stateid */
-               stp = find_ol_stateid(stateid);
-               if (!stp)
-                       goto out;
+               stp = openlockstateid(s);
                status = nfserr_bad_stateid;
                if (nfs4_check_fh(current_fh, stp))
                        goto out;
                if (stp->st_stateowner->so_is_open_owner
                    && !openowner(stp->st_stateowner)->oo_confirmed)
                        goto out;
-               status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid,
-                                                 nfsd4_has_session(cstate));
-               if (status)
-                       goto out;
                status = nfs4_check_openmode(stp, flags);
                if (status)
                        goto out;
This page took 0.024774 seconds and 5 git commands to generate.