Further cleanups to use of timestamps in NFS:
- Use NFSD_MONOSEC (which maps to time_uptime) instead of the seconds portion of wall-time stamps to manage timeouts on events. - Remove unused nd_starttime from the per-request structure in the new NFS server. - Use nanotime() for the modification time on a delegation to get as precise a time as possible. - Use time_second instead of extracting the second from a call to getmicrotime(). Submitted by: bde (3) Reviewed by: bde, rmacklem MFC after: 2 weeks
This commit is contained in:
parent
4d04cf1d9e
commit
a89a2c8ba4
@ -523,7 +523,6 @@ struct nfsrv_descript {
|
||||
int *nd_errp; /* Pointer to ret status */
|
||||
u_int32_t nd_retxid; /* Reply xid */
|
||||
struct nfsrvcache *nd_rp; /* Assoc. cache entry */
|
||||
struct timeval nd_starttime; /* Time RPC initiated */
|
||||
fhandle_t nd_fh; /* File handle */
|
||||
struct ucred *nd_cred; /* Credentials */
|
||||
uid_t nd_saveduid; /* Saved uid */
|
||||
|
@ -459,18 +459,17 @@ nfs_feedback(int type, int proc, void *arg)
|
||||
{
|
||||
struct nfs_feedback_arg *nf = (struct nfs_feedback_arg *) arg;
|
||||
struct nfsmount *nmp = nf->nf_mount;
|
||||
struct timeval now;
|
||||
|
||||
getmicrouptime(&now);
|
||||
time_t now;
|
||||
|
||||
switch (type) {
|
||||
case FEEDBACK_REXMIT2:
|
||||
case FEEDBACK_RECONNECT:
|
||||
if (nf->nf_lastmsg + nmp->nm_tprintf_delay < now.tv_sec) {
|
||||
now = NFSD_MONOSEC;
|
||||
if (nf->nf_lastmsg + nmp->nm_tprintf_delay < now) {
|
||||
nfs_down(nmp, nf->nf_td,
|
||||
"not responding", 0, NFSSTA_TIMEO);
|
||||
nf->nf_tprintfmsg = TRUE;
|
||||
nf->nf_lastmsg = now.tv_sec;
|
||||
nf->nf_lastmsg = now;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -501,7 +500,7 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp,
|
||||
u_int16_t procnum;
|
||||
u_int trylater_delay = 1;
|
||||
struct nfs_feedback_arg nf;
|
||||
struct timeval timo, now;
|
||||
struct timeval timo;
|
||||
AUTH *auth;
|
||||
struct rpc_callextra ext;
|
||||
enum clnt_stat stat;
|
||||
@ -617,8 +616,7 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp,
|
||||
bzero(&nf, sizeof(struct nfs_feedback_arg));
|
||||
nf.nf_mount = nmp;
|
||||
nf.nf_td = td;
|
||||
getmicrouptime(&now);
|
||||
nf.nf_lastmsg = now.tv_sec -
|
||||
nf.nf_lastmsg = NFSD_MONOSEC -
|
||||
((nmp->nm_tprintf_delay)-(nmp->nm_tprintf_initial_delay));
|
||||
}
|
||||
|
||||
|
@ -587,12 +587,6 @@ void nfsrvd_rcv(struct socket *, void *, int);
|
||||
#define NFSCNHASH(c, v)
|
||||
#define NCHNAMLEN 9999999
|
||||
|
||||
/*
|
||||
* Define these to use the time of day clock.
|
||||
*/
|
||||
#define NFSGETTIME(t) (getmicrotime(t))
|
||||
#define NFSGETNANOTIME(t) (getnanotime(t))
|
||||
|
||||
/*
|
||||
* These macros are defined to initialize and set the timer routine.
|
||||
*/
|
||||
|
@ -2447,7 +2447,7 @@ nfscl_renewthread(struct nfsclclient *clp, NFSPROC_T *p)
|
||||
u_int32_t clidrev;
|
||||
int error, cbpathdown, islept, igotlock, ret, clearok;
|
||||
uint32_t recover_done_time = 0;
|
||||
struct timespec mytime;
|
||||
time_t mytime;
|
||||
static time_t prevsec = 0;
|
||||
struct nfscllockownerfh *lfhp, *nlfhp;
|
||||
struct nfscllockownerfhhead lfh;
|
||||
@ -2720,9 +2720,9 @@ nfscl_renewthread(struct nfsclclient *clp, NFSPROC_T *p)
|
||||
* Call nfscl_cleanupkext() once per second to check for
|
||||
* open/lock owners where the process has exited.
|
||||
*/
|
||||
NFSGETNANOTIME(&mytime);
|
||||
if (prevsec != mytime.tv_sec) {
|
||||
prevsec = mytime.tv_sec;
|
||||
mytime = NFSD_MONOSEC;
|
||||
if (prevsec != mytime) {
|
||||
prevsec = mytime;
|
||||
nfscl_cleanupkext(clp, &lfh);
|
||||
}
|
||||
|
||||
@ -4611,7 +4611,7 @@ nfscl_delegmodtime(vnode_t vp)
|
||||
}
|
||||
dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len);
|
||||
if (dp != NULL && (dp->nfsdl_flags & NFSCLDL_WRITE)) {
|
||||
NFSGETNANOTIME(&dp->nfsdl_modtime);
|
||||
nanotime(&dp->nfsdl_modtime);
|
||||
dp->nfsdl_flags |= NFSCLDL_MODTIMESET;
|
||||
}
|
||||
NFSUNLOCKCLSTATE();
|
||||
|
@ -310,7 +310,6 @@ nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, struct socket *so,
|
||||
} else {
|
||||
isdgram = 1;
|
||||
}
|
||||
NFSGETTIME(&nd->nd_starttime);
|
||||
|
||||
/*
|
||||
* Two cases:
|
||||
|
@ -3967,7 +3967,6 @@ nfsrv_setupstable(NFSPROC_T *p)
|
||||
int error, i, tryagain;
|
||||
off_t off = 0;
|
||||
ssize_t aresid, len;
|
||||
struct timeval curtime;
|
||||
|
||||
/*
|
||||
* If NFSNSF_UPDATEDONE is set, this is a restart of the nfsds without
|
||||
@ -3978,8 +3977,7 @@ nfsrv_setupstable(NFSPROC_T *p)
|
||||
/*
|
||||
* Set Grace over just until the file reads successfully.
|
||||
*/
|
||||
NFSGETTIME(&curtime);
|
||||
nfsrvboottime = curtime.tv_sec;
|
||||
nfsrvboottime = time_second;
|
||||
LIST_INIT(&sf->nsf_head);
|
||||
sf->nsf_flags = (NFSNSF_GRACEOVER | NFSNSF_NEEDLOCK);
|
||||
sf->nsf_eograce = NFSD_MONOSEC + NFSRV_LEASEDELTA;
|
||||
@ -4650,8 +4648,7 @@ nfsrv_cleandeleg(vnode_t vp, struct nfslockfile *lfp,
|
||||
APPLESTATIC void
|
||||
nfsd_recalldelegation(vnode_t vp, NFSPROC_T *p)
|
||||
{
|
||||
struct timespec mytime;
|
||||
int32_t starttime;
|
||||
time_t starttime;
|
||||
int error;
|
||||
|
||||
/*
|
||||
@ -4675,8 +4672,7 @@ nfsd_recalldelegation(vnode_t vp, NFSPROC_T *p)
|
||||
* Now, call nfsrv_checkremove() in a loop while it returns
|
||||
* NFSERR_DELAY. Return upon any other error or when timed out.
|
||||
*/
|
||||
NFSGETNANOTIME(&mytime);
|
||||
starttime = (u_int32_t)mytime.tv_sec;
|
||||
starttime = NFSD_MONOSEC;
|
||||
do {
|
||||
if (NFSVOPLOCK(vp, LK_EXCLUSIVE) == 0) {
|
||||
error = nfsrv_checkremove(vp, 0, p);
|
||||
@ -4684,11 +4680,7 @@ nfsd_recalldelegation(vnode_t vp, NFSPROC_T *p)
|
||||
} else
|
||||
error = EPERM;
|
||||
if (error == NFSERR_DELAY) {
|
||||
NFSGETNANOTIME(&mytime);
|
||||
if (((u_int32_t)mytime.tv_sec - starttime) >
|
||||
NFS_REMOVETIMEO &&
|
||||
((u_int32_t)mytime.tv_sec - starttime) <
|
||||
100000)
|
||||
if (NFSD_MONOSEC - starttime > NFS_REMOVETIMEO)
|
||||
break;
|
||||
/* Sleep for a short period of time */
|
||||
(void) nfs_catnap(PZERO, 0, "nfsremove");
|
||||
@ -4949,9 +4941,7 @@ nfsrv_notsamecredname(struct nfsrv_descript *nd, struct nfsclient *clp)
|
||||
static time_t
|
||||
nfsrv_leaseexpiry(void)
|
||||
{
|
||||
struct timeval curtime;
|
||||
|
||||
NFSGETTIME(&curtime);
|
||||
if (nfsrv_stablefirst.nsf_eograce > NFSD_MONOSEC)
|
||||
return (NFSD_MONOSEC + 2 * (nfsrv_lease + NFSRV_LEASEDELTA));
|
||||
return (NFSD_MONOSEC + nfsrv_lease + NFSRV_LEASEDELTA);
|
||||
|
@ -394,18 +394,17 @@ nfs_feedback(int type, int proc, void *arg)
|
||||
{
|
||||
struct nfs_feedback_arg *nf = (struct nfs_feedback_arg *) arg;
|
||||
struct nfsmount *nmp = nf->nf_mount;
|
||||
struct timeval now;
|
||||
|
||||
getmicrouptime(&now);
|
||||
time_t now;
|
||||
|
||||
switch (type) {
|
||||
case FEEDBACK_REXMIT2:
|
||||
case FEEDBACK_RECONNECT:
|
||||
if (nf->nf_lastmsg + nmp->nm_tprintf_delay < now.tv_sec) {
|
||||
now = time_uptime;
|
||||
if (nf->nf_lastmsg + nmp->nm_tprintf_delay < now) {
|
||||
nfs_down(nmp, nf->nf_td,
|
||||
"not responding", 0, NFSSTA_TIMEO);
|
||||
nf->nf_tprintfmsg = TRUE;
|
||||
nf->nf_lastmsg = now.tv_sec;
|
||||
nf->nf_lastmsg = now;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -438,7 +437,6 @@ nfs_request(struct vnode *vp, struct mbuf *mreq, int procnum,
|
||||
time_t waituntil;
|
||||
caddr_t dpos;
|
||||
int error = 0, timeo;
|
||||
struct timeval now;
|
||||
AUTH *auth = NULL;
|
||||
enum nfs_rto_timer_t timer;
|
||||
struct nfs_feedback_arg nf;
|
||||
@ -455,8 +453,7 @@ nfs_request(struct vnode *vp, struct mbuf *mreq, int procnum,
|
||||
bzero(&nf, sizeof(struct nfs_feedback_arg));
|
||||
nf.nf_mount = nmp;
|
||||
nf.nf_td = td;
|
||||
getmicrouptime(&now);
|
||||
nf.nf_lastmsg = now.tv_sec -
|
||||
nf.nf_lastmsg = time_uptime -
|
||||
((nmp->nm_tprintf_delay) - (nmp->nm_tprintf_initial_delay));
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user