Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb10fb67 authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFSv4: Cleanup the setting of the nfs4 lease period



Make a helper function nfs4_set_lease_period() and have
nfs41_setup_state_renewal() and nfs4_do_fsinfo() use it.

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 3851f1cd
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -395,6 +395,10 @@ extern void nfs4_schedule_state_renewal(struct nfs_client *);
extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
extern void nfs4_kill_renewd(struct nfs_client *);
extern void nfs4_kill_renewd(struct nfs_client *);
extern void nfs4_renew_state(struct work_struct *);
extern void nfs4_renew_state(struct work_struct *);
extern void nfs4_set_lease_period(struct nfs_client *clp,
		unsigned long lease,
		unsigned long lastrenewed);



/* nfs4state.c */
/* nfs4state.c */
struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp);
struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp);
+3 −6
Original line number Original line Diff line number Diff line
@@ -4237,12 +4237,9 @@ static int nfs4_do_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, str
		err = _nfs4_do_fsinfo(server, fhandle, fsinfo);
		err = _nfs4_do_fsinfo(server, fhandle, fsinfo);
		trace_nfs4_fsinfo(server, fhandle, fsinfo->fattr, err);
		trace_nfs4_fsinfo(server, fhandle, fsinfo->fattr, err);
		if (err == 0) {
		if (err == 0) {
			struct nfs_client *clp = server->nfs_client;
			nfs4_set_lease_period(server->nfs_client,

					fsinfo->lease_time * HZ,
			spin_lock(&clp->cl_lock);
					now);
			clp->cl_lease_time = fsinfo->lease_time * HZ;
			clp->cl_last_renewal = now;
			spin_unlock(&clp->cl_lock);
			break;
			break;
		}
		}
		err = nfs4_handle_exception(server, err, &exception);
		err = nfs4_handle_exception(server, err, &exception);
+17 −0
Original line number Original line Diff line number Diff line
@@ -136,6 +136,23 @@ nfs4_kill_renewd(struct nfs_client *clp)
	cancel_delayed_work_sync(&clp->cl_renewd);
	cancel_delayed_work_sync(&clp->cl_renewd);
}
}


/**
 * nfs4_set_lease_period - Sets the lease period on a nfs_client
 *
 * @clp: pointer to nfs_client
 * @lease: new value for lease period
 * @lastrenewed: time at which lease was last renewed
 */
void nfs4_set_lease_period(struct nfs_client *clp,
		unsigned long lease,
		unsigned long lastrenewed)
{
	spin_lock(&clp->cl_lock);
	clp->cl_lease_time = lease;
	clp->cl_last_renewal = lastrenewed;
	spin_unlock(&clp->cl_lock);
}

/*
/*
 * Local variables:
 * Local variables:
 *   c-basic-offset: 8
 *   c-basic-offset: 8
+3 −6
Original line number Original line Diff line number Diff line
@@ -277,20 +277,17 @@ static int nfs41_setup_state_renewal(struct nfs_client *clp)
{
{
	int status;
	int status;
	struct nfs_fsinfo fsinfo;
	struct nfs_fsinfo fsinfo;
	unsigned long now;


	if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
	if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
		nfs4_schedule_state_renewal(clp);
		nfs4_schedule_state_renewal(clp);
		return 0;
		return 0;
	}
	}


	now = jiffies;
	status = nfs4_proc_get_lease_time(clp, &fsinfo);
	status = nfs4_proc_get_lease_time(clp, &fsinfo);
	if (status == 0) {
	if (status == 0) {
		/* Update lease time and schedule renewal */
		nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now);
		spin_lock(&clp->cl_lock);
		clp->cl_lease_time = fsinfo.lease_time * HZ;
		clp->cl_last_renewal = jiffies;
		spin_unlock(&clp->cl_lock);

		nfs4_schedule_state_renewal(clp);
		nfs4_schedule_state_renewal(clp);
	}
	}