3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/types.h>
26 #include <sys/param.h>
27 #include <sys/systm.h>
28 #include <sys/buf.h>
29 #include <sys/cred.h>
30 #include <sys/errno.h>
31 #include <sys/vnode.h>
32 #include <sys/vfs_opreg.h>
33 #include <sys/cmn_err.h>
34 #include <sys/swap.h>
35 #include <sys/mman.h>
36 #include <sys/vmsystm.h>
37 #include <sys/vtrace.h>
38 #include <sys/debug.h>
39 #include <sys/sysmacros.h>
40 #include <sys/vm.h>
41
42 #include <sys/fs/swapnode.h>
99 }
100
101 /*
102 * Return all the pages from [off..off+len] in given file
103 */
104 /*ARGSUSED*/
105 static int
106 swap_getpage(
107 struct vnode *vp,
108 offset_t off,
109 size_t len,
110 uint_t *protp,
111 page_t *pl[],
112 size_t plsz,
113 struct seg *seg,
114 caddr_t addr,
115 enum seg_rw rw,
116 struct cred *cr,
117 caller_context_t *ct)
118 {
119 int err;
120
121 SWAPFS_PRINT(SWAP_VOPS, "swap_getpage: vp %p, off %llx, len %lx\n",
122 (void *)vp, off, len, 0, 0);
123
124 TRACE_3(TR_FAC_SWAPFS, TR_SWAPFS_GETPAGE,
125 "swapfs getpage:vp %p off %llx len %ld",
126 (void *)vp, off, len);
127
128 if (len <= PAGESIZE) {
129 err = swap_getapage(vp, (u_offset_t)off, len, protp, pl, plsz,
130 seg, addr, rw, cr);
131 } else {
132 err = pvn_getpages(swap_getapage, vp, (u_offset_t)off, len,
133 protp, pl, plsz, seg, addr, rw, cr);
134 }
135
136 return (err);
137 }
138
139 /*
140 * Called from pvn_getpages or swap_getpage to get a particular page.
141 */
142 /*ARGSUSED*/
143 static int
144 swap_getapage(
145 struct vnode *vp,
146 u_offset_t off,
147 size_t len,
148 uint_t *protp,
149 page_t *pl[],
150 size_t plsz,
151 struct seg *seg,
152 caddr_t addr,
153 enum seg_rw rw,
154 struct cred *cr)
155 {
156 struct page *pp, *rpp;
157 int flags;
158 int err = 0;
159 struct vnode *pvp = NULL;
160 u_offset_t poff;
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 #include <sys/types.h>
27 #include <sys/param.h>
28 #include <sys/systm.h>
29 #include <sys/buf.h>
30 #include <sys/cred.h>
31 #include <sys/errno.h>
32 #include <sys/vnode.h>
33 #include <sys/vfs_opreg.h>
34 #include <sys/cmn_err.h>
35 #include <sys/swap.h>
36 #include <sys/mman.h>
37 #include <sys/vmsystm.h>
38 #include <sys/vtrace.h>
39 #include <sys/debug.h>
40 #include <sys/sysmacros.h>
41 #include <sys/vm.h>
42
43 #include <sys/fs/swapnode.h>
100 }
101
102 /*
103 * Return all the pages from [off..off+len] in given file
104 */
105 /*ARGSUSED*/
106 static int
107 swap_getpage(
108 struct vnode *vp,
109 offset_t off,
110 size_t len,
111 uint_t *protp,
112 page_t *pl[],
113 size_t plsz,
114 struct seg *seg,
115 caddr_t addr,
116 enum seg_rw rw,
117 struct cred *cr,
118 caller_context_t *ct)
119 {
120 SWAPFS_PRINT(SWAP_VOPS, "swap_getpage: vp %p, off %llx, len %lx\n",
121 (void *)vp, off, len, 0, 0);
122
123 TRACE_3(TR_FAC_SWAPFS, TR_SWAPFS_GETPAGE,
124 "swapfs getpage:vp %p off %llx len %ld",
125 (void *)vp, off, len);
126
127 return (pvn_getpages(swap_getapage, vp, (u_offset_t)off, len, protp,
128 pl, plsz, seg, addr, rw, cr));
129 }
130
131 /*
132 * Called from pvn_getpages to get a particular page.
133 */
134 /*ARGSUSED*/
135 static int
136 swap_getapage(
137 struct vnode *vp,
138 u_offset_t off,
139 size_t len,
140 uint_t *protp,
141 page_t *pl[],
142 size_t plsz,
143 struct seg *seg,
144 caddr_t addr,
145 enum seg_rw rw,
146 struct cred *cr)
147 {
148 struct page *pp, *rpp;
149 int flags;
150 int err = 0;
151 struct vnode *pvp = NULL;
152 u_offset_t poff;
|