]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
nfsd: make NFSv4 lease time per net
authorStanislav Kinsbursky <skinsbursky@parallels.com>
Tue, 27 Nov 2012 11:11:44 +0000 (14:11 +0300)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 28 Nov 2012 15:39:46 +0000 (10:39 -0500)
Lease 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>
fs/nfsd/netns.h
fs/nfsd/nfs4callback.c
fs/nfsd/nfs4state.c
fs/nfsd/nfs4xdr.c
fs/nfsd/nfsctl.c
fs/nfsd/nfsd.h

index 9047706b3e1018e386537346e22df5c2668ff42b..0c20be82cb01fa21245cfd9f2211586da52b3312 100644 (file)
@@ -87,6 +87,8 @@ struct nfsd_net {
 
        struct file *rec_file;
        bool in_grace;
+
+       time_t nfsd4_lease;
 };
 
 extern int nfsd_net_id;
index 826cc269c4457569413c55bc6b258ff93d9ba67d..99bc85ff02179f3e28ed36f56872e1e48d190e21 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/slab.h>
 #include "nfsd.h"
 #include "state.h"
+#include "netns.h"
 
 #define NFSDDBG_FACILITY                NFSDDBG_PROC
 
@@ -625,9 +626,10 @@ static const struct rpc_program cb_program = {
        .pipe_dir_name          = "nfsd4_cb",
 };
 
-static int max_cb_time(void)
+static int max_cb_time(struct net *net)
 {
-       return max(nfsd4_lease/10, (time_t)1) * HZ;
+       struct nfsd_net *nn = net_generic(net, nfsd_net_id);
+       return max(nn->nfsd4_lease/10, (time_t)1) * HZ;
 }
 
 static struct rpc_cred *callback_cred;
@@ -659,7 +661,7 @@ static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc
 static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
 {
        struct rpc_timeout      timeparms = {
-               .to_initval     = max_cb_time(),
+               .to_initval     = max_cb_time(clp->net),
                .to_retries     = 0,
        };
        struct rpc_create_args args = {
index fb98f291aac2f725f453b9dad575cb067bc78c8a..932b2ca6f203ec6ae805510bf14e6c2dd5a2ea42 100644 (file)
@@ -51,7 +51,6 @@
 #define NFSDDBG_FACILITY                NFSDDBG_PROC
 
 /* Globals */
-time_t nfsd4_lease = 90;     /* default lease time */
 time_t nfsd4_grace = 90;
 
 #define all_ones {{~0,~0},~0}
@@ -3184,7 +3183,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 = nfsd4_lease;
+       nfsd4_grace = nn->nfsd4_lease;
 }
 
 static time_t
@@ -3194,9 +3193,9 @@ nfs4_laundromat(struct nfsd_net *nn)
        struct nfs4_openowner *oo;
        struct nfs4_delegation *dp;
        struct list_head *pos, *next, reaplist;
-       time_t cutoff = get_seconds() - nfsd4_lease;
-       time_t t, clientid_val = nfsd4_lease;
-       time_t u, test_val = nfsd4_lease;
+       time_t cutoff = get_seconds() - nn->nfsd4_lease;
+       time_t t, clientid_val = nn->nfsd4_lease;
+       time_t u, test_val = nn->nfsd4_lease;
 
        nfs4_lock_state();
 
@@ -3245,7 +3244,7 @@ nfs4_laundromat(struct nfsd_net *nn)
                dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
                unhash_delegation(dp);
        }
-       test_val = nfsd4_lease;
+       test_val = nn->nfsd4_lease;
        list_for_each_safe(pos, next, &nn->close_lru) {
                oo = container_of(pos, struct nfs4_openowner, oo_close_lru);
                if (time_after((unsigned long)oo->oo_time, (unsigned long)cutoff)) {
index 250171c5c311deabd41fa8814d889299b6b77eab..b775366a0a68ff166c25791080a3477c26a8a408 100644 (file)
@@ -53,6 +53,7 @@
 #include "vfs.h"
 #include "state.h"
 #include "cache.h"
+#include "netns.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
 
@@ -2052,6 +2053,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
                .mnt    = exp->ex_path.mnt,
                .dentry = dentry,
        };
+       struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
 
        BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1);
        BUG_ON(bmval0 & ~nfsd_suppattrs0(minorversion));
@@ -2212,7 +2214,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
        if (bmval0 & FATTR4_WORD0_LEASE_TIME) {
                if ((buflen -= 4) < 0)
                        goto out_resource;
-               WRITE32(nfsd4_lease);
+               WRITE32(nn->nfsd4_lease);
        }
        if (bmval0 & FATTR4_WORD0_RDATTR_ERROR) {
                if ((buflen -= 4) < 0)
index f5ab74af6ce2a1e24893ccfa51e89d492d3a61d6..09d909a42ececdf4f8fbb7a8dc65face91048b4e 100644 (file)
@@ -909,7 +909,8 @@ static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, time_
  */
 static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
 {
-       return nfsd4_write_time(file, buf, size, &nfsd4_lease);
+       struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
+       return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease);
 }
 
 /**
@@ -1060,6 +1061,7 @@ int nfsd_net_id;
 static __net_init int nfsd_init_net(struct net *net)
 {
        int retval;
+       struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 
        retval = nfsd_export_init(net);
        if (retval)
@@ -1067,6 +1069,7 @@ static __net_init int nfsd_init_net(struct net *net)
        retval = nfsd_idmap_init(net);
        if (retval)
                goto out_idmap_error;
+       nn->nfsd4_lease = 90;   /* default lease time */
        return 0;
 
 out_idmap_error:
index d7b210b735e10fb115783707336bc5a686e27f3f..a8f7325a9124aa0f9ffaeafc3c0f83a1e5c6bd2b 100644 (file)
@@ -276,7 +276,6 @@ extern struct timeval       nfssvc_boot;
 
 #ifdef CONFIG_NFSD_V4
 
-extern time_t nfsd4_lease;
 extern time_t nfsd4_grace;
 
 /* before processing a COMPOUND operation, we have to check that there