Skip to content

Commit

Permalink
nfsd: make NFSv4 grace time per net
Browse files Browse the repository at this point in the history
Grace time is a part of NFSv4 state engine, which is constructed per network
namespace.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Stanislav Kinsbursky authored and J. Bruce Fields committed Nov 28, 2012
1 parent 3d73371 commit 5284b44
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions fs/nfsd/netns.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct nfsd_net {
bool in_grace;

time_t nfsd4_lease;
time_t nfsd4_grace;
};

extern int nfsd_net_id;
Expand Down
9 changes: 3 additions & 6 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@

#define NFSDDBG_FACILITY NFSDDBG_PROC

/* Globals */
time_t nfsd4_grace = 90;

#define all_ones {{~0,~0},~0}
static const stateid_t one_stateid = {
.si_generation = ~0,
Expand Down Expand Up @@ -3183,7 +3180,7 @@ nfsd4_end_grace(struct nfsd_net *nn)
* to see the (possibly new, possibly shorter) lease time, we
* can safely set the next grace time to the current lease time:
*/
nfsd4_grace = nn->nfsd4_lease;
nn->nfsd4_grace = nn->nfsd4_lease;
}

static time_t
Expand Down Expand Up @@ -4884,8 +4881,8 @@ nfs4_state_start_net(struct net *net)
locks_start_grace(net, &nn->nfsd4_manager);
nn->grace_ended = false;
printk(KERN_INFO "NFSD: starting %ld-second grace period (net %p)\n",
nfsd4_grace, net);
queue_delayed_work(laundry_wq, &nn->laundromat_work, nfsd4_grace * HZ);
nn->nfsd4_grace, net);
queue_delayed_work(laundry_wq, &nn->laundromat_work, nn->nfsd4_grace * HZ);
return 0;
}

Expand Down
4 changes: 3 additions & 1 deletion fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,8 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
*/
static ssize_t write_gracetime(struct file *file, char *buf, size_t size)
{
return nfsd4_write_time(file, buf, size, &nfsd4_grace);
struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace);
}

static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size)
Expand Down Expand Up @@ -1070,6 +1071,7 @@ static __net_init int nfsd_init_net(struct net *net)
if (retval)
goto out_idmap_error;
nn->nfsd4_lease = 90; /* default lease time */
nn->nfsd4_grace = 90;
return 0;

out_idmap_error:
Expand Down
2 changes: 0 additions & 2 deletions fs/nfsd/nfsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ extern struct timeval nfssvc_boot;

#ifdef CONFIG_NFSD_V4

extern time_t nfsd4_grace;

/* before processing a COMPOUND operation, we have to check that there
* is enough space in the buffer for XDR encode to succeed. otherwise,
* we might process an operation with side effects, and be unable to
Expand Down

0 comments on commit 5284b44

Please sign in to comment.