diff options
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 63 |
1 files changed, 12 insertions, 51 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 9bec088e7657..16c9a43218c3 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -53,7 +53,7 @@ | |||
53 | 53 | ||
54 | /* Globals */ | 54 | /* Globals */ |
55 | static time_t lease_time = 90; /* default lease time */ | 55 | static time_t lease_time = 90; /* default lease time */ |
56 | static time_t old_lease_time = 90; /* past incarnation lease time */ | 56 | static time_t user_lease_time = 90; |
57 | static u32 nfs4_reclaim_init = 0; | 57 | static u32 nfs4_reclaim_init = 0; |
58 | time_t boot_time; | 58 | time_t boot_time; |
59 | static time_t grace_end = 0; | 59 | static time_t grace_end = 0; |
@@ -3205,11 +3205,9 @@ __nfs4_state_init(void) | |||
3205 | INIT_LIST_HEAD(&del_recall_lru); | 3205 | INIT_LIST_HEAD(&del_recall_lru); |
3206 | spin_lock_init(&recall_lock); | 3206 | spin_lock_init(&recall_lock); |
3207 | boot_time = get_seconds(); | 3207 | boot_time = get_seconds(); |
3208 | grace_time = max(old_lease_time, lease_time); | 3208 | grace_time = max(user_lease_time, lease_time); |
3209 | if (reclaim_str_hashtbl_size == 0) | 3209 | lease_time = user_lease_time; |
3210 | grace_time = 0; | 3210 | printk("NFSD: starting %ld-second grace period\n", grace_time); |
3211 | if (grace_time) | ||
3212 | printk("NFSD: starting %ld-second grace period\n", grace_time); | ||
3213 | grace_end = boot_time + grace_time; | 3211 | grace_end = boot_time + grace_time; |
3214 | INIT_WORK(&laundromat_work,laundromat_main, NULL); | 3212 | INIT_WORK(&laundromat_work,laundromat_main, NULL); |
3215 | laundry_wq = create_singlethread_workqueue("nfsd4"); | 3213 | laundry_wq = create_singlethread_workqueue("nfsd4"); |
@@ -3307,53 +3305,16 @@ nfs4_state_shutdown(void) | |||
3307 | /* | 3305 | /* |
3308 | * Called when leasetime is changed. | 3306 | * Called when leasetime is changed. |
3309 | * | 3307 | * |
3310 | * if nfsd is not started, simply set the global lease. | 3308 | * The only way the protocol gives us to handle on-the-fly lease changes is to |
3311 | * | 3309 | * simulate a reboot. Instead of doing that, we just wait till the next time |
3312 | * if nfsd(s) are running, lease change requires nfsv4 state to be reset. | 3310 | * we start to register any changes in lease time. If the administrator |
3313 | * e.g: boot_time is reset, existing nfs4_client structs are | 3311 | * really wants to change the lease time *now*, they can go ahead and bring |
3314 | * used to fill reclaim_str_hashtbl, then all state (except for the | 3312 | * nfsd down and then back up again after changing the lease time. |
3315 | * reclaim_str_hashtbl) is re-initialized. | ||
3316 | * | ||
3317 | * if the old lease time is greater than the new lease time, the grace | ||
3318 | * period needs to be set to the old lease time to allow clients to reclaim | ||
3319 | * their state. XXX - we may want to set the grace period == lease time | ||
3320 | * after an initial grace period == old lease time | ||
3321 | * | ||
3322 | * if an error occurs in this process, the new lease is set, but the server | ||
3323 | * will not honor OPEN or LOCK reclaims, and will return nfserr_no_grace | ||
3324 | * which means OPEN/LOCK/READ/WRITE will fail during grace period. | ||
3325 | * | ||
3326 | * clients will attempt to reset all state with SETCLIENTID/CONFIRM, and | ||
3327 | * OPEN and LOCK reclaims. | ||
3328 | */ | 3313 | */ |
3329 | void | 3314 | void |
3330 | nfs4_reset_lease(time_t leasetime) | 3315 | nfs4_reset_lease(time_t leasetime) |
3331 | { | 3316 | { |
3332 | struct nfs4_client *clp; | 3317 | lock_kernel(); |
3333 | int i; | 3318 | user_lease_time = leasetime; |
3334 | 3319 | unlock_kernel(); | |
3335 | printk("NFSD: New leasetime %ld\n",leasetime); | ||
3336 | if (!nfs4_init) | ||
3337 | return; | ||
3338 | nfs4_lock_state(); | ||
3339 | old_lease_time = lease_time; | ||
3340 | lease_time = leasetime; | ||
3341 | |||
3342 | nfs4_release_reclaim(); | ||
3343 | |||
3344 | /* populate reclaim_str_hashtbl with current confirmed nfs4_clientid */ | ||
3345 | for (i = 0; i < CLIENT_HASH_SIZE; i++) { | ||
3346 | list_for_each_entry(clp, &conf_id_hashtbl[i], cl_idhash) { | ||
3347 | if (!nfs4_client_to_reclaim(clp->cl_name.data, | ||
3348 | clp->cl_name.len)) { | ||
3349 | nfs4_release_reclaim(); | ||
3350 | goto init_state; | ||
3351 | } | ||
3352 | } | ||
3353 | } | ||
3354 | init_state: | ||
3355 | __nfs4_state_shutdown(); | ||
3356 | __nfs4_state_init(); | ||
3357 | nfs4_unlock_state(); | ||
3358 | } | 3320 | } |
3359 | |||