diff options
author | bde <bde@FreeBSD.org> | 1998-07-03 18:46:52 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-07-03 18:46:52 +0000 |
commit | dfd9848c30c89d2bd43b93309c934a84cc254107 (patch) | |
tree | 9d19fdccc10074893d94a205159868f759b143ad /sys | |
parent | e15057ae7cfa8d8f9f129ea1ec98514ab36f269d (diff) | |
download | FreeBSD-src-dfd9848c30c89d2bd43b93309c934a84cc254107.zip FreeBSD-src-dfd9848c30c89d2bd43b93309c934a84cc254107.tar.gz |
Centralized in-core inode update. Update the in-core inode directly
in ufs_setattr() so that there is no need to pass timestamps to
UFS_UPDATE() (everything else just needs the current time). Ignore
the passed-in timestamps in UFS_UPDATE() and always call ufs_itimes()
(was: itimes()) to do the update. The timestamps are still passed
so that all the callers don't need to be changed yet.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/gnu/ext2fs/ext2_inode.c | 20 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_inode.c | 20 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 27 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_extern.h | 3 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 34 |
5 files changed, 33 insertions, 71 deletions
diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c index f6cc413..a094ad2 100644 --- a/sys/gnu/ext2fs/ext2_inode.c +++ b/sys/gnu/ext2fs/ext2_inode.c @@ -91,25 +91,13 @@ ext2_update(vp, access, modify, waitfor) struct inode *ip; int error; + ufs_itimes(vp); ip = VTOI(vp); - if (vp->v_mount->mnt_flag & MNT_RDONLY) { - ip->i_flag &= - ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); + if ((ip->i_flag & IN_MODIFIED) == 0) return (0); - } - if ((ip->i_flag & - (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0) + ip->i_flag &= ~IN_MODIFIED; + if (vp->v_mount->mnt_flag & MNT_RDONLY) return (0); - if (ip->i_flag & IN_ACCESS) - ip->i_atime = access->tv_sec; - if (ip->i_flag & IN_UPDATE) { - ip->i_mtime = modify->tv_sec; - ip->i_modrev++; - } - if (ip->i_flag & IN_CHANGE) { - ip->i_ctime = time_second; - } - ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_e2fs; if (error = bread(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c index f6cc413..a094ad2 100644 --- a/sys/gnu/fs/ext2fs/ext2_inode.c +++ b/sys/gnu/fs/ext2fs/ext2_inode.c @@ -91,25 +91,13 @@ ext2_update(vp, access, modify, waitfor) struct inode *ip; int error; + ufs_itimes(vp); ip = VTOI(vp); - if (vp->v_mount->mnt_flag & MNT_RDONLY) { - ip->i_flag &= - ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); + if ((ip->i_flag & IN_MODIFIED) == 0) return (0); - } - if ((ip->i_flag & - (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0) + ip->i_flag &= ~IN_MODIFIED; + if (vp->v_mount->mnt_flag & MNT_RDONLY) return (0); - if (ip->i_flag & IN_ACCESS) - ip->i_atime = access->tv_sec; - if (ip->i_flag & IN_UPDATE) { - ip->i_mtime = modify->tv_sec; - ip->i_modrev++; - } - if (ip->i_flag & IN_CHANGE) { - ip->i_ctime = time_second; - } - ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_e2fs; if (error = bread(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 5297fd1..89254a2 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.42 1998/05/04 17:43:48 dyson Exp $ + * $Id: ffs_inode.c,v 1.43 1998/06/14 19:31:28 julian Exp $ */ #include "opt_quota.h" @@ -52,6 +52,7 @@ #include <ufs/ufs/quota.h> #include <ufs/ufs/ufsmount.h> #include <ufs/ufs/inode.h> +#include <ufs/ufs/ufs_extern.h> #include <ufs/ffs/fs.h> #include <ufs/ffs/ffs_extern.h> @@ -80,29 +81,13 @@ ffs_update(vp, access, modify, waitfor) struct inode *ip; int error; + ufs_itimes(vp); ip = VTOI(vp); - if (vp->v_mount->mnt_flag & MNT_RDONLY) { - ip->i_flag &= - ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); + if ((ip->i_flag & IN_MODIFIED) == 0 && waitfor != MNT_WAIT) return (0); - } - if (((ip->i_flag & - (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0) && - (waitfor != MNT_WAIT)) + ip->i_flag &= ~IN_MODIFIED; + if (vp->v_mount->mnt_flag & MNT_RDONLY) return (0); - /* - * XXX: Some callers make a copy too early (before the i/o has - * completed)... - */ - if (ip->i_flag & IN_ACCESS) - ip->i_atime = access->tv_sec; - if (ip->i_flag & IN_UPDATE) { - ip->i_mtime = modify->tv_sec; - ip->i_modrev++; - } - if (ip->i_flag & IN_CHANGE) - ip->i_ctime = time_second; - ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_fs; /* * Ensure that uid and gid are correct. This is a temporary diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index 55d068c..7798b97 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 - * $Id: ufs_extern.h,v 1.22 1997/10/27 12:50:57 bde Exp $ + * $Id: ufs_extern.h,v 1.23 1998/03/08 09:59:24 julian Exp $ */ #ifndef _UFS_UFS_EXTERN_H_ @@ -84,6 +84,7 @@ struct vnode * void ufs_ihashrem __P((struct inode *)); int ufs_inactive __P((struct vop_inactive_args *)); int ufs_init __P((struct vfsconf *)); +void ufs_itimes __P((struct vnode *vp)); int ufs_lookup __P((struct vop_cachedlookup_args *)); int ufs_reclaim __P((struct vop_reclaim_args *)); int ufs_root __P((struct mount *, struct vnode **)); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index b1c3179..bbf701c 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.89 1998/06/27 06:45:04 phk Exp $ + * $Id: ufs_vnops.c,v 1.88 1998/06/08 23:55:33 julian Exp $ */ #include "opt_quota.h" @@ -71,7 +71,6 @@ #include <ufs/ufs/ufsmount.h> #include <ufs/ufs/ufs_extern.h> -static void itimes __P((struct vnode *vp)); static int ufs_abortop __P((struct vop_abortop_args *)); static int ufs_access __P((struct vop_access_args *)); static int ufs_advlock __P((struct vop_advlock_args *)); @@ -134,8 +133,8 @@ static struct odirtemplate omastertemplate = { 0, DIRBLKSIZ - 12, 2, ".." }; -static void -itimes(vp) +void +ufs_itimes(vp) struct vnode *vp; { struct inode *ip; @@ -270,7 +269,7 @@ ufs_close(ap) simple_lock(&vp->v_interlock); if (vp->v_usecount > 1) - itimes(vp); + ufs_itimes(vp); simple_unlock(&vp->v_interlock); return (0); } @@ -373,7 +372,7 @@ ufs_getattr(ap) register struct inode *ip = VTOI(vp); register struct vattr *vap = ap->a_vap; - itimes(vp); + ufs_itimes(vp); /* * Copy from inode table */ @@ -401,7 +400,7 @@ ufs_getattr(ap) else vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize; vap->va_bytes = dbtob((u_quad_t)ip->i_blocks); - vap->va_type = IFTOVT(ip->i_mode); + vap->va_type = vp->v_type; vap->va_filerev = ip->i_modrev; return (0); } @@ -423,7 +422,6 @@ ufs_setattr(ap) struct inode *ip = VTOI(vp); struct ucred *cred = ap->a_cred; struct proc *p = ap->a_p; - struct timeval atimeval, mtimeval; int error; /* @@ -503,11 +501,13 @@ ufs_setattr(ap) ip->i_flag |= IN_ACCESS; if (vap->va_mtime.tv_sec != VNOVAL) ip->i_flag |= IN_CHANGE | IN_UPDATE; - atimeval.tv_sec = vap->va_atime.tv_sec; - atimeval.tv_usec = vap->va_atime.tv_nsec / 1000; - mtimeval.tv_sec = vap->va_mtime.tv_sec; - mtimeval.tv_usec = vap->va_mtime.tv_nsec / 1000; - error = UFS_UPDATE(vp, &atimeval, &mtimeval, 0); + ufs_itimes(vp); + if (vap->va_mtime.tv_sec != VNOVAL) + ip->i_atime = vap->va_atime.tv_sec; + if (vap->va_atime.tv_sec != VNOVAL) + ip->i_mtime = vap->va_mtime.tv_sec; + error = UFS_UPDATE(vp, (struct timeval *)0, + (struct timeval *)0, 0); if (error) return (error); } @@ -1761,8 +1761,8 @@ ufs_print(ap) register struct vnode *vp = ap->a_vp; register struct inode *ip = VTOI(vp); - printf("tag VT_UFS, ino %ld, on dev %x (%d, %d)", ip->i_number, - ip->i_dev, major(ip->i_dev), minor(ip->i_dev)); + printf("tag VT_UFS, ino %ld, on dev %d, %d", ip->i_number, + major(ip->i_dev), minor(ip->i_dev)); if (vp->v_type == VFIFO) fifo_printinfo(vp); lockmgr_printinfo(&ip->i_lock); @@ -1834,7 +1834,7 @@ ufsspec_close(ap) simple_lock(&vp->v_interlock); if (vp->v_usecount > 1) - itimes(vp); + ufs_itimes(vp); simple_unlock(&vp->v_interlock); return (VOCALL(spec_vnodeop_p, VOFFSET(vop_close), ap)); } @@ -1904,7 +1904,7 @@ ufsfifo_close(ap) simple_lock(&vp->v_interlock); if (vp->v_usecount > 1) - itimes(vp); + ufs_itimes(vp); simple_unlock(&vp->v_interlock); return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap)); } |