From 227ee8a188f0f8da52dabd7c2c13748a2578efce Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Mon, 30 Mar 1998 09:56:58 +0000 Subject: 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 --- sys/gnu/ext2fs/ext2_inode.c | 4 ++-- sys/gnu/ext2fs/ext2_readwrite.c | 2 +- sys/gnu/ext2fs/ext2_vfsops.c | 2 +- sys/gnu/ext2fs/ext2_vnops.c | 10 +++++----- sys/gnu/fs/ext2fs/ext2_inode.c | 4 ++-- sys/gnu/fs/ext2fs/ext2_readwrite.c | 2 +- sys/gnu/fs/ext2fs/ext2_vfsops.c | 2 +- sys/gnu/fs/ext2fs/ext2_vnops.c | 10 +++++----- 8 files changed, 18 insertions(+), 18 deletions(-) (limited to 'sys/gnu') diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c index 5231fececfadc..92ea5bf4aa754 100644 --- a/sys/gnu/ext2fs/ext2_inode.c +++ b/sys/gnu/ext2fs/ext2_inode.c @@ -109,7 +109,7 @@ ext2_update(vp, access, modify, waitfor) ip->i_modrev++; } if (ip->i_flag & IN_CHANGE) { - ip->i_ctime = time.tv_sec; + ip->i_ctime = time_second; } ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_e2fs; @@ -171,7 +171,7 @@ printf("ext2_truncate called %d to %d\n", VTOI(ovp)->i_number, length); return EFBIG; oip = VTOI(ovp); - gettime(&tv); + getmicrotime(&tv); if (ovp->v_type == VLNK && oip->i_size < ovp->v_mount->mnt_maxsymlinklen) { #if DIAGNOSTIC diff --git a/sys/gnu/ext2fs/ext2_readwrite.c b/sys/gnu/ext2fs/ext2_readwrite.c index 68522e54febc0..b49666afe1bae 100644 --- a/sys/gnu/ext2fs/ext2_readwrite.c +++ b/sys/gnu/ext2fs/ext2_readwrite.c @@ -289,7 +289,7 @@ WRITE(ap) uio->uio_resid = resid; } } else if (resid > uio->uio_resid && (ioflag & IO_SYNC)) { - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(vp, &tv, &tv, 1); } return (error); diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 635876b6e20d4..9a8dad14d6d45 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -837,7 +837,7 @@ ext2_sync(mp, waitfor, cred, p) panic("update: rofs mod"); } fs->s_dirt = 0; - fs->s_es->s_wtime = time.tv_sec; + fs->s_es->s_wtime = time_second; allerror = ext2_sbupdate(ump, waitfor); } /* diff --git a/sys/gnu/ext2fs/ext2_vnops.c b/sys/gnu/ext2fs/ext2_vnops.c index bb2a373a23c78..61a0a5a0719d4 100644 --- a/sys/gnu/ext2fs/ext2_vnops.c +++ b/sys/gnu/ext2fs/ext2_vnops.c @@ -229,7 +229,7 @@ loop: #endif } splx(s); - gettime(&tv); + getmicrotime(&tv); return (UFS_UPDATE(ap->a_vp, &tv, &tv, ap->a_waitfor == MNT_WAIT)); } @@ -354,7 +354,7 @@ ext2_link(ap) } ip->i_nlink++; ip->i_flag |= IN_CHANGE; - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(vp, &tv, &tv, 1); if (!error) error = ext2_direnter(ip, tdvp, cnp); @@ -526,7 +526,7 @@ abortit: */ ip->i_nlink++; ip->i_flag |= IN_CHANGE; - gettime(&tv); + getmicrotime(&tv); if (error = UFS_UPDATE(fvp, &tv, &tv, 1)) { VOP_UNLOCK(fvp, 0, p); goto bad; @@ -897,7 +897,7 @@ ext2_mkdir(ap) ip->i_nlink = 2; if (cnp->cn_flags & ISWHITEOUT) ip->i_flags |= UF_OPAQUE; - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(tvp, &tv, &tv, 1); /* @@ -1178,7 +1178,7 @@ ext2_makeinode(mode, dvp, vpp, cnp) /* * Make sure inode goes to disk before directory entry. */ - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(tvp, &tv, &tv, 1); if (error) goto bad; diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c index 5231fececfadc..92ea5bf4aa754 100644 --- a/sys/gnu/fs/ext2fs/ext2_inode.c +++ b/sys/gnu/fs/ext2fs/ext2_inode.c @@ -109,7 +109,7 @@ ext2_update(vp, access, modify, waitfor) ip->i_modrev++; } if (ip->i_flag & IN_CHANGE) { - ip->i_ctime = time.tv_sec; + ip->i_ctime = time_second; } ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_e2fs; @@ -171,7 +171,7 @@ printf("ext2_truncate called %d to %d\n", VTOI(ovp)->i_number, length); return EFBIG; oip = VTOI(ovp); - gettime(&tv); + getmicrotime(&tv); if (ovp->v_type == VLNK && oip->i_size < ovp->v_mount->mnt_maxsymlinklen) { #if DIAGNOSTIC diff --git a/sys/gnu/fs/ext2fs/ext2_readwrite.c b/sys/gnu/fs/ext2fs/ext2_readwrite.c index 68522e54febc0..b49666afe1bae 100644 --- a/sys/gnu/fs/ext2fs/ext2_readwrite.c +++ b/sys/gnu/fs/ext2fs/ext2_readwrite.c @@ -289,7 +289,7 @@ WRITE(ap) uio->uio_resid = resid; } } else if (resid > uio->uio_resid && (ioflag & IO_SYNC)) { - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(vp, &tv, &tv, 1); } return (error); diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index 635876b6e20d4..9a8dad14d6d45 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -837,7 +837,7 @@ ext2_sync(mp, waitfor, cred, p) panic("update: rofs mod"); } fs->s_dirt = 0; - fs->s_es->s_wtime = time.tv_sec; + fs->s_es->s_wtime = time_second; allerror = ext2_sbupdate(ump, waitfor); } /* diff --git a/sys/gnu/fs/ext2fs/ext2_vnops.c b/sys/gnu/fs/ext2fs/ext2_vnops.c index bb2a373a23c78..61a0a5a0719d4 100644 --- a/sys/gnu/fs/ext2fs/ext2_vnops.c +++ b/sys/gnu/fs/ext2fs/ext2_vnops.c @@ -229,7 +229,7 @@ loop: #endif } splx(s); - gettime(&tv); + getmicrotime(&tv); return (UFS_UPDATE(ap->a_vp, &tv, &tv, ap->a_waitfor == MNT_WAIT)); } @@ -354,7 +354,7 @@ ext2_link(ap) } ip->i_nlink++; ip->i_flag |= IN_CHANGE; - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(vp, &tv, &tv, 1); if (!error) error = ext2_direnter(ip, tdvp, cnp); @@ -526,7 +526,7 @@ abortit: */ ip->i_nlink++; ip->i_flag |= IN_CHANGE; - gettime(&tv); + getmicrotime(&tv); if (error = UFS_UPDATE(fvp, &tv, &tv, 1)) { VOP_UNLOCK(fvp, 0, p); goto bad; @@ -897,7 +897,7 @@ ext2_mkdir(ap) ip->i_nlink = 2; if (cnp->cn_flags & ISWHITEOUT) ip->i_flags |= UF_OPAQUE; - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(tvp, &tv, &tv, 1); /* @@ -1178,7 +1178,7 @@ ext2_makeinode(mode, dvp, vpp, cnp) /* * Make sure inode goes to disk before directory entry. */ - gettime(&tv); + getmicrotime(&tv); error = UFS_UPDATE(tvp, &tv, &tv, 1); if (error) goto bad; -- cgit v1.3