Add vnode_pager_clean_{a,}sync(9)

Bump __FreeBSD_version for ZFS use.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43356
This commit is contained in:
Konstantin Belousov 2024-01-08 07:18:40 +02:00
parent 1f62718d8b
commit b068bb09a1
16 changed files with 82 additions and 118 deletions

View file

@ -66,6 +66,7 @@ enum symfollow { NO_FOLLOW = NOFOLLOW };
#include <sys/syscallsubr.h> #include <sys/syscallsubr.h>
#include <sys/vm.h> #include <sys/vm.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vnode_pager.h>
typedef struct vop_vector vnodeops_t; typedef struct vop_vector vnodeops_t;
#define VOP_FID VOP_VPTOFH #define VOP_FID VOP_VPTOFH
@ -100,11 +101,11 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync)
#else #else
if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) { if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) {
#endif #endif
int flags = sync ? OBJPC_SYNC : 0;
vn_lock(vp, LK_SHARED | LK_RETRY); vn_lock(vp, LK_SHARED | LK_RETRY);
zfs_vmobject_wlock(vp->v_object); if (sync)
vm_object_page_clean(vp->v_object, 0, 0, flags); vnode_pager_clean_sync(vp);
zfs_vmobject_wunlock(vp->v_object); else
vnode_pager_clean_async(vp);
VOP_UNLOCK1(vp); VOP_UNLOCK1(vp);
} }
} }

View file

@ -95,6 +95,7 @@
#include <vm/vm_map.h> #include <vm/vm_map.h>
#include <vm/vm_page.h> #include <vm/vm_page.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vnode_pager.h>
#include "fuse.h" #include "fuse.h"
#include "fuse_file.h" #include "fuse_file.h"
@ -945,11 +946,7 @@ fuse_io_invalbuf(struct vnode *vp, struct thread *td)
} }
fvdat->flag |= FN_FLUSHINPROG; fvdat->flag |= FN_FLUSHINPROG;
if (vp->v_bufobj.bo_object != NULL) { vnode_pager_clean_sync(vp);
VM_OBJECT_WLOCK(vp->v_bufobj.bo_object);
vm_object_page_clean(vp->v_bufobj.bo_object, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(vp->v_bufobj.bo_object);
}
error = vinvalbuf(vp, V_SAVE, PCATCH, 0); error = vinvalbuf(vp, V_SAVE, PCATCH, 0);
while (error) { while (error) {
if (error == ERESTART || error == EINTR) { if (error == ERESTART || error == EINTR) {

View file

@ -1428,11 +1428,9 @@ ncl_vinvalbuf(struct vnode *vp, int flags, struct thread *td, int intrflg)
/* /*
* Now, flush as required. * Now, flush as required.
*/ */
if ((flags & (V_SAVE | V_VMIO)) == V_SAVE && if ((flags & (V_SAVE | V_VMIO)) == V_SAVE) {
vp->v_bufobj.bo_object != NULL) { vnode_pager_clean_sync(vp);
VM_OBJECT_WLOCK(vp->v_bufobj.bo_object);
vm_object_page_clean(vp->v_bufobj.bo_object, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(vp->v_bufobj.bo_object);
/* /*
* If the page clean was interrupted, fail the invalidation. * If the page clean was interrupted, fail the invalidation.
* Not doing so, we run the risk of losing dirty pages in the * Not doing so, we run the risk of losing dirty pages in the

View file

@ -47,6 +47,8 @@
#include <sys/taskqueue.h> #include <sys/taskqueue.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#include <vm/vm_param.h>
#include <vm/vnode_pager.h>
#include <vm/uma.h> #include <vm/uma.h>
#include <fs/nfs/nfsport.h> #include <fs/nfs/nfsport.h>
@ -236,7 +238,6 @@ ncl_inactive(struct vop_inactive_args *ap)
struct vnode *vp = ap->a_vp; struct vnode *vp = ap->a_vp;
struct nfsnode *np; struct nfsnode *np;
struct thread *td; struct thread *td;
boolean_t retv;
td = curthread; td = curthread;
np = VTONFS(vp); np = VTONFS(vp);
@ -250,17 +251,9 @@ ncl_inactive(struct vop_inactive_args *ap)
* buffers/pages must be flushed before the close, so that the * buffers/pages must be flushed before the close, so that the
* stateid is available for the writes. * stateid is available for the writes.
*/ */
if (vp->v_object != NULL) { vnode_pager_clean_sync(vp);
VM_OBJECT_WLOCK(vp->v_object); (void)ncl_flush(vp, MNT_WAIT, td, 1, 0);
retv = vm_object_page_clean(vp->v_object, 0, 0, (void)nfsrpc_close(vp, 1, td);
OBJPC_SYNC);
VM_OBJECT_WUNLOCK(vp->v_object);
} else
retv = TRUE;
if (retv == TRUE) {
(void)ncl_flush(vp, MNT_WAIT, td, 1, 0);
(void)nfsrpc_close(vp, 1, td);
}
} }
NFSLOCKNODE(np); NFSLOCKNODE(np);

View file

@ -67,6 +67,7 @@
#include <vm/vm.h> #include <vm/vm.h>
#include <vm/vm_extern.h> #include <vm/vm_extern.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vnode_pager.h>
#include <fs/nfs/nfsport.h> #include <fs/nfs/nfsport.h>
#include <fs/nfsclient/nfsnode.h> #include <fs/nfsclient/nfsnode.h>
@ -766,9 +767,7 @@ nfs_open(struct vop_open_args *ap)
if (VN_IS_DOOMED(vp)) if (VN_IS_DOOMED(vp))
return (EBADF); return (EBADF);
} }
VM_OBJECT_WLOCK(obj); vnode_pager_clean_sync(vp);
vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(obj);
} }
/* Now, flush the buffer cache. */ /* Now, flush the buffer cache. */
@ -854,9 +853,7 @@ nfs_close(struct vop_close_args *ap)
if (VN_IS_DOOMED(vp) && ap->a_fflag != FNONBLOCK) if (VN_IS_DOOMED(vp) && ap->a_fflag != FNONBLOCK)
return (EBADF); return (EBADF);
} }
VM_OBJECT_WLOCK(vp->v_object); vnode_pager_clean_async(vp);
vm_object_page_clean(vp->v_object, 0, 0, 0);
VM_OBJECT_WUNLOCK(vp->v_object);
} }
NFSLOCKNODE(np); NFSLOCKNODE(np);
if (np->n_flag & NMODIFIED) { if (np->n_flag & NMODIFIED) {
@ -3637,7 +3634,6 @@ nfs_allocate(struct vop_allocate_args *ap)
{ {
struct vnode *vp = ap->a_vp; struct vnode *vp = ap->a_vp;
struct thread *td = curthread; struct thread *td = curthread;
vm_object_t obj;
struct nfsvattr nfsva; struct nfsvattr nfsva;
struct nfsmount *nmp; struct nfsmount *nmp;
struct nfsnode *np; struct nfsnode *np;
@ -3667,12 +3663,7 @@ nfs_allocate(struct vop_allocate_args *ap)
* file's allocation on the server. * file's allocation on the server.
*/ */
if (error == 0) { if (error == 0) {
obj = vp->v_object; vnode_pager_clean_sync(vp);
if (obj != NULL) {
VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(obj);
}
error = ncl_flush(vp, MNT_WAIT, td, 1, 0); error = ncl_flush(vp, MNT_WAIT, td, 1, 0);
} }
if (error == 0) if (error == 0)
@ -3908,9 +3899,7 @@ nfs_copy_file_range(struct vop_copy_file_range_args *ap)
vn_finished_write(mp); vn_finished_write(mp);
goto relock; goto relock;
} }
VM_OBJECT_WLOCK(invp_obj); vnode_pager_clean_sync(invp);
vm_object_page_clean(invp_obj, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(invp_obj);
} }
error = ncl_flush(invp, MNT_WAIT, curthread, 1, 0); error = ncl_flush(invp, MNT_WAIT, curthread, 1, 0);
} }
@ -4069,7 +4058,6 @@ static int
nfs_ioctl(struct vop_ioctl_args *ap) nfs_ioctl(struct vop_ioctl_args *ap)
{ {
struct vnode *vp = ap->a_vp; struct vnode *vp = ap->a_vp;
vm_object_t obj;
struct nfsvattr nfsva; struct nfsvattr nfsva;
struct nfsmount *nmp; struct nfsmount *nmp;
int attrflag, content, error, ret; int attrflag, content, error, ret;
@ -4114,10 +4102,7 @@ nfs_ioctl(struct vop_ioctl_args *ap)
* size is up to date on the Metadata Server. * size is up to date on the Metadata Server.
*/ */
obj = vp->v_object; vnode_pager_clean_sync(vp);
VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(obj);
error = ncl_flush(vp, MNT_WAIT, ap->a_td, 1, 0); error = ncl_flush(vp, MNT_WAIT, ap->a_td, 1, 0);
if (error == 0) if (error == 0)
error = nfsrpc_seek(vp, (off_t *)ap->a_data, &eof, error = nfsrpc_seek(vp, (off_t *)ap->a_data, &eof,

View file

@ -51,6 +51,8 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <nlm/nlm_prot.h> #include <nlm/nlm_prot.h>
#include <nlm/nlm.h> #include <nlm/nlm.h>
#include <vm/vm_param.h>
#include <vm/vnode_pager.h>
FEATURE(nfsd, "NFSv4 server"); FEATURE(nfsd, "NFSv4 server");
@ -1715,11 +1717,7 @@ nfsvno_fsync(struct vnode *vp, u_int64_t off, int cnt, struct ucred *cred,
/* /*
* Give up and do the whole thing * Give up and do the whole thing
*/ */
if (vp->v_object && vm_object_mightbedirty(vp->v_object)) { vnode_pager_clean_sync(vp);
VM_OBJECT_WLOCK(vp->v_object);
vm_object_page_clean(vp->v_object, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(vp->v_object);
}
error = VOP_FSYNC(vp, MNT_WAIT, td); error = VOP_FSYNC(vp, MNT_WAIT, td);
} else { } else {
/* /*

View file

@ -636,12 +636,7 @@ smbfs_vinvalbuf(struct vnode *vp, struct thread *td)
} }
np->n_flag |= NFLUSHINPROG; np->n_flag |= NFLUSHINPROG;
if (vp->v_bufobj.bo_object != NULL) { vnode_pager_clean_sync(vp);
VM_OBJECT_WLOCK(vp->v_bufobj.bo_object);
vm_object_page_clean(vp->v_bufobj.bo_object, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(vp->v_bufobj.bo_object);
}
error = vinvalbuf(vp, V_SAVE, PCATCH, 0); error = vinvalbuf(vp, V_SAVE, PCATCH, 0);
while (error) { while (error) {
if (error == ERESTART || error == EINTR) { if (error == ERESTART || error == EINTR) {

View file

@ -67,6 +67,7 @@
#include <vm/pmap.h> #include <vm/pmap.h>
#include <vm/vm_map.h> #include <vm/vm_map.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vnode_pager.h>
#include <vm/uma.h> #include <vm/uma.h>
#include <sys/aio.h> #include <sys/aio.h>
@ -717,7 +718,6 @@ static int
aio_fsync_vnode(struct thread *td, struct vnode *vp, int op) aio_fsync_vnode(struct thread *td, struct vnode *vp, int op)
{ {
struct mount *mp; struct mount *mp;
vm_object_t obj;
int error; int error;
for (;;) { for (;;) {
@ -725,12 +725,7 @@ aio_fsync_vnode(struct thread *td, struct vnode *vp, int op)
if (error != 0) if (error != 0)
break; break;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
obj = vp->v_object; vnode_pager_clean_async(vp);
if (obj != NULL) {
VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, 0);
VM_OBJECT_WUNLOCK(obj);
}
if (op == LIO_DSYNC) if (op == LIO_DSYNC)
error = VOP_FDATASYNC(vp, td); error = VOP_FDATASYNC(vp, td);
else else

View file

@ -94,6 +94,7 @@
#include <vm/vm_map.h> #include <vm/vm_map.h>
#include <vm/vm_page.h> #include <vm/vm_page.h>
#include <vm/vm_kern.h> #include <vm/vm_kern.h>
#include <vm/vnode_pager.h>
#include <vm/uma.h> #include <vm/uma.h>
#if defined(DEBUG_VFS_LOCKS) && (!defined(INVARIANTS) || !defined(WITNESS)) #if defined(DEBUG_VFS_LOCKS) && (!defined(INVARIANTS) || !defined(WITNESS))
@ -3989,7 +3990,6 @@ vdrop_recycle(struct vnode *vp)
static int static int
vinactivef(struct vnode *vp) vinactivef(struct vnode *vp)
{ {
struct vm_object *obj;
int error; int error;
ASSERT_VOP_ELOCKED(vp, "vinactive"); ASSERT_VOP_ELOCKED(vp, "vinactive");
@ -3999,6 +3999,7 @@ vinactivef(struct vnode *vp)
vp->v_iflag |= VI_DOINGINACT; vp->v_iflag |= VI_DOINGINACT;
vp->v_iflag &= ~VI_OWEINACT; vp->v_iflag &= ~VI_OWEINACT;
VI_UNLOCK(vp); VI_UNLOCK(vp);
/* /*
* Before moving off the active list, we must be sure that any * Before moving off the active list, we must be sure that any
* modified pages are converted into the vnode's dirty * modified pages are converted into the vnode's dirty
@ -4009,12 +4010,9 @@ vinactivef(struct vnode *vp)
* point that VOP_INACTIVE() is called, there could still be * point that VOP_INACTIVE() is called, there could still be
* pending I/O and dirty pages in the object. * pending I/O and dirty pages in the object.
*/ */
if ((obj = vp->v_object) != NULL && (vp->v_vflag & VV_NOSYNC) == 0 && if ((vp->v_vflag & VV_NOSYNC) == 0)
vm_object_mightbedirty(obj)) { vnode_pager_clean_async(vp);
VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, 0);
VM_OBJECT_WUNLOCK(obj);
}
error = VOP_INACTIVE(vp); error = VOP_INACTIVE(vp);
VI_LOCK(vp); VI_LOCK(vp);
VNPASS(vp->v_iflag & VI_DOINGINACT, vp); VNPASS(vp->v_iflag & VI_DOINGINACT, vp);
@ -4112,11 +4110,7 @@ vflush(struct mount *mp, int rootrefs, int flags, struct thread *td)
* vnodes open for writing. * vnodes open for writing.
*/ */
if (flags & WRITECLOSE) { if (flags & WRITECLOSE) {
if (vp->v_object != NULL) { vnode_pager_clean_async(vp);
VM_OBJECT_WLOCK(vp->v_object);
vm_object_page_clean(vp->v_object, 0, 0, 0);
VM_OBJECT_WUNLOCK(vp->v_object);
}
do { do {
error = VOP_FSYNC(vp, MNT_WAIT, td); error = VOP_FSYNC(vp, MNT_WAIT, td);
} while (error == ERELOOKUP); } while (error == ERELOOKUP);
@ -5094,17 +5088,12 @@ static void __noinline
vfs_periodic_msync_inactive(struct mount *mp, int flags) vfs_periodic_msync_inactive(struct mount *mp, int flags)
{ {
struct vnode *vp, *mvp; struct vnode *vp, *mvp;
struct vm_object *obj; int lkflags;
int lkflags, objflags;
bool seen_defer; bool seen_defer;
lkflags = LK_EXCLUSIVE | LK_INTERLOCK; lkflags = LK_EXCLUSIVE | LK_INTERLOCK;
if (flags != MNT_WAIT) { if (flags != MNT_WAIT)
lkflags |= LK_NOWAIT; lkflags |= LK_NOWAIT;
objflags = OBJPC_NOSYNC;
} else {
objflags = OBJPC_SYNC;
}
MNT_VNODE_FOREACH_LAZY(vp, mp, mvp, vfs_periodic_msync_inactive_filter, NULL) { MNT_VNODE_FOREACH_LAZY(vp, mp, mvp, vfs_periodic_msync_inactive_filter, NULL) {
seen_defer = false; seen_defer = false;
@ -5120,11 +5109,11 @@ vfs_periodic_msync_inactive(struct mount *mp, int flags)
continue; continue;
} }
if (vget(vp, lkflags) == 0) { if (vget(vp, lkflags) == 0) {
obj = vp->v_object; if ((vp->v_vflag & VV_NOSYNC) == 0) {
if (obj != NULL && (vp->v_vflag & VV_NOSYNC) == 0) { if (flags == MNT_WAIT)
VM_OBJECT_WLOCK(obj); vnode_pager_clean_sync(vp);
vm_object_page_clean(obj, 0, 0, objflags); else
VM_OBJECT_WUNLOCK(obj); vnode_pager_clean_async(vp);
} }
vput(vp); vput(vp);
if (seen_defer) if (seen_defer)

View file

@ -83,6 +83,7 @@
#include <vm/vm.h> #include <vm/vm.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vm_page.h> #include <vm/vm_page.h>
#include <vm/vnode_pager.h>
#include <vm/uma.h> #include <vm/uma.h>
#include <fs/devfs/devfs.h> #include <fs/devfs/devfs.h>
@ -3546,11 +3547,7 @@ kern_fsync(struct thread *td, int fd, bool fullsync)
goto drop; goto drop;
vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY); vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY);
AUDIT_ARG_VNODE1(vp); AUDIT_ARG_VNODE1(vp);
if (vp->v_object != NULL) { vnode_pager_clean_async(vp);
VM_OBJECT_WLOCK(vp->v_object);
vm_object_page_clean(vp->v_object, 0, 0, 0);
VM_OBJECT_WUNLOCK(vp->v_object);
}
error = fullsync ? VOP_FSYNC(vp, MNT_WAIT, td) : VOP_FDATASYNC(vp, td); error = fullsync ? VOP_FSYNC(vp, MNT_WAIT, td) : VOP_FDATASYNC(vp, td);
VOP_UNLOCK(vp); VOP_UNLOCK(vp);
vn_finished_write(mp); vn_finished_write(mp);

View file

@ -88,6 +88,7 @@
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vm_page.h> #include <vm/vm_page.h>
#include <vm/vm_pager.h> #include <vm/vm_pager.h>
#include <vm/vnode_pager.h>
#ifdef HWPMC_HOOKS #ifdef HWPMC_HOOKS
#include <sys/pmckern.h> #include <sys/pmckern.h>
@ -2575,7 +2576,6 @@ int
vn_bmap_seekhole_locked(struct vnode *vp, u_long cmd, off_t *off, vn_bmap_seekhole_locked(struct vnode *vp, u_long cmd, off_t *off,
struct ucred *cred) struct ucred *cred)
{ {
vm_object_t obj;
off_t size; off_t size;
daddr_t bn, bnp; daddr_t bn, bnp;
uint64_t bsize; uint64_t bsize;
@ -2600,12 +2600,7 @@ vn_bmap_seekhole_locked(struct vnode *vp, u_long cmd, off_t *off,
} }
/* See the comment in ufs_bmap_seekdata(). */ /* See the comment in ufs_bmap_seekdata(). */
obj = vp->v_object; vnode_pager_clean_sync(vp);
if (obj != NULL) {
VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(obj);
}
bsize = vp->v_mount->mnt_stat.f_iosize; bsize = vp->v_mount->mnt_stat.f_iosize;
for (bn = noff / bsize; noff < size; bn++, noff += bsize - for (bn = noff / bsize; noff < size; bn++, noff += bsize -

View file

@ -73,7 +73,7 @@
* cannot include sys/param.h and should only be updated here. * cannot include sys/param.h and should only be updated here.
*/ */
#undef __FreeBSD_version #undef __FreeBSD_version
#define __FreeBSD_version 1500008 #define __FreeBSD_version 1500009
/* /*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,

View file

@ -52,6 +52,7 @@
#include <vm/vm.h> #include <vm/vm.h>
#include <vm/vm_extern.h> #include <vm/vm_extern.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vnode_pager.h>
static int ffs_rawread_readahead(struct vnode *vp, static int ffs_rawread_readahead(struct vnode *vp,
caddr_t udata, caddr_t udata,
@ -132,15 +133,10 @@ ffs_rawread_sync(struct vnode *vp)
vn_finished_write(mp); vn_finished_write(mp);
return (EIO); return (EIO);
} }
/* Attempt to msync mmap() regions to clean dirty mmap */ VI_UNLOCK(vp);
if ((obj = vp->v_object) != NULL &&
vm_object_mightbedirty(obj)) { /* Attempt to msync mmap() regions to clean dirty mmap */
VI_UNLOCK(vp); vnode_pager_clean_sync(vp);
VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(obj);
} else
VI_UNLOCK(vp);
/* Wait for pending writes to complete */ /* Wait for pending writes to complete */
BO_LOCK(bo); BO_LOCK(bo);

View file

@ -48,6 +48,7 @@
#include <vm/vm.h> #include <vm/vm.h>
#include <vm/vm_object.h> #include <vm/vm_object.h>
#include <vm/vnode_pager.h>
#include <ufs/ufs/extattr.h> #include <ufs/ufs/extattr.h>
#include <ufs/ufs/quota.h> #include <ufs/ufs/quota.h>
@ -347,7 +348,6 @@ ufs_bmap_seekdata(struct vnode *vp, off_t *offp)
struct inode *ip; struct inode *ip;
struct mount *mp; struct mount *mp;
struct ufsmount *ump; struct ufsmount *ump;
vm_object_t obj;
ufs2_daddr_t bn, daddr, nextbn; ufs2_daddr_t bn, daddr, nextbn;
uint64_t bsize; uint64_t bsize;
off_t numblks; off_t numblks;
@ -370,12 +370,7 @@ ufs_bmap_seekdata(struct vnode *vp, off_t *offp)
* pages into buffer writes to ensure that we see all * pages into buffer writes to ensure that we see all
* allocated data. * allocated data.
*/ */
obj = vp->v_object; vnode_pager_clean_sync(vp);
if (obj != NULL) {
VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
VM_OBJECT_WUNLOCK(obj);
}
bsize = mp->mnt_stat.f_iosize; bsize = mp->mnt_stat.f_iosize;
for (bn = *offp / bsize, numblks = howmany(ip->i_size, bsize); for (bn = *offp / bsize, numblks = howmany(ip->i_size, bsize);

View file

@ -1690,3 +1690,30 @@ vnode_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp)
{ {
*vpp = object->handle; *vpp = object->handle;
} }
static void
vnode_pager_clean1(struct vnode *vp, int sync_flags)
{
struct vm_object *obj;
ASSERT_VOP_LOCKED(vp, "needs lock for writes");
obj = vp->v_object;
if (obj == NULL)
return;
VM_OBJECT_WLOCK(obj);
vm_object_page_clean(obj, 0, 0, sync_flags);
VM_OBJECT_WUNLOCK(obj);
}
void
vnode_pager_clean_sync(struct vnode *vp)
{
vnode_pager_clean1(vp, OBJPC_SYNC);
}
void
vnode_pager_clean_async(struct vnode *vp)
{
vnode_pager_clean1(vp, 0);
}

View file

@ -39,6 +39,9 @@
#ifdef _KERNEL #ifdef _KERNEL
struct vnode;
void vnode_pager_clean_sync(struct vnode *vp);
void vnode_pager_clean_async(struct vnode *vp);
int vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m,
int count, int *rbehind, int *rahead, vop_getpages_iodone_t iodone, int count, int *rbehind, int *rahead, vop_getpages_iodone_t iodone,
void *arg); void *arg);