aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@cse.unsw.edu.au>2005-06-24 01:04:25 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:06:35 -0400
commit190e4fbf96037e5e526ba3210f2bcc2a3b6fe964 (patch)
tree957fb35a6a2895622c4db0052160fd91d06153e8 /fs/nfsd/nfs4state.c
parentcb36d6345752fa24827044c68e15f6708a40d9f6 (diff)
[PATCH] knfsd: nfsd4: initialize recovery directory
NFSv4 clients are required to know what state they have on the server so that they can reclaim it on server reboot. However, it is possible for pathalogical combinations of server reboots and network partitions to leave a client in a state where it cannot know whether it has lost its state on the server. For this reason, rfc3530 requires that we store some information about clients to stable storage. So we maintain a directory /var/lib/nfs/v4recovery with a subdirectory for each client with active state. We leave open the possibility of including files underneath each such subdirectory with information about the client, but for now the subdirectories are empty. We create a client subdirectory whenever a client makes its first non-reclaim open_confirm. We remove a client subdirectory whenever either a) its lease expires, or b) the grace period ends without it reclaiming anything. When handling reclaims, we allow the reclaim if and only if the client doing the reclaim has a subdirectory. This patch adds just the code to scan the recovery directory on nfsd startup. Signed-off-by: Andy Adamson <andros@citi.umich.edu> 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/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 0b47a97e953d..6b9d23c39afe 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -71,6 +71,7 @@ static stateid_t onestateid; /* bits all 1 */
71static struct nfs4_stateid * find_stateid(stateid_t *stid, int flags); 71static struct nfs4_stateid * find_stateid(stateid_t *stid, int flags);
72static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid); 72static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid);
73static void release_stateid_lockowners(struct nfs4_stateid *open_stp); 73static void release_stateid_lockowners(struct nfs4_stateid *open_stp);
74extern char recovery_dirname[];
74 75
75/* Locking: 76/* Locking:
76 * 77 *
@@ -3091,8 +3092,8 @@ alloc_reclaim(void)
3091/* 3092/*
3092 * failure => all reset bets are off, nfserr_no_grace... 3093 * failure => all reset bets are off, nfserr_no_grace...
3093 */ 3094 */
3094static int 3095int
3095nfs4_client_to_reclaim(char *name) 3096nfs4_client_to_reclaim(const char *name)
3096{ 3097{
3097 unsigned int strhashval; 3098 unsigned int strhashval;
3098 struct nfs4_client_reclaim *crp = NULL; 3099 struct nfs4_client_reclaim *crp = NULL;
@@ -3202,6 +3203,17 @@ nfs4_state_init(void)
3202 reclaim_str_hashtbl_size = 0; 3203 reclaim_str_hashtbl_size = 0;
3203} 3204}
3204 3205
3206static void
3207nfsd4_load_reboot_recovery_data(void)
3208{
3209 int status;
3210
3211 nfsd4_init_recdir(recovery_dirname);
3212 status = nfsd4_recdir_load();
3213 if (status)
3214 printk("NFSD: Failure reading reboot recovery data\n");
3215}
3216
3205/* initialization to perform when the nfsd service is started: */ 3217/* initialization to perform when the nfsd service is started: */
3206 3218
3207static void 3219static void
@@ -3228,6 +3240,7 @@ nfs4_state_start(void)
3228 status = nfsd4_init_slabs(); 3240 status = nfsd4_init_slabs();
3229 if (status) 3241 if (status)
3230 return status; 3242 return status;
3243 nfsd4_load_reboot_recovery_data();
3231 __nfs4_state_start(); 3244 __nfs4_state_start();
3232 nfs4_init = 1; 3245 nfs4_init = 1;
3233 return 0; 3246 return 0;
@@ -3286,6 +3299,7 @@ __nfs4_state_shutdown(void)
3286 cancel_delayed_work(&laundromat_work); 3299 cancel_delayed_work(&laundromat_work);
3287 flush_workqueue(laundry_wq); 3300 flush_workqueue(laundry_wq);
3288 destroy_workqueue(laundry_wq); 3301 destroy_workqueue(laundry_wq);
3302 nfsd4_shutdown_recdir();
3289 nfs4_init = 0; 3303 nfs4_init = 0;
3290} 3304}
3291 3305