aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-09-07 16:06:42 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-09-13 18:29:58 -0400
commitdcef0413da9a17bfca917d8b49baf309ce76b737 (patch)
treeef07ceebbba23e7c2a6e454e6ed57b610354fde7
parent91a8c04031d051db41ec2a8c15e24622da037382 (diff)
nfsd4: move some of nfs4_stateid into a separate structure
We want delegations to share more with open/lock stateid's, so first we'll pull out some of the common stuff we want to share. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/nfs4state.c174
-rw-r--r--fs/nfsd/state.h29
2 files changed, 106 insertions, 97 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 768382d1de97..d0bb5a5613a9 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -159,7 +159,7 @@ static struct list_head open_ownerstr_hashtbl[OPEN_OWNER_HASH_SIZE];
159#define FILE_HASH_BITS 8 159#define FILE_HASH_BITS 8
160#define FILE_HASH_SIZE (1 << FILE_HASH_BITS) 160#define FILE_HASH_SIZE (1 << FILE_HASH_BITS)
161 161
162/* hash table for (open)nfs4_stateid */ 162/* hash table for (open)nfs4_ol_stateid */
163#define STATEID_HASH_BITS 10 163#define STATEID_HASH_BITS 10
164#define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS) 164#define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS)
165#define STATEID_HASH_MASK (STATEID_HASH_SIZE - 1) 165#define STATEID_HASH_MASK (STATEID_HASH_SIZE - 1)
@@ -219,7 +219,7 @@ static void nfs4_file_put_access(struct nfs4_file *fp, int oflag)
219} 219}
220 220
221static struct nfs4_delegation * 221static struct nfs4_delegation *
222alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_fh *current_fh, u32 type) 222alloc_init_deleg(struct nfs4_client *clp, struct nfs4_ol_stateid *stp, struct svc_fh *current_fh, u32 type)
223{ 223{
224 struct nfs4_delegation *dp; 224 struct nfs4_delegation *dp;
225 struct nfs4_file *fp = stp->st_file; 225 struct nfs4_file *fp = stp->st_file;
@@ -380,7 +380,7 @@ set_deny(unsigned int *deny, unsigned long bmap) {
380} 380}
381 381
382static int 382static int
383test_share(struct nfs4_stateid *stp, struct nfsd4_open *open) { 383test_share(struct nfs4_ol_stateid *stp, struct nfsd4_open *open) {
384 unsigned int access, deny; 384 unsigned int access, deny;
385 385
386 set_access(&access, stp->st_access_bmap); 386 set_access(&access, stp->st_access_bmap);
@@ -403,14 +403,14 @@ static int nfs4_access_to_omode(u32 access)
403 BUG(); 403 BUG();
404} 404}
405 405
406static void unhash_generic_stateid(struct nfs4_stateid *stp) 406static void unhash_generic_stateid(struct nfs4_ol_stateid *stp)
407{ 407{
408 list_del(&stp->st_hash); 408 list_del(&stp->st_stid.sc_hash);
409 list_del(&stp->st_perfile); 409 list_del(&stp->st_perfile);
410 list_del(&stp->st_perstateowner); 410 list_del(&stp->st_perstateowner);
411} 411}
412 412
413static void close_generic_stateid(struct nfs4_stateid *stp) 413static void close_generic_stateid(struct nfs4_ol_stateid *stp)
414{ 414{
415 int i; 415 int i;
416 416
@@ -426,13 +426,13 @@ static void close_generic_stateid(struct nfs4_stateid *stp)
426 stp->st_file = NULL; 426 stp->st_file = NULL;
427} 427}
428 428
429static void free_generic_stateid(struct nfs4_stateid *stp) 429static void free_generic_stateid(struct nfs4_ol_stateid *stp)
430{ 430{
431 close_generic_stateid(stp); 431 close_generic_stateid(stp);
432 kmem_cache_free(stateid_slab, stp); 432 kmem_cache_free(stateid_slab, stp);
433} 433}
434 434
435static void release_lock_stateid(struct nfs4_stateid *stp) 435static void release_lock_stateid(struct nfs4_ol_stateid *stp)
436{ 436{
437 struct file *file; 437 struct file *file;
438 438
@@ -445,14 +445,14 @@ static void release_lock_stateid(struct nfs4_stateid *stp)
445 445
446static void unhash_lockowner(struct nfs4_lockowner *lo) 446static void unhash_lockowner(struct nfs4_lockowner *lo)
447{ 447{
448 struct nfs4_stateid *stp; 448 struct nfs4_ol_stateid *stp;
449 449
450 list_del(&lo->lo_owner.so_idhash); 450 list_del(&lo->lo_owner.so_idhash);
451 list_del(&lo->lo_owner.so_strhash); 451 list_del(&lo->lo_owner.so_strhash);
452 list_del(&lo->lo_perstateid); 452 list_del(&lo->lo_perstateid);
453 while (!list_empty(&lo->lo_owner.so_stateids)) { 453 while (!list_empty(&lo->lo_owner.so_stateids)) {
454 stp = list_first_entry(&lo->lo_owner.so_stateids, 454 stp = list_first_entry(&lo->lo_owner.so_stateids,
455 struct nfs4_stateid, st_perstateowner); 455 struct nfs4_ol_stateid, st_perstateowner);
456 release_lock_stateid(stp); 456 release_lock_stateid(stp);
457 } 457 }
458} 458}
@@ -464,7 +464,7 @@ static void release_lockowner(struct nfs4_lockowner *lo)
464} 464}
465 465
466static void 466static void
467release_stateid_lockowners(struct nfs4_stateid *open_stp) 467release_stateid_lockowners(struct nfs4_ol_stateid *open_stp)
468{ 468{
469 struct nfs4_lockowner *lo; 469 struct nfs4_lockowner *lo;
470 470
@@ -475,7 +475,7 @@ release_stateid_lockowners(struct nfs4_stateid *open_stp)
475 } 475 }
476} 476}
477 477
478static void release_open_stateid(struct nfs4_stateid *stp) 478static void release_open_stateid(struct nfs4_ol_stateid *stp)
479{ 479{
480 unhash_generic_stateid(stp); 480 unhash_generic_stateid(stp);
481 release_stateid_lockowners(stp); 481 release_stateid_lockowners(stp);
@@ -484,14 +484,14 @@ static void release_open_stateid(struct nfs4_stateid *stp)
484 484
485static void unhash_openowner(struct nfs4_openowner *oo) 485static void unhash_openowner(struct nfs4_openowner *oo)
486{ 486{
487 struct nfs4_stateid *stp; 487 struct nfs4_ol_stateid *stp;
488 488
489 list_del(&oo->oo_owner.so_idhash); 489 list_del(&oo->oo_owner.so_idhash);
490 list_del(&oo->oo_owner.so_strhash); 490 list_del(&oo->oo_owner.so_strhash);
491 list_del(&oo->oo_perclient); 491 list_del(&oo->oo_perclient);
492 while (!list_empty(&oo->oo_owner.so_stateids)) { 492 while (!list_empty(&oo->oo_owner.so_stateids)) {
493 stp = list_first_entry(&oo->oo_owner.so_stateids, 493 stp = list_first_entry(&oo->oo_owner.so_stateids,
494 struct nfs4_stateid, st_perstateowner); 494 struct nfs4_ol_stateid, st_perstateowner);
495 release_open_stateid(stp); 495 release_open_stateid(stp);
496 } 496 }
497} 497}
@@ -1068,26 +1068,26 @@ same_stateid(stateid_t *id_one, stateid_t *id_two)
1068 return id_one->si_fileid == id_two->si_fileid; 1068 return id_one->si_fileid == id_two->si_fileid;
1069} 1069}
1070 1070
1071static struct nfs4_stateid *find_stateid(stateid_t *t) 1071static struct nfs4_ol_stateid *find_stateid(stateid_t *t)
1072{ 1072{
1073 struct nfs4_stateid *s; 1073 struct nfs4_stid *s;
1074 unsigned int hashval; 1074 unsigned int hashval;
1075 1075
1076 hashval = stateid_hashval(t->si_stateownerid, t->si_fileid); 1076 hashval = stateid_hashval(t->si_stateownerid, t->si_fileid);
1077 list_for_each_entry(s, &stateid_hashtbl[hashval], st_hash) 1077 list_for_each_entry(s, &stateid_hashtbl[hashval], sc_hash)
1078 if (same_stateid(&s->st_stateid, t)) 1078 if (same_stateid(&s->sc_stateid, t))
1079 return s; 1079 return openlockstateid(s);
1080 return NULL; 1080 return NULL;
1081} 1081}
1082 1082
1083static struct nfs4_stateid *find_stateid_by_type(stateid_t *t, char typemask) 1083static struct nfs4_ol_stateid *find_stateid_by_type(stateid_t *t, char typemask)
1084{ 1084{
1085 struct nfs4_stateid *s; 1085 struct nfs4_ol_stateid *s;
1086 1086
1087 s = find_stateid(t); 1087 s = find_stateid(t);
1088 if (!s) 1088 if (!s)
1089 return NULL; 1089 return NULL;
1090 if (typemask & s->st_type) 1090 if (typemask & s->st_stid.sc_type)
1091 return s; 1091 return s;
1092 return NULL; 1092 return NULL;
1093} 1093}
@@ -2232,7 +2232,7 @@ nfsd4_init_slabs(void)
2232 if (file_slab == NULL) 2232 if (file_slab == NULL)
2233 goto out_nomem; 2233 goto out_nomem;
2234 stateid_slab = kmem_cache_create("nfsd4_stateids", 2234 stateid_slab = kmem_cache_create("nfsd4_stateids",
2235 sizeof(struct nfs4_stateid), 0, 0, NULL); 2235 sizeof(struct nfs4_ol_stateid), 0, 0, NULL);
2236 if (stateid_slab == NULL) 2236 if (stateid_slab == NULL)
2237 goto out_nomem; 2237 goto out_nomem;
2238 deleg_slab = kmem_cache_create("nfsd4_delegations", 2238 deleg_slab = kmem_cache_create("nfsd4_delegations",
@@ -2314,23 +2314,23 @@ alloc_init_open_stateowner(unsigned int strhashval, struct nfs4_client *clp, str
2314} 2314}
2315 2315
2316