Skip to contentSkip to conversation

nfs4.0: Refetch lease_time after clientID reset

PATCH Superseded Donald Buczek 1 participant 5 messages Feb 27, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover nfs4.0: Refetch lease_time after clientID reset

We've noticed, that nfs mounts with vers=4.0 do not pick up a updated lease_time after a restart of the nfs server. This was discussed in the thread "4.0 client and server restart with decreased lease time" on linux-nfs [1].

This patch set fixes the issue for nsf4.0 clients so that hey behave as nfs4.1 and nfs4.2 clients do. After a new clientID is established, the lease_time is re-fetched and used.

I've notcied, that the flag NFS_CS_CHECK_LEASE_TIME is not functional in the existing code. It is set and tested, but never reset. Either nfs4_setup_state_renewal should reset the flag after it verified the lease_time or the flag could be removed altogether. I left it as is, because I don't known what is preferred.

[1] https://marc.info/?t=154954022700002&r=1&w=2

Donald Buczek (4):
nfs: Fix copy-and-paste error in debug message
nfs4: Rename nfs41_setup_state_renewal
nfs4: Move nfs4_setup_state_renewal nfs4.0: Refetch lease_time after clientid update

 fs/nfs/nfs4state.c | 46 +++++++++++++++++++++++-----------------------
 fs/nfs/nfs4xdr.c   |  2 +-
 2 files changed, 24 insertions(+), 24 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/4 nfs: Fix copy-and-paste error in debug message

The debug message of decode_attr_lease_time incorrectly says "file size". Fix it to "lease time".

---
 fs/nfs/nfs4xdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4xdr.c +1 -1
index 2fc8f6fa25e4..34adaa899a8c 100644
@@ -3471,7 +3471,7 @@ static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint
 		*res = be32_to_cpup(p);
 		bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
 	}
-	dprintk("%s: file size=%u\n", __func__, (unsigned int)*res);
+	dprintk("%s: lease time=%u\n", __func__, (unsigned int)*res);
 	return 0;
 out_overflow:
 	print_overflow_msg(__func__, xdr);
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/4 nfs4: Rename nfs41_setup_state_renewal

In reply to Donald Buczek

The function nfs41_setup_state_renewal is useful to the nfs 4.0 client as well, so rename the function to nfs4_setup_state_renewal.

---
 fs/nfs/nfs4state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4state.c +2 -2
index 02488b50534a..28863a9b705d 100644
@@ -282,7 +282,7 @@ static int nfs4_begin_drain_session(struct nfs_client *clp)
 
 #if defined(CONFIG_NFS_V4_1)
 
-static int nfs41_setup_state_renewal(struct nfs_client *clp)
+static int nfs4_setup_state_renewal(struct nfs_client *clp)
 {
 	int status;
 	struct nfs_fsinfo fsinfo;
@@ -309,7 +309,7 @@ static void nfs41_finish_session_reset(struct nfs_client *clp)
 	clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
 	/* create_session negotiated new slot table */
 	clear_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state);
-	nfs41_setup_state_renewal(clp);
+	nfs4_setup_state_renewal(clp);
 }
 
 int nfs41_init_clientid(struct nfs_client *clp, const struct cred *cred)
Signature · 1 line
2.21.0
#3 lore raw

PATCH 3/4 nfs4: Move nfs4_setup_state_renewal

In reply to Donald Buczek

The function nfs4_setup_state_renewal is to be used by nfs4_init_clientid. Move it further to the top of the source file to include it regardles of CONFIG_NFS_V4_1 and to save a forward declaration. No code changed.

---
 fs/nfs/nfs4state.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)
fs/nfs/nfs4state.c +21 -21
index 28863a9b705d..ba6889dcf3d6 100644
@@ -87,6 +87,27 @@ const nfs4_stateid current_stateid = {
 
 static DEFINE_MUTEX(nfs_clid_init_mutex);
 
+static int nfs4_setup_state_renewal(struct nfs_client *clp)
+{
+	int status;
+	struct nfs_fsinfo fsinfo;
+	unsigned long now;
+
+	if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
+		nfs4_schedule_state_renewal(clp);
+		return 0;
+	}
+
+	now = jiffies;
+	status = nfs4_proc_get_lease_time(clp, &fsinfo);
+	if (status == 0) {
+		nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now);
+		nfs4_schedule_state_renewal(clp);
+	}
+
+	return status;
+}
+
 int nfs4_init_clientid(struct nfs_client *clp, const struct cred *cred)
 {
 	struct nfs4_setclientid_res clid = {
@@ -282,27 +303,6 @@ static int nfs4_begin_drain_session(struct nfs_client *clp)
 
 #if defined(CONFIG_NFS_V4_1)
 
-static int nfs4_setup_state_renewal(struct nfs_client *clp)
-{
-	int status;
-	struct nfs_fsinfo fsinfo;
-	unsigned long now;
-
-	if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
-		nfs4_schedule_state_renewal(clp);
-		return 0;
-	}
-
-	now = jiffies;
-	status = nfs4_proc_get_lease_time(clp, &fsinfo);
-	if (status == 0) {
-		nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now);
-		nfs4_schedule_state_renewal(clp);
-	}
-
-	return status;
-}
-
 static void nfs41_finish_session_reset(struct nfs_client *clp)
 {
 	clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
Signature · 1 line
2.21.0
#4 lore raw

PATCH 4/4 nfs4.0: Refetch lease_time after clientid update

In reply to Donald Buczek

RFC 7530 requires us to refetch the lease time attribute once a new clientID is established. This is already implemented for the nfs4.1(+) clients by nfs41_init_clientid, which calls nfs41_finish_session_reset, which calls nfs4_setup_state_renewal.

Let nfs4_init_clientid, which is used for 4.0 clients, call nfs4_setup_state_renewal as well.

---
 fs/nfs/nfs4state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4state.c +1 -1
index ba6889dcf3d6..6059cb5408ff 100644
@@ -135,7 +135,7 @@ int nfs4_init_clientid(struct nfs_client *clp, const struct cred *cred)
 	if (status != 0)
 		goto out;
 	clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
-	nfs4_schedule_state_renewal(clp);
+	nfs4_setup_state_renewal(clp);
 out:
 	return status;
 }
Signature · 1 line
2.21.0