Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_subr.c
Show First 20 Lines • Show All 3,092 Lines • ▼ Show 20 Lines | |||||
static int busyprt = 0; /* print out busy vnodes */ | static int busyprt = 0; /* print out busy vnodes */ | ||||
SYSCTL_INT(_debug, OID_AUTO, busyprt, CTLFLAG_RW, &busyprt, 0, "Print out busy vnodes"); | SYSCTL_INT(_debug, OID_AUTO, busyprt, CTLFLAG_RW, &busyprt, 0, "Print out busy vnodes"); | ||||
#endif | #endif | ||||
int | int | ||||
vflush(struct mount *mp, int rootrefs, int flags, struct thread *td) | vflush(struct mount *mp, int rootrefs, int flags, struct thread *td) | ||||
{ | { | ||||
struct vnode *vp, *mvp, *rootvp = NULL; | struct vnode *vp, *mvp, *rootvp = NULL; | ||||
struct vm_object *obj; | |||||
struct vattr vattr; | struct vattr vattr; | ||||
int busy = 0, error; | int busy = 0, error; | ||||
CTR4(KTR_VFS, "%s: mp %p with rootrefs %d and flags %d", __func__, mp, | CTR4(KTR_VFS, "%s: mp %p with rootrefs %d and flags %d", __func__, mp, | ||||
rootrefs, flags); | rootrefs, flags); | ||||
if (rootrefs > 0) { | if (rootrefs > 0) { | ||||
KASSERT((flags & (SKIPSYSTEM | WRITECLOSE)) == 0, | KASSERT((flags & (SKIPSYSTEM | WRITECLOSE)) == 0, | ||||
("vflush: bad args")); | ("vflush: bad args")); | ||||
Show All 26 Lines | if ((flags & SKIPSYSTEM) && (vp->v_vflag & VV_SYSTEM)) { | ||||
continue; | continue; | ||||
} | } | ||||
/* | /* | ||||
* If WRITECLOSE is set, flush out unlinked but still open | * If WRITECLOSE is set, flush out unlinked but still open | ||||
* files (even if open only for reading) and regular file | * files (even if open only for reading) and regular file | ||||
* vnodes open for writing. | * vnodes open for writing. | ||||
*/ | */ | ||||
if (flags & WRITECLOSE) { | if (flags & WRITECLOSE) { | ||||
if (vp->v_object != NULL) { | obj = vp->v_object; | ||||
VM_OBJECT_WLOCK(vp->v_object); | if (obj != NULL && | ||||
vm_object_page_clean(vp->v_object, 0, 0, 0); | (obj->flags & OBJ_MIGHTBEDIRTY) != 0) { | ||||
VM_OBJECT_WUNLOCK(vp->v_object); | VM_OBJECT_WLOCK(obj); | ||||
vm_object_page_clean(obj, 0, 0, 0); | |||||
VM_OBJECT_WUNLOCK(obj); | |||||
} | } | ||||
error = VOP_FSYNC(vp, MNT_WAIT, td); | error = VOP_FSYNC(vp, MNT_WAIT, td); | ||||
if (error != 0) { | if (error != 0) { | ||||
VOP_UNLOCK(vp, 0); | VOP_UNLOCK(vp, 0); | ||||
vdrop(vp); | vdrop(vp); | ||||
MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); | MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,412 Lines • Show Last 20 Lines |