diff options
author | phk <phk@FreeBSD.org> | 1998-03-30 09:56:58 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-03-30 09:56:58 +0000 |
commit | 9b703b14551addf9806978973e2ddc427d4908b4 (patch) | |
tree | 91f2de8432f719153d0de9465a9ebeee33c29077 /sys/ufs/ffs | |
parent | add2782c4ec0d7c4447da2b33d1413a2754f8a3e (diff) | |
download | FreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.zip FreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.tar.gz |
Eradicate the variable "time" from the kernel, using various measures.
"time" wasn't a atomic variable, so splfoo() protection were needed
around any access to it, unless you just wanted the seconds part.
Most uses of time.tv_sec now uses the new variable time_second instead.
gettime() changed to getmicrotime(0.
Remove a couple of unneeded splfoo() protections, the new getmicrotime()
is atomic, (until Bruce sets a breakpoint in it).
A couple of places needed random data, so use read_random() instead
of mucking about with time which isn't random.
Add a new nfs_curusec() function.
Mark a couple of bogosities involving the now disappeard time variable.
Update ffs_update() to avoid the weird "== &time" checks, by fixing the
one remaining call that passwd &time as args.
Change profiling in ncr.c to use ticks instead of time. Resolution is
the same.
Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call
hzto() which subtracts time" sequences.
Reviewed by: bde
Diffstat (limited to 'sys/ufs/ffs')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 12 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 27 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 4 |
4 files changed, 18 insertions, 31 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 8eab25a..f0e69b6 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95 - * $Id: ffs_alloc.c,v 1.47 1998/02/06 12:14:13 eivind Exp $ + * $Id: ffs_alloc.c,v 1.48 1998/03/08 09:58:42 julian Exp $ */ #include "opt_quota.h" @@ -837,7 +837,7 @@ ffs_fragextend(ip, cg, bprev, osize, nsize) brelse(bp); return (0); } - cgp->cg_time = time.tv_sec; + cgp->cg_time = time_second; bno = dtogd(fs, bprev); for (i = numfrags(fs, osize); i < frags; i++) if (isclr(cg_blksfree(cgp), bno + i)) { @@ -904,7 +904,7 @@ ffs_alloccg(ip, cg, bpref, size) brelse(bp); return (0); } - cgp->cg_time = time.tv_sec; + cgp->cg_time = time_second; if (size == fs->fs_bsize) { bno = ffs_alloccgblk(ip, bp, bpref); bdwrite(bp); @@ -1230,7 +1230,7 @@ ffs_nodealloccg(ip, cg, ipref, mode) brelse(bp); return (0); } - cgp->cg_time = time.tv_sec; + cgp->cg_time = time_second; if (ipref) { ipref %= fs->fs_ipg; if (isclr(cg_inosused(cgp), ipref)) @@ -1322,7 +1322,7 @@ ffs_blkfree(ip, bno, size) brelse(bp); return; } - cgp->cg_time = time.tv_sec; + cgp->cg_time = time_second; bno = dtogd(fs, bno); if (size == fs->fs_bsize) { blkno = fragstoblks(fs, bno); @@ -1483,7 +1483,7 @@ ffs_vfree( pvp, ino, mode) brelse(bp); return (0); } - cgp->cg_time = time.tv_sec; + cgp->cg_time = time_second; ino %= fs->fs_ipg; if (isclr(cg_inosused(cgp), ino)) { printf("dev = 0x%lx, ino = %ld, fs = %s\n", diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 3fd93dd..dc3f070 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.38 1998/03/19 22:49:42 dyson Exp $ + * $Id: ffs_inode.c,v 1.39 1998/03/26 20:53:49 phk Exp $ */ #include "opt_quota.h" @@ -79,7 +79,6 @@ ffs_update(vp, access, modify, waitfor) struct buf *bp; struct inode *ip; int error; - time_t tv_sec; ip = VTOI(vp); if (vp->v_mount->mnt_flag & MNT_RDONLY) { @@ -92,29 +91,17 @@ ffs_update(vp, access, modify, waitfor) (waitfor != MNT_WAIT)) return (0); /* - * Use a copy of the current time to get consistent timestamps - * (a_access and a_modify are sometimes aliases for &time). - * - * XXX in 2.0, a_access and a_modify are often pointers to the - * same copy of `time'. This is not as good. Some callers forget - * to make a copy; others make a copy too early (before the i/o - * has completed)... - * - * 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 + * XXX: Some callers make a copy too early (before the i/o has + * completed)... */ - tv_sec = time.tv_sec; if (ip->i_flag & IN_ACCESS) - ip->i_atime = - (access == &time ? tv_sec : access->tv_sec); + ip->i_atime = access->tv_sec; if (ip->i_flag & IN_UPDATE) { - ip->i_mtime = - (modify == &time ? tv_sec : modify->tv_sec); + ip->i_mtime = modify->tv_sec; ip->i_modrev++; } if (ip->i_flag & IN_CHANGE) - ip->i_ctime = tv_sec; + ip->i_ctime = time_second; ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_fs; /* @@ -184,7 +171,7 @@ ffs_truncate(vp, length, flags, cred, p) return (EINVAL); if (length > fs->fs_maxfilesize) return (EFBIG); - gettime(&tv); + getmicrotime(&tv); if (ovp->v_type == VLNK && (oip->i_size < ovp->v_mount->mnt_maxsymlinklen || oip->i_din.di_blocks == 0)) { #ifdef DIAGNOSTIC diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 96ef5bb..9b4753c 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95 - * $Id: ffs_vfsops.c,v 1.76 1998/03/08 09:59:06 julian Exp $ + * $Id: ffs_vfsops.c,v 1.77 1998/03/27 14:20:57 peter Exp $ */ #include "opt_quota.h" @@ -967,7 +967,7 @@ loop: } else { simple_unlock(&mntvnode_slock); simple_unlock(&vp->v_interlock); - gettime(&tv); + getmicrotime(&tv); /* UFS_UPDATE(vp, &tv, &tv, waitfor == MNT_WAIT); */ UFS_UPDATE(vp, &tv, &tv, 0); simple_lock(&mntvnode_slock); @@ -1247,7 +1247,7 @@ ffs_sbupdate(mp, waitfor) return (allerror); bp = getblk(mp->um_devvp, SBLOCK, (int)fs->fs_sbsize, 0, 0); fs->fs_fmod = 0; - fs->fs_time = time.tv_sec; + fs->fs_time = time_second; bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize); /* Restore compatibility to old file systems. XXX */ dfs = (struct fs *)bp->b_data; /* XXX */ diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 9e42e63..e7127f5 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_vnops.c 8.15 (Berkeley) 5/14/95 - * $Id: ffs_vnops.c,v 1.46 1998/03/21 05:16:09 dyson Exp $ + * $Id: ffs_vnops.c,v 1.47 1998/03/28 10:33:26 bde Exp $ */ #include <sys/param.h> @@ -253,7 +253,7 @@ loop2: #endif } } - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(ap->a_vp, &tv, &tv, (ap->a_waitfor == MNT_WAIT)); if (error) return (error); |