uvm_vnp_zerorange() logically and by implementation more a part of ubc than uvm_vnode, so move it over.diff -r1.66 -r1.67 src/sys/uvm/uvm_bio.c
(pooka)
--- src/sys/uvm/uvm_bio.c 2008/11/27 08:46:09 1.66
+++ src/sys/uvm/uvm_bio.c 2009/08/04 23:31:57 1.67
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uvm_bio.c,v 1.66 2008/11/27 08:46:09 pooka Exp $ */ | 1 | /* $NetBSD: uvm_bio.c,v 1.67 2009/08/04 23:31:57 pooka Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998 Chuck Silvers. | 4 | * Copyright (c) 1998 Chuck Silvers. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -24,36 +24,37 @@ | @@ -24,36 +24,37 @@ | |||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. | |
29 | * | 29 | * | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * uvm_bio.c: buffered i/o object mapping cache | 33 | * uvm_bio.c: buffered i/o object mapping cache | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.66 2008/11/27 08:46:09 pooka Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.67 2009/08/04 23:31:57 pooka Exp $"); | |
38 | 38 | |||
39 | #include "opt_uvmhist.h" | 39 | #include "opt_uvmhist.h" | |
40 | #include "opt_ubc.h" | 40 | #include "opt_ubc.h" | |
41 | 41 | |||
42 | #include <sys/param.h> | 42 | #include <sys/param.h> | |
43 | #include <sys/systm.h> | 43 | #include <sys/systm.h> | |
44 | #include <sys/kmem.h> | 44 | #include <sys/kmem.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/proc.h> | 46 | #include <sys/proc.h> | |
47 | #include <sys/vnode.h> | |||
47 | 48 | |||
48 | #include <uvm/uvm.h> | 49 | #include <uvm/uvm.h> | |
49 | 50 | |||
50 | /* | 51 | /* | |
51 | * global data structures | 52 | * global data structures | |
52 | */ | 53 | */ | |
53 | 54 | |||
54 | /* | 55 | /* | |
55 | * local functions | 56 | * local functions | |
56 | */ | 57 | */ | |
57 | 58 | |||
58 | static int ubc_fault(struct uvm_faultinfo *, vaddr_t, struct vm_page **, | 59 | static int ubc_fault(struct uvm_faultinfo *, vaddr_t, struct vm_page **, | |
59 | int, int, vm_prot_t, int); | 60 | int, int, vm_prot_t, int); | |
@@ -686,13 +687,42 @@ ubc_uiomove(struct uvm_object *uobj, str | @@ -686,13 +687,42 @@ ubc_uiomove(struct uvm_object *uobj, str | |||
686 | printf("%s: error=%d\n", __func__, error); | 687 | printf("%s: error=%d\n", __func__, error); | |
687 | memset(win, 0, bytelen); | 688 | memset(win, 0, bytelen); | |
688 | } | 689 | } | |
689 | ubc_release(win, flags); | 690 | ubc_release(win, flags); | |
690 | off += bytelen; | 691 | off += bytelen; | |
691 | todo -= bytelen; | 692 | todo -= bytelen; | |
692 | if (error != 0 && (flags & UBC_PARTIALOK) != 0) { | 693 | if (error != 0 && (flags & UBC_PARTIALOK) != 0) { | |
693 | break; | 694 | break; | |
694 | } | 695 | } | |
695 | } | 696 | } | |
696 | 697 | |||
697 | return error; | 698 | return error; | |
698 | } | 699 | } | |
700 | ||||
701 | ||||
702 | /* | |||
703 | * uvm_vnp_zerorange: set a range of bytes in a file to zero. | |||
704 | */ | |||
705 | ||||
706 | void | |||
707 | uvm_vnp_zerorange(struct vnode *vp, off_t off, size_t len) | |||
708 | { | |||
709 | void *win; | |||
710 | int flags; | |||
711 | ||||
712 | /* | |||
713 | * XXXUBC invent kzero() and use it | |||
714 | */ | |||
715 | ||||
716 | while (len) { | |||
717 | vsize_t bytelen = len; | |||
718 | ||||
719 | win = ubc_alloc(&vp->v_uobj, off, &bytelen, UVM_ADV_NORMAL, | |||
720 | UBC_WRITE); | |||
721 | memset(win, 0, bytelen); | |||
722 | flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0; | |||
723 | ubc_release(win, flags); | |||
724 | ||||
725 | off += bytelen; | |||
726 | len -= bytelen; | |||
727 | } | |||
728 | } |
--- src/sys/uvm/uvm_vnode.c 2009/08/04 23:03:01 1.91
+++ src/sys/uvm/uvm_vnode.c 2009/08/04 23:31:57 1.92
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uvm_vnode.c,v 1.91 2009/08/04 23:03:01 pooka Exp $ */ | 1 | /* $NetBSD: uvm_vnode.c,v 1.92 2009/08/04 23:31:57 pooka Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. | 4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. | |
5 | * Copyright (c) 1991, 1993 | 5 | * Copyright (c) 1991, 1993 | |
6 | * The Regents of the University of California. | 6 | * The Regents of the University of California. | |
7 | * Copyright (c) 1990 University of Utah. | 7 | * Copyright (c) 1990 University of Utah. | |
8 | * | 8 | * | |
9 | * All rights reserved. | 9 | * All rights reserved. | |
10 | * | 10 | * | |
11 | * This code is derived from software contributed to Berkeley by | 11 | * This code is derived from software contributed to Berkeley by | |
12 | * the Systems Programming Group of the University of Utah Computer | 12 | * the Systems Programming Group of the University of Utah Computer | |
13 | * Science Department. | 13 | * Science Department. | |
14 | * | 14 | * | |
@@ -40,27 +40,27 @@ | @@ -40,27 +40,27 @@ | |||
40 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 40 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
41 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 41 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
42 | * SUCH DAMAGE. | 42 | * SUCH DAMAGE. | |
43 | * | 43 | * | |
44 | * @(#)vnode_pager.c 8.8 (Berkeley) 2/13/94 | 44 | * @(#)vnode_pager.c 8.8 (Berkeley) 2/13/94 | |
45 | * from: Id: uvm_vnode.c,v 1.1.2.26 1998/02/02 20:38:07 chuck Exp | 45 | * from: Id: uvm_vnode.c,v 1.1.2.26 1998/02/02 20:38:07 chuck Exp | |
46 | */ | 46 | */ | |
47 | 47 | |||
48 | /* | 48 | /* | |
49 | * uvm_vnode.c: the vnode pager. | 49 | * uvm_vnode.c: the vnode pager. | |
50 | */ | 50 | */ | |
51 | 51 | |||
52 | #include <sys/cdefs.h> | 52 | #include <sys/cdefs.h> | |
53 | __KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.91 2009/08/04 23:03:01 pooka Exp $"); | 53 | __KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.92 2009/08/04 23:31:57 pooka Exp $"); | |
54 | 54 | |||
55 | #include "opt_uvmhist.h" | 55 | #include "opt_uvmhist.h" | |
56 | 56 | |||
57 | #include <sys/param.h> | 57 | #include <sys/param.h> | |
58 | #include <sys/systm.h> | 58 | #include <sys/systm.h> | |
59 | #include <sys/kernel.h> | 59 | #include <sys/kernel.h> | |
60 | #include <sys/proc.h> | 60 | #include <sys/proc.h> | |
61 | #include <sys/malloc.h> | 61 | #include <sys/malloc.h> | |
62 | #include <sys/vnode.h> | 62 | #include <sys/vnode.h> | |
63 | #include <sys/disklabel.h> | 63 | #include <sys/disklabel.h> | |
64 | #include <sys/ioctl.h> | 64 | #include <sys/ioctl.h> | |
65 | #include <sys/fcntl.h> | 65 | #include <sys/fcntl.h> | |
66 | #include <sys/conf.h> | 66 | #include <sys/conf.h> | |
@@ -362,54 +362,26 @@ void | @@ -362,54 +362,26 @@ void | |||
362 | uvm_vnp_setwritesize(struct vnode *vp, voff_t newsize) | 362 | uvm_vnp_setwritesize(struct vnode *vp, voff_t newsize) | |
363 | { | 363 | { | |
364 | 364 | |||
365 | mutex_enter(&vp->v_interlock); | 365 | mutex_enter(&vp->v_interlock); | |
366 | KASSERT(newsize != VSIZENOTSET); | 366 | KASSERT(newsize != VSIZENOTSET); | |
367 | KASSERT(vp->v_size != VSIZENOTSET); | 367 | KASSERT(vp->v_size != VSIZENOTSET); | |
368 | KASSERT(vp->v_writesize != VSIZENOTSET); | 368 | KASSERT(vp->v_writesize != VSIZENOTSET); | |
369 | KASSERT(vp->v_size <= vp->v_writesize); | 369 | KASSERT(vp->v_size <= vp->v_writesize); | |
370 | KASSERT(vp->v_size <= newsize); | 370 | KASSERT(vp->v_size <= newsize); | |
371 | vp->v_writesize = newsize; | 371 | vp->v_writesize = newsize; | |
372 | mutex_exit(&vp->v_interlock); | 372 | mutex_exit(&vp->v_interlock); | |
373 | } | 373 | } | |
374 | 374 | |||
375 | /* | |||
376 | * uvm_vnp_zerorange: set a range of bytes in a file to zero. | |||
377 | */ | |||
378 | ||||
379 | void | |||
380 | uvm_vnp_zerorange(struct vnode *vp, off_t off, size_t len) | |||
381 | { | |||
382 | void *win; | |||
383 | int flags; | |||
384 | ||||
385 | /* | |||
386 | * XXXUBC invent kzero() and use it | |||
387 | */ | |||
388 | ||||
389 | while (len) { | |||
390 | vsize_t bytelen = len; | |||
391 | ||||
392 | win = ubc_alloc(&vp->v_uobj, off, &bytelen, UVM_ADV_NORMAL, | |||
393 | UBC_WRITE); | |||
394 | memset(win, 0, bytelen); | |||
395 | flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0; | |||
396 | ubc_release(win, flags); | |||
397 | ||||
398 | off += bytelen; | |||
399 | len -= bytelen; | |||
400 | } | |||
401 | } | |||
402 | ||||
403 | bool | 375 | bool | |
404 | uvn_text_p(struct uvm_object *uobj) | 376 | uvn_text_p(struct uvm_object *uobj) | |
405 | { | 377 | { | |
406 | struct vnode *vp = (struct vnode *)uobj; | 378 | struct vnode *vp = (struct vnode *)uobj; | |
407 | 379 | |||
408 | return (vp->v_iflag & VI_EXECMAP) != 0; | 380 | return (vp->v_iflag & VI_EXECMAP) != 0; | |
409 | } | 381 | } | |
410 | 382 | |||
411 | bool | 383 | bool | |
412 | uvn_clean_p(struct uvm_object *uobj) | 384 | uvn_clean_p(struct uvm_object *uobj) | |
413 | { | 385 | { | |
414 | struct vnode *vp = (struct vnode *)uobj; | 386 | struct vnode *vp = (struct vnode *)uobj; | |
415 | 387 |