Support more intelligent sync operations for MNT_NOATIME.
PR: kern/5577 Submitted by: Craig Leres <leres@ee.lbl.gov>
This commit is contained in:
parent
0da25c39b2
commit
de1050d8e4
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95
|
||||
* $Id: ffs_inode.c,v 1.29 1997/10/16 20:32:34 phk Exp $
|
||||
* $Id: ffs_inode.c,v 1.30 1998/01/06 05:23:36 dyson Exp $
|
||||
*/
|
||||
|
||||
#include "opt_quota.h"
|
||||
@ -87,9 +87,15 @@ ffs_update(vp, access, modify, waitfor)
|
||||
~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (vp->v_mount->mnt_flag & MNT_NOATIME) {
|
||||
ip->i_flag &=~ IN_ACCESS;
|
||||
}
|
||||
|
||||
if ((ip->i_flag &
|
||||
(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Use a copy of the current time to get consistent timestamps
|
||||
* (a_access and a_modify are sometimes aliases for &time).
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95
|
||||
* $Id: ffs_vfsops.c,v 1.65 1998/01/17 09:16:43 dyson Exp $
|
||||
* $Id: ffs_vfsops.c,v 1.66 1998/01/22 17:30:17 dyson Exp $
|
||||
*/
|
||||
|
||||
#include "opt_quota.h"
|
||||
@ -849,6 +849,7 @@ ffs_sync(mp, waitfor, cred, p)
|
||||
struct fs *fs;
|
||||
struct timeval tv;
|
||||
int error, allerror = 0;
|
||||
u_long fmask;
|
||||
|
||||
fs = ump->um_fs;
|
||||
if (fs->fs_fmod != 0 && fs->fs_ronly != 0) { /* XXX */
|
||||
@ -858,6 +859,11 @@ ffs_sync(mp, waitfor, cred, p)
|
||||
/*
|
||||
* Write back each (modified) inode.
|
||||
*/
|
||||
|
||||
fmask = (mp->mnt_flag & MNT_NOATIME)?
|
||||
(IN_CHANGE | IN_MODIFIED | IN_UPDATE) :
|
||||
(IN_CHANGE | IN_MODIFIED | IN_UPDATE | IN_ACCESS);
|
||||
|
||||
simple_lock(&mntvnode_slock);
|
||||
loop:
|
||||
for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
|
||||
@ -870,8 +876,7 @@ ffs_sync(mp, waitfor, cred, p)
|
||||
simple_lock(&vp->v_interlock);
|
||||
nvp = vp->v_mntvnodes.le_next;
|
||||
ip = VTOI(vp);
|
||||
if (((ip->i_flag &
|
||||
(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0) &&
|
||||
if (((ip->i_flag & fmask) == 0) &&
|
||||
vp->v_dirtyblkhd.lh_first == NULL) {
|
||||
simple_unlock(&vp->v_interlock);
|
||||
continue;
|
||||
@ -895,7 +900,6 @@ ffs_sync(mp, waitfor, cred, p)
|
||||
simple_unlock(&mntvnode_slock);
|
||||
simple_unlock(&vp->v_interlock);
|
||||
gettime(&tv);
|
||||
/* UFS_UPDATE(vp, &tv, &tv, waitfor == MNT_WAIT); */
|
||||
UFS_UPDATE(vp, &tv, &tv, 0);
|
||||
simple_lock(&mntvnode_slock);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ffs_vnops.c 8.15 (Berkeley) 5/14/95
|
||||
* $Id: ffs_vnops.c,v 1.37 1997/10/27 13:33:45 bde Exp $
|
||||
* $Id: ffs_vnops.c,v 1.38 1998/01/06 05:23:44 dyson Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -105,6 +105,9 @@ SYSCTL_NODE(_vfs, MOUNT_UFS, ffs, CTLFLAG_RW, 0, "FFS filesystem");
|
||||
|
||||
#include <ufs/ufs/ufs_readwrite.c>
|
||||
|
||||
int ffs_log_sync = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Synch an open file.
|
||||
*/
|
||||
@ -126,7 +129,6 @@ ffs_fsync(ap)
|
||||
int s;
|
||||
daddr_t lbn;
|
||||
|
||||
|
||||
if (vp->v_type == VBLK) {
|
||||
lbn = INT_MAX;
|
||||
} else {
|
||||
@ -135,6 +137,12 @@ ffs_fsync(ap)
|
||||
lbn = lblkno(ip->i_fs, (ip->i_size + ip->i_fs->fs_bsize - 1));
|
||||
}
|
||||
|
||||
if (ffs_log_sync) {
|
||||
struct inode* ip = VTOI(vp);
|
||||
printf("fsync i %u iflags 0x%x vn 0x%x vtype %d tag %d vflags 0x%x\n",
|
||||
ip->i_number, ip->i_flag, vp, vp->v_type, vp->v_tag, vp->v_flag);
|
||||
}
|
||||
|
||||
pass = 0;
|
||||
/*
|
||||
* Flush all dirty buffers associated with a vnode.
|
||||
@ -148,6 +156,11 @@ ffs_fsync(ap)
|
||||
if ((bp->b_flags & B_DELWRI) == 0)
|
||||
panic("ffs_fsync: not dirty");
|
||||
|
||||
if (ffs_log_sync) {
|
||||
printf(" blk %u (%u) flags 0x%x vn 0x%x\n", bp->b_lblkno, bp->b_blkno,
|
||||
bp->b_flags, bp->b_vp);
|
||||
}
|
||||
|
||||
if (((bp->b_vp != vp) || (ap->a_waitfor != MNT_NOWAIT)) ||
|
||||
((vp->v_type != VREG) && (vp->v_type != VBLK))) {
|
||||
|
||||
@ -206,5 +219,5 @@ ffs_fsync(ap)
|
||||
}
|
||||
|
||||
gettime(&tv);
|
||||
return (UFS_UPDATE(ap->a_vp, &tv, &tv, ap->a_waitfor == MNT_WAIT));
|
||||
return (UFS_UPDATE(ap->a_vp, &tv, &tv, 1));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user