diff options
-rw-r--r-- | fs/nfsd/netns.h | 1 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 39 | ||||
-rw-r--r-- | fs/nfsd/state.h | 1 |
3 files changed, 25 insertions, 16 deletions
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index b6deebd08ef2..65c2431ea32f 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h | |||
@@ -37,6 +37,7 @@ struct nfsd_net { | |||
37 | 37 | ||
38 | struct lock_manager nfsd4_manager; | 38 | struct lock_manager nfsd4_manager; |
39 | bool grace_ended; | 39 | bool grace_ended; |
40 | time_t boot_time; | ||
40 | }; | 41 | }; |
41 | 42 | ||
42 | extern int nfsd_net_id; | 43 | extern int nfsd_net_id; |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index aebb58d3ac4a..cc894eda385a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -53,7 +53,6 @@ | |||
53 | /* Globals */ | 53 | /* Globals */ |
54 | time_t nfsd4_lease = 90; /* default lease time */ | 54 | time_t nfsd4_lease = 90; /* default lease time */ |
55 | time_t nfsd4_grace = 90; | 55 | time_t nfsd4_grace = 90; |
56 | static time_t boot_time; | ||
57 | 56 | ||
58 | #define all_ones {{~0,~0},~0} | 57 | #define all_ones {{~0,~0},~0} |
59 | static const stateid_t one_stateid = { | 58 | static const stateid_t one_stateid = { |
@@ -1056,12 +1055,12 @@ renew_client(struct nfs4_client *clp) | |||
1056 | 1055 | ||
1057 | /* SETCLIENTID and SETCLIENTID_CONFIRM Helper functions */ | 1056 | /* SETCLIENTID and SETCLIENTID_CONFIRM Helper functions */ |
1058 | static int | 1057 | static int |
1059 | STALE_CLIENTID(clientid_t *clid) | 1058 | STALE_CLIENTID(clientid_t *clid, struct nfsd_net *nn) |
1060 | { | 1059 | { |
1061 | if (clid->cl_boot == boot_time) | 1060 | if (clid->cl_boot == nn->boot_time) |
1062 | return 0; | 1061 | return 0; |
1063 | dprintk("NFSD stale clientid (%08x/%08x) boot_time %08lx\n", | 1062 | dprintk("NFSD stale clientid (%08x/%08x) boot_time %08lx\n", |
1064 | clid->cl_boot, clid->cl_id, boot_time); | 1063 | clid->cl_boot, clid->cl_id, nn->boot_time); |
1065 | return 1; | 1064 | return 1; |
1066 | } | 1065 | } |
1067 | 1066 | ||
@@ -1242,8 +1241,9 @@ same_creds(struct svc_cred *cr1, struct svc_cred *cr2) | |||
1242 | static void gen_clid(struct nfs4_client *clp) | 1241 | static void gen_clid(struct nfs4_client *clp) |
1243 | { | 1242 | { |
1244 | static u32 current_clientid = 1; | 1243 | static u32 current_clientid = 1; |
1244 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | ||
1245 | 1245 | ||
1246 | clp->cl_clientid.cl_boot = boot_time; | 1246 | clp->cl_clientid.cl_boot = nn->boot_time; |
1247 | clp->cl_clientid.cl_id = current_clientid++; | 1247 | clp->cl_clientid.cl_id = current_clientid++; |
1248 | } | 1248 | } |
1249 | 1249 | ||
@@ -2226,8 +2226,9 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
2226 | nfs4_verifier confirm = setclientid_confirm->sc_confirm; | 2226 | nfs4_verifier confirm = setclientid_confirm->sc_confirm; |
2227 | clientid_t * clid = &setclientid_confirm->sc_clientid; | 2227 | clientid_t * clid = &setclientid_confirm->sc_clientid; |
2228 | __be32 status; | 2228 | __be32 status; |
2229 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | ||
2229 | 2230 | ||
2230 | if (STALE_CLIENTID(clid)) | 2231 | if (STALE_CLIENTID(clid, nn)) |
2231 | return nfserr_stale_clientid; | 2232 | return nfserr_stale_clientid; |
2232 | nfs4_lock_state(); | 2233 | nfs4_lock_state(); |
2233 | 2234 | ||
@@ -2586,8 +2587,9 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate, | |||
2586 | unsigned int strhashval; | 2587 | unsigned int strhashval; |
2587 | struct nfs4_openowner *oo = NULL; | 2588 | struct nfs4_openowner *oo = NULL; |
2588 | __be32 status; | 2589 | __be32 status; |
2590 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | ||
2589 | 2591 | ||
2590 | if (STALE_CLIENTID(&open->op_clientid)) | 2592 | if (STALE_CLIENTID(&open->op_clientid, nn)) |
2591 | return nfserr_stale_clientid; | 2593 | return nfserr_stale_clientid; |
2592 | /* | 2594 | /* |
2593 | * In case we need it later, after we've already created the | 2595 | * In case we need it later, after we've already created the |
@@ -3095,12 +3097,13 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
3095 | { | 3097 | { |
3096 | struct nfs4_client *clp; | 3098 | struct nfs4_client *clp; |
3097 | __be32 status; | 3099 | __be32 status; |
3100 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | ||
3098 | 3101 | ||
3099 | nfs4_lock_state(); | 3102 | nfs4_lock_state(); |
3100 | dprintk("process_renew(%08x/%08x): starting\n", | 3103 | dprintk("process_renew(%08x/%08x): starting\n", |
3101 | clid->cl_boot, clid->cl_id); | 3104 | clid->cl_boot, clid->cl_id); |
3102 | status = nfserr_stale_clientid; | 3105 | status = nfserr_stale_clientid; |
3103 | if (STALE_CLIENTID(clid)) | 3106 | if (STALE_CLIENTID(clid, nn)) |
3104 | goto out; | 3107 | goto out; |
3105 | clp = find_confirmed_client(clid); | 3108 | clp = find_confirmed_client(clid); |
3106 | status = nfserr_expired; | 3109 | status = nfserr_expired; |
@@ -3130,7 +3133,7 @@ nfsd4_end_grace(struct net *net) | |||
3130 | 3133 | ||
3131 | dprintk("NFSD: end of grace period\n"); | 3134 | dprintk("NFSD: end of grace period\n"); |
3132 | nn->grace_ended = true; | 3135 | nn->grace_ended = true; |
3133 | nfsd4_record_grace_done(net, boot_time); | 3136 | nfsd4_record_grace_done(net, nn->boot_time); |
3134 | locks_end_grace(&nn->nfsd4_manager); | 3137 | locks_end_grace(&nn->nfsd4_manager); |
3135 | /* | 3138 | /* |
3136 | * Now that every NFSv4 client has had the chance to recover and | 3139 | * Now that every NFSv4 client has had the chance to recover and |
@@ -3236,9 +3239,9 @@ static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_ol_stateid *s | |||
3236 | } | 3239 | } |
3237 | 3240 | ||
3238 | static int | 3241 | static int |
3239 | STALE_STATEID(stateid_t *stateid) | 3242 | STALE_STATEID(stateid_t *stateid, struct nfsd_net *nn) |
3240 | { | 3243 | { |
3241 | if (stateid->si_opaque.so_clid.cl_boot == boot_time) | 3244 | if (stateid->si_opaque.so_clid.cl_boot == nn->boot_time) |
3242 | return 0; | 3245 | return 0; |
3243 | dprintk("NFSD: stale stateid " STATEID_FMT "!\n", | 3246 | dprintk("NFSD: stale stateid " STATEID_FMT "!\n", |
3244 | STATEID_VAL(stateid)); | 3247 | STATEID_VAL(stateid)); |
@@ -3373,10 +3376,11 @@ static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid) | |||
3373 | static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, struct nfs4_stid **s) | 3376 | static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, struct nfs4_stid **s) |
3374 | { | 3377 | { |
3375 | struct nfs4_client *cl; | 3378 | struct nfs4_client *cl; |
3379 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | ||
3376 | 3380 | ||
3377 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) | 3381 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) |
3378 | return nfserr_bad_stateid; | 3382 | return nfserr_bad_stateid; |
3379 | if (STALE_STATEID(stateid)) | 3383 | if (STALE_STATEID(stateid, nn)) |
3380 | return nfserr_stale_stateid; | 3384 | return nfserr_stale_stateid; |
3381 | cl = find_confirmed_client(&stateid->si_opaque.so_clid); | 3385 | cl = find_confirmed_client(&stateid->si_opaque.so_clid); |
3382 | if (!cl) | 3386 | if (!cl) |
@@ -4048,6 +4052,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
4048 | bool new_state = false; | 4052 | bool new_state = false; |
4049 | int lkflg; | 4053 | int lkflg; |
4050 | int err; | 4054 | int err; |
4055 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | ||
4051 | 4056 | ||
4052 | dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", | 4057 | dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", |
4053 | (long long) lock->lk_offset, | 4058 | (long long) lock->lk_offset, |
@@ -4074,7 +4079,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
4074 | sizeof(clientid_t)); | 4079 | sizeof(clientid_t)); |
4075 | 4080 | ||
4076 | status = nfserr_stale_clientid; | 4081 | status = nfserr_stale_clientid; |
4077 | if (STALE_CLIENTID(&lock->lk_new_clientid)) | 4082 | if (STALE_CLIENTID(&lock->lk_new_clientid, nn)) |
4078 | goto out; | 4083 | goto out; |
4079 | 4084 | ||
4080 | /* validate and update open stateid and open seqid */ | 4085 | /* validate and update open stateid and open seqid */ |
@@ -4208,6 +4213,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
4208 | struct file_lock file_lock; | 4213 | struct file_lock file_lock; |
4209 | struct nfs4_lockowner *lo; | 4214 | struct nfs4_lockowner *lo; |
4210 | __be32 status; | 4215 | __be32 status; |
4216 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | ||
4211 | 4217 | ||
4212 | if (locks_in_grace(SVC_NET(rqstp))) | 4218 | if (locks_in_grace(SVC_NET(rqstp))) |
4213 | return nfserr_grace; | 4219 | return nfserr_grace; |
@@ -4218,7 +4224,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
4218 | nfs4_lock_state(); | 4224 | nfs4_lock_state(); |
4219 | 4225 | ||
4220 | status = nfserr_stale_clientid; | 4226 | status = nfserr_stale_clientid; |
4221 | if (!nfsd4_has_session(cstate) && STALE_CLIENTID(&lockt->lt_clientid)) | 4227 | if (!nfsd4_has_session(cstate) && STALE_CLIENTID(&lockt->lt_clientid, nn)) |
4222 | goto out; | 4228 | goto out; |
4223 | 4229 | ||
4224 | if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) | 4230 | if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) |
@@ -4367,6 +4373,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, | |||
4367 | struct list_head matches; | 4373 | struct list_head matches; |
4368 | unsigned int hashval = ownerstr_hashval(clid->cl_id, owner); | 4374 | unsigned int hashval = ownerstr_hashval(clid->cl_id, owner); |
4369 | __be32 status; | 4375 | __be32 status; |
4376 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | ||
4370 | 4377 | ||
4371 | dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n", | 4378 | dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n", |
4372 | clid->cl_boot, clid->cl_id); | 4379 | clid->cl_boot, clid->cl_id); |
@@ -4374,7 +4381,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, | |||
4374 | /* XXX check for lease expiration */ | 4381 | /* XXX check for lease expiration */ |
4375 | 4382 | ||
4376 | status = nfserr_stale_clientid; | 4383 | status = nfserr_stale_clientid; |
4377 | if (STALE_CLIENTID(clid)) | 4384 | if (STALE_CLIENTID(clid, nn)) |
4378 | return status; | 4385 | return status; |
4379 | 4386 | ||
4380 | nfs4_lock_state(); | 4387 | nfs4_lock_state(); |
@@ -4701,7 +4708,7 @@ nfs4_state_start(void) | |||
4701 | */ | 4708 | */ |
4702 | get_net(net); | 4709 | get_net(net); |
4703 | nfsd4_client_tracking_init(net); | 4710 | nfsd4_client_tracking_init(net); |
4704 | boot_time = get_seconds(); | 4711 | nn->boot_time = get_seconds(); |
4705 | locks_start_grace(net, &nn->nfsd4_manager); | 4712 | locks_start_grace(net, &nn->nfsd4_manager); |
4706 | nn->grace_ended = false; | 4713 | nn->grace_ended = false; |
4707 | printk(KERN_INFO "NFSD: starting %ld-second grace period\n", | 4714 | printk(KERN_INFO "NFSD: starting %ld-second grace period\n", |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 981ef10141b3..e6173147f982 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -450,6 +450,7 @@ static inline struct nfs4_ol_stateid *openlockstateid(struct nfs4_stid *s) | |||
450 | #define WR_STATE 0x00000020 | 450 | #define WR_STATE 0x00000020 |
451 | 451 | ||
452 | struct nfsd4_compound_state; | 452 | struct nfsd4_compound_state; |
453 | struct nfsd_net; | ||
453 | 454 | ||
454 | extern __be32 nfs4_preprocess_stateid_op(struct net *net, | 455 | extern __be32 nfs4_preprocess_stateid_op(struct net *net, |
455 | struct nfsd4_compound_state *cstate, | 456 | struct nfsd4_compound_state *cstate, |