aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-08-26 20:40:28 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-08-27 14:21:18 -0400
commit48483bf23a568f3ef4cc7ad2c8f1a082f10ad0e7 (patch)
tree7eafa1dd82e7aeccfded9aff023c972d78f4609f /fs
parent8e82fa8fdcd1271d45bf6a5195801c706e190d69 (diff)
nfsd4: simplify recovery dir setting
Move around some of this code, simplify a bit. Reviewed-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfs4recover.c36
-rw-r--r--fs/nfsd/nfs4state.c41
-rw-r--r--fs/nfsd/state.h2
3 files changed, 34 insertions, 45 deletions
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 29d77f60585b..c3466610e6cd 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -45,6 +45,7 @@
45 45
46/* Globals */ 46/* Globals */
47static struct file *rec_file; 47static struct file *rec_file;
48static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery";
48 49
49static int 50static int
50nfs4_save_creds(const struct cred **original_creds) 51nfs4_save_creds(const struct cred **original_creds)
@@ -354,13 +355,13 @@ nfsd4_recdir_load(void) {
354 */ 355 */
355 356
356void 357void
357nfsd4_init_recdir(char *rec_dirname) 358nfsd4_init_recdir()
358{ 359{
359 const struct cred *original_cred; 360 const struct cred *original_cred;
360 int status; 361 int status;
361 362
362 printk("NFSD: Using %s as the NFSv4 state recovery directory\n", 363 printk("NFSD: Using %s as the NFSv4 state recovery directory\n",
363 rec_dirname); 364 user_recovery_dirname);
364 365
365 BUG_ON(rec_file); 366 BUG_ON(rec_file);
366 367
@@ -372,10 +373,10 @@ nfsd4_init_recdir(char *rec_dirname)
372 return; 373 return;
373 } 374 }
374 375
375 rec_file = filp_open(rec_dirname, O_RDONLY | O_DIRECTORY, 0); 376 rec_file = filp_open(user_recovery_dirname, O_RDONLY | O_DIRECTORY, 0);
376 if (IS_ERR(rec_file)) { 377 if (IS_ERR(rec_file)) {
377 printk("NFSD: unable to find recovery directory %s\n", 378 printk("NFSD: unable to find recovery directory %s\n",
378 rec_dirname); 379 user_recovery_dirname);
379 rec_file = NULL; 380 rec_file = NULL;
380 } 381 }
381 382
@@ -390,3 +391,30 @@ nfsd4_shutdown_recdir(void)
390 fput(rec_file); 391 fput(rec_file);
391 rec_file = NULL; 392 rec_file = NULL;
392} 393}
394
395/*
396 * Change the NFSv4 recovery directory to recdir.
397 */
398int
399nfs4_reset_recoverydir(char *recdir)
400{
401 int status;
402 struct path path;
403
404 status = kern_path(recdir, LOOKUP_FOLLOW, &path);
405 if (status)
406 return status;
407 status = -ENOTDIR;
408 if (S_ISDIR(path.dentry->d_inode->i_mode)) {
409 strcpy(user_recovery_dirname, recdir);
410 status = 0;
411 }
412 path_put(&path);
413 return status;
414}
415
416char *
417nfs4_recoverydir(void)
418{
419 return user_recovery_dirname;
420}
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index aa0a36e3b09e..36d0beb76864 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -64,8 +64,6 @@ static struct nfs4_stateid * find_stateid(stateid_t *stid, int flags);
64static struct nfs4_stateid * search_for_stateid(stateid_t *stid); 64static struct nfs4_stateid * search_for_stateid(stateid_t *stid);
65static struct nfs4_delegation * search_for_delegation(stateid_t *stid); 65static struct nfs4_delegation * search_for_delegation(stateid_t *stid);
66static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid); 66static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid);
67static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery";
68static void nfs4_set_recdir(char *recdir);
69static int check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner); 67static int check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner);
70 68
71/* Locking: */ 69/* Locking: */
@@ -4523,7 +4521,7 @@ nfsd4_load_reboot_recovery_data(void)
4523 int status; 4521 int status;
4524 4522
4525 nfs4_lock_state(); 4523 nfs4_lock_state();
4526 nfsd4_init_recdir(user_recovery_dirname); 4524 nfsd4_init_recdir();
4527 status = nfsd4_recdir_load(); 4525 status = nfsd4_recdir_load();
4528 nfs4_unlock_state(); 4526 nfs4_unlock_state();
4529 if (status) 4527 if (status)
@@ -4632,40 +4630,3 @@ nfs4_state_shutdown(void)
4632 nfs4_unlock_state(); 4630 nfs4_unlock_state();
4633 nfsd4_destroy_callback_queue(); 4631 nfsd4_destroy_callback_queue();
4634} 4632}
4635
4636/*
4637 * user_recovery_dirname is protected by the nfsd_mutex since it's only
4638 * accessed when nfsd is starting.
4639 */
4640static void
4641nfs4_set_recdir(char *recdir)
4642{
4643 strcpy(user_recovery_dirname, recdir);
4644}
4645
4646/*
4647 * Change the NFSv4 recovery directory to recdir.
4648 */
4649int
4650nfs4_reset_recoverydir(char *recdir)
4651{
4652 int status;
4653 struct path path;
4654
4655 status = kern_path(recdir, LOOKUP_FOLLOW, &path);
4656 if (status)
4657 return status;
4658 status = -ENOTDIR;
4659 if (S_ISDIR(path.dentry->d_inode->i_mode)) {
4660 nfs4_set_recdir(recdir);
4661 status = 0;
4662 }
4663 path_put(&path);
4664 return status;
4665}
4666
4667char *
4668nfs4_recoverydir(void)
4669{
4670 return user_recovery_dirname;
4671}
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index 5cfebe504056..12c1b1ef52ec 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -467,7 +467,7 @@ extern void nfsd4_destroy_callback_queue(void);
467extern void nfsd4_shutdown_callback(struct nfs4_client *); 467extern void nfsd4_shutdown_callback(struct nfs4_client *);
468extern void nfs4_put_delegation(struct nfs4_delegation *dp); 468extern void nfs4_put_delegation(struct nfs4_delegation *dp);
469extern __be32 nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname); 469extern __be32 nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname);
470extern void nfsd4_init_recdir(char *recdir_name); 470extern void nfsd4_init_recdir(void);
471extern int nfsd4_recdir_load(void); 471extern int nfsd4_recdir_load(void);
472extern void nfsd4_shutdown_recdir(void); 472extern void nfsd4_shutdown_recdir(void);
473extern int nfs4_client_to_reclaim(const char *name); 473extern int nfs4_client_to_reclaim(const char *name);