Commit ac4d8ff2 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] knfsd: nfsd4: clean up state initialization

Separate out stuff that needs initialization on startup from stuff that only
needs initialization on module init from static data.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 76a3550e
...@@ -117,7 +117,7 @@ static void release_stateid(struct nfs4_stateid *stp, int flags); ...@@ -117,7 +117,7 @@ static void release_stateid(struct nfs4_stateid *stp, int flags);
*/ */
/* recall_lock protects the del_recall_lru */ /* recall_lock protects the del_recall_lru */
spinlock_t recall_lock; spinlock_t recall_lock = SPIN_LOCK_UNLOCKED;
static struct list_head del_recall_lru; static struct list_head del_recall_lru;
static void static void
...@@ -3179,23 +3179,13 @@ nfs4_check_open_reclaim(clientid_t *clid) ...@@ -3179,23 +3179,13 @@ nfs4_check_open_reclaim(clientid_t *clid)
return nfs4_find_reclaim_client(clid) ? nfs_ok : nfserr_reclaim_bad; return nfs4_find_reclaim_client(clid) ? nfs_ok : nfserr_reclaim_bad;
} }
/* initialization to perform at module load time: */
/* void
* Start and stop routines nfs4_state_init(void)
*/
static void
__nfs4_state_start(void)
{ {
int i; int i;
time_t grace_time;
if (!nfs4_reclaim_init) {
for (i = 0; i < CLIENT_HASH_SIZE; i++)
INIT_LIST_HEAD(&reclaim_str_hashtbl[i]);
reclaim_str_hashtbl_size = 0;
nfs4_reclaim_init = 1;
}
for (i = 0; i < CLIENT_HASH_SIZE; i++) { for (i = 0; i < CLIENT_HASH_SIZE; i++) {
INIT_LIST_HEAD(&conf_id_hashtbl[i]); INIT_LIST_HEAD(&conf_id_hashtbl[i]);
INIT_LIST_HEAD(&conf_str_hashtbl[i]); INIT_LIST_HEAD(&conf_str_hashtbl[i]);
...@@ -3217,19 +3207,28 @@ __nfs4_state_start(void) ...@@ -3217,19 +3207,28 @@ __nfs4_state_start(void)
INIT_LIST_HEAD(&lock_ownerid_hashtbl[i]); INIT_LIST_HEAD(&lock_ownerid_hashtbl[i]);
INIT_LIST_HEAD(&lock_ownerstr_hashtbl[i]); INIT_LIST_HEAD(&lock_ownerstr_hashtbl[i]);
} }
memset(&zerostateid, 0, sizeof(stateid_t));
memset(&onestateid, ~0, sizeof(stateid_t)); memset(&onestateid, ~0, sizeof(stateid_t));
INIT_LIST_HEAD(&close_lru); INIT_LIST_HEAD(&close_lru);
INIT_LIST_HEAD(&client_lru); INIT_LIST_HEAD(&client_lru);
INIT_LIST_HEAD(&del_recall_lru); INIT_LIST_HEAD(&del_recall_lru);
spin_lock_init(&recall_lock); for (i = 0; i < CLIENT_HASH_SIZE; i++)
INIT_LIST_HEAD(&reclaim_str_hashtbl[i]);
reclaim_str_hashtbl_size = 0;
nfs4_reclaim_init = 1;
}
/* initialization to perform when the nfsd service is started: */
static void
__nfs4_state_start(void)
{
time_t grace_time;
boot_time = get_seconds(); boot_time = get_seconds();
grace_time = max(user_lease_time, lease_time); grace_time = max(user_lease_time, lease_time);
lease_time = user_lease_time; lease_time = user_lease_time;
printk("NFSD: starting %ld-second grace period\n", grace_time); printk("NFSD: starting %ld-second grace period\n", grace_time);
grace_end = boot_time + grace_time; grace_end = boot_time + grace_time;
INIT_WORK(&laundromat_work,laundromat_main, NULL);
laundry_wq = create_singlethread_workqueue("nfsd4"); laundry_wq = create_singlethread_workqueue("nfsd4");
queue_delayed_work(laundry_wq, &laundromat_work, NFSD_LEASE_TIME*HZ); queue_delayed_work(laundry_wq, &laundromat_work, NFSD_LEASE_TIME*HZ);
} }
......
...@@ -397,6 +397,7 @@ static int __init init_nfsd(void) ...@@ -397,6 +397,7 @@ static int __init init_nfsd(void)
nfsd_cache_init(); /* RPC reply cache */ nfsd_cache_init(); /* RPC reply cache */
nfsd_export_init(); /* Exports table */ nfsd_export_init(); /* Exports table */
nfsd_lockd_init(); /* lockd->nfsd callbacks */ nfsd_lockd_init(); /* lockd->nfsd callbacks */
nfs4_state_init(); /* NFSv4 locking state */
#ifdef CONFIG_NFSD_V4 #ifdef CONFIG_NFSD_V4
nfsd_idmap_init(); /* Name to ID mapping */ nfsd_idmap_init(); /* Name to ID mapping */
#endif /* CONFIG_NFSD_V4 */ #endif /* CONFIG_NFSD_V4 */
......
...@@ -145,11 +145,13 @@ int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *); ...@@ -145,11 +145,13 @@ int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *);
* NFSv4 State * NFSv4 State
*/ */
#ifdef CONFIG_NFSD_V4 #ifdef CONFIG_NFSD_V4
void nfs4_state_init(void);
int nfs4_state_start(void); int nfs4_state_start(void);
void nfs4_state_shutdown(void); void nfs4_state_shutdown(void);
time_t nfs4_lease_time(void); time_t nfs4_lease_time(void);
void nfs4_reset_lease(time_t leasetime); void nfs4_reset_lease(time_t leasetime);
#else #else
static inline void nfs4_state_init(void){};
static inline int nfs4_state_start(void){return 0;} static inline int nfs4_state_start(void){return 0;}
static inline void nfs4_state_shutdown(void){} static inline void nfs4_state_shutdown(void){}
static inline time_t nfs4_lease_time(void){return 0;} static inline time_t nfs4_lease_time(void){return 0;}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment