uvm_vnp_zerorange() logically and by implementation more a part of

ubc than uvm_vnode, so move it over.
This commit is contained in:
pooka 2009-08-04 23:31:57 +00:00
parent bb3158c0b1
commit e0fc658a3c
2 changed files with 34 additions and 32 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_bio.c,v 1.66 2008/11/27 08:46:09 pooka Exp $ */
/* $NetBSD: uvm_bio.c,v 1.67 2009/08/04 23:31:57 pooka Exp $ */
/*
* Copyright (c) 1998 Chuck Silvers.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.66 2008/11/27 08:46:09 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.67 2009/08/04 23:31:57 pooka Exp $");
#include "opt_uvmhist.h"
#include "opt_ubc.h"
@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.66 2008/11/27 08:46:09 pooka Exp $");
#include <sys/kmem.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <uvm/uvm.h>
@ -696,3 +697,32 @@ ubc_uiomove(struct uvm_object *uobj, struct uio *uio, vsize_t todo, int advice,
return error;
}
/*
* uvm_vnp_zerorange: set a range of bytes in a file to zero.
*/
void
uvm_vnp_zerorange(struct vnode *vp, off_t off, size_t len)
{
void *win;
int flags;
/*
* XXXUBC invent kzero() and use it
*/
while (len) {
vsize_t bytelen = len;
win = ubc_alloc(&vp->v_uobj, off, &bytelen, UVM_ADV_NORMAL,
UBC_WRITE);
memset(win, 0, bytelen);
flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0;
ubc_release(win, flags);
off += bytelen;
len -= bytelen;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_vnode.c,v 1.91 2009/08/04 23:03:01 pooka Exp $ */
/* $NetBSD: uvm_vnode.c,v 1.92 2009/08/04 23:31:57 pooka Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.91 2009/08/04 23:03:01 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.92 2009/08/04 23:31:57 pooka Exp $");
#include "opt_uvmhist.h"
@ -372,34 +372,6 @@ uvm_vnp_setwritesize(struct vnode *vp, voff_t newsize)
mutex_exit(&vp->v_interlock);
}
/*
* uvm_vnp_zerorange: set a range of bytes in a file to zero.
*/
void
uvm_vnp_zerorange(struct vnode *vp, off_t off, size_t len)
{
void *win;
int flags;
/*
* XXXUBC invent kzero() and use it
*/
while (len) {
vsize_t bytelen = len;
win = ubc_alloc(&vp->v_uobj, off, &bytelen, UVM_ADV_NORMAL,
UBC_WRITE);
memset(win, 0, bytelen);
flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0;
ubc_release(win, flags);
off += bytelen;
len -= bytelen;
}
}
bool
uvn_text_p(struct uvm_object *uobj)
{