void nfs4_renew_state(struct work_struct *work) { const struct nfs4_state_maintenance_ops *ops; struct nfs_client *clp = container_of(work, struct nfs_client, cl_renewd.work); struct rpc_cred *cred; long lease; unsigned long last, now; unsigned renew_flags = 0; ops = clp->cl_mvops->state_renewal_ops; dprintk("%s: start\n", __func__); if (test_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state)) goto out; spin_lock(&clp->cl_lock); lease = clp->cl_lease_time; last = clp->cl_last_renewal; now = jiffies; /* Are we close to a lease timeout? */ if (time_after(now, last + lease/3)) renew_flags |= NFS4_RENEW_TIMEOUT; if (nfs_delegations_present(clp)) renew_flags |= NFS4_RENEW_DELEGATION_CB; if (renew_flags != 0) { cred = ops->get_state_renewal_cred_locked(clp); spin_unlock(&clp->cl_lock); if (cred == NULL) { if (!(renew_flags & NFS4_RENEW_DELEGATION_CB)) { set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); goto out; } nfs_expire_all_delegations(clp); } else { /* Queue an asynchronous RENEW. */ ops->sched_state_renewal(clp, cred, renew_flags); put_rpccred(cred); goto out_exp; } } else { dprintk("%s: failed to call renewd. Reason: lease not expired \n", __func__); spin_unlock(&clp->cl_lock); } nfs4_schedule_state_renewal(clp); out_exp: nfs_expire_unreferenced_delegations(clp); out: dprintk("%s: done\n", __func__); }
void nfs4_renew_state(struct work_struct *work) { struct nfs4_state_maintenance_ops *ops; struct nfs_client *clp = container_of(work, struct nfs_client, cl_renewd.work); struct rpc_cred *cred; long lease, timeout; unsigned long last, now; ops = nfs4_state_renewal_ops[clp->cl_minorversion]; dprintk("%s: start\n", __func__); /* Are there any active superblocks? */ if (list_empty(&clp->cl_superblocks)) goto out; spin_lock(&clp->cl_lock); lease = clp->cl_lease_time; last = clp->cl_last_renewal; now = jiffies; timeout = (2 * lease) / 3 + (long)last - (long)now; /* Are we close to a lease timeout? */ if (time_after(now, last + lease/3)) { cred = ops->get_state_renewal_cred_locked(clp); spin_unlock(&clp->cl_lock); if (cred == NULL) { if (list_empty(&clp->cl_delegations)) { set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); goto out; } nfs_expire_all_delegations(clp); } else { /* Queue an asynchronous RENEW. */ ops->sched_state_renewal(clp, cred); put_rpccred(cred); } timeout = (2 * lease) / 3; spin_lock(&clp->cl_lock); } else dprintk("%s: failed to call renewd. Reason: lease not expired \n", __func__); if (timeout < 5 * HZ) /* safeguard */ timeout = 5 * HZ; dprintk("%s: requeueing work. Lease period = %ld\n", __func__, (timeout + HZ - 1) / HZ); cancel_delayed_work(&clp->cl_renewd); schedule_delayed_work(&clp->cl_renewd, timeout); spin_unlock(&clp->cl_lock); nfs_expire_unreferenced_delegations(clp); out: dprintk("%s: done\n", __func__); }
void nfs4_renew_state(struct work_struct *work) { const struct nfs4_state_maintenance_ops *ops; struct nfs_client *clp = container_of(work, struct nfs_client, cl_renewd.work); struct rpc_cred *cred; long lease; unsigned long last, now; ops = clp->cl_mvops->state_renewal_ops; dprintk("%s: start\n", __func__); if (test_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state)) goto out; spin_lock(&clp->cl_lock); lease = clp->cl_lease_time; last = clp->cl_last_renewal; now = jiffies; /* Are we close to a lease timeout? */ if (time_after(now, last + lease/3)) { cred = ops->get_state_renewal_cred_locked(clp); spin_unlock(&clp->cl_lock); if (cred == NULL) { if (list_empty(&clp->cl_delegations)) { set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); goto out; } nfs_expire_all_delegations(clp); } else { struct ve_struct *ve; /* Queue an asynchronous RENEW. */ ve = set_exec_env(clp->cl_rpcclient->cl_xprt->owner_env); ops->sched_state_renewal(clp, cred); (void)set_exec_env(ve); put_rpccred(cred); goto out_exp; } } else { dprintk("%s: failed to call renewd. Reason: lease not expired \n", __func__); spin_unlock(&clp->cl_lock); } nfs4_schedule_state_renewal(clp); out_exp: nfs_expire_unreferenced_delegations(clp); out: dprintk("%s: done\n", __func__); }
void nfs4_renew_state(void *data) { struct nfs4_client *clp = (struct nfs4_client *)data; struct rpc_cred *cred; long lease, timeout; unsigned long last, now; down_read(&clp->cl_sem); dprintk("%s: start\n", __FUNCTION__); /* Are there any active superblocks? */ if (list_empty(&clp->cl_superblocks)) goto out; spin_lock(&clp->cl_lock); lease = clp->cl_lease_time; last = clp->cl_last_renewal; now = jiffies; timeout = (2 * lease) / 3 + (long)last - (long)now; /* Are we close to a lease timeout? */ if (time_after(now, last + lease/3)) { cred = nfs4_get_renew_cred(clp); if (cred == NULL) { set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); spin_unlock(&clp->cl_lock); nfs_expire_all_delegations(clp); goto out; } spin_unlock(&clp->cl_lock); /* Queue an asynchronous RENEW. */ nfs4_proc_async_renew(clp, cred); put_rpccred(cred); timeout = (2 * lease) / 3; spin_lock(&clp->cl_lock); } else dprintk("%s: failed to call renewd. Reason: lease not expired \n", __FUNCTION__); if (timeout < 5 * HZ) /* safeguard */ timeout = 5 * HZ; dprintk("%s: requeueing work. Lease period = %ld\n", __FUNCTION__, (timeout + HZ - 1) / HZ); cancel_delayed_work(&clp->cl_renewd); schedule_delayed_work(&clp->cl_renewd, timeout); spin_unlock(&clp->cl_lock); out: up_read(&clp->cl_sem); dprintk("%s: done\n", __FUNCTION__); }