aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNeilBrown <neilb@cse.unsw.edu.au>2005-06-24 01:03:21 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:06:31 -0400
commitd99a05adf8490cc171b7709554936b8f3ac9e362 (patch)
tree64be372b75ff074a4220491a439add60d7d92323 /fs
parent58da282b733cff4caef805c6555c7a3b90772946 (diff)
[PATCH] knfsd: nfsd4: simplify lease changing
The only way the protocol gives to change the lease time on the fly is to simulate a reboot. We don't have that completely right in the current code; among other things, we should probably put lockd in grace too while we do this. For now, let's just keep this simple, and wait till the next time nfsd starts to register any changes in lease time. If the administrator really wants to change the lease time *now*, they can go ahead and bring nfsd down and then back up again after changing the lease time. Also remove the "if (reclaim_str_hashtbl_size == 0)" case, a shortcut which skips the grace period if we know of no clients in need of recovery. This isn't going to work well with nlm. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfs4state.c63
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 */
55static time_t lease_time = 90; /* default lease time */ 55static time_t lease_time = 90; /* default lease time */
56static time_t old_lease_time = 90; /* past incarnation lease time */ 56static time_t user_lease_time = 90;
57static u32 nfs4_reclaim_init = 0; 57static u32 nfs4_reclaim_init = 0;
58time_t boot_time; 58time_t boot_time;
59static time_t grace_end = 0; 59static 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 */
3329void 3314void
3330nfs4_reset_lease(time_t leasetime) 3315nfs4_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 }
3354init_state:
3355 __nfs4_state_shutdown();
3356 __nfs4_state_init();
3357 nfs4_unlock_state();
3358} 3320}
3359