vm_vfs.c revision 1.1 1 /* $NetBSD: vm_vfs.c,v 1.1 2008/11/19 14:10:49 pooka Exp $ */
2
3 /*
4 * Copyright (c) 2008 Antti Kantee. All Rights Reserved.
5 *
6 * Development of this software was supported by the
7 * Finnish Cultural Foundation.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, 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
28 * SUCH DAMAGE.
29 */
30
31 #include <sys/param.h>
32
33 #include <sys/buf.h>
34 #include <sys/vnode.h>
35
36 #include <uvm/uvm.h>
37 #include <uvm/uvm_readahead.h>
38
39 static int vn_get(struct uvm_object *, voff_t, struct vm_page **,
40 int *, int, vm_prot_t, int, int);
41 static int vn_put(struct uvm_object *, voff_t, voff_t, int);
42
43 const struct uvm_pagerops uvm_vnodeops = {
44 .pgo_get = vn_get,
45 .pgo_put = vn_put,
46 };
47
48 /*
49 * vnode pager
50 */
51
52 static int
53 vn_get(struct uvm_object *uobj, voff_t off, struct vm_page **pgs,
54 int *npages, int centeridx, vm_prot_t access_type,
55 int advice, int flags)
56 {
57 struct vnode *vp = (struct vnode *)uobj;
58
59 return VOP_GETPAGES(vp, off, pgs, npages, centeridx, access_type,
60 advice, flags);
61 }
62
63 static int
64 vn_put(struct uvm_object *uobj, voff_t offlo, voff_t offhi, int flags)
65 {
66 struct vnode *vp = (struct vnode *)uobj;
67
68 return VOP_PUTPAGES(vp, offlo, offhi, flags);
69 }
70
71 void
72 uvm_aio_biodone1(struct buf *bp)
73 {
74
75 panic("%s: unimplemented", __func__);
76 }
77
78 void
79 uvm_aio_biodone(struct buf *bp)
80 {
81
82 uvm_aio_aiodone(bp);
83 }
84
85 void
86 uvm_aio_aiodone(struct buf *bp)
87 {
88
89 if (((bp->b_flags|bp->b_cflags) & (B_READ|BC_NOCACHE)) == 0 && bioopsp)
90 bioopsp->io_pageiodone(bp);
91 }
92
93 struct uvm_ractx *
94 uvm_ra_allocctx()
95 {
96
97 return NULL;
98 }
99
100 void
101 uvm_ra_freectx(struct uvm_ractx *ra)
102 {
103
104 return;
105 }
106
107 bool
108 uvn_clean_p(struct uvm_object *uobj)
109 {
110 struct vnode *vp = (void *)uobj;
111
112 return (vp->v_iflag & VI_ONWORKLST) == 0;
113 }
114