Mon Mar 29 02:13:38 2021 UTC ()
Don't use legacy VM types.


(simonb)
diff -r1.6 -r1.7 src/sys/fs/nfs/client/nfs_clbio.c
diff -r1.3 -r1.4 src/sys/fs/nfs/server/nfs_nfsdport.c

cvs diff -r1.6 -r1.7 src/sys/fs/nfs/client/nfs_clbio.c (expand / switch to unified diff)

--- src/sys/fs/nfs/client/nfs_clbio.c 2020/09/29 03:02:19 1.6
+++ src/sys/fs/nfs/client/nfs_clbio.c 2021/03/29 02:13:37 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: nfs_clbio.c,v 1.6 2020/09/29 03:02:19 msaitoh Exp $ */ 1/* $NetBSD: nfs_clbio.c,v 1.7 2021/03/29 02:13:37 simonb Exp $ */
2/*- 2/*-
3 * Copyright (c) 1989, 1993 3 * Copyright (c) 1989, 1993
4 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to Berkeley by 6 * This code is derived from software contributed to Berkeley by
7 * Rick Macklem at The University of Guelph. 7 * Rick Macklem at The University of Guelph.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE. 31 * SUCH DAMAGE.
32 * 32 *
33 * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 33 * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37/* __FBSDID("FreeBSD: head/sys/fs/nfsclient/nfs_clbio.c 304026 2016-08-12 22:44:59Z rmacklem "); */ 37/* __FBSDID("FreeBSD: head/sys/fs/nfsclient/nfs_clbio.c 304026 2016-08-12 22:44:59Z rmacklem "); */
38__RCSID("$NetBSD: nfs_clbio.c,v 1.6 2020/09/29 03:02:19 msaitoh Exp $"); 38__RCSID("$NetBSD: nfs_clbio.c,v 1.7 2021/03/29 02:13:37 simonb Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/buf.h> 42#include <sys/buf.h>
43#include <sys/kernel.h> 43#include <sys/kernel.h>
44#include <sys/mount.h> 44#include <sys/mount.h>
45#include <sys/rwlock.h> 45#include <sys/rwlock.h>
46#include <sys/vmmeter.h> 46#include <sys/vmmeter.h>
47#include <sys/vnode.h> 47#include <sys/vnode.h>
48 48
49#include <fs/nfs/common/nfsport.h> 49#include <fs/nfs/common/nfsport.h>
50#include <fs/nfs/client/nfsmount.h> 50#include <fs/nfs/client/nfsmount.h>
51#include <fs/nfs/client/nfs.h> 51#include <fs/nfs/client/nfs.h>
@@ -67,27 +67,27 @@ static struct buf *nfs_getcacheblk(struc @@ -67,27 +67,27 @@ static struct buf *nfs_getcacheblk(struc
67 struct thread *td); 67 struct thread *td);
68static int nfs_directio_write(struct vnode *vp, struct uio *uiop, 68static int nfs_directio_write(struct vnode *vp, struct uio *uiop,
69 struct ucred *cred, int ioflag); 69 struct ucred *cred, int ioflag);
70 70
71/* 71/*
72 * Vnode op for VM getpages. 72 * Vnode op for VM getpages.
73 */ 73 */
74int 74int
75ncl_getpages(struct vop_getpages_args *ap) 75ncl_getpages(struct vop_getpages_args *ap)
76{ 76{
77 int i, error, nextoff, size, toff, count, npages; 77 int i, error, nextoff, size, toff, count, npages;
78 struct uio uio; 78 struct uio uio;
79 struct iovec iov; 79 struct iovec iov;
80 vm_offset_t kva; 80 vaddr_t kva;
81 struct buf *bp; 81 struct buf *bp;
82 struct vnode *vp; 82 struct vnode *vp;
83 struct thread *td; 83 struct thread *td;
84 struct ucred *cred; 84 struct ucred *cred;
85 struct nfsmount *nmp; 85 struct nfsmount *nmp;
86 vm_object_t object; 86 vm_object_t object;
87 vm_page_t *pages; 87 vm_page_t *pages;
88 struct nfsnode *np; 88 struct nfsnode *np;
89 89
90 vp = ap->a_vp; 90 vp = ap->a_vp;
91 np = VTONFS(vp); 91 np = VTONFS(vp);
92 td = curthread; /* XXX */ 92 td = curthread; /* XXX */
93 cred = curthread->td_ucred; /* XXX */ 93 cred = curthread->td_ucred; /* XXX */
@@ -127,27 +127,27 @@ ncl_getpages(struct vop_getpages_args *a @@ -127,27 +127,27 @@ ncl_getpages(struct vop_getpages_args *a
127 * XXXGL: is that true for NFS, where short read can occur??? 127 * XXXGL: is that true for NFS, where short read can occur???
128 */ 128 */
129 VM_OBJECT_WLOCK(object); 129 VM_OBJECT_WLOCK(object);
130 if (pages[npages - 1]->valid != 0 && --npages == 0) 130 if (pages[npages - 1]->valid != 0 && --npages == 0)
131 goto out; 131 goto out;
132 VM_OBJECT_WUNLOCK(object); 132 VM_OBJECT_WUNLOCK(object);
133 133
134 /* 134 /*
135 * We use only the kva address for the buffer, but this is extremely 135 * We use only the kva address for the buffer, but this is extremely
136 * convenient and fast. 136 * convenient and fast.
137 */ 137 */
138 bp = getpbuf(&ncl_pbuf_freecnt); 138 bp = getpbuf(&ncl_pbuf_freecnt);
139 139
140 kva = (vm_offset_t) bp->b_data; 140 kva = (vaddr_t) bp->b_data;
141 pmap_qenter(kva, pages, npages); 141 pmap_qenter(kva, pages, npages);
142 PCPU_INC(cnt.v_vnodein); 142 PCPU_INC(cnt.v_vnodein);
143 PCPU_ADD(cnt.v_vnodepgsin, npages); 143 PCPU_ADD(cnt.v_vnodepgsin, npages);
144 144
145 count = npages << PAGE_SHIFT; 145 count = npages << PAGE_SHIFT;
146 iov.iov_base = (caddr_t) kva; 146 iov.iov_base = (caddr_t) kva;
147 iov.iov_len = count; 147 iov.iov_len = count;
148 uio.uio_iov = &iov; 148 uio.uio_iov = &iov;
149 uio.uio_iovcnt = 1; 149 uio.uio_iovcnt = 1;
150 uio.uio_offset = IDX_TO_OFF(pages[0]->pindex); 150 uio.uio_offset = IDX_TO_OFF(pages[0]->pindex);
151 uio.uio_resid = count; 151 uio.uio_resid = count;
152 uio.uio_segflg = UIO_SYSSPACE; 152 uio.uio_segflg = UIO_SYSSPACE;
153 uio.uio_rw = UIO_READ; 153 uio.uio_rw = UIO_READ;
@@ -211,27 +211,27 @@ out: @@ -211,27 +211,27 @@ out:
211 if (ap->a_rahead) 211 if (ap->a_rahead)
212 *ap->a_rahead = 0; 212 *ap->a_rahead = 0;
213 return (VM_PAGER_OK); 213 return (VM_PAGER_OK);
214} 214}
215 215
216/* 216/*
217 * Vnode op for VM putpages. 217 * Vnode op for VM putpages.
218 */ 218 */
219int 219int
220ncl_putpages(struct vop_putpages_args *ap) 220ncl_putpages(struct vop_putpages_args *ap)
221{ 221{
222 struct uio uio; 222 struct uio uio;
223 struct iovec iov; 223 struct iovec iov;
224 vm_offset_t kva; 224 vaddr_t kva;
225 struct buf *bp; 225 struct buf *bp;
226 int iomode, must_commit, i, error, npages, count; 226 int iomode, must_commit, i, error, npages, count;
227 off_t offset; 227 off_t offset;
228 int *rtvals; 228 int *rtvals;
229 struct vnode *vp; 229 struct vnode *vp;
230 struct thread *td; 230 struct thread *td;
231 struct ucred *cred; 231 struct ucred *cred;
232 struct nfsmount *nmp; 232 struct nfsmount *nmp;
233 struct nfsnode *np; 233 struct nfsnode *np;
234 vm_page_t *pages; 234 vm_page_t *pages;
235 235
236 vp = ap->a_vp; 236 vp = ap->a_vp;
237 np = VTONFS(vp); 237 np = VTONFS(vp);
@@ -273,27 +273,27 @@ ncl_putpages(struct vop_putpages_args *a @@ -273,27 +273,27 @@ ncl_putpages(struct vop_putpages_args *a
273 if (offset + count > np->n_size) { 273 if (offset + count > np->n_size) {
274 count = np->n_size - offset; 274 count = np->n_size - offset;
275 if (count < 0) 275 if (count < 0)
276 count = 0; 276 count = 0;
277 } 277 }
278 mtx_unlock(&np->n_mtx); 278 mtx_unlock(&np->n_mtx);
279 279
280 /* 280 /*
281 * We use only the kva address for the buffer, but this is extremely 281 * We use only the kva address for the buffer, but this is extremely
282 * convenient and fast. 282 * convenient and fast.
283 */ 283 */
284 bp = getpbuf(&ncl_pbuf_freecnt); 284 bp = getpbuf(&ncl_pbuf_freecnt);
285 285
286 kva = (vm_offset_t) bp->b_data; 286 kva = (vaddr_t) bp->b_data;
287 pmap_qenter(kva, pages, npages); 287 pmap_qenter(kva, pages, npages);
288 PCPU_INC(cnt.v_vnodeout); 288 PCPU_INC(cnt.v_vnodeout);
289 PCPU_ADD(cnt.v_vnodepgsout, count); 289 PCPU_ADD(cnt.v_vnodepgsout, count);
290 290
291 iov.iov_base = (caddr_t) kva; 291 iov.iov_base = (caddr_t) kva;
292 iov.iov_len = count; 292 iov.iov_len = count;
293 uio.uio_iov = &iov; 293 uio.uio_iov = &iov;
294 uio.uio_iovcnt = 1; 294 uio.uio_iovcnt = 1;
295 uio.uio_offset = offset; 295 uio.uio_offset = offset;
296 uio.uio_resid = count; 296 uio.uio_resid = count;
297 uio.uio_segflg = UIO_SYSSPACE; 297 uio.uio_segflg = UIO_SYSSPACE;
298 uio.uio_rw = UIO_WRITE; 298 uio.uio_rw = UIO_WRITE;
299 uio.uio_td = td; 299 uio.uio_td = td;

cvs diff -r1.3 -r1.4 src/sys/fs/nfs/server/nfs_nfsdport.c (expand / switch to unified diff)

--- src/sys/fs/nfs/server/nfs_nfsdport.c 2018/09/03 16:29:34 1.3
+++ src/sys/fs/nfs/server/nfs_nfsdport.c 2021/03/29 02:13:38 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: nfs_nfsdport.c,v 1.3 2018/09/03 16:29:34 riastradh Exp $ */ 1/* $NetBSD: nfs_nfsdport.c,v 1.4 2021/03/29 02:13:38 simonb Exp $ */
2/*- 2/*-
3 * Copyright (c) 1989, 1993 3 * Copyright (c) 1989, 1993
4 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to Berkeley by 6 * This code is derived from software contributed to Berkeley by
7 * Rick Macklem at The University of Guelph. 7 * Rick Macklem at The University of Guelph.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE. 31 * SUCH DAMAGE.
32 * 32 *
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36/* __FBSDID("FreeBSD: head/sys/fs/nfsserver/nfs_nfsdport.c 308212 2016-11-02 12:43:15Z kib "); */ 36/* __FBSDID("FreeBSD: head/sys/fs/nfsserver/nfs_nfsdport.c 308212 2016-11-02 12:43:15Z kib "); */
37__RCSID("$NetBSD: nfs_nfsdport.c,v 1.3 2018/09/03 16:29:34 riastradh Exp $"); 37__RCSID("$NetBSD: nfs_nfsdport.c,v 1.4 2021/03/29 02:13:38 simonb Exp $");
38 38
39#if 0 39#if 0
40#include <sys/capsicum.h> 40#include <sys/capsicum.h>
41#endif 41#endif
42 42
43/* 43/*
44 * Functions that perform the vfs operations required by the routines in 44 * Functions that perform the vfs operations required by the routines in
45 * nfsd_serv.c. It is hoped that this change will make the server more 45 * nfsd_serv.c. It is hoped that this change will make the server more
46 * portable. 46 * portable.
47 */ 47 */
48 48
49#include <fs/nfs/common/nfsport.h> 49#include <fs/nfs/common/nfsport.h>
50#include <sys/hash.h> 50#include <sys/hash.h>
@@ -126,27 +126,27 @@ static struct nfsheur { @@ -126,27 +126,27 @@ static struct nfsheur {
126 126
127 127
128/* 128/*
129 * Heuristic to detect sequential operation. 129 * Heuristic to detect sequential operation.
130 */ 130 */
131static struct nfsheur * 131static struct nfsheur *
132nfsrv_sequential_heuristic(struct uio *uio, struct vnode *vp) 132nfsrv_sequential_heuristic(struct uio *uio, struct vnode *vp)
133{ 133{
134 struct nfsheur *nh; 134 struct nfsheur *nh;
135 int hi, try; 135 int hi, try;
136 136
137 /* Locate best candidate. */ 137 /* Locate best candidate. */
138 try = 32; 138 try = 32;
139 hi = ((int)(vm_offset_t)vp / sizeof(struct vnode)) % NUM_HEURISTIC; 139 hi = ((int)(vaddr_t)vp / sizeof(struct vnode)) % NUM_HEURISTIC;
140 nh = &nfsheur[hi]; 140 nh = &nfsheur[hi];
141 while (try--) { 141 while (try--) {
142 if (nfsheur[hi].nh_vp == vp) { 142 if (nfsheur[hi].nh_vp == vp) {
143 nh = &nfsheur[hi]; 143 nh = &nfsheur[hi];
144 break; 144 break;
145 } 145 }
146 if (nfsheur[hi].nh_use > 0) 146 if (nfsheur[hi].nh_use > 0)
147 --nfsheur[hi].nh_use; 147 --nfsheur[hi].nh_use;
148 hi = (hi + 1) % NUM_HEURISTIC; 148 hi = (hi + 1) % NUM_HEURISTIC;
149 if (nfsheur[hi].nh_use < nh->nh_use) 149 if (nfsheur[hi].nh_use < nh->nh_use)
150 nh = &nfsheur[hi]; 150 nh = &nfsheur[hi];
151 } 151 }
152 152