Skip to content

Commit 2f60ea6

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
NFSv4: The NFSv4.0 client must send RENEW calls if it holds a delegation
RFC3530 states that if the client holds a delegation, then it is obliged to continue to send RENEW calls once every lease period in order to allow the server to return NFS4ERR_CB_PATH_DOWN if the callback path is unreachable. This is not required for NFSv4.1, since the server can at any time set the SEQ4_STATUS_CB_PATH_DOWN_SESSION in any SEQUENCE operation. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent 8534d4e commit 2f60ea6

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎fs/nfs/nfs4_fs.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ enum nfs4_session_state {
5656
NFS4_SESSION_DRAINING,
5757
};
5858

59+
#define NFS4_RENEW_TIMEOUT 0x01
60+
#define NFS4_RENEW_DELEGATION_CB 0x02
61+
5962
struct nfs4_minor_version_ops {
6063
u32 minor_version;
6164

@@ -225,7 +228,7 @@ struct nfs4_state_recovery_ops {
225228
};
226229

227230
struct nfs4_state_maintenance_ops {
228-
int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *);
231+
int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *, unsigned);
229232
struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *);
230233
int (*renew_lease)(struct nfs_client *, struct rpc_cred *);
231234
};

‎fs/nfs/nfs4proc.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3386,7 +3386,7 @@ static const struct rpc_call_ops nfs4_renew_ops = {
33863386
.rpc_release = nfs4_renew_release,
33873387
};
33883388

3389-
static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred)
3389+
static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags)
33903390
{
33913391
struct rpc_message msg = {
33923392
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW],
@@ -3395,6 +3395,8 @@ static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred)
33953395
};
33963396
struct nfs4_renewdata *data;
33973397

3398+
if (renew_flags == 0)
3399+
return 0;
33983400
if (!atomic_inc_not_zero(&clp->cl_count))
33993401
return -EIO;
34003402
data = kmalloc(sizeof(*data), GFP_NOFS);
@@ -5504,11 +5506,13 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, struct rpc_
55045506
return rpc_run_task(&task_setup_data);
55055507
}
55065508

5507-
static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cred)
5509+
static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags)
55085510
{
55095511
struct rpc_task *task;
55105512
int ret = 0;
55115513

5514+
if ((renew_flags & NFS4_RENEW_TIMEOUT) == 0)
5515+
return 0;
55125516
task = _nfs41_proc_sequence(clp, cred);
55135517
if (IS_ERR(task))
55145518
ret = PTR_ERR(task);

‎fs/nfs/nfs4renewd.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ nfs4_renew_state(struct work_struct *work)
6060
struct rpc_cred *cred;
6161
long lease;
6262
unsigned long last, now;
63+
unsigned renew_flags = 0;
6364

6465
ops = clp->cl_mvops->state_renewal_ops;
6566
dprintk("%s: start\n", __func__);
@@ -72,18 +73,23 @@ nfs4_renew_state(struct work_struct *work)
7273
last = clp->cl_last_renewal;
7374
now = jiffies;
7475
/* Are we close to a lease timeout? */
75-
if (time_after(now, last + lease/3)) {
76+
if (time_after(now, last + lease/3))
77+
renew_flags |= NFS4_RENEW_TIMEOUT;
78+
if (nfs_delegations_present(clp))
79+
renew_flags |= NFS4_RENEW_DELEGATION_CB;
80+
81+
if (renew_flags != 0) {
7682
cred = ops->get_state_renewal_cred_locked(clp);
7783
spin_unlock(&clp->cl_lock);
7884
if (cred == NULL) {
79-
if (!nfs_delegations_present(clp)) {
85+
if (!(renew_flags & NFS4_RENEW_DELEGATION_CB)) {
8086
set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
8187
goto out;
8288
}
8389
nfs_expire_all_delegations(clp);
8490
} else {
8591
/* Queue an asynchronous RENEW. */
86-
ops->sched_state_renewal(clp, cred);
92+
ops->sched_state_renewal(clp, cred, renew_flags);
8793
put_rpccred(cred);
8894
goto out_exp;
8995
}

0 commit comments

Comments
 (0)