Commit 9430fb6b authored by Ricardo Labiaga's avatar Ricardo Labiaga Committed by Trond Myklebust

nfs41: nfs41_setup_state_renewal

Move call to get the lease time and the setup of the state
renewal out of nfs4_create_session so that it can be called
after clearing the DRAINING flag.  We use the getattr RPC
to obtain the lease time, which requires a sequence slot.
Signed-off-by: default avatarRicardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent bcb56164
...@@ -225,6 +225,8 @@ extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp); ...@@ -225,6 +225,8 @@ extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
extern int nfs4_proc_create_session(struct nfs_client *); extern int nfs4_proc_create_session(struct nfs_client *);
extern int nfs4_proc_destroy_session(struct nfs4_session *); extern int nfs4_proc_destroy_session(struct nfs4_session *);
extern int nfs4_init_session(struct nfs_server *server); extern int nfs4_init_session(struct nfs_server *server);
extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
struct nfs_fsinfo *fsinfo);
#else /* CONFIG_NFS_v4_1 */ #else /* CONFIG_NFS_v4_1 */
static inline int nfs4_setup_sequence(struct nfs_client *clp, static inline int nfs4_setup_sequence(struct nfs_client *clp,
struct nfs4_sequence_args *args, struct nfs4_sequence_res *res, struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
......
...@@ -4745,7 +4745,6 @@ int nfs4_proc_create_session(struct nfs_client *clp) ...@@ -4745,7 +4745,6 @@ int nfs4_proc_create_session(struct nfs_client *clp)
{ {
int status; int status;
unsigned *ptr; unsigned *ptr;
struct nfs_fsinfo fsinfo;
struct nfs4_session *session = clp->cl_session; struct nfs4_session *session = clp->cl_session;
dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); dprintk("--> %s clp=%p session=%p\n", __func__, clp, session);
...@@ -4767,18 +4766,6 @@ int nfs4_proc_create_session(struct nfs_client *clp) ...@@ -4767,18 +4766,6 @@ int nfs4_proc_create_session(struct nfs_client *clp)
ptr = (unsigned *)&session->sess_id.data[0]; ptr = (unsigned *)&session->sess_id.data[0];
dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__, dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__,
clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]);
/* Get the lease time */
status = nfs4_proc_get_lease_time(clp, &fsinfo);
if (status == 0) {
/* Update lease time and schedule renewal */
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);
}
out: out:
dprintk("<-- %s\n", __func__); dprintk("<-- %s\n", __func__);
return status; return status;
......
...@@ -116,16 +116,38 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp) ...@@ -116,16 +116,38 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp)
#if defined(CONFIG_NFS_V4_1) #if defined(CONFIG_NFS_V4_1)
static int nfs41_setup_state_renewal(struct nfs_client *clp)
{
int status;
struct nfs_fsinfo fsinfo;
status = nfs4_proc_get_lease_time(clp, &fsinfo);
if (status == 0) {
/* Update lease time and schedule renewal */
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);
}
return status;
}
int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
{ {
int status; int status;
status = nfs4_proc_exchange_id(clp, cred); status = nfs4_proc_exchange_id(clp, cred);
if (status == 0) if (status != 0)
/* create session schedules state renewal upon success */ goto out;
status = nfs4_proc_create_session(clp); status = nfs4_proc_create_session(clp);
if (status == 0) if (status != 0)
nfs_mark_client_ready(clp, NFS_CS_READY); goto out;
nfs41_setup_state_renewal(clp);
nfs_mark_client_ready(clp, NFS_CS_READY);
out:
return status; return status;
} }
...@@ -1248,6 +1270,8 @@ static int nfs4_reset_session(struct nfs_client *clp) ...@@ -1248,6 +1270,8 @@ static int nfs4_reset_session(struct nfs_client *clp)
/* Wake up the next rpc task even on error */ /* Wake up the next rpc task even on error */
clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state); clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state);
rpc_wake_up(&clp->cl_session->fc_slot_table.slot_tbl_waitq); rpc_wake_up(&clp->cl_session->fc_slot_table.slot_tbl_waitq);
if (status == 0)
nfs41_setup_state_renewal(clp);
return status; return status;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment