diff options
-rw-r--r-- | sys/fs/msdosfs/msdosfs_denode.c | 4 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_vnops.c | 10 | ||||
-rw-r--r-- | sys/fs/portalfs/portal_vnops.c | 5 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_vnops.c | 8 | ||||
-rw-r--r-- | sys/gnu/ext2fs/inode.h | 25 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/inode.h | 25 | ||||
-rw-r--r-- | sys/i386/boot/dosboot/inode.h | 15 | ||||
-rw-r--r-- | sys/kern/kern_clock.c | 42 | ||||
-rw-r--r-- | sys/kern/kern_tc.c | 42 | ||||
-rw-r--r-- | sys/kern/kern_time.c | 3 | ||||
-rw-r--r-- | sys/kern/sys_pipe.c | 14 | ||||
-rw-r--r-- | sys/miscfs/devfs/devfs_tree.c | 6 | ||||
-rw-r--r-- | sys/miscfs/devfs/devfs_vnops.c | 18 | ||||
-rw-r--r-- | sys/miscfs/kernfs/kernfs_vnops.c | 8 | ||||
-rw-r--r-- | sys/miscfs/portal/portal_vnops.c | 5 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_vnops.c | 8 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_denode.c | 4 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_vnops.c | 10 | ||||
-rw-r--r-- | sys/sys/pipe.h | 8 | ||||
-rw-r--r-- | sys/sys/time.h | 62 | ||||
-rw-r--r-- | sys/sys/timetc.h | 62 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 3 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 25 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 31 |
24 files changed, 216 insertions, 227 deletions
diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 5130727..6c4513d 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_denode.c,v 1.32 1998/02/18 09:28:33 jkh Exp $ */ +/* $Id: msdosfs_denode.c,v 1.33 1998/03/20 02:33:35 kato Exp $ */ /* $NetBSD: msdosfs_denode.c,v 1.28 1998/02/10 14:10:00 mrg Exp $ */ /*- @@ -364,7 +364,7 @@ deupdat(dep, waitfor) if (DETOV(dep)->v_mount->mnt_flag & MNT_RDONLY) return (0); - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(dep, &ts, &ts, &ts); if ((dep->de_flag & DE_MODIFIED) == 0) return (0); diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index cbfb35d..4185114 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vnops.c,v 1.65 1998/03/06 09:46:31 msmith Exp $ */ +/* $Id: msdosfs_vnops.c,v 1.66 1998/03/20 02:33:42 kato Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ /*- @@ -180,7 +180,7 @@ msdosfs_create(ap) ndirent.de_devvp = pdep->de_devvp; ndirent.de_pmp = pdep->de_pmp; ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE; - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(&ndirent, &ts, &ts, &ts); error = createde(&ndirent, pdep, &dep, cnp); if (error) @@ -239,7 +239,7 @@ msdosfs_close(ap) simple_lock(&vp->v_interlock); if (vp->v_usecount > 1) { - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(dep, &ts, &ts, &ts); } simple_unlock(&vp->v_interlock); @@ -340,7 +340,7 @@ msdosfs_getattr(ap) u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry); u_long fileid; - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(dep, &ts, &ts, &ts); vap->va_fsid = dep->de_dev; /* @@ -1356,7 +1356,7 @@ msdosfs_mkdir(ap) bzero(&ndirent, sizeof(ndirent)); ndirent.de_pmp = pmp; ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE; - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(&ndirent, &ts, &ts, &ts); /* diff --git a/sys/fs/portalfs/portal_vnops.c b/sys/fs/portalfs/portal_vnops.c index e622cff..93a223f 100644 --- a/sys/fs/portalfs/portal_vnops.c +++ b/sys/fs/portalfs/portal_vnops.c @@ -35,7 +35,7 @@ * * @(#)portal_vnops.c 8.14 (Berkeley) 5/21/95 * - * $Id: portal_vnops.c,v 1.28 1997/10/27 13:33:41 bde Exp $ + * $Id: portal_vnops.c,v 1.29 1997/11/06 19:29:38 phk Exp $ */ /* @@ -453,8 +453,7 @@ portal_getattr(ap) vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0]; vap->va_size = DEV_BSIZE; vap->va_blocksize = DEV_BSIZE; - microtime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, &vap->va_atime); + nanotime(&vap->va_atime); vap->va_mtime = vap->va_atime; vap->va_ctime = vap->va_ctime; vap->va_gen = 0; diff --git a/sys/fs/procfs/procfs_vnops.c b/sys/fs/procfs/procfs_vnops.c index a346ae7..78b6d92 100644 --- a/sys/fs/procfs/procfs_vnops.c +++ b/sys/fs/procfs/procfs_vnops.c @@ -36,7 +36,7 @@ * * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 * - * $Id: procfs_vnops.c,v 1.54 1998/02/06 12:13:42 eivind Exp $ + * $Id: procfs_vnops.c,v 1.55 1998/02/09 06:09:46 eivind Exp $ */ /* @@ -475,11 +475,7 @@ procfs_getattr(ap) * p_stat structure is not addressible if u. gets * swapped out for that process. */ - { - struct timeval tv; - microtime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, &vap->va_ctime); - } + nanotime(&vap->va_ctime); vap->va_atime = vap->va_mtime = vap->va_ctime; /* diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h index 4bd1cf5..c787e1e 100644 --- a/sys/gnu/ext2fs/inode.h +++ b/sys/gnu/ext2fs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.20 1998/01/30 11:34:02 phk Exp $ + * $Id: inode.h,v 1.21 1998/03/08 09:59:21 julian Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -143,29 +143,6 @@ struct indir { #define VTOI(vp) ((struct inode *)(vp)->v_data) #define ITOV(ip) ((ip)->i_vnode) -/* - * XXX this is too long to be a macro, and isn't used in any time-critical - * place; in fact it is only used in ufs_vnops.c so it shouldn't be in a - * header file. - */ -#define ITIMES(ip, t1, t2) { \ - long tv_sec = time.tv_sec; \ - if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ - (ip)->i_flag |= IN_MODIFIED; \ - if ((ip)->i_flag & IN_ACCESS) \ - (ip)->i_atime \ - = ((t1) == &time ? tv_sec : (t1)->tv_sec); \ - if ((ip)->i_flag & IN_UPDATE) { \ - (ip)->i_mtime \ - = ((t2) == &time ? tv_sec : (t2)->tv_sec); \ - (ip)->i_modrev++; \ - } \ - if ((ip)->i_flag & IN_CHANGE) \ - (ip)->i_ctime = tv_sec; \ - (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ - } \ -} - /* Determine if soft dependencies are being done */ #define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP) diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h index 4bd1cf5..c787e1e 100644 --- a/sys/gnu/fs/ext2fs/inode.h +++ b/sys/gnu/fs/ext2fs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.20 1998/01/30 11:34:02 phk Exp $ + * $Id: inode.h,v 1.21 1998/03/08 09:59:21 julian Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -143,29 +143,6 @@ struct indir { #define VTOI(vp) ((struct inode *)(vp)->v_data) #define ITOV(ip) ((ip)->i_vnode) -/* - * XXX this is too long to be a macro, and isn't used in any time-critical - * place; in fact it is only used in ufs_vnops.c so it shouldn't be in a - * header file. - */ -#define ITIMES(ip, t1, t2) { \ - long tv_sec = time.tv_sec; \ - if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ - (ip)->i_flag |= IN_MODIFIED; \ - if ((ip)->i_flag & IN_ACCESS) \ - (ip)->i_atime \ - = ((t1) == &time ? tv_sec : (t1)->tv_sec); \ - if ((ip)->i_flag & IN_UPDATE) { \ - (ip)->i_mtime \ - = ((t2) == &time ? tv_sec : (t2)->tv_sec); \ - (ip)->i_modrev++; \ - } \ - if ((ip)->i_flag & IN_CHANGE) \ - (ip)->i_ctime = tv_sec; \ - (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ - } \ -} - /* Determine if soft dependencies are being done */ #define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP) diff --git a/sys/i386/boot/dosboot/inode.h b/sys/i386/boot/dosboot/inode.h index 61cc957..0a692e3 100644 --- a/sys/i386/boot/dosboot/inode.h +++ b/sys/i386/boot/dosboot/inode.h @@ -31,7 +31,7 @@ * SUCH DAMAGE.
*
* from: @(#)inode.h 7.17 (Berkeley) 5/8/91
- * $Id$
+ * $Id: inode.h,v 1.4 1997/02/22 09:30:56 peter Exp $
*/
#ifndef _UFS_INODE_H_
@@ -157,19 +157,6 @@ extern ino_t dirpref(); (void) iupdat(ip, t1, t2, waitfor); \
}
-#define ITIMES(ip, t1, t2) { \
- if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
- (ip)->i_flag |= IMOD; \
- if ((ip)->i_flag&IACC) \
- (ip)->i_atime = (t1)->tv_sec; \
- if ((ip)->i_flag&IUPD) \
- (ip)->i_mtime = (t2)->tv_sec; \
- if ((ip)->i_flag&ICHG) \
- (ip)->i_ctime = time.tv_sec; \
- (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
- } \
-}
-
/*
* This overlays the fid sturcture (see mount.h)
*/
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 927e5f6..84b9875 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -39,7 +39,7 @@ static volatile int print_tci = 1; * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.57 1998/02/20 16:35:49 phk Exp $ + * $Id: kern_clock.c,v 1.58 1998/03/16 10:19:12 phk Exp $ */ #include <sys/param.h> @@ -222,17 +222,6 @@ hardclock(frame) ++softticks; } -void -gettime(struct timeval *tvp) -{ - int s; - - s = splclock(); - /* XXX should use microtime() iff tv_usec is used. */ - *tvp = time; - splx(s); -} - /* * Compute number of hz until specified time. Used to * compute third argument to timeout() from an absolute time. @@ -495,6 +484,35 @@ sysctl_kern_clockrate SYSCTL_HANDLER_ARGS SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD, 0, 0, sysctl_kern_clockrate, "S,clockinfo",""); + +/* + * We have four functions for looking at the clock, two for microseconds + * and two for nanoseconds. For each there is fast but less precise + * version "get{nano|micro}time" which will return a time which is up + * to 1/HZ previous to the call, whereas the raw version "{nano|micro}time" + * will return a timestamp which is as precise as possible. + */ + +void +getmicrotime(struct timeval *tvp) +{ + struct timecounter *tc; + + tc = timecounter; + tvp->tv_sec = tc->offset_sec; + tvp->tv_usec = tc->offset_micro; +} + +void +getnanotime(struct timespec *tsp) +{ + struct timecounter *tc; + + tc = timecounter; + tsp->tv_sec = tc->offset_sec; + tsp->tv_nsec = tc->offset_nano; +} + void microtime(struct timeval *tv) { diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 927e5f6..84b9875 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -39,7 +39,7 @@ static volatile int print_tci = 1; * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.57 1998/02/20 16:35:49 phk Exp $ + * $Id: kern_clock.c,v 1.58 1998/03/16 10:19:12 phk Exp $ */ #include <sys/param.h> @@ -222,17 +222,6 @@ hardclock(frame) ++softticks; } -void -gettime(struct timeval *tvp) -{ - int s; - - s = splclock(); - /* XXX should use microtime() iff tv_usec is used. */ - *tvp = time; - splx(s); -} - /* * Compute number of hz until specified time. Used to * compute third argument to timeout() from an absolute time. @@ -495,6 +484,35 @@ sysctl_kern_clockrate SYSCTL_HANDLER_ARGS SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD, 0, 0, sysctl_kern_clockrate, "S,clockinfo",""); + +/* + * We have four functions for looking at the clock, two for microseconds + * and two for nanoseconds. For each there is fast but less precise + * version "get{nano|micro}time" which will return a time which is up + * to 1/HZ previous to the call, whereas the raw version "{nano|micro}time" + * will return a timestamp which is as precise as possible. + */ + +void +getmicrotime(struct timeval *tvp) +{ + struct timecounter *tc; + + tc = timecounter; + tvp->tv_sec = tc->offset_sec; + tvp->tv_usec = tc->offset_micro; +} + +void +getnanotime(struct timespec *tsp) +{ + struct timecounter *tc; + + tc = timecounter; + tsp->tv_sec = tc->offset_sec; + tsp->tv_nsec = tc->offset_nano; +} + void microtime(struct timeval *tv) { diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 295e8fa..a1fb4e3 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)kern_time.c 8.1 (Berkeley) 6/10/93 - * $Id: kern_time.c,v 1.41 1998/02/20 16:35:53 phk Exp $ + * $Id: kern_time.c,v 1.42 1998/02/25 04:10:32 bde Exp $ */ #include <sys/param.h> @@ -163,6 +163,7 @@ clock_settime(p, uap) return (error); if (ats.tv_nsec < 0 || ats.tv_nsec >= 1000000000) return (EINVAL); + /* XXX Don't convert nsec->usec and back */ TIMESPEC_TO_TIMEVAL(&atv, &ats); if ((error = settime(&atv))) return (error); diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 8c008a2..c237952 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -16,7 +16,7 @@ * 4. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: sys_pipe.c,v 1.38 1998/02/06 12:13:26 eivind Exp $ + * $Id: sys_pipe.c,v 1.39 1998/02/09 06:09:25 eivind Exp $ */ /* @@ -251,7 +251,7 @@ pipeinit(cpipe) cpipe->pipe_state = 0; cpipe->pipe_peer = NULL; cpipe->pipe_busy = 0; - gettime(&cpipe->pipe_ctime); + getnanotime(&cpipe->pipe_ctime); cpipe->pipe_atime = cpipe->pipe_ctime; cpipe->pipe_mtime = cpipe->pipe_ctime; bzero(&cpipe->pipe_sel, sizeof cpipe->pipe_sel); @@ -436,7 +436,7 @@ pipe_read(fp, uio, cred) } if (error == 0) - gettime(&rpipe->pipe_atime); + getnanotime(&rpipe->pipe_atime); --rpipe->pipe_busy; if ((rpipe->pipe_busy == 0) && (rpipe->pipe_state & PIPE_WANT)) { @@ -908,7 +908,7 @@ pipe_write(fp, uio, cred) error = 0; if (error == 0) - gettime(&wpipe->pipe_mtime); + getnanotime(&wpipe->pipe_mtime); /* * We have something to offer, @@ -1018,9 +1018,9 @@ pipe_stat(pipe, ub) ub->st_blksize = pipe->pipe_buffer.size; ub->st_size = pipe->pipe_buffer.cnt; ub->st_blocks = (ub->st_size + ub->st_blksize - 1) / ub->st_blksize; - TIMEVAL_TO_TIMESPEC(&pipe->pipe_atime, &ub->st_atimespec); - TIMEVAL_TO_TIMESPEC(&pipe->pipe_mtime, &ub->st_mtimespec); - TIMEVAL_TO_TIMESPEC(&pipe->pipe_ctime, &ub->st_ctimespec); + ub->st_atimespec = pipe->pipe_atime; + ub->st_mtimespec = pipe->pipe_mtime; + ub->st_ctimespec = pipe->pipe_ctime; /* * Left as 0: st_dev, st_ino, st_nlink, st_uid, st_gid, st_rdev, * st_flags, st_gen. diff --git a/sys/miscfs/devfs/devfs_tree.c b/sys/miscfs/devfs/devfs_tree.c index c2ef85b..20d46f1 100644 --- a/sys/miscfs/devfs/devfs_tree.c +++ b/sys/miscfs/devfs/devfs_tree.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: devfs_tree.c,v 1.48 1997/11/08 19:02:26 julian Exp $ + * $Id: devfs_tree.c,v 1.49 1998/01/02 07:31:06 julian Exp $ */ #include "opt_devfs.h" @@ -435,7 +435,7 @@ dev_add_node(int entrytype, union typeinfo *by, dn_p proto, */ bzero(dnp,sizeof(devnode_t)); dnp->type = entrytype; - TIMEVAL_TO_TIMESPEC(&time,&(dnp->ctime)) + getnanotime(&(dnp->ctime)); dnp->mtime = dnp->ctime; dnp->atime = dnp->ctime; dnp->nextsibling = dnp; @@ -527,7 +527,7 @@ int dev_touch(devnm_p key) /* update the node for this dev */ { DBPRINT(("dev_touch\n")); - TIMEVAL_TO_TIMESPEC(&time,&(key->dnp->mtime)) + getnanotime(&(key->dnp->mtime)); return 0; /*XXX*/ } diff --git a/sys/miscfs/devfs/devfs_vnops.c b/sys/miscfs/devfs/devfs_vnops.c index fde502b..773d903 100644 --- a/sys/miscfs/devfs/devfs_vnops.c +++ b/sys/miscfs/devfs/devfs_vnops.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: devfs_vnops.c,v 1.51 1998/01/02 07:31:06 julian Exp $ + * $Id: devfs_vnops.c,v 1.52 1998/03/10 09:12:19 julian Exp $ */ #include <sys/param.h> @@ -531,7 +531,6 @@ devfs_setattr(struct vop_setattr_args *ap) gid_t *gp; int i; dn_p file_node; - struct timeval tv; if (error = devfs_vntodn(vp,&file_node)) { @@ -578,8 +577,7 @@ DBPRINT(("setattr\n")); return (EACCES); file_node->atime = vap->va_atime; file_node->mtime = vap->va_mtime; - microtime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, &file_node->ctime); + nanotime(&file_node->ctime); return (0); } @@ -675,7 +673,7 @@ DBPRINT(("read\n")); case VCHR: case VBLK: error = VOCALL(spec_vnodeop_p, VOFFSET(vop_read), ap); - TIMEVAL_TO_TIMESPEC(&time,&(file_node->atime)) + getnanotime(&(file_node->atime)); return(error); default: @@ -715,7 +713,7 @@ DBPRINT(("write\n")); case VCHR: case VBLK: error = VOCALL(spec_vnodeop_p, VOFFSET(vop_write), ap); - TIMEVAL_TO_TIMESPEC(&time,&(file_node->mtime)) + getnanotime(&(file_node->mtime)); return(error); default: @@ -828,7 +826,7 @@ abortit: /*********************************** * Start actually doing things.... * ***********************************/ - TIMEVAL_TO_TIMESPEC(&time,&(tdp->mtime)); + getnanotime(&(tdp->mtime)); /* @@ -918,7 +916,7 @@ abortit: /*********************************** * Start actually doing things.... * ***********************************/ - TIMEVAL_TO_TIMESPEC(&time,&(tdp->atime)); + getnanotime(&(tdp->atime)); error = dev_add_name(cnp->cn_nameptr, tdp, NULL, @@ -1084,7 +1082,7 @@ abortit: /*********************************** * Start actually doing things.... * ***********************************/ - TIMEVAL_TO_TIMESPEC(&time,&(fp->atime)); + getnanotime(&(fp->atime)); /* * Check if just deleting a link name. */ @@ -1276,7 +1274,7 @@ DBPRINT(("readdir\n")); startpos = uio->uio_offset; name_node = dir_node->by.Dir.dirlist; nodenumber = 0; - TIMEVAL_TO_TIMESPEC(&time,&(dir_node->atime)) + getnanotime(&(dir_node->atime)); while ((name_node || (nodenumber < 2)) && (uio->uio_resid > 0)) { diff --git a/sys/miscfs/kernfs/kernfs_vnops.c b/sys/miscfs/kernfs/kernfs_vnops.c index 8ec320e..41d5430 100644 --- a/sys/miscfs/kernfs/kernfs_vnops.c +++ b/sys/miscfs/kernfs/kernfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)kernfs_vnops.c 8.15 (Berkeley) 5/21/95 - * $Id: kernfs_vnops.c,v 1.27 1997/10/26 20:55:18 phk Exp $ + * $Id: kernfs_vnops.c,v 1.28 1997/10/27 13:33:40 bde Exp $ */ /* @@ -383,11 +383,7 @@ kernfs_getattr(ap) vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0]; vap->va_size = 0; vap->va_blocksize = DEV_BSIZE; - { - struct timeval tv; - microtime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, &vap->va_atime); - } + nanotime(&vap->va_atime); vap->va_mtime = vap->va_atime; vap->va_ctime = vap->va_ctime; vap->va_gen = 0; diff --git a/sys/miscfs/portal/portal_vnops.c b/sys/miscfs/portal/portal_vnops.c index e622cff..93a223f 100644 --- a/sys/miscfs/portal/portal_vnops.c +++ b/sys/miscfs/portal/portal_vnops.c @@ -35,7 +35,7 @@ * * @(#)portal_vnops.c 8.14 (Berkeley) 5/21/95 * - * $Id: portal_vnops.c,v 1.28 1997/10/27 13:33:41 bde Exp $ + * $Id: portal_vnops.c,v 1.29 1997/11/06 19:29:38 phk Exp $ */ /* @@ -453,8 +453,7 @@ portal_getattr(ap) vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0]; vap->va_size = DEV_BSIZE; vap->va_blocksize = DEV_BSIZE; - microtime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, &vap->va_atime); + nanotime(&vap->va_atime); vap->va_mtime = vap->va_atime; vap->va_ctime = vap->va_ctime; vap->va_gen = 0; diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index a346ae7..78b6d92 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -36,7 +36,7 @@ * * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 * - * $Id: procfs_vnops.c,v 1.54 1998/02/06 12:13:42 eivind Exp $ + * $Id: procfs_vnops.c,v 1.55 1998/02/09 06:09:46 eivind Exp $ */ /* @@ -475,11 +475,7 @@ procfs_getattr(ap) * p_stat structure is not addressible if u. gets * swapped out for that process. */ - { - struct timeval tv; - microtime(&tv); - TIMEVAL_TO_TIMESPEC(&tv, &vap->va_ctime); - } + nanotime(&vap->va_ctime); vap->va_atime = vap->va_mtime = vap->va_ctime; /* diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c index 5130727..6c4513d 100644 --- a/sys/msdosfs/msdosfs_denode.c +++ b/sys/msdosfs/msdosfs_denode.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_denode.c,v 1.32 1998/02/18 09:28:33 jkh Exp $ */ +/* $Id: msdosfs_denode.c,v 1.33 1998/03/20 02:33:35 kato Exp $ */ /* $NetBSD: msdosfs_denode.c,v 1.28 1998/02/10 14:10:00 mrg Exp $ */ /*- @@ -364,7 +364,7 @@ deupdat(dep, waitfor) if (DETOV(dep)->v_mount->mnt_flag & MNT_RDONLY) return (0); - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(dep, &ts, &ts, &ts); if ((dep->de_flag & DE_MODIFIED) == 0) return (0); diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index cbfb35d..4185114 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vnops.c,v 1.65 1998/03/06 09:46:31 msmith Exp $ */ +/* $Id: msdosfs_vnops.c,v 1.66 1998/03/20 02:33:42 kato Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ /*- @@ -180,7 +180,7 @@ msdosfs_create(ap) ndirent.de_devvp = pdep->de_devvp; ndirent.de_pmp = pdep->de_pmp; ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE; - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(&ndirent, &ts, &ts, &ts); error = createde(&ndirent, pdep, &dep, cnp); if (error) @@ -239,7 +239,7 @@ msdosfs_close(ap) simple_lock(&vp->v_interlock); if (vp->v_usecount > 1) { - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(dep, &ts, &ts, &ts); } simple_unlock(&vp->v_interlock); @@ -340,7 +340,7 @@ msdosfs_getattr(ap) u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry); u_long fileid; - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(dep, &ts, &ts, &ts); vap->va_fsid = dep->de_dev; /* @@ -1356,7 +1356,7 @@ msdosfs_mkdir(ap) bzero(&ndirent, sizeof(ndirent)); ndirent.de_pmp = pmp; ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE; - TIMEVAL_TO_TIMESPEC(&time, &ts); + getnanotime(&ts); DETIMES(&ndirent, &ts, &ts, &ts); /* diff --git a/sys/sys/pipe.h b/sys/sys/pipe.h index 82e7b5c..7454cdf 100644 --- a/sys/sys/pipe.h +++ b/sys/sys/pipe.h @@ -18,7 +18,7 @@ * 5. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: pipe.h,v 1.8 1997/02/22 09:45:40 peter Exp $ + * $Id: pipe.h,v 1.9 1997/04/09 16:53:45 bde Exp $ */ #ifndef _SYS_PIPE_H_ @@ -99,9 +99,9 @@ struct pipe { struct pipebuf pipe_buffer; /* data storage */ struct pipemapping pipe_map; /* pipe mapping for direct I/O */ struct selinfo pipe_sel; /* for compat with select */ - struct timeval pipe_atime; /* time of last access */ - struct timeval pipe_mtime; /* time of last modify */ - struct timeval pipe_ctime; /* time of status change */ + struct timespec pipe_atime; /* time of last access */ + struct timespec pipe_mtime; /* time of last modify */ + struct timespec pipe_ctime; /* time of status change */ int pipe_pgid; /* process/group for async I/O */ struct pipe *pipe_peer; /* link with other direction */ u_int pipe_state; /* pipe status info */ diff --git a/sys/sys/time.h b/sys/sys/time.h index b3ec8b7..e06ea26 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $Id: time.h,v 1.19 1998/02/25 02:14:14 bde Exp $ + * $Id: time.h,v 1.20 1998/03/04 10:26:44 dufault Exp $ */ #ifndef _SYS_TIME_H_ @@ -78,20 +78,22 @@ struct timezone { #define DST_CAN 6 /* Canada */ /* - * Structure used to interface to the machine dependent hardware - * support for timekeeping. + * Structure used to interface to the machine dependent hardware support + * for timekeeping. * - * A timecounter is a binary counter which has two simple properties: - * * it runs at a fixed frequency. - * * must not roll over in less than (1+epsilon)/HZ + * A timecounter is a (hard or soft) binary counter which has two properties: + * * it runs at a fixed, known frequency. + * * it must not roll over in less than (1 + delta)/HZ seconds. "delta" + * is expected to be less than 20 msec, but no hard data has been + * collected on this. 16 bit at 5 MHz (31 msec) is known to work. * - * get_timecount reads the counter. + * get_timedelta() returns difference between the counter now and offset_count. * - * get_timedelta returns difference between the counter now and offset_count + * get_timecount() reads the counter. * - * counter_mask removes unimplemented bits from the count value + * counter_mask removes unimplemented bits from the count value. * - * frequency should be obvious + * frequency is the counter frequency in hz. * * name is a short mnemonic name for this counter. * @@ -100,34 +102,44 @@ struct timezone { * adjustment [PPM << 16] which means that the smallest unit of correction * you can apply amounts to 481.5 usec/year. * - * scale_micro [2^32 * usec/tick] - * - * scale_nano_i [ns/tick] - * - * scale_nano_f [(ns/2^32)/tick] + * scale_micro [2^32 * usec/tick]. + * scale_nano_i [ns/tick]. + * scale_nano_f [(ns/2^32)/tick]. * * offset_count is the contents of the counter which corresponds to the - * rest of the offset_* values + * rest of the offset_* values. * - * offset_sec [s] - * offset_micro [usec] + * offset_sec [s]. + * offset_micro [usec]. * offset_nano [ns/2^32] is misnamed, the real unit is .23283064365... * attoseconds (10E-18) and before you ask: yes, they are in fact * called attoseconds, it comes from "atten" for 18 in Danish/Swedish. + * + * Each timecounter must supply an array of three timecounters, this is needed + * to guarantee atomicity in the code. Index zero is used to transport + * modifications, for instance done with sysctl, into the timecounter being + * used in a safe way. Such changes may be adopted with a delay of up to 1/HZ, + * index one & two are used alternately for the actual timekeeping. + * + * `other' points to the opposite "work" timecounter, ie, in index one it + * points to index two and vice versa + * + * `tweak' points to index zero. + * */ struct timecounter; -typedef u_int timecounter_get_t __P((struct timecounter *)); +typedef unsigned timecounter_get_t __P((struct timecounter *)); typedef u_int64_t timecounter_delta_t __P((void)); struct timecounter { - /* These fields must be initialized by the driver */ + /* These fields must be initialized by the driver. */ timecounter_get_t *get_timedelta; timecounter_delta_t *get_timecount; u_int64_t counter_mask; u_int32_t frequency; char *name; - /* These fields will be managed by the generic code */ + /* These fields will be managed by the generic code. */ int cost; int32_t adjustment; u_int32_t scale_micro; @@ -211,14 +223,16 @@ struct clockinfo { extern struct timecounter *timecounter; void forward_timecounter __P((void)); -void gettime __P((struct timeval *tv)); -void init_timecounter __P((struct timecounter *)); +void getmicrotime __P((struct timeval *tv)); +void getnanotime __P((struct timespec *tv)); +#define gettime(xxx) getmicrotime(xxx) /* XXX be compatible */ +void init_timecounter __P((struct timecounter *tc)); int itimerfix __P((struct timeval *tv)); int itimerdecr __P((struct itimerval *itp, int usec)); void microtime __P((struct timeval *tv)); void nanotime __P((struct timespec *ts)); void second_overflow __P((u_int32_t *psec)); -void set_timecounter __P((struct timespec *)); +void set_timecounter __P((struct timespec *ts)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); #else /* !KERNEL */ diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h index b3ec8b7..e06ea26 100644 --- a/sys/sys/timetc.h +++ b/sys/sys/timetc.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $Id: time.h,v 1.19 1998/02/25 02:14:14 bde Exp $ + * $Id: time.h,v 1.20 1998/03/04 10:26:44 dufault Exp $ */ #ifndef _SYS_TIME_H_ @@ -78,20 +78,22 @@ struct timezone { #define DST_CAN 6 /* Canada */ /* - * Structure used to interface to the machine dependent hardware - * support for timekeeping. + * Structure used to interface to the machine dependent hardware support + * for timekeeping. * - * A timecounter is a binary counter which has two simple properties: - * * it runs at a fixed frequency. - * * must not roll over in less than (1+epsilon)/HZ + * A timecounter is a (hard or soft) binary counter which has two properties: + * * it runs at a fixed, known frequency. + * * it must not roll over in less than (1 + delta)/HZ seconds. "delta" + * is expected to be less than 20 msec, but no hard data has been + * collected on this. 16 bit at 5 MHz (31 msec) is known to work. * - * get_timecount reads the counter. + * get_timedelta() returns difference between the counter now and offset_count. * - * get_timedelta returns difference between the counter now and offset_count + * get_timecount() reads the counter. * - * counter_mask removes unimplemented bits from the count value + * counter_mask removes unimplemented bits from the count value. * - * frequency should be obvious + * frequency is the counter frequency in hz. * * name is a short mnemonic name for this counter. * @@ -100,34 +102,44 @@ struct timezone { * adjustment [PPM << 16] which means that the smallest unit of correction * you can apply amounts to 481.5 usec/year. * - * scale_micro [2^32 * usec/tick] - * - * scale_nano_i [ns/tick] - * - * scale_nano_f [(ns/2^32)/tick] + * scale_micro [2^32 * usec/tick]. + * scale_nano_i [ns/tick]. + * scale_nano_f [(ns/2^32)/tick]. * * offset_count is the contents of the counter which corresponds to the - * rest of the offset_* values + * rest of the offset_* values. * - * offset_sec [s] - * offset_micro [usec] + * offset_sec [s]. + * offset_micro [usec]. * offset_nano [ns/2^32] is misnamed, the real unit is .23283064365... * attoseconds (10E-18) and before you ask: yes, they are in fact * called attoseconds, it comes from "atten" for 18 in Danish/Swedish. + * + * Each timecounter must supply an array of three timecounters, this is needed + * to guarantee atomicity in the code. Index zero is used to transport + * modifications, for instance done with sysctl, into the timecounter being + * used in a safe way. Such changes may be adopted with a delay of up to 1/HZ, + * index one & two are used alternately for the actual timekeeping. + * + * `other' points to the opposite "work" timecounter, ie, in index one it + * points to index two and vice versa + * + * `tweak' points to index zero. + * */ struct timecounter; -typedef u_int timecounter_get_t __P((struct timecounter *)); +typedef unsigned timecounter_get_t __P((struct timecounter *)); typedef u_int64_t timecounter_delta_t __P((void)); struct timecounter { - /* These fields must be initialized by the driver */ + /* These fields must be initialized by the driver. */ timecounter_get_t *get_timedelta; timecounter_delta_t *get_timecount; u_int64_t counter_mask; u_int32_t frequency; char *name; - /* These fields will be managed by the generic code */ + /* These fields will be managed by the generic code. */ int cost; int32_t adjustment; u_int32_t scale_micro; @@ -211,14 +223,16 @@ struct clockinfo { extern struct timecounter *timecounter; void forward_timecounter __P((void)); -void gettime __P((struct timeval *tv)); -void init_timecounter __P((struct timecounter *)); +void getmicrotime __P((struct timeval *tv)); +void getnanotime __P((struct timespec *tv)); +#define gettime(xxx) getmicrotime(xxx) /* XXX be compatible */ +void init_timecounter __P((struct timecounter *tc)); int itimerfix __P((struct timeval *tv)); int itimerdecr __P((struct itimerval *itp, int usec)); void microtime __P((struct timeval *tv)); void nanotime __P((struct timespec *ts)); void second_overflow __P((u_int32_t *psec)); -void set_timecounter __P((struct timespec *)); +void set_timecounter __P((struct timespec *ts)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); #else /* !KERNEL */ diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 02ce546..3fd93dd 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 - * $Id: ffs_inode.c,v 1.37 1998/03/16 01:55:43 dyson Exp $ + * $Id: ffs_inode.c,v 1.38 1998/03/19 22:49:42 dyson Exp $ */ #include "opt_quota.h" @@ -102,6 +102,7 @@ ffs_update(vp, access, modify, waitfor) * * XXX there should be a function or macro for reading the time * (e.g., some machines may require splclock()). + * XXX there are: they're called get{micro|nano}time */ tv_sec = time.tv_sec; if (ip->i_flag & IN_ACCESS) diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 4bd1cf5..c787e1e 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.20 1998/01/30 11:34:02 phk Exp $ + * $Id: inode.h,v 1.21 1998/03/08 09:59:21 julian Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -143,29 +143,6 @@ struct indir { #define VTOI(vp) ((struct inode *)(vp)->v_data) #define ITOV(ip) ((ip)->i_vnode) -/* - * XXX this is too long to be a macro, and isn't used in any time-critical - * place; in fact it is only used in ufs_vnops.c so it shouldn't be in a - * header file. - */ -#define ITIMES(ip, t1, t2) { \ - long tv_sec = time.tv_sec; \ - if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ - (ip)->i_flag |= IN_MODIFIED; \ - if ((ip)->i_flag & IN_ACCESS) \ - (ip)->i_atime \ - = ((t1) == &time ? tv_sec : (t1)->tv_sec); \ - if ((ip)->i_flag & IN_UPDATE) { \ - (ip)->i_mtime \ - = ((t2) == &time ? tv_sec : (t2)->tv_sec); \ - (ip)->i_modrev++; \ - } \ - if ((ip)->i_flag & IN_CHANGE) \ - (ip)->i_ctime = tv_sec; \ - (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ - } \ -} - /* Determine if soft dependencies are being done */ #define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP) diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 82a7cc3..b922ba7 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95 - * $Id: ufs_vnops.c,v 1.78 1998/02/09 06:11:14 eivind Exp $ + * $Id: ufs_vnops.c,v 1.79 1998/03/08 09:59:44 julian Exp $ */ #include "opt_quota.h" @@ -123,6 +123,27 @@ union _qcvt { } /* + * XXX this is too long to be a macro, and isn't used in any time-critical + * place; + */ +#define ITIMES(ip) { \ + struct timeval tv; \ + getmicrotime(&tv); \ + if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ + (ip)->i_flag |= IN_MODIFIED; \ + if ((ip)->i_flag & IN_ACCESS) \ + (ip)->i_atime = tv.tv_sec; \ + if ((ip)->i_flag & IN_UPDATE) { \ + (ip)->i_mtime = tv.tv_sec; \ + (ip)->i_modrev++; \ + } \ + if ((ip)->i_flag & IN_CHANGE) \ + (ip)->i_ctime = tv.tv_sec; \ + (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ + } \ +} + +/* * A virgin directory (no blushing please). */ static struct dirtemplate mastertemplate = { @@ -246,7 +267,7 @@ ufs_close(ap) simple_lock(&vp->v_interlock); if (vp->v_usecount > 1) - ITIMES(ip, &time, &time); + ITIMES(ip); simple_unlock(&vp->v_interlock); return (0); } @@ -349,7 +370,7 @@ ufs_getattr(ap) register struct inode *ip = VTOI(vp); register struct vattr *vap = ap->a_vap; - ITIMES(ip, &time, &time); + ITIMES(ip); /* * Copy from inode table */ @@ -1807,7 +1828,7 @@ ufsspec_close(ap) simple_lock(&vp->v_interlock); if (ap->a_vp->v_usecount > 1) - ITIMES(ip, &time, &time); + ITIMES(ip); simple_unlock(&vp->v_interlock); return (VOCALL (spec_vnodeop_p, VOFFSET(vop_close), ap)); } @@ -1871,7 +1892,7 @@ ufsfifo_close(ap) simple_lock(&vp->v_interlock); if (ap->a_vp->v_usecount > 1) - ITIMES(ip, &time, &time); + ITIMES(ip); simple_unlock(&vp->v_interlock); return (VOCALL (fifo_vnodeop_p, VOFFSET(vop_close), ap)); } |