Skip to content

Commit 7dc2993

Browse files
rmilkowskiamschuma-ntap
authored andcommitted
NFSv4.0: nfs4_do_fsinfo() should not do implicit lease renewals
Currently, each time nfs4_do_fsinfo() is called it will do an implicit NFS4 lease renewal, which is not compliant with the NFS4 specification. This can result in a lease being expired by an NFS server. Commit 83ca7f5 ("NFS: Avoid PUTROOTFH when managing leases") introduced implicit client lease renewal in nfs4_do_fsinfo(), which can result in the NFSv4.0 lease to expire on a server side, and servers returning NFS4ERR_EXPIRED or NFS4ERR_STALE_CLIENTID. This can easily be reproduced by frequently unmounting a sub-mount, then stat'ing it to get it mounted again, which will delay or even completely prevent client from sending RENEW operations if no other NFS operations are issued. Eventually nfs server will expire client's lease and return an error on file access or next RENEW. This can also happen when a sub-mount is automatically unmounted due to inactivity (after nfs_mountpoint_expiry_timeout), then it is mounted again via stat(). This can result in a short window during which client's lease will expire on a server but not on a client. This specific case was observed on production systems. This patch removes the implicit lease renewal from nfs4_do_fsinfo(). Fixes: 83ca7f5 ("NFS: Avoid PUTROOTFH when managing leases") Signed-off-by: Robert Milkowski <rmilkowski@gmail.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 924491f commit 7dc2993

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

‎fs/nfs/nfs4_fs.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,7 @@ extern void nfs4_schedule_state_renewal(struct nfs_client *);
447447
extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
448448
extern void nfs4_kill_renewd(struct nfs_client *);
449449
extern void nfs4_renew_state(struct work_struct *);
450-
extern void nfs4_set_lease_period(struct nfs_client *clp,
451-
unsigned long lease,
452-
unsigned long lastrenewed);
450+
extern void nfs4_set_lease_period(struct nfs_client *clp, unsigned long lease);
453451

454452

455453
/* nfs4state.c */

‎fs/nfs/nfs4proc.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5053,16 +5053,13 @@ static int nfs4_do_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, str
50535053
struct nfs4_exception exception = {
50545054
.interruptible = true,
50555055
};
5056-
unsigned long now = jiffies;
50575056
int err;
50585057

50595058
do {
50605059
err = _nfs4_do_fsinfo(server, fhandle, fsinfo);
50615060
trace_nfs4_fsinfo(server, fhandle, fsinfo->fattr, err);
50625061
if (err == 0) {
5063-
nfs4_set_lease_period(server->nfs_client,
5064-
fsinfo->lease_time * HZ,
5065-
now);
5062+
nfs4_set_lease_period(server->nfs_client, fsinfo->lease_time * HZ);
50665063
break;
50675064
}
50685065
err = nfs4_handle_exception(server, err, &exception);
@@ -6126,6 +6123,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program,
61266123
.callback_data = &setclientid,
61276124
.flags = RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN,
61286125
};
6126+
unsigned long now = jiffies;
61296127
int status;
61306128

61316129
/* nfs_client_id4 */
@@ -6158,6 +6156,9 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program,
61586156
clp->cl_acceptor = rpcauth_stringify_acceptor(setclientid.sc_cred);
61596157
put_rpccred(setclientid.sc_cred);
61606158
}
6159+
6160+
if (status == 0)
6161+
do_renew_lease(clp, now);
61616162
out:
61626163
trace_nfs4_setclientid(clp, status);
61636164
dprintk("NFS reply setclientid: %d\n", status);
@@ -8245,6 +8246,7 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cre
82458246
struct rpc_task *task;
82468247
struct nfs41_exchange_id_args *argp;
82478248
struct nfs41_exchange_id_res *resp;
8249+
unsigned long now = jiffies;
82488250
int status;
82498251

82508252
task = nfs4_run_exchange_id(clp, cred, sp4_how, NULL);
@@ -8265,6 +8267,8 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cre
82658267
if (status != 0)
82668268
goto out;
82678269

8270+
do_renew_lease(clp, now);
8271+
82688272
clp->cl_clientid = resp->clientid;
82698273
clp->cl_exchange_flags = resp->flags;
82708274
clp->cl_seqid = resp->seqid;

‎fs/nfs/nfs4renewd.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,12 @@ nfs4_kill_renewd(struct nfs_client *clp)
138138
*
139139
* @clp: pointer to nfs_client
140140
* @lease: new value for lease period
141-
* @lastrenewed: time at which lease was last renewed
142141
*/
143142
void nfs4_set_lease_period(struct nfs_client *clp,
144-
unsigned long lease,
145-
unsigned long lastrenewed)
143+
unsigned long lease)
146144
{
147145
spin_lock(&clp->cl_lock);
148146
clp->cl_lease_time = lease;
149-
clp->cl_last_renewal = lastrenewed;
150147
spin_unlock(&clp->cl_lock);
151148

152149
/* Cap maximum reconnect timeout at 1/2 lease period */

‎fs/nfs/nfs4state.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,15 @@ static int nfs4_setup_state_renewal(struct nfs_client *clp)
9292
{
9393
int status;
9494
struct nfs_fsinfo fsinfo;
95-
unsigned long now;
9695

9796
if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
9897
nfs4_schedule_state_renewal(clp);
9998
return 0;
10099
}
101100

102-
now = jiffies;
103101
status = nfs4_proc_get_lease_time(clp, &fsinfo);
104102
if (status == 0) {
105-
nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now);
103+
nfs4_set_lease_period(clp, fsinfo.lease_time * HZ);
106104
nfs4_schedule_state_renewal(clp);
107105
}
108106

0 commit comments

Comments
 (0)