Commit 33dcc481 authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields

nfsd: don't use locks_in_grace to determine whether to call nfs4_grace_end

It's possible that lockd or another lock manager might still be on the
list after we call nfsd4_end_grace. If the laundromat thread runs
again at that point, then we could end up calling nfsd4_end_grace more
than once.

That's not only inefficient, but calling nfsd4_recdir_purge_old more
than once could be problematic. Fix this by adding a new global
"grace_ended" flag and use that to determine whether we've already
called nfsd4_grace_end.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent a9aa53df
...@@ -3155,10 +3155,17 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -3155,10 +3155,17 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
static struct lock_manager nfsd4_manager = { static struct lock_manager nfsd4_manager = {
}; };
static bool grace_ended;
static void static void
nfsd4_end_grace(void) nfsd4_end_grace(void)
{ {
/* do nothing if grace period already ended */
if (grace_ended)
return;
dprintk("NFSD: end of grace period\n"); dprintk("NFSD: end of grace period\n");
grace_ended = true;
nfsd4_record_grace_done(&init_net, boot_time); nfsd4_record_grace_done(&init_net, boot_time);
locks_end_grace(&nfsd4_manager); locks_end_grace(&nfsd4_manager);
/* /*
...@@ -3183,7 +3190,6 @@ nfs4_laundromat(void) ...@@ -3183,7 +3190,6 @@ nfs4_laundromat(void)
nfs4_lock_state(); nfs4_lock_state();
dprintk("NFSD: laundromat service - starting\n"); dprintk("NFSD: laundromat service - starting\n");
if (locks_in_grace())
nfsd4_end_grace(); nfsd4_end_grace();
INIT_LIST_HEAD(&reaplist); INIT_LIST_HEAD(&reaplist);
spin_lock(&client_lock); spin_lock(&client_lock);
...@@ -4718,6 +4724,7 @@ nfs4_state_start(void) ...@@ -4718,6 +4724,7 @@ nfs4_state_start(void)
nfsd4_client_tracking_init(&init_net); nfsd4_client_tracking_init(&init_net);
boot_time = get_seconds(); boot_time = get_seconds();
locks_start_grace(&nfsd4_manager); locks_start_grace(&nfsd4_manager);
grace_ended = false;
printk(KERN_INFO "NFSD: starting %ld-second grace period\n", printk(KERN_INFO "NFSD: starting %ld-second grace period\n",
nfsd4_grace); nfsd4_grace);
ret = set_callback_cred(); ret = set_callback_cred();
......
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