aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
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 /fs/nfsd/nfs4state.c
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>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c174
1 files changed, 87 insertions, 87 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 768382d1de9..d0bb5a5613a 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
2316static inline void 2316static inline void
2317init_open_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *open) { 2317init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *open) {
2318 struct nfs4_openowner *oo = open->op_openowner; 2318 struct nfs4_openowner *oo = open->op_openowner;
2319 unsigned int hashval = stateid_hashval(oo->oo_owner.so_id, fp->fi_id); 2319 unsigned int hashval = stateid_hashval(oo->oo_owner.so_id, fp->fi_id);
2320 2320
2321 INIT_LIST_HEAD(&stp->st_lockowners); 2321 INIT_LIST_HEAD(&stp->st_lockowners);
2322 list_add(&stp->st_hash, &stateid_hashtbl[hashval]); 2322 list_add(&stp->st_stid.sc_hash, &stateid_hashtbl[hashval]);
2323 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); 2323 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids);
2324 list_add(&stp->st_perfile, &fp->fi_stateids); 2324 list_add(&stp->st_perfile, &fp->fi_stateids);
2325 stp->st_type = NFS4_OPEN_STID; 2325 stp->st_stid.sc_type = NFS4_OPEN_STID;
2326 stp->st_stateowner = &oo->oo_owner; 2326 stp->st_stateowner = &oo->oo_owner;
2327 get_nfs4_file(fp); 2327 get_nfs4_file(fp);
2328 stp->st_file = fp; 2328 stp->st_file = fp;
2329 stp->st_stateid.si_boot = boot_time; 2329 stp->st_stid.sc_stateid.si_boot = boot_time;
2330 stp->st_stateid.si_stateownerid = oo->oo_owner.so_id; 2330 stp->st_stid.sc_stateid.si_stateownerid = oo->oo_owner.so_id;
2331 stp->st_stateid.si_fileid = fp->fi_id; 2331 stp->st_stid.sc_stateid.si_fileid = fp->fi_id;
2332 /* note will be incremented before first return to client: */ 2332 /* note will be incremented before first return to client: */
2333 stp->st_stateid.si_generation = 0; 2333 stp->st_stid.sc_stateid.si_generation = 0;
2334 stp->st_access_bmap = 0; 2334 stp->st_access_bmap = 0;
2335 stp->st_deny_bmap = 0; 2335 stp->st_deny_bmap = 0;
2336 __set_bit(open->op_share_access & ~NFS4_SHARE_WANT_MASK, 2336 __set_bit(open->op_share_access & ~NFS4_SHARE_WANT_MASK,
@@ -2422,7 +2422,7 @@ nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
2422{ 2422{
2423 struct inode *ino = current_fh->fh_dentry->d_inode; 2423 struct inode *ino = current_fh->fh_dentry->d_inode;
2424 struct nfs4_file *fp; 2424 struct nfs4_file *fp;
2425 struct nfs4_stateid *stp; 2425 struct nfs4_ol_stateid *stp;
2426 __be32 ret; 2426 __be32 ret;
2427 2427
2428 dprintk("NFSD: nfs4_share_conflict\n"); 2428 dprintk("NFSD: nfs4_share_conflict\n");
@@ -2611,9 +2611,9 @@ out:
2611} 2611}
2612 2612
2613static __be32 2613static __be32
2614nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_stateid **stpp) 2614nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_ol_stateid **stpp)
2615{ 2615{
2616 struct nfs4_stateid *local; 2616 struct nfs4_ol_stateid *local;
2617 struct nfs4_openowner *oo = open->op_openowner; 2617 struct nfs4_openowner *oo = open->op_openowner;
2618 2618
2619 list_for_each_entry(local, &fp->fi_stateids, st_perfile) { 2619 list_for_each_entry(local, &fp->fi_stateids, st_perfile) {
@@ -2630,7 +2630,7 @@ nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_state
2630 return nfs_ok; 2630 return nfs_ok;
2631} 2631}
2632 2632
2633static inline struct nfs4_stateid * 2633static inline struct nfs4_ol_stateid *
2634nfs4_alloc_stateid(void) 2634nfs4_alloc_stateid(void)
2635{ 2635{
2636 return kmem_cache_alloc(stateid_slab, GFP_KERNEL); 2636 return kmem_cache_alloc(stateid_slab, GFP_KERNEL);
@@ -2672,11 +2672,11 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,
2672} 2672}
2673 2673
2674static __be32 2674static __be32
2675nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp, 2675nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_ol_stateid **stpp,
2676 struct nfs4_file *fp, struct svc_fh *cur_fh, 2676 struct nfs4_file *fp, struct svc_fh *cur_fh,
2677 struct nfsd4_open *open) 2677 struct nfsd4_open *open)
2678{ 2678{
2679 struct nfs4_stateid *stp; 2679 struct nfs4_ol_stateid *stp;
2680 __be32 status; 2680 __be32 status;
2681 2681
2682 stp = nfs4_alloc_stateid(); 2682 stp = nfs4_alloc_stateid();
@@ -2708,7 +2708,7 @@ nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh,
2708} 2708}
2709 2709
2710static __be32 2710static __be32
2711nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open) 2711nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open *open)
2712{ 2712{
2713 u32 op_share_access = open->op_share_access & ~NFS4_SHARE_WANT_MASK; 2713 u32 op_share_access = open->op_share_access & ~NFS4_SHARE_WANT_MASK;
2714 bool new_access; 2714 bool new_access;
@@ -2820,7 +2820,7 @@ static int nfs4_set_delegation(struct nfs4_delegation *dp, int flag)
2820 * Attempt to hand out a delegation. 2820 * Attempt to hand out a delegation.
2821 */ 2821 */
2822static void 2822static void
2823nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_stateid *stp) 2823nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_ol_stateid *stp)
2824{ 2824{
2825 struct nfs4_delegation *dp; 2825 struct nfs4_delegation *dp;
2826 struct nfs4_openowner *oo = container_of(stp->st_stateowner, struct nfs4_openowner, oo_owner); 2826 struct nfs4_openowner *oo = container_of(stp->st_stateowner, struct nfs4_openowner, oo_owner);
@@ -2888,7 +2888,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
2888 struct nfsd4_compoundres *resp = rqstp->rq_resp; 2888 struct nfsd4_compoundres *resp = rqstp->rq_resp;
2889 struct nfs4_file *fp = NULL; 2889 struct nfs4_file *fp = NULL;
2890 struct inode *ino = current_fh->fh_dentry->d_inode; 2890 struct inode *ino = current_fh->fh_dentry->d_inode;
2891 struct nfs4_stateid *stp = NULL; 2891 struct nfs4_ol_stateid *stp = NULL;
2892 struct nfs4_delegation *dp = NULL; 2892 struct nfs4_delegation *dp = NULL;
2893 __be32 status; 2893 __be32 status;
2894 2894
@@ -2938,8 +2938,8 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
2938 goto out; 2938 goto out;
2939 } 2939 }
2940 } 2940 }
2941 update_stateid(&stp->st_stateid); 2941 update_stateid(&stp->st_stid.sc_stateid);
2942 memcpy(&open->op_stateid, &stp->st_stateid, sizeof(stateid_t)); 2942 memcpy(&open->op_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
2943 2943
2944 if (nfsd4_has_session(&resp->cstate)) 2944 if (nfsd4_has_session(&resp->cstate))
2945 open->op_openowner->oo_confirmed = 1; 2945 open->op_openowner->oo_confirmed = 1;
@@ -2953,7 +2953,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
2953 status = nfs_ok; 2953 status = nfs_ok;
2954 2954
2955 dprintk("%s: stateid=" STATEID_FMT "\n", __func__, 2955 dprintk("%s: stateid=" STATEID_FMT "\n", __func__,
2956 STATEID_VAL(&stp->st_stateid)); 2956 STATEID_VAL(&stp->st_stid.sc_stateid));
2957out: 2957out:
2958 if (fp) 2958 if (fp)
2959 put_nfs4_file(fp); 2959 put_nfs4_file(fp);
@@ -3122,7 +3122,7 @@ static struct nfs4_openowner * search_close_lru(u32 st_id)
3122} 3122}
3123 3123
3124static inline int 3124static inline int
3125nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stateid *stp) 3125nfs4_check_fh(struct svc_fh *fhp, struct nfs4_ol_stateid *stp)
3126{ 3126{
3127 return fhp->fh_dentry->d_inode != stp->st_file->fi_inode; 3127 return fhp->fh_dentry->d_inode != stp->st_file->fi_inode;
3128} 3128}
@@ -3153,7 +3153,7 @@ access_permit_write(unsigned long access_bmap)
3153} 3153}
3154 3154
3155static 3155static
3156__be32 nfs4_check_openmode(struct nfs4_stateid *stp, int flags) 3156__be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags)
3157{ 3157{
3158 __be32 status = nfserr_openmode; 3158 __be32 status = nfserr_openmode;
3159 3159
@@ -3237,7 +3237,7 @@ static int is_delegation_stateid(stateid_t *stateid)
3237 3237
3238__be32 nfs4_validate_stateid(stateid_t *stateid, bool has_session) 3238__be32 nfs4_validate_stateid(stateid_t *stateid, bool has_session)
3239{ 3239{
3240 struct nfs4_stateid *stp = NULL; 3240 struct nfs4_ol_stateid *stp = NULL;
3241 __be32 status = nfserr_stale_stateid; 3241 __be32 status = nfserr_stale_stateid;
3242 3242
3243 if (STALE_STATEID(stateid)) 3243 if (STALE_STATEID(stateid))
@@ -3252,7 +3252,7 @@ __be32 nfs4_validate_stateid(stateid_t *stateid, bool has_session)
3252 && !openowner(stp->st_stateowner)->oo_confirmed) 3252 && !openowner(stp->st_stateowner)->oo_confirmed)
3253 goto out; 3253 goto out;
3254 3254
3255 status = check_stateid_generation(stateid, &stp->st_stateid, has_session); 3255 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, has_session);
3256 if (status) 3256 if (status)
3257 goto out; 3257 goto out;
3258 3258
@@ -3268,7 +3268,7 @@ __be32
3268nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, 3268nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
3269 stateid_t *stateid, int flags, struct file **filpp) 3269 stateid_t *stateid, int flags, struct file **filpp)
3270{ 3270{
3271 struct nfs4_stateid *stp = NULL; 3271 struct nfs4_ol_stateid *stp = NULL;
3272 struct nfs4_delegation *dp = NULL; 3272 struct nfs4_delegation *dp = NULL;
3273 struct svc_fh *current_fh = &cstate->current_fh; 3273 struct svc_fh *current_fh = &cstate->current_fh;
3274 struct inode *ino = current_fh->fh_dentry->d_inode; 3274 struct inode *ino = current_fh->fh_dentry->d_inode;
@@ -3317,7 +3317,7 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
3317 if (stp->st_stateowner->so_is_open_owner 3317 if (stp->st_stateowner->so_is_open_owner
3318 && !openowner(stp->st_stateowner)->oo_confirmed) 3318 && !openowner(stp->st_stateowner)->oo_confirmed)
3319 goto out; 3319 goto out;
3320 status = check_stateid_generation(stateid, &stp->st_stateid, 3320 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid,
3321 nfsd4_has_session(cstate)); 3321 nfsd4_has_session(cstate));
3322 if (status) 3322 if (status)
3323 goto out; 3323 goto out;
@@ -3347,7 +3347,7 @@ nfsd4_free_delegation_stateid(stateid_t *stateid)
3347} 3347}
3348 3348
3349static __be32 3349static __be32
3350nfsd4_free_lock_stateid(struct nfs4_stateid *stp) 3350nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp)
3351{ 3351{
3352 if (check_for_locks(stp->st_file, lockowner(stp->st_stateowner))) 3352 if (check_for_locks(stp->st_file, lockowner(stp->st_stateowner)))
3353 return nfserr_locks_held; 3353 return nfserr_locks_held;
@@ -3374,7 +3374,7 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3374 struct nfsd4_free_stateid *free_stateid) 3374 struct nfsd4_free_stateid *free_stateid)
3375{ 3375{
3376 stateid_t *stateid = &free_stateid->fr_stateid; 3376 stateid_t *stateid = &free_stateid->fr_stateid;
3377 struct nfs4_stateid *stp; 3377 struct nfs4_ol_stateid *stp;
3378 __be32 ret; 3378 __be32 ret;
3379 3379
3380 nfs4_lock_state(); 3380 nfs4_lock_state();
@@ -3388,11 +3388,11 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3388 ret = nfserr_bad_stateid; 3388 ret = nfserr_bad_stateid;
3389 goto out; 3389 goto out;
3390 } 3390 }
3391 ret = check_stateid_generation(stateid, &stp->st_stateid, 1); 3391 ret = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, 1);
3392 if (ret) 3392 if (ret)
3393 goto out; 3393 goto out;
3394 3394
3395 if (stp->st_type == NFS4_OPEN_STID) { 3395 if (stp->st_stid.sc_type == NFS4_OPEN_STID) {
3396 ret = nfserr_locks_held; 3396 ret = nfserr_locks_held;
3397 goto out; 3397 goto out;
3398 } else { 3398 } else {
@@ -3421,7 +3421,7 @@ static __be32 nfs4_nospecial_stateid_checks(stateid_t *stateid)
3421 return nfs_ok; 3421 return nfs_ok;
3422} 3422}
3423 3423
3424static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_stateid *stp) 3424static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp)
3425{ 3425{
3426 struct svc_fh *current_fh = &cstate->current_fh; 3426 struct svc_fh *current_fh = &cstate->current_fh;
3427 struct nfs4_stateowner *sop = stp->st_stateowner; 3427 struct nfs4_stateowner *sop = stp->st_stateowner;
@@ -3432,7 +3432,7 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_
3432 status = nfsd4_check_seqid(cstate, sop, seqid); 3432 status = nfsd4_check_seqid(cstate, sop, seqid);
3433 if (status) 3433 if (status)
3434 return status; 3434 return status;
3435 return check_stateid_generation(stateid, &stp->st_stateid, nfsd4_has_session(cstate)); 3435 return check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
3436} 3436}
3437 3437
3438/* 3438/*
@@ -3441,7 +3441,7 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_
3441static __be32 3441static __be32
3442nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, 3442nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
3443 stateid_t *stateid, char typemask, 3443 stateid_t *stateid, char typemask,
3444 struct nfs4_stateid **stpp) 3444 struct nfs4_ol_stateid **stpp)
3445{ 3445{
3446 __be32 status; 3446 __be32 status;
3447 3447
@@ -3461,7 +3461,7 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
3461 return nfs4_seqid_op_checks(cstate, stateid, seqid, *stpp); 3461 return nfs4_seqid_op_checks(cstate, stateid, seqid, *stpp);
3462} 3462}
3463 3463
3464static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, stateid_t *stateid, struct nfs4_stateid **stpp) 3464static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, stateid_t *stateid, struct nfs4_ol_stateid **stpp)
3465{ 3465{
3466 __be32 status; 3466 __be32 status;
3467 struct nfs4_openowner *oo; 3467 struct nfs4_openowner *oo;
@@ -3482,7 +3482,7 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3482{ 3482{
3483 __be32 status; 3483 __be32 status;
3484 struct nfs4_openowner *oo; 3484 struct nfs4_openowner *oo;
3485 struct nfs4_stateid *stp; 3485 struct nfs4_ol_stateid *stp;
3486 3486
3487 dprintk("NFSD: nfsd4_open_confirm on file %.*s\n", 3487 dprintk("NFSD: nfsd4_open_confirm on file %.*s\n",
3488 (int)cstate->current_fh.fh_dentry->d_name.len, 3488 (int)cstate->current_fh.fh_dentry->d_name.len,
@@ -3504,10 +3504,10 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3504 if (oo->oo_confirmed) 3504 if (oo->oo_confirmed)
3505 goto out; 3505 goto out;
3506 oo->oo_confirmed = 1; 3506 oo->oo_confirmed = 1;
3507 update_stateid(&stp->st_stateid); 3507 update_stateid(&stp->st_stid.sc_stateid);
3508 memcpy(&oc->oc_resp_stateid, &stp->st_stateid, sizeof(stateid_t)); 3508 memcpy(&oc->oc_resp_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
3509 dprintk("NFSD: %s: success, seqid=%d stateid=" STATEID_FMT "\n", 3509 dprintk("NFSD: %s: success, seqid=%d stateid=" STATEID_FMT "\n",
3510 __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stateid)); 3510 __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stid.sc_stateid));
3511 3511
3512 nfsd4_create_clid_dir(oo->oo_owner.so_client); 3512 nfsd4_create_clid_dir(oo->oo_owner.so_client);
3513 status = nfs_ok; 3513 status = nfs_ok;
@@ -3517,7 +3517,7 @@ out:
3517 return status; 3517 return status;
3518} 3518}
3519 3519
3520static inline void nfs4_file_downgrade(struct nfs4_stateid *stp, unsigned int to_access) 3520static inline void nfs4_file_downgrade(struct nfs4_ol_stateid *stp, unsigned int to_access)
3521{ 3521{
3522 int i; 3522 int i;
3523 3523
@@ -3545,7 +3545,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
3545 struct nfsd4_open_downgrade *od) 3545 struct nfsd4_open_downgrade *od)
3546{ 3546{
3547 __be32 status; 3547 __be32 status;
3548 struct nfs4_stateid *stp; 3548 struct nfs4_ol_stateid *stp;
3549 3549
3550 dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n", 3550 dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n",
3551 (int)cstate->current_fh.fh_dentry->d_name.len, 3551 (int)cstate->current_fh.fh_dentry->d_name.len,
@@ -3575,8 +3575,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
3575 3575
3576 reset_union_bmap_deny(od->od_share_deny, &stp->st_deny_bmap); 3576 reset_union_bmap_deny(od->od_share_deny, &stp->st_deny_bmap);
3577 3577
3578 update_stateid(&stp->st_stateid); 3578 update_stateid(&stp->st_stid.sc_stateid);
3579 memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t)); 3579 memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
3580 status = nfs_ok; 3580 status = nfs_ok;
3581out: 3581out:
3582 if (!cstate->replay_owner) 3582 if (!cstate->replay_owner)
@@ -3593,7 +3593,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3593{ 3593{
3594 __be32 status; 3594 __be32 status;
3595 struct nfs4_openowner *oo; 3595 struct nfs4_openowner *oo;
3596 struct nfs4_stateid *stp; 3596 struct nfs4_ol_stateid *stp;
3597 3597
3598 dprintk("NFSD: nfsd4_close on file %.*s\n", 3598 dprintk("NFSD: nfsd4_close on file %.*s\n",
3599 (int)cstate->current_fh.fh_dentry->d_name.len, 3599 (int)cstate->current_fh.fh_dentry->d_name.len,
@@ -3622,8 +3622,8 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3622 goto out; 3622 goto out;
3623 oo = openowner(stp->st_stateowner); 3623 oo = openowner(stp->st_stateowner);
3624 status = nfs_ok; 3624 status = nfs_ok;
3625 update_stateid(&stp->st_stateid); 3625 update_stateid(&stp->st_stid.sc_stateid);
3626 memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t)); 3626 memcpy(&close->cl_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
3627 3627
3628 /* release_stateid() calls nfsd_close() if needed */ 3628 /* release_stateid() calls nfsd_close() if needed */
3629 release_open_stateid(stp); 3629 release_open_stateid(stp);
@@ -3828,7 +3828,7 @@ find_lockowner_str(struct inode *inode, clientid_t *clid,
3828 return NULL; 3828 return NULL;
3829} 3829}
3830 3830
3831static void hash_lockowner(struct nfs4_lockowner *lo, unsigned int strhashval, struct nfs4_client *clp, struct nfs4_stateid *open_stp) 3831static void hash_lockowner(struct nfs4_lockowner *lo, unsigned int strhashval, struct nfs4_client *clp, struct nfs4_ol_stateid *open_stp)
3832{ 3832{
3833 unsigned int idhashval; 3833 unsigned int idhashval;
3834 3834
@@ -3847,7 +3847,7 @@ static void hash_lockowner(struct nfs4_lockowner *lo, unsigned int strhashval, s
3847 */ 3847 */
3848 3848
3849static struct nfs4_lockowner * 3849static struct nfs4_lockowner *
3850alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, struct nfs4_stateid *open_stp, struct nfsd4_lock *lock) { 3850alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, struct nfs4_ol_stateid *open_stp, struct nfsd4_lock *lock) {
3851 struct nfs4_lockowner *lo; 3851 struct nfs4_lockowner *lo;
3852 3852
3853 lo = alloc_stateowner(lockowner_slab, &lock->lk_new_owner, clp); 3853 lo = alloc_stateowner(lockowner_slab, &lock->lk_new_owner, clp);
@@ -3862,27 +3862,27 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, str
3862 return lo; 3862 return lo;
3863} 3863}
3864 3864
3865static struct nfs4_stateid * 3865static struct nfs4_ol_stateid *
3866alloc_init_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp, struct nfs4_stateid *open_stp) 3866alloc_init_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp, struct nfs4_ol_stateid *open_stp)
3867{ 3867{
3868 struct nfs4_stateid *stp; 3868 struct nfs4_ol_stateid *stp;
3869 unsigned int hashval = stateid_hashval(lo->lo_owner.so_id, fp->fi_id); 3869 unsigned int hashval = stateid_hashval(lo->lo_owner.so_id, fp->fi_id);
3870 3870
3871 stp = nfs4_alloc_stateid(); 3871 stp = nfs4_alloc_stateid();
3872 if (stp == NULL) 3872 if (stp == NULL)
3873 goto out; 3873 goto out;
3874 list_add(&stp->st_hash, &stateid_hashtbl[hashval]); 3874 list_add(&stp->st_stid.sc_hash, &stateid_hashtbl[hashval]);
3875 list_add(&stp->st_perfile, &fp->fi_stateids); 3875 list_add(&stp->st_perfile, &fp->fi_stateids);
3876 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); 3876 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids);
3877 stp->st_stateowner = &lo->lo_owner; 3877 stp->st_stateowner = &lo->lo_owner;
3878 stp->st_type = NFS4_LOCK_STID; 3878 stp->st_stid.sc_type = NFS4_LOCK_STID;
3879 get_nfs4_file(fp); 3879 get_nfs4_file(fp);
3880 stp->st_file = fp; 3880 stp->st_file = fp;
3881 stp->st_stateid.si_boot = boot_time; 3881 stp->st_stid.sc_stateid.si_boot = boot_time;
3882 stp->st_stateid.si_stateownerid = lo->lo_owner.so_id; 3882 stp->st_stid.sc_stateid.si_stateownerid = lo->lo_owner.so_id;
3883 stp->st_stateid.si_fileid = fp->fi_id; 3883 stp->st_stid.sc_stateid.si_fileid = fp->fi_id;
3884 /* note will be incremented before first return to client: */ 3884 /* note will be incremented before first return to client: */
3885 stp->st_stateid.si_generation = 0; 3885 stp->st_stid.sc_stateid.si_generation = 0;
3886 stp->st_access_bmap = 0; 3886 stp->st_access_bmap = 0;
3887 stp->st_deny_bmap = open_stp->st_deny_bmap; 3887 stp->st_deny_bmap = open_stp->st_deny_bmap;
3888 stp->st_openstp = open_stp; 3888 stp->st_openstp = open_stp;
@@ -3898,7 +3898,7 @@ check_lock_length(u64 offset, u64 length)
3898 LOFF_OVERFLOW(offset, length))); 3898 LOFF_OVERFLOW(offset, length)));
3899} 3899}
3900 3900
3901static void get_lock_access(struct nfs4_stateid *lock_stp, u32 access) 3901static void get_lock_access(struct nfs4_ol_stateid *lock_stp, u32 access)
3902{ 3902{
3903 struct nfs4_file *fp = lock_stp->st_file; 3903 struct nfs4_file *fp = lock_stp->st_file;
3904 int oflag = nfs4_access_to_omode(access); 3904 int oflag = nfs4_access_to_omode(access);
@@ -3918,7 +3918,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3918{ 3918{
3919 struct nfs4_openowner *open_sop = NULL; 3919 struct nfs4_openowner *open_sop = NULL;
3920 struct nfs4_lockowner *lock_sop = NULL; 3920 struct nfs4_lockowner *lock_sop = NULL;
3921 struct nfs4_stateid *lock_stp; 3921 struct nfs4_ol_stateid *lock_stp;
3922 struct nfs4_file *fp; 3922 struct nfs4_file *fp;
3923 struct file *filp = NULL; 3923 struct file *filp = NULL;
3924 struct file_lock file_lock; 3924 struct file_lock file_lock;
@@ -3949,7 +3949,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3949 * Use open owner and open stateid to create lock owner and 3949 * Use open owner and open stateid to create lock owner and
3950 * lock stateid. 3950 * lock stateid.
3951 */ 3951 */
3952 struct nfs4_stateid *open_stp = NULL; 3952 struct nfs4_ol_stateid *open_stp = NULL;
3953 3953
3954 status = nfserr_stale_clientid; 3954 status = nfserr_stale_clientid;
3955 if (!nfsd4_has_session(cstate) && 3955 if (!nfsd4_has_session(cstate) &&
@@ -4052,8 +4052,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4052 err = vfs_lock_file(filp, F_SETLK, &file_lock, &conflock); 4052 err = vfs_lock_file(filp, F_SETLK, &file_lock, &conflock);
4053 switch (-err) { 4053 switch (-err) {
4054 case 0: /* success! */ 4054 case 0: /* success! */
4055 update_stateid(&lock_stp->st_stateid); 4055 update_stateid(&lock_stp->st_stid.sc_stateid);
4056 memcpy(&lock->lk_resp_stateid, &lock_stp->st_stateid, 4056 memcpy(&lock->lk_resp_stateid, &lock_stp->st_stid.sc_stateid,
4057 sizeof(stateid_t)); 4057 sizeof(stateid_t));
4058 status = 0; 4058 status = 0;
4059 break; 4059 break;
@@ -4172,7 +4172,7 @@ __be32
4172nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, 4172nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4173 struct nfsd4_locku *locku) 4173 struct nfsd4_locku *locku)
4174{ 4174{
4175 struct nfs4_stateid *stp; 4175 struct nfs4_ol_stateid *stp;
4176 struct file *filp = NULL; 4176 struct file *filp = NULL;
4177 struct file_lock file_lock; 4177 struct file_lock file_lock;
4178 __be32 status; 4178 __be32 status;
@@ -4220,8 +4220,8 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4220 /* 4220 /*
4221 * OK, unlock succeeded; the only thing left to do is update the stateid. 4221 * OK, unlock succeeded; the only thing left to do is update the stateid.
4222 */ 4222 */
4223 update_stateid(&stp->st_stateid); 4223 update_stateid(&stp->st_stid.sc_stateid);
4224 memcpy(&locku->lu_stateid, &stp->st_stateid, sizeof(stateid_t)); 4224 memcpy(&locku->lu_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
4225 4225
4226out: 4226out:
4227 nfs4_unlock_state(); 4227 nfs4_unlock_state();
@@ -4264,7 +4264,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
4264 clientid_t *clid = &rlockowner->rl_clientid; 4264 clientid_t *clid = &rlockowner->rl_clientid;
4265 struct nfs4_stateowner *sop; 4265 struct nfs4_stateowner *sop;
4266 struct nfs4_lockowner *lo; 4266 struct nfs4_lockowner *lo;
4267 struct nfs4_stateid *stp; 4267 struct nfs4_ol_stateid *stp;
4268 struct xdr_netobj *owner = &rlockowner->rl_owner; 4268 struct xdr_netobj *owner = &rlockowner->rl_owner;
4269 struct list_head matches; 4269 struct list_head matches;
4270 int i; 4270 int i;