diff options
author | mckusick <mckusick@FreeBSD.org> | 2012-04-20 07:00:28 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2012-04-20 07:00:28 +0000 |
commit | d9895ac1fe988335e2619f56d942d954d835bb07 (patch) | |
tree | 10f55b579602c4e2bd1320448bee01fb50952a9d /sys/kern/vfs_subr.c | |
parent | 5b7b29e35b332608560671cf15919cf03d76f9ca (diff) | |
download | FreeBSD-src-d9895ac1fe988335e2619f56d942d954d835bb07.zip FreeBSD-src-d9895ac1fe988335e2619f56d942d954d835bb07.tar.gz |
This update uses the MNT_VNODE_FOREACH_ACTIVE interface that loops
over just the active vnodes associated with a mount point to replace
MNT_VNODE_FOREACH_ALL in the vfs_msync, ffs_sync_lazy, and qsync
routines.
The vfs_msync routine is run every 30 seconds for every writably
mounted filesystem. It ensures that any files mmap'ed from the
filesystem with modified pages have those pages queued to be
written back to the file from which they are mapped.
The ffs_lazy_sync and qsync routines are run every 30 seconds for
every writably mounted UFS/FFS filesystem. The ffs_lazy_sync routine
ensures that any files that have been accessed in the previous
30 seconds have had their access times queued for updating in the
filesystem. The qsync routine ensures that any files with modified
quotas have those quotas queued to be written back to their
associated quota file.
In a system configured with 250,000 vnodes, less than 1000 are
typically active at any point in time. Prior to this change all
250,000 vnodes would be locked and inspected twice every minute
by the syncer. For UFS/FFS filesystems they would be locked and
inspected six times every minute (twice by each of these three
routines since each of these routines does its own pass over the
vnodes associated with a mount point). With this change the syncer
now locks and inspects only the tiny set of vnodes that are active.
Reviewed by: kib
Tested by: Peter Holm
MFC after: 2 weeks
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 7af71e9..d660262 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2484,6 +2484,7 @@ vdropl(struct vnode *vp) void vinactive(struct vnode *vp, struct thread *td) { + struct vm_object *obj; ASSERT_VOP_ELOCKED(vp, "vinactive"); ASSERT_VI_LOCKED(vp, "vinactive"); @@ -2493,6 +2494,17 @@ vinactive(struct vnode *vp, struct thread *td) vp->v_iflag |= VI_DOINGINACT; vp->v_iflag &= ~VI_OWEINACT; VI_UNLOCK(vp); + /* + * Before moving off the active list, we must be sure that any + * modified pages are on the vnode's dirty list since these will + * no longer be checked once the vnode is on the inactive list. + */ + obj = vp->v_object; + if (obj != NULL && (obj->flags & OBJ_MIGHTBEDIRTY) != 0) { + VM_OBJECT_LOCK(obj); + vm_object_page_clean(obj, 0, 0, OBJPC_NOSYNC); + VM_OBJECT_UNLOCK(obj); + } VOP_INACTIVE(vp, td); VI_LOCK(vp); VNASSERT(vp->v_iflag & VI_DOINGINACT, vp, @@ -3362,7 +3374,7 @@ vfs_msync(struct mount *mp, int flags) struct vm_object *obj; CTR2(KTR_VFS, "%s: mp %p", __func__, mp); - MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { + MNT_VNODE_FOREACH_ACTIVE(vp, mp, mvp) { obj = vp->v_object; if (obj != NULL && (obj->flags & OBJ_MIGHTBEDIRTY) != 0 && (flags == MNT_WAIT || VOP_ISLOCKED(vp) == 0)) { |