diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-07-25 08:57:22 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-07-27 16:49:22 -0400 |
commit | 5ccb0066f2d561549cc4d73d7f56b4ce3ca7a8a1 (patch) | |
tree | 43ca9eff5c94fc3609d858ce2a430c544fcc5f99 /fs/nfsd | |
parent | db9c4553412d72c6a05e0168d1d487f66e0660b3 (diff) |
LockD: pass actual network namespace to grace period management functions
Passed network namespace replaced hard-coded init_net
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 18 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 29 | ||||
-rw-r--r-- | fs/nfsd/state.h | 3 |
3 files changed, 27 insertions, 23 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 987e719fbae..c9c1c0a2541 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -354,10 +354,10 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
354 | /* Openowner is now set, so sequence id will get bumped. Now we need | 354 | /* Openowner is now set, so sequence id will get bumped. Now we need |
355 | * these checks before we do any creates: */ | 355 | * these checks before we do any creates: */ |
356 | status = nfserr_grace; | 356 | status = nfserr_grace; |
357 | if (locks_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) | 357 | if (locks_in_grace(SVC_NET(rqstp)) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) |
358 | goto out; | 358 | goto out; |
359 | status = nfserr_no_grace; | 359 | status = nfserr_no_grace; |
360 | if (!locks_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) | 360 | if (!locks_in_grace(SVC_NET(rqstp)) && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) |
361 | goto out; | 361 | goto out; |
362 | 362 | ||
363 | switch (open->op_claim_type) { | 363 | switch (open->op_claim_type) { |
@@ -686,7 +686,8 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
686 | 686 | ||
687 | nfs4_lock_state(); | 687 | nfs4_lock_state(); |
688 | /* check stateid */ | 688 | /* check stateid */ |
689 | if ((status = nfs4_preprocess_stateid_op(cstate, &read->rd_stateid, | 689 | if ((status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), |
690 | cstate, &read->rd_stateid, | ||
690 | RD_STATE, &read->rd_filp))) { | 691 | RD_STATE, &read->rd_filp))) { |
691 | dprintk("NFSD: nfsd4_read: couldn't process stateid!\n"); | 692 | dprintk("NFSD: nfsd4_read: couldn't process stateid!\n"); |
692 | goto out; | 693 | goto out; |
@@ -741,7 +742,7 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
741 | { | 742 | { |
742 | __be32 status; | 743 | __be32 status; |
743 | 744 | ||
744 | if (locks_in_grace()) | 745 | if (locks_in_grace(SVC_NET(rqstp))) |
745 | return nfserr_grace; | 746 | return nfserr_grace; |
746 | status = nfsd_unlink(rqstp, &cstate->current_fh, 0, | 747 | status = nfsd_unlink(rqstp, &cstate->current_fh, 0, |
747 | remove->rm_name, remove->rm_namelen); | 748 | remove->rm_name, remove->rm_namelen); |
@@ -760,8 +761,8 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
760 | 761 | ||
761 | if (!cstate->save_fh.fh_dentry) | 762 | if (!cstate->save_fh.fh_dentry) |
762 | return status; | 763 | return status; |
763 | if (locks_in_grace() && !(cstate->save_fh.fh_export->ex_flags | 764 | if (locks_in_grace(SVC_NET(rqstp)) && |
764 | & NFSEXP_NOSUBTREECHECK)) | 765 | !(cstate->save_fh.fh_export->ex_flags & NFSEXP_NOSUBTREECHECK)) |
765 | return nfserr_grace; | 766 | return nfserr_grace; |
766 | status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, | 767 | status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, |
767 | rename->rn_snamelen, &cstate->current_fh, | 768 | rename->rn_snamelen, &cstate->current_fh, |
@@ -845,7 +846,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
845 | 846 | ||
846 | if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { | 847 | if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { |
847 | nfs4_lock_state(); | 848 | nfs4_lock_state(); |
848 | status = nfs4_preprocess_stateid_op(cstate, | 849 | status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), cstate, |
849 | &setattr->sa_stateid, WR_STATE, NULL); | 850 | &setattr->sa_stateid, WR_STATE, NULL); |
850 | nfs4_unlock_state(); | 851 | nfs4_unlock_state(); |
851 | if (status) { | 852 | if (status) { |
@@ -890,7 +891,8 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
890 | return nfserr_inval; | 891 | return nfserr_inval; |
891 | 892 | ||
892 | nfs4_lock_state(); | 893 | nfs4_lock_state(); |
893 | status = nfs4_preprocess_stateid_op(cstate, stateid, WR_STATE, &filp); | 894 | status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), |
895 | cstate, stateid, WR_STATE, &filp); | ||
894 | if (filp) | 896 | if (filp) |
895 | get_file(filp); | 897 | get_file(filp); |
896 | nfs4_unlock_state(); | 898 | nfs4_unlock_state(); |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 4a44b50c2f5..34f65f10fa4 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -2885,7 +2885,8 @@ static void nfsd4_open_deleg_none_ext(struct nfsd4_open *open, int status) | |||
2885 | * Attempt to hand out a delegation. | 2885 | * Attempt to hand out a delegation. |
2886 | */ | 2886 | */ |
2887 | static void | 2887 | static void |
2888 | nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_ol_stateid *stp) | 2888 | nfs4_open_delegation(struct net *net, struct svc_fh *fh, |
2889 | struct nfsd4_open *open, struct nfs4_ol_stateid *stp) | ||
2889 | { | 2890 | { |
2890 | struct nfs4_delegation *dp; | 2891 | struct nfs4_delegation *dp; |
2891 | struct nfs4_openowner *oo = container_of(stp->st_stateowner, struct nfs4_openowner, oo_owner); | 2892 | struct nfs4_openowner *oo = container_of(stp->st_stateowner, struct nfs4_openowner, oo_owner); |
@@ -2906,7 +2907,7 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_ol_ | |||
2906 | case NFS4_OPEN_CLAIM_NULL: | 2907 | case NFS4_OPEN_CLAIM_NULL: |
2907 | /* Let's not give out any delegations till everyone's | 2908 | /* Let's not give out any delegations till everyone's |
2908 | * had the chance to reclaim theirs.... */ | 2909 | * had the chance to reclaim theirs.... */ |
2909 | if (locks_in_grace()) | 2910 | if (locks_in_grace(net)) |
2910 | goto out; | 2911 | goto out; |
2911 | if (!cb_up || !(oo->oo_flags & NFS4_OO_CONFIRMED)) | 2912 | if (!cb_up || !(oo->oo_flags & NFS4_OO_CONFIRMED)) |
2912 | goto out; | 2913 | goto out; |
@@ -3040,7 +3041,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf | |||
3040 | * Attempt to hand out a delegation. No error return, because the | 3041 | * Attempt to hand out a delegation. No error return, because the |
3041 | * OPEN succeeds even if we fail. | 3042 | * OPEN succeeds even if we fail. |
3042 | */ | 3043 | */ |
3043 | nfs4_open_delegation(current_fh, open, stp); | 3044 | nfs4_open_delegation(SVC_NET(rqstp), current_fh, open, stp); |
3044 | nodeleg: | 3045 | nodeleg: |
3045 | status = nfs_ok; | 3046 | status = nfs_ok; |
3046 | 3047 | ||
@@ -3279,11 +3280,11 @@ out: | |||
3279 | } | 3280 | } |
3280 | 3281 | ||
3281 | static inline __be32 | 3282 | static inline __be32 |
3282 | check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags) | 3283 | check_special_stateids(struct net *net, svc_fh *current_fh, stateid_t *stateid, int flags) |
3283 | { | 3284 | { |
3284 | if (ONE_STATEID(stateid) && (flags & RD_STATE)) | 3285 | if (ONE_STATEID(stateid) && (flags & RD_STATE)) |
3285 | return nfs_ok; | 3286 | return nfs_ok; |
3286 | else if (locks_in_grace()) { | 3287 | else if (locks_in_grace(net)) { |
3287 | /* Answer in remaining cases depends on existence of | 3288 | /* Answer in remaining cases depends on existence of |
3288 | * conflicting state; so we must wait out the grace period. */ | 3289 | * conflicting state; so we must wait out the grace period. */ |
3289 | return nfserr_grace; | 3290 | return nfserr_grace; |
@@ -3300,9 +3301,9 @@ check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags) | |||
3300 | * that are not able to provide mandatory locking. | 3301 | * that are not able to provide mandatory locking. |
3301 | */ | 3302 | */ |
3302 | static inline int | 3303 | static inline int |
3303 | grace_disallows_io(struct inode *inode) | 3304 | grace_disallows_io(struct net *net, struct inode *inode) |
3304 | { | 3305 | { |
3305 | return locks_in_grace() && mandatory_lock(inode); | 3306 | return locks_in_grace(net) && mandatory_lock(inode); |
3306 | } | 3307 | } |
3307 | 3308 | ||
3308 | /* Returns true iff a is later than b: */ | 3309 | /* Returns true iff a is later than b: */ |
@@ -3393,7 +3394,7 @@ static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, s | |||
3393 | * Checks for stateid operations | 3394 | * Checks for stateid operations |
3394 | */ | 3395 | */ |
3395 | __be32 | 3396 | __be32 |
3396 | nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | 3397 | nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate, |
3397 | stateid_t *stateid, int flags, struct file **filpp) | 3398 | stateid_t *stateid, int flags, struct file **filpp) |
3398 | { | 3399 | { |
3399 | struct nfs4_stid *s; | 3400 | struct nfs4_stid *s; |
@@ -3406,11 +3407,11 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | |||
3406 | if (filpp) | 3407 | if (filpp) |
3407 | *filpp = NULL; | 3408 | *filpp = NULL; |
3408 | 3409 | ||
3409 | if (grace_disallows_io(ino)) | 3410 | if (grace_disallows_io(net, ino)) |
3410 | return nfserr_grace; | 3411 | return nfserr_grace; |
3411 | 3412 | ||
3412 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) | 3413 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) |
3413 | return check_special_stateids(current_fh, stateid, flags); | 3414 | return check_special_stateids(net, current_fh, stateid, flags); |
3414 | 3415 | ||
3415 | status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, &s); | 3416 | status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, &s); |
3416 | if (status) | 3417 | if (status) |
@@ -4107,10 +4108,10 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
4107 | goto out; | 4108 | goto out; |
4108 | 4109 | ||
4109 | status = nfserr_grace; | 4110 | status = nfserr_grace; |
4110 | if (locks_in_grace() && !lock->lk_reclaim) | 4111 | if (locks_in_grace(SVC_NET(rqstp)) && !lock->lk_reclaim) |
4111 | goto out; | 4112 | goto out; |
4112 | status = nfserr_no_grace; | 4113 | status = nfserr_no_grace; |
4113 | if (!locks_in_grace() && lock->lk_reclaim) | 4114 | if (!locks_in_grace(SVC_NET(rqstp)) && lock->lk_reclaim) |
4114 | goto out; | 4115 | goto out; |
4115 | 4116 | ||
4116 | locks_init_lock(&file_lock); | 4117 | locks_init_lock(&file_lock); |
@@ -4210,7 +4211,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
4210 | struct nfs4_lockowner *lo; | 4211 | struct nfs4_lockowner *lo; |
4211 | __be32 status; | 4212 | __be32 status; |
4212 | 4213 | ||
4213 | if (locks_in_grace()) | 4214 | if (locks_in_grace(SVC_NET(rqstp))) |
4214 | return nfserr_grace; | 4215 | return nfserr_grace; |
4215 | 4216 | ||
4216 | if (check_lock_length(lockt->lt_offset, lockt->lt_length)) | 4217 | if (check_lock_length(lockt->lt_offset, lockt->lt_length)) |
@@ -4703,7 +4704,7 @@ nfs4_state_start(void) | |||
4703 | get_net(net); | 4704 | get_net(net); |
4704 | nfsd4_client_tracking_init(net); | 4705 | nfsd4_client_tracking_init(net); |
4705 | boot_time = get_seconds(); | 4706 | boot_time = get_seconds(); |
4706 | locks_start_grace(&nn->nfsd4_manager); | 4707 | locks_start_grace(net, &nn->nfsd4_manager); |
4707 | grace_ended = false; | 4708 | grace_ended = false; |
4708 | printk(KERN_INFO "NFSD: starting %ld-second grace period\n", | 4709 | printk(KERN_INFO "NFSD: starting %ld-second grace period\n", |
4709 | nfsd4_grace); | 4710 | nfsd4_grace); |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 495df4e3aa6..981ef10141b 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -451,7 +451,8 @@ static inline struct nfs4_ol_stateid *openlockstateid(struct nfs4_stid *s) | |||
451 | 451 | ||
452 | struct nfsd4_compound_state; | 452 | struct nfsd4_compound_state; |
453 | 453 | ||
454 | extern __be32 nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | 454 | extern __be32 nfs4_preprocess_stateid_op(struct net *net, |
455 | struct nfsd4_compound_state *cstate, | ||
455 | stateid_t *stateid, int flags, struct file **filp); | 456 | stateid_t *stateid, int flags, struct file **filp); |
456 | extern void nfs4_lock_state(void); | 457 | extern void nfs4_lock_state(void); |
457 | extern void nfs4_unlock_state(void); | 458 | extern void nfs4_unlock_state(void); |