aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-08-22 18:01:43 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-08-31 17:56:00 -0400
commitb79abaddfe7ef29e00d71721cf03a33e00d53317 (patch)
treea5a6dda2a09775b388ecf7c89a5807fba7f2f334 /fs
parent5fa0bbb4ee5481a6b3e83c4968142ca433d71914 (diff)
nfsd4: consolidate lock & open stateid tables
There's no reason to have two separate hash tables for open and lock stateid's. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfs4state.c63
1 files changed, 15 insertions, 48 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 7de214b860db..0198328c0e84 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -61,7 +61,6 @@ static u64 current_sessionid = 1;
61 61
62/* forward declarations */ 62/* forward declarations */
63static struct nfs4_stateid * find_stateid(stateid_t *stid, int flags); 63static struct nfs4_stateid * find_stateid(stateid_t *stid, int flags);
64static struct nfs4_stateid * search_for_stateid(stateid_t *stid);
65static struct nfs4_delegation * search_for_delegation(stateid_t *stid); 64static struct nfs4_delegation * search_for_delegation(stateid_t *stid);
66static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid); 65static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid);
67static int check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner); 66static int check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner);
@@ -3211,7 +3210,7 @@ __be32 nfs4_validate_stateid(stateid_t *stateid, bool has_session)
3211 goto out; 3210 goto out;
3212 3211
3213 status = nfserr_expired; 3212 status = nfserr_expired;
3214 stp = search_for_stateid(stateid); 3213 stp = find_stateid(stateid, 0);
3215 if (!stp) 3214 if (!stp)
3216 goto out; 3215 goto out;
3217 status = nfserr_bad_stateid; 3216 status = nfserr_bad_stateid;
@@ -3349,7 +3348,7 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3349 goto out; 3348 goto out;
3350 } 3349 }
3351 3350
3352 stp = search_for_stateid(stateid); 3351 stp = find_stateid(stateid, 0);
3353 if (!stp) { 3352 if (!stp) {
3354 ret = nfserr_bad_stateid; 3353 ret = nfserr_bad_stateid;
3355 goto out; 3354 goto out;
@@ -3718,7 +3717,6 @@ lock_ownerstr_hashval(struct inode *inode, u32 cl_id,
3718 3717
3719static struct list_head lock_ownerid_hashtbl[LOCK_HASH_SIZE]; 3718static struct list_head lock_ownerid_hashtbl[LOCK_HASH_SIZE];
3720static struct list_head lock_ownerstr_hashtbl[LOCK_HASH_SIZE]; 3719static struct list_head lock_ownerstr_hashtbl[LOCK_HASH_SIZE];
3721static struct list_head lockstateid_hashtbl[STATEID_HASH_SIZE];
3722 3720
3723static int 3721static int
3724same_stateid(stateid_t *id_one, stateid_t *id_two) 3722same_stateid(stateid_t *id_one, stateid_t *id_two)
@@ -3728,50 +3726,21 @@ same_stateid(stateid_t *id_one, stateid_t *id_two)
3728 return id_one->si_fileid == id_two->si_fileid; 3726 return id_one->si_fileid == id_two->si_fileid;
3729} 3727}
3730 3728
3731static struct nfs4_stateid * 3729static struct nfs4_stateid *find_stateid(stateid_t *t, int flags)
3732find_stateid(stateid_t *stid, int flags)
3733{ 3730{
3734 struct nfs4_stateid *local; 3731 struct nfs4_stateid *s;
3735 u32 st_id = stid->si_stateownerid;
3736 u32 f_id = stid->si_fileid;
3737 unsigned int hashval; 3732 unsigned int hashval;
3738 3733
3739 dprintk("NFSD: find_stateid flags 0x%x\n",flags); 3734 hashval = stateid_hashval(t->si_stateownerid, t->si_fileid);
3740 if (flags & (LOCK_STATE | RD_STATE | WR_STATE)) { 3735 list_for_each_entry(s, &stateid_hashtbl[hashval], st_hash) {
3741 hashval = stateid_hashval(st_id, f_id); 3736 if (!same_stateid(&s->st_stateid, t))
3742 list_for_each_entry(local, &lockstateid_hashtbl[hashval], st_hash) { 3737 continue;
3743 if ((local->st_stateid.si_stateownerid == st_id) && 3738 if (flags & LOCK_STATE && s->st_type != NFS4_LOCK_STID)
3744 (local->st_stateid.si_fileid == f_id)) 3739 return NULL;
3745 return local; 3740 if (flags & OPEN_STATE && s->st_type != NFS4_OPEN_STID)
3746 } 3741 return NULL;
3747 } 3742 return s;
3748
3749 if (flags & (OPEN_STATE | RD_STATE | WR_STATE)) {
3750 hashval = stateid_hashval(st_id, f_id);
3751 list_for_each_entry(local, &stateid_hashtbl[hashval], st_hash) {
3752 if ((local->st_stateid.si_stateownerid == st_id) &&
3753 (local->st_stateid.si_fileid == f_id))
3754 return local;
3755 } 3743 }
3756 }
3757 return NULL;
3758}
3759
3760static struct nfs4_stateid *
3761search_for_stateid(stateid_t *stid)
3762{
3763 struct nfs4_stateid *local;
3764 unsigned int hashval = stateid_hashval(stid->si_stateownerid, stid->si_fileid);
3765
3766 list_for_each_entry(local, &lockstateid_hashtbl[hashval], st_hash) {
3767 if (same_stateid(&local->st_stateid, stid))
3768 return local;
3769 }
3770
3771 list_for_each_entry(local, &stateid_hashtbl[hashval], st_hash) {
3772 if (same_stateid(&local->st_stateid, stid))
3773 return local;
3774 }
3775 return NULL; 3744 return NULL;
3776} 3745}
3777 3746
@@ -3920,7 +3889,7 @@ alloc_init_lock_stateid(struct nfs4_stateowner *sop, struct nfs4_file *fp, struc
3920 INIT_LIST_HEAD(&stp->st_perfile); 3889 INIT_LIST_HEAD(&stp->st_perfile);
3921 INIT_LIST_HEAD(&stp->st_perstateowner); 3890 INIT_LIST_HEAD(&stp->st_perstateowner);
3922 INIT_LIST_HEAD(&stp->st_lockowners); /* not used */ 3891 INIT_LIST_HEAD(&stp->st_lockowners); /* not used */
3923 list_add(&stp->st_hash, &lockstateid_hashtbl[hashval]); 3892 list_add(&stp->st_hash, &stateid_hashtbl[hashval]);
3924 list_add(&stp->st_perfile, &fp->fi_stateids); 3893 list_add(&stp->st_perfile, &fp->fi_stateids);
3925 list_add(&stp->st_perstateowner, &sop->so_stateids); 3894 list_add(&stp->st_perstateowner, &sop->so_stateids);
3926 stp->st_stateowner = sop; 3895 stp->st_stateowner = sop;
@@ -4497,10 +4466,8 @@ nfs4_state_init(void)
4497 INIT_LIST_HEAD(&open_ownerstr_hashtbl[i]); 4466 INIT_LIST_HEAD(&open_ownerstr_hashtbl[i]);
4498 INIT_LIST_HEAD(&open_ownerid_hashtbl[i]); 4467 INIT_LIST_HEAD(&open_ownerid_hashtbl[i]);
4499 } 4468 }
4500 for (i = 0; i < STATEID_HASH_SIZE; i++) { 4469 for (i = 0; i < STATEID_HASH_SIZE; i++)
4501 INIT_LIST_HEAD(&stateid_hashtbl[i]); 4470 INIT_LIST_HEAD(&stateid_hashtbl[i]);
4502 INIT_LIST_HEAD(&lockstateid_hashtbl[i]);
4503 }
4504 for (i = 0; i < LOCK_HASH_SIZE; i++) { 4471 for (i = 0; i < LOCK_HASH_SIZE; i++) {
4505 INIT_LIST_HEAD(&lock_ownerid_hashtbl[i]); 4472 INIT_LIST_HEAD(&lock_ownerid_hashtbl[i]);
4506 INIT_LIST_HEAD(&lock_ownerstr_hashtbl[i]); 4473 INIT_LIST_HEAD(&lock_ownerstr_hashtbl[i]);