PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself) - Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed somewhere. Use it to decide whether to do direct-mapped copy, rather than poking around directly in the vnode in ubc_uiomove(), which is ugly and doesn't work for tmpfs. It would be nicer to contain all this in UVM but the filesystem provides the needed locking here (VV_MAPPED) and to reinvent that would suck more. - Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where appropriate.diff -r1.52 -r1.53 src/sys/fs/adosfs/advnops.c
(ad)
--- src/sys/fs/adosfs/advnops.c 2020/04/23 09:58:37 1.52
+++ src/sys/fs/adosfs/advnops.c 2020/04/23 21:47:07 1.53
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: advnops.c,v 1.52 2020/04/23 09:58:37 jdolecek Exp $ */ | 1 | /* $NetBSD: advnops.c,v 1.53 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994 Christian E. Hopps | 4 | * Copyright (c) 1994 Christian E. Hopps | |
5 | * Copyright (c) 1996 Matthias Scheler | 5 | * Copyright (c) 1996 Matthias Scheler | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.52 2020/04/23 09:58:37 jdolecek Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.53 2020/04/23 21:47:07 ad Exp $"); | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | #include <sys/vnode.h> | 39 | #include <sys/vnode.h> | |
40 | #include <sys/mount.h> | 40 | #include <sys/mount.h> | |
41 | #include <sys/time.h> | 41 | #include <sys/time.h> | |
42 | #include <sys/queue.h> | 42 | #include <sys/queue.h> | |
43 | #include <sys/namei.h> | 43 | #include <sys/namei.h> | |
44 | #include <sys/buf.h> | 44 | #include <sys/buf.h> | |
45 | #include <sys/dirent.h> | 45 | #include <sys/dirent.h> | |
46 | #include <sys/inttypes.h> | 46 | #include <sys/inttypes.h> | |
47 | #include <sys/malloc.h> | 47 | #include <sys/malloc.h> | |
48 | #include <sys/pool.h> | 48 | #include <sys/pool.h> | |
@@ -260,27 +260,27 @@ adosfs_read(void *v) | @@ -260,27 +260,27 @@ adosfs_read(void *v) | |||
260 | 260 | |||
261 | if (vp->v_type == VREG && IS_FFS(amp)) { | 261 | if (vp->v_type == VREG && IS_FFS(amp)) { | |
262 | const int advice = IO_ADV_DECODE(sp->a_ioflag); | 262 | const int advice = IO_ADV_DECODE(sp->a_ioflag); | |
263 | error = 0; | 263 | error = 0; | |
264 | 264 | |||
265 | while (uio->uio_resid > 0) { | 265 | while (uio->uio_resid > 0) { | |
266 | vsize_t bytelen = MIN(ap->fsize - uio->uio_offset, | 266 | vsize_t bytelen = MIN(ap->fsize - uio->uio_offset, | |
267 | uio->uio_resid); | 267 | uio->uio_resid); | |
268 | 268 | |||
269 | if (bytelen == 0) { | 269 | if (bytelen == 0) { | |
270 | break; | 270 | break; | |
271 | } | 271 | } | |
272 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 272 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
273 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 273 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
274 | if (error) { | 274 | if (error) { | |
275 | break; | 275 | break; | |
276 | } | 276 | } | |
277 | } | 277 | } | |
278 | goto out; | 278 | goto out; | |
279 | } | 279 | } | |
280 | 280 | |||
281 | do { | 281 | do { | |
282 | size = amp->dbsize; | 282 | size = amp->dbsize; | |
283 | lbn = uio->uio_offset / size; | 283 | lbn = uio->uio_offset / size; | |
284 | on = uio->uio_offset % size; | 284 | on = uio->uio_offset % size; | |
285 | n = MIN(size - on, uio->uio_resid); | 285 | n = MIN(size - on, uio->uio_resid); | |
286 | diff = ap->fsize - uio->uio_offset; | 286 | diff = ap->fsize - uio->uio_offset; |
--- src/sys/fs/cd9660/cd9660_vnops.c 2019/07/12 17:18:30 1.55
+++ src/sys/fs/cd9660/cd9660_vnops.c 2020/04/23 21:47:07 1.56
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cd9660_vnops.c,v 1.55 2019/07/12 17:18:30 maxv Exp $ */ | 1 | /* $NetBSD: cd9660_vnops.c,v 1.56 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1994 | 4 | * Copyright (c) 1994 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley | 7 | * This code is derived from software contributed to Berkeley | |
8 | * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension | 8 | * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension | |
9 | * Support code is derived from software contributed to Berkeley | 9 | * Support code is derived from software contributed to Berkeley | |
10 | * by Atsushi Murai (amurai@spec.co.jp). | 10 | * by Atsushi Murai (amurai@spec.co.jp). | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
34 | * SUCH DAMAGE. | 34 | * SUCH DAMAGE. | |
35 | * | 35 | * | |
36 | * @(#)cd9660_vnops.c 8.15 (Berkeley) 5/27/95 | 36 | * @(#)cd9660_vnops.c 8.15 (Berkeley) 5/27/95 | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | __KERNEL_RCSID(0, "$NetBSD: cd9660_vnops.c,v 1.55 2019/07/12 17:18:30 maxv Exp $"); | 40 | __KERNEL_RCSID(0, "$NetBSD: cd9660_vnops.c,v 1.56 2020/04/23 21:47:07 ad Exp $"); | |
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/namei.h> | 44 | #include <sys/namei.h> | |
45 | #include <sys/resourcevar.h> | 45 | #include <sys/resourcevar.h> | |
46 | #include <sys/kernel.h> | 46 | #include <sys/kernel.h> | |
47 | #include <sys/file.h> | 47 | #include <sys/file.h> | |
48 | #include <sys/stat.h> | 48 | #include <sys/stat.h> | |
49 | #include <sys/buf.h> | 49 | #include <sys/buf.h> | |
50 | #include <sys/proc.h> | 50 | #include <sys/proc.h> | |
51 | #include <sys/mount.h> | 51 | #include <sys/mount.h> | |
52 | #include <sys/vnode.h> | 52 | #include <sys/vnode.h> | |
53 | #include <sys/malloc.h> | 53 | #include <sys/malloc.h> | |
@@ -231,27 +231,27 @@ cd9660_read(void *v) | @@ -231,27 +231,27 @@ cd9660_read(void *v) | |||
231 | imp = ip->i_mnt; | 231 | imp = ip->i_mnt; | |
232 | 232 | |||
233 | if (vp->v_type == VREG) { | 233 | if (vp->v_type == VREG) { | |
234 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | 234 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | |
235 | error = 0; | 235 | error = 0; | |
236 | 236 | |||
237 | while (uio->uio_resid > 0) { | 237 | while (uio->uio_resid > 0) { | |
238 | vsize_t bytelen = MIN(ip->i_size - uio->uio_offset, | 238 | vsize_t bytelen = MIN(ip->i_size - uio->uio_offset, | |
239 | uio->uio_resid); | 239 | uio->uio_resid); | |
240 | 240 | |||
241 | if (bytelen == 0) | 241 | if (bytelen == 0) | |
242 | break; | 242 | break; | |
243 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 243 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
244 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 244 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
245 | if (error) | 245 | if (error) | |
246 | break; | 246 | break; | |
247 | } | 247 | } | |
248 | goto out; | 248 | goto out; | |
249 | } | 249 | } | |
250 | 250 | |||
251 | do { | 251 | do { | |
252 | lbn = cd9660_lblkno(imp, uio->uio_offset); | 252 | lbn = cd9660_lblkno(imp, uio->uio_offset); | |
253 | on = cd9660_blkoff(imp, uio->uio_offset); | 253 | on = cd9660_blkoff(imp, uio->uio_offset); | |
254 | n = MIN(imp->logical_block_size - on, uio->uio_resid); | 254 | n = MIN(imp->logical_block_size - on, uio->uio_resid); | |
255 | diff = (off_t)ip->i_size - uio->uio_offset; | 255 | diff = (off_t)ip->i_size - uio->uio_offset; | |
256 | if (diff <= 0) | 256 | if (diff <= 0) | |
257 | return (0); | 257 | return (0); |
--- src/sys/fs/efs/efs_vnops.c 2017/05/26 14:21:00 1.38
+++ src/sys/fs/efs/efs_vnops.c 2020/04/23 21:47:07 1.39
@@ -1,33 +1,33 @@ | @@ -1,33 +1,33 @@ | |||
1 | /* $NetBSD: efs_vnops.c,v 1.38 2017/05/26 14:21:00 riastradh Exp $ */ | 1 | /* $NetBSD: efs_vnops.c,v 1.39 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2006 Stephen M. Rumble <rumble@ephemeral.org> | 4 | * Copyright (c) 2006 Stephen M. Rumble <rumble@ephemeral.org> | |
5 | * | 5 | * | |
6 | * Permission to use, copy, modify, and distribute this software for any | 6 | * Permission to use, copy, modify, and distribute this software for any | |
7 | * purpose with or without fee is hereby granted, provided that the above | 7 | * purpose with or without fee is hereby granted, provided that the above | |
8 | * copyright notice and this permission notice appear in all copies. | 8 | * copyright notice and this permission notice appear in all copies. | |
9 | * | 9 | * | |
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 | */ | 17 | */ | |
18 | 18 | |||
19 | #include <sys/cdefs.h> | 19 | #include <sys/cdefs.h> | |
20 | __KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.38 2017/05/26 14:21:00 riastradh Exp $"); | 20 | __KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.39 2020/04/23 21:47:07 ad Exp $"); | |
21 | 21 | |||
22 | #include <sys/param.h> | 22 | #include <sys/param.h> | |
23 | #include <sys/systm.h> | 23 | #include <sys/systm.h> | |
24 | #include <sys/proc.h> | 24 | #include <sys/proc.h> | |
25 | #include <sys/kernel.h> | 25 | #include <sys/kernel.h> | |
26 | #include <sys/vnode.h> | 26 | #include <sys/vnode.h> | |
27 | #include <sys/mount.h> | 27 | #include <sys/mount.h> | |
28 | #include <sys/malloc.h> | 28 | #include <sys/malloc.h> | |
29 | #include <sys/namei.h> | 29 | #include <sys/namei.h> | |
30 | #include <sys/dirent.h> | 30 | #include <sys/dirent.h> | |
31 | #include <sys/lockf.h> | 31 | #include <sys/lockf.h> | |
32 | #include <sys/unistd.h> | 32 | #include <sys/unistd.h> | |
33 | #include <sys/buf.h> | 33 | #include <sys/buf.h> | |
@@ -268,27 +268,27 @@ efs_read(void *v) | @@ -268,27 +268,27 @@ efs_read(void *v) | |||
268 | 268 | |||
269 | if (!(uio->uio_offset >= start && | 269 | if (!(uio->uio_offset >= start && | |
270 | uio->uio_offset < (start + len))) { | 270 | uio->uio_offset < (start + len))) { | |
271 | ret = efs_extent_iterator_next(&exi, &ex); | 271 | ret = efs_extent_iterator_next(&exi, &ex); | |
272 | continue; | 272 | continue; | |
273 | } | 273 | } | |
274 | 274 | |||
275 | start = uio->uio_offset - start; | 275 | start = uio->uio_offset - start; | |
276 | 276 | |||
277 | len = MIN(len - start, uio->uio_resid); | 277 | len = MIN(len - start, uio->uio_resid); | |
278 | len = MIN(len, eip->ei_size - uio->uio_offset); | 278 | len = MIN(len, eip->ei_size - uio->uio_offset); | |
279 | 279 | |||
280 | err = ubc_uiomove(&ap->a_vp->v_uobj, uio, len, advice, | 280 | err = ubc_uiomove(&ap->a_vp->v_uobj, uio, len, advice, | |
281 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(ap->a_vp)); | 281 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(ap->a_vp)); | |
282 | if (err) { | 282 | if (err) { | |
283 | EFS_DPRINTF(("efs_read: uiomove error %d\n", | 283 | EFS_DPRINTF(("efs_read: uiomove error %d\n", | |
284 | err)); | 284 | err)); | |
285 | return (err); | 285 | return (err); | |
286 | } | 286 | } | |
287 | } | 287 | } | |
288 | 288 | |||
289 | return ((ret == -1) ? 0 : ret); | 289 | return ((ret == -1) ? 0 : ret); | |
290 | } | 290 | } | |
291 | 291 | |||
292 | static int | 292 | static int | |
293 | efs_readdir(void *v) | 293 | efs_readdir(void *v) | |
294 | { | 294 | { |
--- src/sys/fs/filecorefs/filecore_vnops.c 2015/04/20 23:03:08 1.44
+++ src/sys/fs/filecorefs/filecore_vnops.c 2020/04/23 21:47:07 1.45
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: filecore_vnops.c,v 1.44 2015/04/20 23:03:08 riastradh Exp $ */ | 1 | /* $NetBSD: filecore_vnops.c,v 1.45 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1994 The Regents of the University of California. | 4 | * Copyright (c) 1994 The Regents of the University of California. | |
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. | |
@@ -56,27 +56,27 @@ | @@ -56,27 +56,27 @@ | |||
56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
63 | * SUCH DAMAGE. | 63 | * SUCH DAMAGE. | |
64 | * | 64 | * | |
65 | * filecore_vnops.c 1.2 1998/8/18 | 65 | * filecore_vnops.c 1.2 1998/8/18 | |
66 | */ | 66 | */ | |
67 | 67 | |||
68 | #include <sys/cdefs.h> | 68 | #include <sys/cdefs.h> | |
69 | __KERNEL_RCSID(0, "$NetBSD: filecore_vnops.c,v 1.44 2015/04/20 23:03:08 riastradh Exp $"); | 69 | __KERNEL_RCSID(0, "$NetBSD: filecore_vnops.c,v 1.45 2020/04/23 21:47:07 ad Exp $"); | |
70 | 70 | |||
71 | #include <sys/param.h> | 71 | #include <sys/param.h> | |
72 | #include <sys/systm.h> | 72 | #include <sys/systm.h> | |
73 | #include <sys/namei.h> | 73 | #include <sys/namei.h> | |
74 | #include <sys/resourcevar.h> | 74 | #include <sys/resourcevar.h> | |
75 | #include <sys/kernel.h> | 75 | #include <sys/kernel.h> | |
76 | #include <sys/file.h> | 76 | #include <sys/file.h> | |
77 | #include <sys/stat.h> | 77 | #include <sys/stat.h> | |
78 | #include <sys/buf.h> | 78 | #include <sys/buf.h> | |
79 | #include <sys/proc.h> | 79 | #include <sys/proc.h> | |
80 | #include <sys/conf.h> | 80 | #include <sys/conf.h> | |
81 | #include <sys/mount.h> | 81 | #include <sys/mount.h> | |
82 | #include <sys/vnode.h> | 82 | #include <sys/vnode.h> | |
@@ -220,27 +220,27 @@ filecore_read(void *v) | @@ -220,27 +220,27 @@ filecore_read(void *v) | |||
220 | 220 | |||
221 | if (vp->v_type == VREG) { | 221 | if (vp->v_type == VREG) { | |
222 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | 222 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | |
223 | error = 0; | 223 | error = 0; | |
224 | 224 | |||
225 | while (uio->uio_resid > 0) { | 225 | while (uio->uio_resid > 0) { | |
226 | vsize_t bytelen = MIN(ip->i_size - uio->uio_offset, | 226 | vsize_t bytelen = MIN(ip->i_size - uio->uio_offset, | |
227 | uio->uio_resid); | 227 | uio->uio_resid); | |
228 | 228 | |||
229 | if (bytelen == 0) { | 229 | if (bytelen == 0) { | |
230 | break; | 230 | break; | |
231 | } | 231 | } | |
232 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 232 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
233 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 233 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
234 | if (error) { | 234 | if (error) { | |
235 | break; | 235 | break; | |
236 | } | 236 | } | |
237 | } | 237 | } | |
238 | goto out; | 238 | goto out; | |
239 | } | 239 | } | |
240 | 240 | |||
241 | do { | 241 | do { | |
242 | lbn = filecore_lblkno(fcmp, uio->uio_offset); | 242 | lbn = filecore_lblkno(fcmp, uio->uio_offset); | |
243 | on = filecore_blkoff(fcmp, uio->uio_offset); | 243 | on = filecore_blkoff(fcmp, uio->uio_offset); | |
244 | n = MIN(filecore_blksize(fcmp, ip, lbn) - on, uio->uio_resid); | 244 | n = MIN(filecore_blksize(fcmp, ip, lbn) - on, uio->uio_resid); | |
245 | diff = (off_t)ip->i_size - uio->uio_offset; | 245 | diff = (off_t)ip->i_size - uio->uio_offset; | |
246 | if (diff <= 0) | 246 | if (diff <= 0) |
--- src/sys/fs/hfs/hfs_vnops.c 2017/05/26 14:21:00 1.34
+++ src/sys/fs/hfs/hfs_vnops.c 2020/04/23 21:47:07 1.35
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: hfs_vnops.c,v 1.34 2017/05/26 14:21:00 riastradh Exp $ */ | 1 | /* $NetBSD: hfs_vnops.c,v 1.35 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Yevgeny Binder and Dieter Baron. | 8 | * by Yevgeny Binder and Dieter Baron. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -91,27 +91,27 @@ | @@ -91,27 +91,27 @@ | |||
91 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 91 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
92 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 92 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
93 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 93 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
94 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 94 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
95 | * SUCH DAMAGE. | 95 | * SUCH DAMAGE. | |
96 | */ | 96 | */ | |
97 | 97 | |||
98 | 98 | |||
99 | /* | 99 | /* | |
100 | * Apple HFS+ filesystem | 100 | * Apple HFS+ filesystem | |
101 | */ | 101 | */ | |
102 | 102 | |||
103 | #include <sys/cdefs.h> | 103 | #include <sys/cdefs.h> | |
104 | __KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.34 2017/05/26 14:21:00 riastradh Exp $"); | 104 | __KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.35 2020/04/23 21:47:07 ad Exp $"); | |
105 | 105 | |||
106 | #ifdef _KERNEL_OPT | 106 | #ifdef _KERNEL_OPT | |
107 | #include "opt_ipsec.h" | 107 | #include "opt_ipsec.h" | |
108 | #endif | 108 | #endif | |
109 | 109 | |||
110 | #include <sys/param.h> | 110 | #include <sys/param.h> | |
111 | #include <sys/systm.h> | 111 | #include <sys/systm.h> | |
112 | #include <sys/kernel.h> | 112 | #include <sys/kernel.h> | |
113 | #include <sys/vmmeter.h> | 113 | #include <sys/vmmeter.h> | |
114 | #include <sys/time.h> | 114 | #include <sys/time.h> | |
115 | #include <sys/proc.h> | 115 | #include <sys/proc.h> | |
116 | #include <sys/vnode.h> | 116 | #include <sys/vnode.h> | |
117 | #include <sys/malloc.h> | 117 | #include <sys/malloc.h> | |
@@ -842,27 +842,27 @@ hfs_vop_read(void *v) | @@ -842,27 +842,27 @@ hfs_vop_read(void *v) | |||
842 | 842 | |||
843 | if (vp->v_type != VREG && vp->v_type != VLNK) | 843 | if (vp->v_type != VREG && vp->v_type != VLNK) | |
844 | return EINVAL; | 844 | return EINVAL; | |
845 | 845 | |||
846 | error = 0; | 846 | error = 0; | |
847 | while (uio->uio_resid > 0 && error == 0) { | 847 | while (uio->uio_resid > 0 && error == 0) { | |
848 | vsize_t len; | 848 | vsize_t len; | |
849 | 849 | |||
850 | len = MIN(uio->uio_resid, fsize - uio->uio_offset); | 850 | len = MIN(uio->uio_resid, fsize - uio->uio_offset); | |
851 | if (len == 0) | 851 | if (len == 0) | |
852 | break; | 852 | break; | |
853 | 853 | |||
854 | error = ubc_uiomove(&vp->v_uobj, uio, len, advice, | 854 | error = ubc_uiomove(&vp->v_uobj, uio, len, advice, | |
855 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 855 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
856 | } | 856 | } | |
857 | 857 | |||
858 | return error; | 858 | return error; | |
859 | } | 859 | } | |
860 | 860 | |||
861 | int | 861 | int | |
862 | hfs_vop_readdir(void *v) | 862 | hfs_vop_readdir(void *v) | |
863 | { | 863 | { | |
864 | struct vop_readdir_args /* { | 864 | struct vop_readdir_args /* { | |
865 | struct vnode *a_vp; | 865 | struct vnode *a_vp; | |
866 | struct uio *a_uio; | 866 | struct uio *a_uio; | |
867 | kauth_cred_t a_cred; | 867 | kauth_cred_t a_cred; | |
868 | int *a_eofflag; | 868 | int *a_eofflag; |
--- src/sys/fs/msdosfs/msdosfs_denode.c 2020/04/13 19:23:17 1.58
+++ src/sys/fs/msdosfs/msdosfs_denode.c 2020/04/23 21:47:07 1.59
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msdosfs_denode.c,v 1.58 2020/04/13 19:23:17 ad Exp $ */ | 1 | /* $NetBSD: msdosfs_denode.c,v 1.59 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. | 4 | * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. | |
5 | * Copyright (C) 1994, 1995, 1997 TooLs GmbH. | 5 | * Copyright (C) 1994, 1995, 1997 TooLs GmbH. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). | 7 | * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). | |
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 | |
@@ -38,27 +38,27 @@ | @@ -38,27 +38,27 @@ | |||
38 | * it, and don't remove this notice. | 38 | * it, and don't remove this notice. | |
39 | * | 39 | * | |
40 | * This software is provided "as is". | 40 | * This software is provided "as is". | |
41 | * | 41 | * | |
42 | * The author supplies this software to be publicly redistributed on the | 42 | * The author supplies this software to be publicly redistributed on the | |
43 | * understanding that the author is not responsible for the correct | 43 | * understanding that the author is not responsible for the correct | |
44 | * functioning of this software in any circumstances and is not liable for | 44 | * functioning of this software in any circumstances and is not liable for | |
45 | * any damages caused by this software. | 45 | * any damages caused by this software. | |
46 | * | 46 | * | |
47 | * October 1992 | 47 | * October 1992 | |
48 | */ | 48 | */ | |
49 | 49 | |||
50 | #include <sys/cdefs.h> | 50 | #include <sys/cdefs.h> | |
51 | __KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.58 2020/04/13 19:23:17 ad Exp $"); | 51 | __KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.59 2020/04/23 21:47:07 ad Exp $"); | |
52 | 52 | |||
53 | #include <sys/param.h> | 53 | #include <sys/param.h> | |
54 | #include <sys/systm.h> | 54 | #include <sys/systm.h> | |
55 | #include <sys/mount.h> | 55 | #include <sys/mount.h> | |
56 | #include <sys/malloc.h> | 56 | #include <sys/malloc.h> | |
57 | #include <sys/pool.h> | 57 | #include <sys/pool.h> | |
58 | #include <sys/proc.h> | 58 | #include <sys/proc.h> | |
59 | #include <sys/buf.h> | 59 | #include <sys/buf.h> | |
60 | #include <sys/vnode.h> | 60 | #include <sys/vnode.h> | |
61 | #include <sys/kernel.h> /* defines "time" */ | 61 | #include <sys/kernel.h> /* defines "time" */ | |
62 | #include <sys/dirent.h> | 62 | #include <sys/dirent.h> | |
63 | #include <sys/namei.h> | 63 | #include <sys/namei.h> | |
64 | #include <sys/kauth.h> | 64 | #include <sys/kauth.h> | |
@@ -415,27 +415,27 @@ detrunc(struct denode *dep, u_long lengt | @@ -415,27 +415,27 @@ detrunc(struct denode *dep, u_long lengt | |||
415 | printf("detrunc(): bread fails %d\n", error); | 415 | printf("detrunc(): bread fails %d\n", error); | |
416 | #endif | 416 | #endif | |
417 | return (error); | 417 | return (error); | |
418 | } | 418 | } | |
419 | memset((char *)bp->b_data + boff, 0, | 419 | memset((char *)bp->b_data + boff, 0, | |
420 | pmp->pm_bpcluster - boff); | 420 | pmp->pm_bpcluster - boff); | |
421 | if (flags & IO_SYNC) | 421 | if (flags & IO_SYNC) | |
422 | bwrite(bp); | 422 | bwrite(bp); | |
423 | else | 423 | else | |
424 | bdwrite(bp); | 424 | bdwrite(bp); | |
425 | } else { | 425 | } else { | |
426 | ubc_zerorange(&DETOV(dep)->v_uobj, length, | 426 | ubc_zerorange(&DETOV(dep)->v_uobj, length, | |
427 | pmp->pm_bpcluster - boff, | 427 | pmp->pm_bpcluster - boff, | |
428 | UBC_UNMAP_FLAG(DETOV(dep))); | 428 | UBC_VNODE_FLAGS(DETOV(dep))); | |
429 | } | 429 | } | |
430 | } | 430 | } | |
431 | 431 | |||
432 | /* | 432 | /* | |
433 | * Write out the updated directory entry. Even if the update fails | 433 | * Write out the updated directory entry. Even if the update fails | |
434 | * we free the trailing clusters. | 434 | * we free the trailing clusters. | |
435 | */ | 435 | */ | |
436 | dep->de_FileSize = length; | 436 | dep->de_FileSize = length; | |
437 | if (!isadir) | 437 | if (!isadir) | |
438 | dep->de_flag |= DE_UPDATE|DE_MODIFIED; | 438 | dep->de_flag |= DE_UPDATE|DE_MODIFIED; | |
439 | vtruncbuf(DETOV(dep), lastblock + 1, 0, 0); | 439 | vtruncbuf(DETOV(dep), lastblock + 1, 0, 0); | |
440 | allerror = deupdat(dep, 1); | 440 | allerror = deupdat(dep, 1); | |
441 | #ifdef MSDOSFS_DEBUG | 441 | #ifdef MSDOSFS_DEBUG | |
@@ -513,27 +513,27 @@ deextend(struct denode *dep, u_long leng | @@ -513,27 +513,27 @@ deextend(struct denode *dep, u_long leng | |||
513 | } | 513 | } | |
514 | 514 | |||
515 | /* | 515 | /* | |
516 | * Zero extend file range; ubc_zerorange() uses ubc_alloc() and a | 516 | * Zero extend file range; ubc_zerorange() uses ubc_alloc() and a | |
517 | * memset(); we set the write size so ubc won't read in file data that | 517 | * memset(); we set the write size so ubc won't read in file data that | |
518 | * is zero'd later. | 518 | * is zero'd later. | |
519 | */ | 519 | */ | |
520 | osize = dep->de_FileSize; | 520 | osize = dep->de_FileSize; | |
521 | dep->de_FileSize = length; | 521 | dep->de_FileSize = length; | |
522 | uvm_vnp_setwritesize(DETOV(dep), (voff_t)dep->de_FileSize); | 522 | uvm_vnp_setwritesize(DETOV(dep), (voff_t)dep->de_FileSize); | |
523 | dep->de_flag |= DE_UPDATE|DE_MODIFIED; | 523 | dep->de_flag |= DE_UPDATE|DE_MODIFIED; | |
524 | ubc_zerorange(&DETOV(dep)->v_uobj, (off_t)osize, | 524 | ubc_zerorange(&DETOV(dep)->v_uobj, (off_t)osize, | |
525 | (size_t)(round_page(dep->de_FileSize) - osize), | 525 | (size_t)(round_page(dep->de_FileSize) - osize), | |
526 | UBC_UNMAP_FLAG(DETOV(dep))); | 526 | UBC_VNODE_FLAGS(DETOV(dep))); | |
527 | uvm_vnp_setsize(DETOV(dep), (voff_t)dep->de_FileSize); | 527 | uvm_vnp_setsize(DETOV(dep), (voff_t)dep->de_FileSize); | |
528 | return (deupdat(dep, 1)); | 528 | return (deupdat(dep, 1)); | |
529 | } | 529 | } | |
530 | 530 | |||
531 | int | 531 | int | |
532 | msdosfs_reclaim(void *v) | 532 | msdosfs_reclaim(void *v) | |
533 | { | 533 | { | |
534 | struct vop_reclaim_v2_args /* { | 534 | struct vop_reclaim_v2_args /* { | |
535 | struct vnode *a_vp; | 535 | struct vnode *a_vp; | |
536 | } */ *ap = v; | 536 | } */ *ap = v; | |
537 | struct vnode *vp = ap->a_vp; | 537 | struct vnode *vp = ap->a_vp; | |
538 | struct denode *dep = VTODE(vp); | 538 | struct denode *dep = VTODE(vp); | |
539 | 539 |
--- src/sys/fs/msdosfs/msdosfs_vnops.c 2020/04/13 19:23:17 1.101
+++ src/sys/fs/msdosfs/msdosfs_vnops.c 2020/04/23 21:47:07 1.102
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msdosfs_vnops.c,v 1.101 2020/04/13 19:23:17 ad Exp $ */ | 1 | /* $NetBSD: msdosfs_vnops.c,v 1.102 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. | 4 | * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. | |
5 | * Copyright (C) 1994, 1995, 1997 TooLs GmbH. | 5 | * Copyright (C) 1994, 1995, 1997 TooLs GmbH. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). | 7 | * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). | |
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 | |
@@ -38,27 +38,27 @@ | @@ -38,27 +38,27 @@ | |||
38 | * it, and don't remove this notice. | 38 | * it, and don't remove this notice. | |
39 | * | 39 | * | |
40 | * This software is provided "as is". | 40 | * This software is provided "as is". | |
41 | * | 41 | * | |
42 | * The author supplies this software to be publicly redistributed on the | 42 | * The author supplies this software to be publicly redistributed on the | |
43 | * understanding that the author is not responsible for the correct | 43 | * understanding that the author is not responsible for the correct | |
44 | * functioning of this software in any circumstances and is not liable for | 44 | * functioning of this software in any circumstances and is not liable for | |
45 | * any damages caused by this software. | 45 | * any damages caused by this software. | |
46 | * | 46 | * | |
47 | * October 1992 | 47 | * October 1992 | |
48 | */ | 48 | */ | |
49 | 49 | |||
50 | #include <sys/cdefs.h> | 50 | #include <sys/cdefs.h> | |
51 | __KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.101 2020/04/13 19:23:17 ad Exp $"); | 51 | __KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.102 2020/04/23 21:47:07 ad Exp $"); | |
52 | 52 | |||
53 | #include <sys/param.h> | 53 | #include <sys/param.h> | |
54 | #include <sys/systm.h> | 54 | #include <sys/systm.h> | |
55 | #include <sys/namei.h> | 55 | #include <sys/namei.h> | |
56 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ | 56 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ | |
57 | #include <sys/kernel.h> | 57 | #include <sys/kernel.h> | |
58 | #include <sys/file.h> /* define FWRITE ... */ | 58 | #include <sys/file.h> /* define FWRITE ... */ | |
59 | #include <sys/stat.h> | 59 | #include <sys/stat.h> | |
60 | #include <sys/buf.h> | 60 | #include <sys/buf.h> | |
61 | #include <sys/proc.h> | 61 | #include <sys/proc.h> | |
62 | #include <sys/mount.h> | 62 | #include <sys/mount.h> | |
63 | #include <sys/vnode.h> | 63 | #include <sys/vnode.h> | |
64 | #include <sys/signalvar.h> | 64 | #include <sys/signalvar.h> | |
@@ -470,27 +470,27 @@ msdosfs_read(void *v) | @@ -470,27 +470,27 @@ msdosfs_read(void *v) | |||
470 | if (uio->uio_offset >= dep->de_FileSize) | 470 | if (uio->uio_offset >= dep->de_FileSize) | |
471 | return (0); | 471 | return (0); | |
472 | 472 | |||
473 | if (vp->v_type == VREG) { | 473 | if (vp->v_type == VREG) { | |
474 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | 474 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | |
475 | 475 | |||
476 | while (uio->uio_resid > 0) { | 476 | while (uio->uio_resid > 0) { | |
477 | bytelen = MIN(dep->de_FileSize - uio->uio_offset, | 477 | bytelen = MIN(dep->de_FileSize - uio->uio_offset, | |
478 | uio->uio_resid); | 478 | uio->uio_resid); | |
479 | 479 | |||
480 | if (bytelen == 0) | 480 | if (bytelen == 0) | |
481 | break; | 481 | break; | |
482 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 482 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
483 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 483 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
484 | if (error) | 484 | if (error) | |
485 | break; | 485 | break; | |
486 | } | 486 | } | |
487 | dep->de_flag |= DE_ACCESS; | 487 | dep->de_flag |= DE_ACCESS; | |
488 | goto out; | 488 | goto out; | |
489 | } | 489 | } | |
490 | 490 | |||
491 | /* this loop is only for directories now */ | 491 | /* this loop is only for directories now */ | |
492 | do { | 492 | do { | |
493 | lbn = de_cluster(pmp, uio->uio_offset); | 493 | lbn = de_cluster(pmp, uio->uio_offset); | |
494 | on = uio->uio_offset & pmp->pm_crbomask; | 494 | on = uio->uio_offset & pmp->pm_crbomask; | |
495 | n = MIN(pmp->pm_bpcluster - on, uio->uio_resid); | 495 | n = MIN(pmp->pm_bpcluster - on, uio->uio_resid); | |
496 | if (uio->uio_offset >= dep->de_FileSize) { | 496 | if (uio->uio_offset >= dep->de_FileSize) { | |
@@ -614,36 +614,36 @@ msdosfs_write(void *v) | @@ -614,36 +614,36 @@ msdosfs_write(void *v) | |||
614 | if (uio->uio_offset + resid > osize) { | 614 | if (uio->uio_offset + resid > osize) { | |
615 | count = de_clcount(pmp, uio->uio_offset + resid) - | 615 | count = de_clcount(pmp, uio->uio_offset + resid) - | |
616 | de_clcount(pmp, osize); | 616 | de_clcount(pmp, osize); | |
617 | if ((error = extendfile(dep, count, NULL, NULL, 0))) | 617 | if ((error = extendfile(dep, count, NULL, NULL, 0))) | |
618 | goto errexit; | 618 | goto errexit; | |
619 | 619 | |||
620 | dep->de_FileSize = uio->uio_offset + resid; | 620 | dep->de_FileSize = uio->uio_offset + resid; | |
621 | /* hint uvm to not read in extended part */ | 621 | /* hint uvm to not read in extended part */ | |
622 | uvm_vnp_setwritesize(vp, dep->de_FileSize); | 622 | uvm_vnp_setwritesize(vp, dep->de_FileSize); | |
623 | /* zero out the remainder of the last page */ | 623 | /* zero out the remainder of the last page */ | |
624 | rem = round_page(dep->de_FileSize) - dep->de_FileSize; | 624 | rem = round_page(dep->de_FileSize) - dep->de_FileSize; | |
625 | if (rem > 0) | 625 | if (rem > 0) | |
626 | ubc_zerorange(&vp->v_uobj, (off_t)dep->de_FileSize, | 626 | ubc_zerorange(&vp->v_uobj, (off_t)dep->de_FileSize, | |
627 | rem, UBC_UNMAP_FLAG(vp)); | 627 | rem, UBC_VNODE_FLAGS(vp)); | |
628 | extended = 1; | 628 | extended = 1; | |
629 | } | 629 | } | |
630 | 630 | |||
631 | do { | 631 | do { | |
632 | oldoff = uio->uio_offset; | 632 | oldoff = uio->uio_offset; | |
633 | bytelen = uio->uio_resid; | 633 | bytelen = uio->uio_resid; | |
634 | 634 | |||
635 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | 635 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | |
636 | IO_ADV_DECODE(ioflag), UBC_WRITE | UBC_UNMAP_FLAG(vp)); | 636 | IO_ADV_DECODE(ioflag), UBC_WRITE | UBC_VNODE_FLAGS(vp)); | |
637 | if (error) | 637 | if (error) | |
638 | break; | 638 | break; | |
639 | 639 | |||
640 | /* | 640 | /* | |
641 | * flush what we just wrote if necessary. | 641 | * flush what we just wrote if necessary. | |
642 | * XXXUBC simplistic async flushing. | 642 | * XXXUBC simplistic async flushing. | |
643 | */ | 643 | */ | |
644 | 644 | |||
645 | if (!async && oldoff >> 16 != uio->uio_offset >> 16) { | 645 | if (!async && oldoff >> 16 != uio->uio_offset >> 16) { | |
646 | rw_enter(vp->v_uobj.vmobjlock, RW_WRITER); | 646 | rw_enter(vp->v_uobj.vmobjlock, RW_WRITER); | |
647 | error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16, | 647 | error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16, | |
648 | (uio->uio_offset >> 16) << 16, | 648 | (uio->uio_offset >> 16) << 16, | |
649 | PGO_CLEANIT | PGO_LAZY); | 649 | PGO_CLEANIT | PGO_LAZY); |
--- src/sys/fs/nilfs/nilfs_vnops.c 2020/04/13 19:23:18 1.39
+++ src/sys/fs/nilfs/nilfs_vnops.c 2020/04/23 21:47:07 1.40
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: nilfs_vnops.c,v 1.39 2020/04/13 19:23:18 ad Exp $ */ | 1 | /* $NetBSD: nilfs_vnops.c,v 1.40 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008, 2009 Reinoud Zandijk | 4 | * Copyright (c) 2008, 2009 Reinoud Zandijk | |
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. | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | * | 26 | * | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #ifndef lint | 30 | #ifndef lint | |
31 | __KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.39 2020/04/13 19:23:18 ad Exp $"); | 31 | __KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.40 2020/04/23 21:47:07 ad Exp $"); | |
32 | #endif /* not lint */ | 32 | #endif /* not lint */ | |
33 | 33 | |||
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/namei.h> | 37 | #include <sys/namei.h> | |
38 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ | 38 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ | |
39 | #include <sys/kernel.h> | 39 | #include <sys/kernel.h> | |
40 | #include <sys/file.h> /* define FWRITE ... */ | 40 | #include <sys/file.h> /* define FWRITE ... */ | |
41 | #include <sys/stat.h> | 41 | #include <sys/stat.h> | |
42 | #include <sys/buf.h> | 42 | #include <sys/buf.h> | |
43 | #include <sys/proc.h> | 43 | #include <sys/proc.h> | |
44 | #include <sys/mount.h> | 44 | #include <sys/mount.h> | |
@@ -169,27 +169,27 @@ nilfs_read(void *v) | @@ -169,27 +169,27 @@ nilfs_read(void *v) | |||
169 | error = 0; | 169 | error = 0; | |
170 | while (uio->uio_resid > 0) { | 170 | while (uio->uio_resid > 0) { | |
171 | /* reached end? */ | 171 | /* reached end? */ | |
172 | if (file_size <= uio->uio_offset) | 172 | if (file_size <= uio->uio_offset) | |
173 | break; | 173 | break; | |
174 | 174 | |||
175 | /* maximise length to file extremity */ | 175 | /* maximise length to file extremity */ | |
176 | len = MIN(file_size - uio->uio_offset, uio->uio_resid); | 176 | len = MIN(file_size - uio->uio_offset, uio->uio_resid); | |
177 | if (len == 0) | 177 | if (len == 0) | |
178 | break; | 178 | break; | |
179 | 179 | |||
180 | /* ubc, here we come, prepare to trap */ | 180 | /* ubc, here we come, prepare to trap */ | |
181 | error = ubc_uiomove(uobj, uio, len, advice, | 181 | error = ubc_uiomove(uobj, uio, len, advice, | |
182 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 182 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
183 | if (error) | 183 | if (error) | |
184 | break; | 184 | break; | |
185 | } | 185 | } | |
186 | 186 | |||
187 | /* note access time unless not requested */ | 187 | /* note access time unless not requested */ | |
188 | if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) { | 188 | if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) { | |
189 | nilfs_node->i_flags |= IN_ACCESS; | 189 | nilfs_node->i_flags |= IN_ACCESS; | |
190 | if ((ioflag & IO_SYNC) == IO_SYNC) | 190 | if ((ioflag & IO_SYNC) == IO_SYNC) | |
191 | error = nilfs_update(vp, NULL, NULL, NULL, UPDATE_WAIT); | 191 | error = nilfs_update(vp, NULL, NULL, NULL, UPDATE_WAIT); | |
192 | } | 192 | } | |
193 | 193 | |||
194 | return error; | 194 | return error; | |
195 | } | 195 | } | |
@@ -259,27 +259,27 @@ nilfs_write(void *v) | @@ -259,27 +259,27 @@ nilfs_write(void *v) | |||
259 | uobj = &vp->v_uobj; | 259 | uobj = &vp->v_uobj; | |
260 | resid = uio->uio_resid; | 260 | resid = uio->uio_resid; | |
261 | error = 0; | 261 | error = 0; | |
262 | 262 | |||
263 | uvm_vnp_setwritesize(vp, file_size); | 263 | uvm_vnp_setwritesize(vp, file_size); | |
264 | while (uio->uio_resid > 0) { | 264 | while (uio->uio_resid > 0) { | |
265 | /* maximise length to file extremity */ | 265 | /* maximise length to file extremity */ | |
266 | len = MIN(file_size - uio->uio_offset, uio->uio_resid); | 266 | len = MIN(file_size - uio->uio_offset, uio->uio_resid); | |
267 | if (len == 0) | 267 | if (len == 0) | |
268 | break; | 268 | break; | |
269 | 269 | |||
270 | /* ubc, here we come, prepare to trap */ | 270 | /* ubc, here we come, prepare to trap */ | |
271 | error = ubc_uiomove(uobj, uio, len, advice, | 271 | error = ubc_uiomove(uobj, uio, len, advice, | |
272 | UBC_WRITE | UBC_UNMAP_FLAG(vp)); | 272 | UBC_WRITE | UBC_VNODE_FLAGS(vp)); | |
273 | if (error) | 273 | if (error) | |
274 | break; | 274 | break; | |
275 | } | 275 | } | |
276 | uvm_vnp_setsize(vp, file_size); | 276 | uvm_vnp_setsize(vp, file_size); | |
277 | 277 | |||
278 | /* mark node changed and request update */ | 278 | /* mark node changed and request update */ | |
279 | nilfs_node->i_flags |= IN_CHANGE | IN_UPDATE; | 279 | nilfs_node->i_flags |= IN_CHANGE | IN_UPDATE; | |
280 | if (vp->v_mount->mnt_flag & MNT_RELATIME) | 280 | if (vp->v_mount->mnt_flag & MNT_RELATIME) | |
281 | nilfs_node->i_flags |= IN_ACCESS; | 281 | nilfs_node->i_flags |= IN_ACCESS; | |
282 | 282 | |||
283 | /* | 283 | /* | |
284 | * XXX TODO FFS has code here to reset setuid & setgid when we're not | 284 | * XXX TODO FFS has code here to reset setuid & setgid when we're not | |
285 | * the superuser as a precaution against tampering. | 285 | * the superuser as a precaution against tampering. |
--- src/sys/fs/puffs/puffs_vnops.c 2020/02/23 15:46:40 1.214
+++ src/sys/fs/puffs/puffs_vnops.c 2020/04/23 21:47:07 1.215
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: puffs_vnops.c,v 1.214 2020/02/23 15:46:40 ad Exp $ */ | 1 | /* $NetBSD: puffs_vnops.c,v 1.215 2020/04/23 21:47:07 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. | 4 | * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. | |
5 | * | 5 | * | |
6 | * Development of this software was supported by the | 6 | * Development of this software was supported by the | |
7 | * Google Summer of Code program and the Ulla Tuominen Foundation. | 7 | * Google Summer of Code program and the Ulla Tuominen Foundation. | |
8 | * The Google SoC project was mentored by Bill Studenmund. | 8 | * The Google SoC project was mentored by Bill Studenmund. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 20 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
22 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 22 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.214 2020/02/23 15:46:40 ad Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.215 2020/04/23 21:47:07 ad Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/buf.h> | 36 | #include <sys/buf.h> | |
37 | #include <sys/lockf.h> | 37 | #include <sys/lockf.h> | |
38 | #include <sys/malloc.h> | 38 | #include <sys/malloc.h> | |
39 | #include <sys/mount.h> | 39 | #include <sys/mount.h> | |
40 | #include <sys/namei.h> | 40 | #include <sys/namei.h> | |
41 | #include <sys/vnode.h> | 41 | #include <sys/vnode.h> | |
42 | #include <sys/proc.h> | 42 | #include <sys/proc.h> | |
43 | #include <sys/kernel.h> /* For hz, hardclock_ticks */ | 43 | #include <sys/kernel.h> /* For hz, hardclock_ticks */ | |
44 | 44 | |||
45 | #include <uvm/uvm.h> | 45 | #include <uvm/uvm.h> | |
46 | 46 | |||
@@ -1148,27 +1148,27 @@ puffs_vnop_getattr(void *v) | @@ -1148,27 +1148,27 @@ puffs_vnop_getattr(void *v) | |||
1148 | } | 1148 | } | |
1149 | 1149 | |||
1150 | static void | 1150 | static void | |
1151 | zerofill_lastpage(struct vnode *vp, voff_t off) | 1151 | zerofill_lastpage(struct vnode *vp, voff_t off) | |
1152 | { | 1152 | { | |
1153 | 1153 | |||
1154 | if (trunc_page(off) == off) | 1154 | if (trunc_page(off) == off) | |
1155 | return; | 1155 | return; | |
1156 | 1156 | |||
1157 | if (vp->v_writecount == 0) | 1157 | if (vp->v_writecount == 0) | |
1158 | return; | 1158 | return; | |
1159 | 1159 | |||
1160 | vsize_t len = round_page(off) - off; | 1160 | vsize_t len = round_page(off) - off; | |
1161 | ubc_zerorange(&vp->v_uobj, off, len, UBC_WRITE|UBC_UNMAP_FLAG(vp)); | 1161 | ubc_zerorange(&vp->v_uobj, off, len, UBC_WRITE|UBC_VNODE_FLAGS(vp)); | |
1162 | } | 1162 | } | |
1163 | 1163 | |||
1164 | static int | 1164 | static int | |
1165 | dosetattr(struct vnode *vp, struct vattr *vap, kauth_cred_t cred, int flags) | 1165 | dosetattr(struct vnode *vp, struct vattr *vap, kauth_cred_t cred, int flags) | |
1166 | { | 1166 | { | |
1167 | PUFFS_MSG_VARS(vn, setattr); | 1167 | PUFFS_MSG_VARS(vn, setattr); | |
1168 | struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount); | 1168 | struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount); | |
1169 | struct puffs_node *pn = vp->v_data; | 1169 | struct puffs_node *pn = vp->v_data; | |
1170 | vsize_t oldsize = vp->v_size; | 1170 | vsize_t oldsize = vp->v_size; | |
1171 | int error = 0; | 1171 | int error = 0; | |
1172 | 1172 | |||
1173 | KASSERT(!(flags & SETATTR_CHSIZE) || mutex_owned(&pn->pn_sizemtx)); | 1173 | KASSERT(!(flags & SETATTR_CHSIZE) || mutex_owned(&pn->pn_sizemtx)); | |
1174 | 1174 | |||
@@ -2287,27 +2287,27 @@ puffs_vnop_read(void *v) | @@ -2287,27 +2287,27 @@ puffs_vnop_read(void *v) | |||
2287 | (vp->v_size != 0)) { | 2287 | (vp->v_size != 0)) { | |
2288 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | 2288 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | |
2289 | 2289 | |||
2290 | while (uio->uio_resid > 0) { | 2290 | while (uio->uio_resid > 0) { | |
2291 | if (vp->v_size <= uio->uio_offset) { | 2291 | if (vp->v_size <= uio->uio_offset) { | |
2292 | break; | 2292 | break; | |
2293 | } | 2293 | } | |
2294 | bytelen = MIN(uio->uio_resid, | 2294 | bytelen = MIN(uio->uio_resid, | |
2295 | vp->v_size - uio->uio_offset); | 2295 | vp->v_size - uio->uio_offset); | |
2296 | if (bytelen == 0) | 2296 | if (bytelen == 0) | |
2297 | break; | 2297 | break; | |
2298 | 2298 | |||
2299 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 2299 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
2300 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 2300 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
2301 | if (error) | 2301 | if (error) | |
2302 | break; | 2302 | break; | |
2303 | } | 2303 | } | |
2304 | 2304 | |||
2305 | if ((vp->v_mount->mnt_flag & MNT_NOATIME) == 0) | 2305 | if ((vp->v_mount->mnt_flag & MNT_NOATIME) == 0) | |
2306 | puffs_updatenode(VPTOPP(vp), PUFFS_UPDATEATIME, 0); | 2306 | puffs_updatenode(VPTOPP(vp), PUFFS_UPDATEATIME, 0); | |
2307 | } else { | 2307 | } else { | |
2308 | /* | 2308 | /* | |
2309 | * in case it's not a regular file or we're operating | 2309 | * in case it's not a regular file or we're operating | |
2310 | * uncached, do read in the old-fashioned style, | 2310 | * uncached, do read in the old-fashioned style, | |
2311 | * i.e. explicit read operations | 2311 | * i.e. explicit read operations | |
2312 | */ | 2312 | */ | |
2313 | 2313 | |||
@@ -2397,27 +2397,27 @@ puffs_vnop_write(void *v) | @@ -2397,27 +2397,27 @@ puffs_vnop_write(void *v) | |||
2397 | 2397 | |||
2398 | /* | 2398 | /* | |
2399 | * userspace *should* be allowed to control this, | 2399 | * userspace *should* be allowed to control this, | |
2400 | * but with UBC it's a bit unclear how to handle it | 2400 | * but with UBC it's a bit unclear how to handle it | |
2401 | */ | 2401 | */ | |
2402 | if (ap->a_ioflag & IO_APPEND) | 2402 | if (ap->a_ioflag & IO_APPEND) | |
2403 | uio->uio_offset = vp->v_size; | 2403 | uio->uio_offset = vp->v_size; | |
2404 | 2404 | |||
2405 | origoff = uio->uio_offset; | 2405 | origoff = uio->uio_offset; | |
2406 | 2406 | |||
2407 | if (vp->v_type == VREG && | 2407 | if (vp->v_type == VREG && | |
2408 | PUFFS_USE_PAGECACHE(pmp) && | 2408 | PUFFS_USE_PAGECACHE(pmp) && | |
2409 | !(pn->pn_stat & PNODE_WDIRECT)) { | 2409 | !(pn->pn_stat & PNODE_WDIRECT)) { | |
2410 | ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp); | 2410 | ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp); | |
2411 | 2411 | |||
2412 | while (uio->uio_resid > 0) { | 2412 | while (uio->uio_resid > 0) { | |
2413 | oldoff = uio->uio_offset; | 2413 | oldoff = uio->uio_offset; | |
2414 | bytelen = uio->uio_resid; | 2414 | bytelen = uio->uio_resid; | |
2415 | 2415 | |||
2416 | newoff = oldoff + bytelen; | 2416 | newoff = oldoff + bytelen; | |
2417 | if (vp->v_size < newoff) { | 2417 | if (vp->v_size < newoff) { | |
2418 | uvm_vnp_setwritesize(vp, newoff); | 2418 | uvm_vnp_setwritesize(vp, newoff); | |
2419 | } | 2419 | } | |
2420 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | 2420 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | |
2421 | UVM_ADV_RANDOM, ubcflags); | 2421 | UVM_ADV_RANDOM, ubcflags); | |
2422 | 2422 | |||
2423 | /* | 2423 | /* |
--- src/sys/fs/sysvbfs/sysvbfs_vnops.c 2020/01/17 20:08:08 1.64
+++ src/sys/fs/sysvbfs/sysvbfs_vnops.c 2020/04/23 21:47:08 1.65
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sysvbfs_vnops.c,v 1.64 2020/01/17 20:08:08 ad Exp $ */ | 1 | /* $NetBSD: sysvbfs_vnops.c,v 1.65 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by UCHIYAMA Yasushi. | 8 | * by UCHIYAMA Yasushi. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.64 2020/01/17 20:08:08 ad Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.65 2020/04/23 21:47:08 ad Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/kernel.h> | 36 | #include <sys/kernel.h> | |
37 | #include <sys/resource.h> | 37 | #include <sys/resource.h> | |
38 | #include <sys/vnode.h> | 38 | #include <sys/vnode.h> | |
39 | #include <sys/namei.h> | 39 | #include <sys/namei.h> | |
40 | #include <sys/dirent.h> | 40 | #include <sys/dirent.h> | |
41 | #include <sys/malloc.h> | 41 | #include <sys/malloc.h> | |
42 | #include <sys/lockf.h> | 42 | #include <sys/lockf.h> | |
43 | #include <sys/unistd.h> | 43 | #include <sys/unistd.h> | |
44 | #include <sys/fcntl.h> | 44 | #include <sys/fcntl.h> | |
45 | #include <sys/kauth.h> | 45 | #include <sys/kauth.h> | |
46 | #include <sys/buf.h> | 46 | #include <sys/buf.h> | |
@@ -438,27 +438,27 @@ sysvbfs_read(void *arg) | @@ -438,27 +438,27 @@ sysvbfs_read(void *arg) | |||
438 | break; | 438 | break; | |
439 | case VDIR: | 439 | case VDIR: | |
440 | return EISDIR; | 440 | return EISDIR; | |
441 | default: | 441 | default: | |
442 | return EINVAL; | 442 | return EINVAL; | |
443 | } | 443 | } | |
444 | 444 | |||
445 | err = 0; | 445 | err = 0; | |
446 | while (uio->uio_resid > 0) { | 446 | while (uio->uio_resid > 0) { | |
447 | if ((sz = MIN(filesz - uio->uio_offset, uio->uio_resid)) == 0) | 447 | if ((sz = MIN(filesz - uio->uio_offset, uio->uio_resid)) == 0) | |
448 | break; | 448 | break; | |
449 | 449 | |||
450 | err = ubc_uiomove(&v->v_uobj, uio, sz, advice, | 450 | err = ubc_uiomove(&v->v_uobj, uio, sz, advice, | |
451 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(v)); | 451 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(v)); | |
452 | if (err) | 452 | if (err) | |
453 | break; | 453 | break; | |
454 | DPRINTF("%s: read %ldbyte\n", __func__, sz); | 454 | DPRINTF("%s: read %ldbyte\n", __func__, sz); | |
455 | } | 455 | } | |
456 | 456 | |||
457 | uerr = sysvbfs_update(v, NULL, NULL, UPDATE_WAIT); | 457 | uerr = sysvbfs_update(v, NULL, NULL, UPDATE_WAIT); | |
458 | if (err == 0) | 458 | if (err == 0) | |
459 | err = uerr; | 459 | err = uerr; | |
460 | 460 | |||
461 | return err; | 461 | return err; | |
462 | } | 462 | } | |
463 | 463 | |||
464 | int | 464 | int | |
@@ -485,27 +485,27 @@ sysvbfs_write(void *arg) | @@ -485,27 +485,27 @@ sysvbfs_write(void *arg) | |||
485 | uio->uio_offset = bnode->size; | 485 | uio->uio_offset = bnode->size; | |
486 | 486 | |||
487 | if (uio->uio_resid == 0) | 487 | if (uio->uio_resid == 0) | |
488 | return 0; | 488 | return 0; | |
489 | 489 | |||
490 | if (bnode->size < uio->uio_offset + uio->uio_resid) { | 490 | if (bnode->size < uio->uio_offset + uio->uio_resid) { | |
491 | sysvbfs_file_setsize(v, uio->uio_offset + uio->uio_resid); | 491 | sysvbfs_file_setsize(v, uio->uio_offset + uio->uio_resid); | |
492 | extended = true; | 492 | extended = true; | |
493 | } | 493 | } | |
494 | 494 | |||
495 | while (uio->uio_resid > 0) { | 495 | while (uio->uio_resid > 0) { | |
496 | sz = uio->uio_resid; | 496 | sz = uio->uio_resid; | |
497 | err = ubc_uiomove(&v->v_uobj, uio, sz, advice, | 497 | err = ubc_uiomove(&v->v_uobj, uio, sz, advice, | |
498 | UBC_WRITE | UBC_UNMAP_FLAG(v)); | 498 | UBC_WRITE | UBC_VNODE_FLAGS(v)); | |
499 | if (err) | 499 | if (err) | |
500 | break; | 500 | break; | |
501 | DPRINTF("%s: write %ldbyte\n", __func__, sz); | 501 | DPRINTF("%s: write %ldbyte\n", __func__, sz); | |
502 | } | 502 | } | |
503 | if (err) | 503 | if (err) | |
504 | sysvbfs_file_setsize(v, bnode->size - uio->uio_resid); | 504 | sysvbfs_file_setsize(v, bnode->size - uio->uio_resid); | |
505 | 505 | |||
506 | VN_KNOTE(v, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); | 506 | VN_KNOTE(v, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); | |
507 | 507 | |||
508 | return err; | 508 | return err; | |
509 | } | 509 | } | |
510 | 510 | |||
511 | int | 511 | int |
--- src/sys/fs/tmpfs/tmpfs_subr.c 2020/04/04 20:49:30 1.108
+++ src/sys/fs/tmpfs/tmpfs_subr.c 2020/04/23 21:47:08 1.109
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tmpfs_subr.c,v 1.108 2020/04/04 20:49:30 ad Exp $ */ | 1 | /* $NetBSD: tmpfs_subr.c,v 1.109 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Julio M. Merino Vidal, developed as part of Google's Summer of Code | 8 | * by Julio M. Merino Vidal, developed as part of Google's Summer of Code | |
9 | * 2005 program, and by Mindaugas Rasiukevicius. | 9 | * 2005 program, and by Mindaugas Rasiukevicius. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -63,27 +63,27 @@ | @@ -63,27 +63,27 @@ | |||
63 | * | 63 | * | |
64 | * If an inode has references within the file system (tn_links > 0) and | 64 | * If an inode has references within the file system (tn_links > 0) and | |
65 | * its inactive vnode gets reclaimed/recycled - then the association is | 65 | * its inactive vnode gets reclaimed/recycled - then the association is | |
66 | * broken in tmpfs_reclaim(). In such case, an inode will always pass | 66 | * broken in tmpfs_reclaim(). In such case, an inode will always pass | |
67 | * tmpfs_lookup() and thus vcache_get() to associate a new vnode. | 67 | * tmpfs_lookup() and thus vcache_get() to associate a new vnode. | |
68 | * | 68 | * | |
69 | * Lock order | 69 | * Lock order | |
70 | * | 70 | * | |
71 | * vnode_t::v_vlock -> | 71 | * vnode_t::v_vlock -> | |
72 | * vnode_t::v_interlock | 72 | * vnode_t::v_interlock | |
73 | */ | 73 | */ | |
74 | 74 | |||
75 | #include <sys/cdefs.h> | 75 | #include <sys/cdefs.h> | |
76 | __KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.108 2020/04/04 20:49:30 ad Exp $"); | 76 | __KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.109 2020/04/23 21:47:08 ad Exp $"); | |
77 | 77 | |||
78 | #include <sys/param.h> | 78 | #include <sys/param.h> | |
79 | #include <sys/cprng.h> | 79 | #include <sys/cprng.h> | |
80 | #include <sys/dirent.h> | 80 | #include <sys/dirent.h> | |
81 | #include <sys/event.h> | 81 | #include <sys/event.h> | |
82 | #include <sys/kmem.h> | 82 | #include <sys/kmem.h> | |
83 | #include <sys/mount.h> | 83 | #include <sys/mount.h> | |
84 | #include <sys/namei.h> | 84 | #include <sys/namei.h> | |
85 | #include <sys/time.h> | 85 | #include <sys/time.h> | |
86 | #include <sys/stat.h> | 86 | #include <sys/stat.h> | |
87 | #include <sys/systm.h> | 87 | #include <sys/systm.h> | |
88 | #include <sys/vnode.h> | 88 | #include <sys/vnode.h> | |
89 | #include <sys/kauth.h> | 89 | #include <sys/kauth.h> | |
@@ -919,27 +919,27 @@ tmpfs_reg_resize(struct vnode *vp, off_t | @@ -919,27 +919,27 @@ tmpfs_reg_resize(struct vnode *vp, off_t | |||
919 | if (newsize == oldsize) { | 919 | if (newsize == oldsize) { | |
920 | return 0; | 920 | return 0; | |
921 | } | 921 | } | |
922 | 922 | |||
923 | if (newpages > oldpages) { | 923 | if (newpages > oldpages) { | |
924 | /* Increase the used-memory counter if getting extra pages. */ | 924 | /* Increase the used-memory counter if getting extra pages. */ | |
925 | if (!tmpfs_mem_incr(tmp, (newpages - oldpages) << PAGE_SHIFT)) { | 925 | if (!tmpfs_mem_incr(tmp, (newpages - oldpages) << PAGE_SHIFT)) { | |
926 | return ENOSPC; | 926 | return ENOSPC; | |
927 | } | 927 | } | |
928 | } else if (newsize < oldsize) { | 928 | } else if (newsize < oldsize) { | |
929 | size_t zerolen; | 929 | size_t zerolen; | |
930 | 930 | |||
931 | zerolen = MIN(round_page(newsize), node->tn_size) - newsize; | 931 | zerolen = MIN(round_page(newsize), node->tn_size) - newsize; | |
932 | ubc_zerorange(uobj, newsize, zerolen, UBC_UNMAP_FLAG(vp)); | 932 | ubc_zerorange(uobj, newsize, zerolen, UBC_VNODE_FLAGS(vp)); | |
933 | } | 933 | } | |
934 | 934 | |||
935 | node->tn_spec.tn_reg.tn_aobj_pages = newpages; | 935 | node->tn_spec.tn_reg.tn_aobj_pages = newpages; | |
936 | node->tn_size = newsize; | 936 | node->tn_size = newsize; | |
937 | uvm_vnp_setsize(vp, newsize); | 937 | uvm_vnp_setsize(vp, newsize); | |
938 | 938 | |||
939 | /* | 939 | /* | |
940 | * Free "backing store". | 940 | * Free "backing store". | |
941 | */ | 941 | */ | |
942 | if (newpages < oldpages) { | 942 | if (newpages < oldpages) { | |
943 | rw_enter(uobj->vmobjlock, RW_WRITER); | 943 | rw_enter(uobj->vmobjlock, RW_WRITER); | |
944 | uao_dropswap_range(uobj, newpages, oldpages); | 944 | uao_dropswap_range(uobj, newpages, oldpages); | |
945 | rw_exit(uobj->vmobjlock); | 945 | rw_exit(uobj->vmobjlock); |
--- src/sys/fs/tmpfs/tmpfs_vnops.c 2020/03/14 13:39:36 1.135
+++ src/sys/fs/tmpfs/tmpfs_vnops.c 2020/04/23 21:47:08 1.136
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $ */ | 1 | /* $NetBSD: tmpfs_vnops.c,v 1.136 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Julio M. Merino Vidal, developed as part of Google's Summer of Code | 8 | * by Julio M. Merino Vidal, developed as part of Google's Summer of Code | |
9 | * 2005 program. | 9 | * 2005 program. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * tmpfs vnode interface. | 34 | * tmpfs vnode interface. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.136 2020/04/23 21:47:08 ad Exp $"); | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/dirent.h> | 41 | #include <sys/dirent.h> | |
42 | #include <sys/fcntl.h> | 42 | #include <sys/fcntl.h> | |
43 | #include <sys/event.h> | 43 | #include <sys/event.h> | |
44 | #include <sys/malloc.h> | 44 | #include <sys/malloc.h> | |
45 | #include <sys/namei.h> | 45 | #include <sys/namei.h> | |
46 | #include <sys/stat.h> | 46 | #include <sys/stat.h> | |
47 | #include <sys/uio.h> | 47 | #include <sys/uio.h> | |
48 | #include <sys/unistd.h> | 48 | #include <sys/unistd.h> | |
49 | #include <sys/vnode.h> | 49 | #include <sys/vnode.h> | |
50 | #include <sys/lockf.h> | 50 | #include <sys/lockf.h> | |
51 | #include <sys/kauth.h> | 51 | #include <sys/kauth.h> | |
@@ -536,27 +536,27 @@ tmpfs_read(void *v) | @@ -536,27 +536,27 @@ tmpfs_read(void *v) | |||
536 | error = 0; | 536 | error = 0; | |
537 | 537 | |||
538 | while (error == 0 && uio->uio_resid > 0) { | 538 | while (error == 0 && uio->uio_resid > 0) { | |
539 | vsize_t len; | 539 | vsize_t len; | |
540 | 540 | |||
541 | if (node->tn_size <= uio->uio_offset) { | 541 | if (node->tn_size <= uio->uio_offset) { | |
542 | break; | 542 | break; | |
543 | } | 543 | } | |
544 | len = MIN(node->tn_size - uio->uio_offset, uio->uio_resid); | 544 | len = MIN(node->tn_size - uio->uio_offset, uio->uio_resid); | |
545 | if (len == 0) { | 545 | if (len == 0) { | |
546 | break; | 546 | break; | |
547 | } | 547 | } | |
548 | error = ubc_uiomove(uobj, uio, len, IO_ADV_DECODE(ioflag), | 548 | error = ubc_uiomove(uobj, uio, len, IO_ADV_DECODE(ioflag), | |
549 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 549 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
550 | } | 550 | } | |
551 | 551 | |||
552 | tmpfs_update(vp, TMPFS_UPDATE_ATIME); | 552 | tmpfs_update(vp, TMPFS_UPDATE_ATIME); | |
553 | return error; | 553 | return error; | |
554 | } | 554 | } | |
555 | 555 | |||
556 | int | 556 | int | |
557 | tmpfs_write(void *v) | 557 | tmpfs_write(void *v) | |
558 | { | 558 | { | |
559 | struct vop_write_args /* { | 559 | struct vop_write_args /* { | |
560 | struct vnode *a_vp; | 560 | struct vnode *a_vp; | |
561 | struct uio *a_uio; | 561 | struct uio *a_uio; | |
562 | int a_ioflag; | 562 | int a_ioflag; | |
@@ -598,27 +598,27 @@ tmpfs_write(void *v) | @@ -598,27 +598,27 @@ tmpfs_write(void *v) | |||
598 | goto out; | 598 | goto out; | |
599 | } | 599 | } | |
600 | 600 | |||
601 | uobj = node->tn_spec.tn_reg.tn_aobj; | 601 | uobj = node->tn_spec.tn_reg.tn_aobj; | |
602 | error = 0; | 602 | error = 0; | |
603 | while (error == 0 && uio->uio_resid > 0) { | 603 | while (error == 0 && uio->uio_resid > 0) { | |
604 | vsize_t len; | 604 | vsize_t len; | |
605 | 605 | |||
606 | len = MIN(node->tn_size - uio->uio_offset, uio->uio_resid); | 606 | len = MIN(node->tn_size - uio->uio_offset, uio->uio_resid); | |
607 | if (len == 0) { | 607 | if (len == 0) { | |
608 | break; | 608 | break; | |
609 | } | 609 | } | |
610 | error = ubc_uiomove(uobj, uio, len, IO_ADV_DECODE(ioflag), | 610 | error = ubc_uiomove(uobj, uio, len, IO_ADV_DECODE(ioflag), | |
611 | UBC_WRITE | UBC_UNMAP_FLAG(vp)); | 611 | UBC_WRITE | UBC_VNODE_FLAGS(vp)); | |
612 | } | 612 | } | |
613 | if (error) { | 613 | if (error) { | |
614 | (void)tmpfs_reg_resize(vp, oldsize); | 614 | (void)tmpfs_reg_resize(vp, oldsize); | |
615 | } | 615 | } | |
616 | 616 | |||
617 | tmpfs_update(vp, TMPFS_UPDATE_MTIME | TMPFS_UPDATE_CTIME); | 617 | tmpfs_update(vp, TMPFS_UPDATE_MTIME | TMPFS_UPDATE_CTIME); | |
618 | VN_KNOTE(vp, NOTE_WRITE); | 618 | VN_KNOTE(vp, NOTE_WRITE); | |
619 | out: | 619 | out: | |
620 | if (error) { | 620 | if (error) { | |
621 | KASSERT(oldsize == node->tn_size); | 621 | KASSERT(oldsize == node->tn_size); | |
622 | } else { | 622 | } else { | |
623 | KASSERT(uio->uio_resid == 0); | 623 | KASSERT(uio->uio_resid == 0); | |
624 | } | 624 | } |
--- src/sys/fs/udf/udf_allocation.c 2018/10/14 17:37:40 1.40
+++ src/sys/fs/udf/udf_allocation.c 2020/04/23 21:47:08 1.41
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: udf_allocation.c,v 1.40 2018/10/14 17:37:40 jdolecek Exp $ */ | 1 | /* $NetBSD: udf_allocation.c,v 1.41 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2006, 2008 Reinoud Zandijk | 4 | * Copyright (c) 2006, 2008 Reinoud Zandijk | |
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. | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | * | 26 | * | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #ifndef lint | 30 | #ifndef lint | |
31 | __KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.40 2018/10/14 17:37:40 jdolecek Exp $"); | 31 | __KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.41 2020/04/23 21:47:08 ad Exp $"); | |
32 | #endif /* not lint */ | 32 | #endif /* not lint */ | |
33 | 33 | |||
34 | 34 | |||
35 | #if defined(_KERNEL_OPT) | 35 | #if defined(_KERNEL_OPT) | |
36 | #include "opt_compat_netbsd.h" | 36 | #include "opt_compat_netbsd.h" | |
37 | #endif | 37 | #endif | |
38 | 38 | |||
39 | /* TODO strip */ | 39 | /* TODO strip */ | |
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/sysctl.h> | 42 | #include <sys/sysctl.h> | |
43 | #include <sys/namei.h> | 43 | #include <sys/namei.h> | |
44 | #include <sys/proc.h> | 44 | #include <sys/proc.h> | |
@@ -2668,27 +2668,27 @@ udf_grow_node(struct udf_node *udf_node, | @@ -2668,27 +2668,27 @@ udf_grow_node(struct udf_node *udf_node, | |||
2668 | efe->obj_size = udf_rw64(objsize); | 2668 | efe->obj_size = udf_rw64(objsize); | |
2669 | efe->l_ad = udf_rw32(l_ad); | 2669 | efe->l_ad = udf_rw32(l_ad); | |
2670 | efe->tag.desc_crc_len = udf_rw16(crclen); | 2670 | efe->tag.desc_crc_len = udf_rw16(crclen); | |
2671 | } | 2671 | } | |
2672 | error = 0; | 2672 | error = 0; | |
2673 | 2673 | |||
2674 | /* set new size for uvm */ | 2674 | /* set new size for uvm */ | |
2675 | uvm_vnp_setwritesize(vp, new_size); | 2675 | uvm_vnp_setwritesize(vp, new_size); | |
2676 | uvm_vnp_setsize(vp, new_size); | 2676 | uvm_vnp_setsize(vp, new_size); | |
2677 | 2677 | |||
2678 | #if 0 | 2678 | #if 0 | |
2679 | /* zero append space in buffer */ | 2679 | /* zero append space in buffer */ | |
2680 | ubc_zerorange(&vp->v_uobj, old_size, | 2680 | ubc_zerorange(&vp->v_uobj, old_size, | |
2681 | new_size - old_size, UBC_UNMAP_FLAG(vp)); | 2681 | new_size - old_size, UBC_VNODE_FLAGS(vp)); | |
2682 | #endif | 2682 | #endif | |
2683 | 2683 | |||
2684 | udf_node_sanity_check(udf_node, &new_inflen, &new_lbrec); | 2684 | udf_node_sanity_check(udf_node, &new_inflen, &new_lbrec); | |
2685 | 2685 | |||
2686 | /* unlock */ | 2686 | /* unlock */ | |
2687 | UDF_UNLOCK_NODE(udf_node, 0); | 2687 | UDF_UNLOCK_NODE(udf_node, 0); | |
2688 | 2688 | |||
2689 | KASSERT(new_inflen == orig_inflen + size_diff); | 2689 | KASSERT(new_inflen == orig_inflen + size_diff); | |
2690 | KASSERT(new_lbrec == orig_lbrec); | 2690 | KASSERT(new_lbrec == orig_lbrec); | |
2691 | KASSERT(new_lbrec == 0); | 2691 | KASSERT(new_lbrec == 0); | |
2692 | return 0; | 2692 | return 0; | |
2693 | } | 2693 | } | |
2694 | 2694 | |||
@@ -2774,27 +2774,27 @@ udf_grow_node(struct udf_node *udf_node, | @@ -2774,27 +2774,27 @@ udf_grow_node(struct udf_node *udf_node, | |||
2774 | len = udf_rw32(c_ad.len); | 2774 | len = udf_rw32(c_ad.len); | |
2775 | flags = UDF_EXT_FLAGS(len); | 2775 | flags = UDF_EXT_FLAGS(len); | |
2776 | len = UDF_EXT_LEN(len); | 2776 | len = UDF_EXT_LEN(len); | |
2777 | 2777 | |||
2778 | lastblock_grow = 0; | 2778 | lastblock_grow = 0; | |
2779 | if (len % lb_size > 0) { | 2779 | if (len % lb_size > 0) { | |
2780 | lastblock_grow = lb_size - (len % lb_size); | 2780 | lastblock_grow = lb_size - (len % lb_size); | |
2781 | lastblock_grow = MIN(size_diff, lastblock_grow); | 2781 | lastblock_grow = MIN(size_diff, lastblock_grow); | |
2782 | len += lastblock_grow; | 2782 | len += lastblock_grow; | |
2783 | c_ad.len = udf_rw32(len | flags); | 2783 | c_ad.len = udf_rw32(len | flags); | |
2784 | 2784 | |||
2785 | /* TODO zero appened space in buffer! */ | 2785 | /* TODO zero appened space in buffer! */ | |
2786 | /* using ubc_zerorange(&vp->v_uobj, old_size, */ | 2786 | /* using ubc_zerorange(&vp->v_uobj, old_size, */ | |
2787 | /* new_size - old_size, UBC_UNMAP_FLAG(vp)); ? */ | 2787 | /* new_size - old_size, UBC_VNODE_FLAGS(vp)); ? */ | |
2788 | } | 2788 | } | |
2789 | memset(&s_ad, 0, sizeof(struct long_ad)); | 2789 | memset(&s_ad, 0, sizeof(struct long_ad)); | |
2790 | 2790 | |||
2791 | /* size_diff can be bigger than allowed, so grow in chunks */ | 2791 | /* size_diff can be bigger than allowed, so grow in chunks */ | |
2792 | append_len = size_diff - lastblock_grow; | 2792 | append_len = size_diff - lastblock_grow; | |
2793 | while (append_len > 0) { | 2793 | while (append_len > 0) { | |
2794 | chunk = MIN(append_len, max_len); | 2794 | chunk = MIN(append_len, max_len); | |
2795 | s_ad.len = udf_rw32(chunk | UDF_EXT_FREE); | 2795 | s_ad.len = udf_rw32(chunk | UDF_EXT_FREE); | |
2796 | s_ad.loc.part_num = udf_rw16(0); | 2796 | s_ad.loc.part_num = udf_rw16(0); | |
2797 | s_ad.loc.lb_num = udf_rw32(0); | 2797 | s_ad.loc.lb_num = udf_rw32(0); | |
2798 | 2798 | |||
2799 | if (udf_ads_merge(max_len, lb_size, &c_ad, &s_ad)) { | 2799 | if (udf_ads_merge(max_len, lb_size, &c_ad, &s_ad)) { | |
2800 | /* not mergable (anymore) */ | 2800 | /* not mergable (anymore) */ | |
@@ -2945,27 +2945,27 @@ udf_shrink_node(struct udf_node *udf_nod | @@ -2945,27 +2945,27 @@ udf_shrink_node(struct udf_node *udf_nod | |||
2945 | efe->inf_len = udf_rw64(inflen); | 2945 | efe->inf_len = udf_rw64(inflen); | |
2946 | efe->obj_size = udf_rw64(objsize); | 2946 | efe->obj_size = udf_rw64(objsize); | |
2947 | efe->l_ad = udf_rw32(l_ad); | 2947 | efe->l_ad = udf_rw32(l_ad); | |
2948 | efe->tag.desc_crc_len = udf_rw16(crclen); | 2948 | efe->tag.desc_crc_len = udf_rw16(crclen); | |
2949 | } | 2949 | } | |
2950 | error = 0; | 2950 | error = 0; | |
2951 | 2951 | |||
2952 | /* clear the space in the descriptor */ | 2952 | /* clear the space in the descriptor */ | |
2953 | KASSERT(old_size >= new_size); | 2953 | KASSERT(old_size >= new_size); | |
2954 | memset(data_pos + new_size, 0, old_size - new_size); | 2954 | memset(data_pos + new_size, 0, old_size - new_size); | |
2955 | 2955 | |||
2956 | /* TODO zero appened space in buffer! */ | 2956 | /* TODO zero appened space in buffer! */ | |
2957 | /* using ubc_zerorange(&vp->v_uobj, old_size, */ | 2957 | /* using ubc_zerorange(&vp->v_uobj, old_size, */ | |
2958 | /* old_size - new_size, UBC_UNMAP_FLAG(vp)); ? */ | 2958 | /* old_size - new_size, UBC_VNODE_FLAGS(vp)); ? */ | |
2959 | 2959 | |||
2960 | /* set new size for uvm */ | 2960 | /* set new size for uvm */ | |
2961 | uvm_vnp_setsize(vp, new_size); | 2961 | uvm_vnp_setsize(vp, new_size); | |
2962 | 2962 | |||
2963 | udf_node_sanity_check(udf_node, &new_inflen, &new_lbrec); | 2963 | udf_node_sanity_check(udf_node, &new_inflen, &new_lbrec); | |
2964 | UDF_UNLOCK_NODE(udf_node, 0); | 2964 | UDF_UNLOCK_NODE(udf_node, 0); | |
2965 | 2965 | |||
2966 | KASSERT(new_inflen == orig_inflen - size_diff); | 2966 | KASSERT(new_inflen == orig_inflen - size_diff); | |
2967 | KASSERT(new_lbrec == orig_lbrec); | 2967 | KASSERT(new_lbrec == orig_lbrec); | |
2968 | KASSERT(new_lbrec == 0); | 2968 | KASSERT(new_lbrec == 0); | |
2969 | 2969 | |||
2970 | return 0; | 2970 | return 0; | |
2971 | } | 2971 | } |
--- src/sys/fs/udf/udf_vnops.c 2020/04/14 11:45:42 1.111
+++ src/sys/fs/udf/udf_vnops.c 2020/04/23 21:47:08 1.112
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: udf_vnops.c,v 1.111 2020/04/14 11:45:42 reinoud Exp $ */ | 1 | /* $NetBSD: udf_vnops.c,v 1.112 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2006, 2008 Reinoud Zandijk | 4 | * Copyright (c) 2006, 2008 Reinoud Zandijk | |
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. | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | * | 26 | * | |
27 | * Generic parts are derived from software contributed to The NetBSD Foundation | 27 | * Generic parts are derived from software contributed to The NetBSD Foundation | |
28 | * by Julio M. Merino Vidal, developed as part of Google's Summer of Code | 28 | * by Julio M. Merino Vidal, developed as part of Google's Summer of Code | |
29 | * 2005 program. | 29 | * 2005 program. | |
30 | * | 30 | * | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | #ifndef lint | 34 | #ifndef lint | |
35 | __KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.111 2020/04/14 11:45:42 reinoud Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.112 2020/04/23 21:47:08 ad Exp $"); | |
36 | #endif /* not lint */ | 36 | #endif /* not lint */ | |
37 | 37 | |||
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/namei.h> | 41 | #include <sys/namei.h> | |
42 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ | 42 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/file.h> /* define FWRITE ... */ | 44 | #include <sys/file.h> /* define FWRITE ... */ | |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> | |
46 | #include <sys/buf.h> | 46 | #include <sys/buf.h> | |
47 | #include <sys/proc.h> | 47 | #include <sys/proc.h> | |
48 | #include <sys/mount.h> | 48 | #include <sys/mount.h> | |
@@ -238,27 +238,27 @@ udf_read(void *v) | @@ -238,27 +238,27 @@ udf_read(void *v) | |||
238 | error = 0; | 238 | error = 0; | |
239 | while (uio->uio_resid > 0) { | 239 | while (uio->uio_resid > 0) { | |
240 | /* reached end? */ | 240 | /* reached end? */ | |
241 | if (file_size <= uio->uio_offset) | 241 | if (file_size <= uio->uio_offset) | |
242 | break; | 242 | break; | |
243 | 243 | |||
244 | /* maximise length to file extremity */ | 244 | /* maximise length to file extremity */ | |
245 | len = MIN(file_size - uio->uio_offset, uio->uio_resid); | 245 | len = MIN(file_size - uio->uio_offset, uio->uio_resid); | |
246 | if (len == 0) | 246 | if (len == 0) | |
247 | break; | 247 | break; | |
248 | 248 | |||
249 | /* ubc, here we come, prepare to trap */ | 249 | /* ubc, here we come, prepare to trap */ | |
250 | error = ubc_uiomove(uobj, uio, len, advice, | 250 | error = ubc_uiomove(uobj, uio, len, advice, | |
251 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 251 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
252 | if (error) | 252 | if (error) | |
253 | break; | 253 | break; | |
254 | } | 254 | } | |
255 | 255 | |||
256 | /* note access time unless not requested */ | 256 | /* note access time unless not requested */ | |
257 | if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) { | 257 | if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) { | |
258 | udf_node->i_flags |= IN_ACCESS; | 258 | udf_node->i_flags |= IN_ACCESS; | |
259 | if ((ioflag & IO_SYNC) == IO_SYNC) { | 259 | if ((ioflag & IO_SYNC) == IO_SYNC) { | |
260 | int uerror; | 260 | int uerror; | |
261 | 261 | |||
262 | uerror = udf_update(vp, NULL, NULL, NULL, UPDATE_WAIT); | 262 | uerror = udf_update(vp, NULL, NULL, NULL, UPDATE_WAIT); | |
263 | if (error == 0) | 263 | if (error == 0) | |
264 | error = uerror; | 264 | error = uerror; | |
@@ -356,27 +356,27 @@ udf_write(void *v) | @@ -356,27 +356,27 @@ udf_write(void *v) | |||
356 | /* maximise length to file extremity */ | 356 | /* maximise length to file extremity */ | |
357 | len = MIN(file_size - uio->uio_offset, uio->uio_resid); | 357 | len = MIN(file_size - uio->uio_offset, uio->uio_resid); | |
358 | if (len == 0) | 358 | if (len == 0) | |
359 | break; | 359 | break; | |
360 | 360 | |||
361 | genfs_node_wrlock(vp); | 361 | genfs_node_wrlock(vp); | |
362 | error = GOP_ALLOC(vp, uio->uio_offset, len, aflag, cred); | 362 | error = GOP_ALLOC(vp, uio->uio_offset, len, aflag, cred); | |
363 | genfs_node_unlock(vp); | 363 | genfs_node_unlock(vp); | |
364 | if (error) | 364 | if (error) | |
365 | break; | 365 | break; | |
366 | 366 | |||
367 | /* ubc, here we come, prepare to trap */ | 367 | /* ubc, here we come, prepare to trap */ | |
368 | error = ubc_uiomove(uobj, uio, len, advice, | 368 | error = ubc_uiomove(uobj, uio, len, advice, | |
369 | UBC_WRITE | UBC_UNMAP_FLAG(vp)); | 369 | UBC_WRITE | UBC_VNODE_FLAGS(vp)); | |
370 | if (error) | 370 | if (error) | |
371 | break; | 371 | break; | |
372 | 372 | |||
373 | /* | 373 | /* | |
374 | * flush what we just wrote if necessary. | 374 | * flush what we just wrote if necessary. | |
375 | * XXXUBC simplistic async flushing. | 375 | * XXXUBC simplistic async flushing. | |
376 | * | 376 | * | |
377 | * Directories are excluded since its file data that we want | 377 | * Directories are excluded since its file data that we want | |
378 | * to purge. | 378 | * to purge. | |
379 | */ | 379 | */ | |
380 | if ((vp->v_type != VDIR) && | 380 | if ((vp->v_type != VDIR) && | |
381 | (old_offset >> 16 != uio->uio_offset >> 16)) { | 381 | (old_offset >> 16 != uio->uio_offset >> 16)) { | |
382 | rw_enter(vp->v_uobj.vmobjlock, RW_WRITER); | 382 | rw_enter(vp->v_uobj.vmobjlock, RW_WRITER); |
--- src/sys/fs/v7fs/v7fs_vnops.c 2020/04/13 19:23:18 1.28
+++ src/sys/fs/v7fs/v7fs_vnops.c 2020/04/23 21:47:08 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: v7fs_vnops.c,v 1.28 2020/04/13 19:23:18 ad Exp $ */ | 1 | /* $NetBSD: v7fs_vnops.c,v 1.29 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by UCHIYAMA Yasushi. | 8 | * by UCHIYAMA Yasushi. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.28 2020/04/13 19:23:18 ad Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.29 2020/04/23 21:47:08 ad Exp $"); | |
34 | #if defined _KERNEL_OPT | 34 | #if defined _KERNEL_OPT | |
35 | #include "opt_v7fs.h" | 35 | #include "opt_v7fs.h" | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/kernel.h> | 39 | #include <sys/kernel.h> | |
40 | #include <sys/resource.h> | 40 | #include <sys/resource.h> | |
41 | #include <sys/vnode.h> | 41 | #include <sys/vnode.h> | |
42 | #include <sys/namei.h> | 42 | #include <sys/namei.h> | |
43 | #include <sys/dirent.h> | 43 | #include <sys/dirent.h> | |
44 | #include <sys/kmem.h> | 44 | #include <sys/kmem.h> | |
45 | #include <sys/lockf.h> | 45 | #include <sys/lockf.h> | |
46 | #include <sys/unistd.h> | 46 | #include <sys/unistd.h> | |
@@ -582,27 +582,27 @@ v7fs_read(void *v) | @@ -582,27 +582,27 @@ v7fs_read(void *v) | |||
582 | struct v7fs_node *v7node = vp->v_data; | 582 | struct v7fs_node *v7node = vp->v_data; | |
583 | struct v7fs_inode *inode = &v7node->inode; | 583 | struct v7fs_inode *inode = &v7node->inode; | |
584 | vsize_t sz, filesz = v7fs_inode_filesize(inode); | 584 | vsize_t sz, filesz = v7fs_inode_filesize(inode); | |
585 | const int advice = IO_ADV_DECODE(a->a_ioflag); | 585 | const int advice = IO_ADV_DECODE(a->a_ioflag); | |
586 | int error = 0; | 586 | int error = 0; | |
587 | 587 | |||
588 | DPRINTF("type=%d inode=%d\n", vp->v_type, v7node->inode.inode_number); | 588 | DPRINTF("type=%d inode=%d\n", vp->v_type, v7node->inode.inode_number); | |
589 | 589 | |||
590 | while (uio->uio_resid > 0) { | 590 | while (uio->uio_resid > 0) { | |
591 | if ((sz = MIN(filesz - uio->uio_offset, uio->uio_resid)) == 0) | 591 | if ((sz = MIN(filesz - uio->uio_offset, uio->uio_resid)) == 0) | |
592 | break; | 592 | break; | |
593 | 593 | |||
594 | error = ubc_uiomove(&vp->v_uobj, uio, sz, advice, UBC_READ | | 594 | error = ubc_uiomove(&vp->v_uobj, uio, sz, advice, UBC_READ | | |
595 | UBC_PARTIALOK | UBC_UNMAP_FLAG(v)); | 595 | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
596 | if (error) { | 596 | if (error) { | |
597 | break; | 597 | break; | |
598 | } | 598 | } | |
599 | DPRINTF("read %zubyte\n", sz); | 599 | DPRINTF("read %zubyte\n", sz); | |
600 | } | 600 | } | |
601 | v7node->update_atime = true; | 601 | v7node->update_atime = true; | |
602 | 602 | |||
603 | return error; | 603 | return error; | |
604 | } | 604 | } | |
605 | 605 | |||
606 | int | 606 | int | |
607 | v7fs_write(void *v) | 607 | v7fs_write(void *v) | |
608 | { | 608 | { | |
@@ -634,27 +634,27 @@ v7fs_write(void *v) | @@ -634,27 +634,27 @@ v7fs_write(void *v) | |||
634 | 634 | |||
635 | /* If write region is over filesize, expand. */ | 635 | /* If write region is over filesize, expand. */ | |
636 | size_t newsize= uio->uio_offset + uio->uio_resid; | 636 | size_t newsize= uio->uio_offset + uio->uio_resid; | |
637 | ssize_t expand = newsize - sz; | 637 | ssize_t expand = newsize - sz; | |
638 | if (expand > 0) { | 638 | if (expand > 0) { | |
639 | if ((error = v7fs_datablock_expand(fs, inode, expand))) | 639 | if ((error = v7fs_datablock_expand(fs, inode, expand))) | |
640 | return error; | 640 | return error; | |
641 | uvm_vnp_setsize(vp, newsize); | 641 | uvm_vnp_setsize(vp, newsize); | |
642 | } | 642 | } | |
643 | 643 | |||
644 | while (uio->uio_resid > 0) { | 644 | while (uio->uio_resid > 0) { | |
645 | sz = uio->uio_resid; | 645 | sz = uio->uio_resid; | |
646 | if ((error = ubc_uiomove(&vp->v_uobj, uio, sz, advice, | 646 | if ((error = ubc_uiomove(&vp->v_uobj, uio, sz, advice, | |
647 | UBC_WRITE | UBC_UNMAP_FLAG(v)))) | 647 | UBC_WRITE | UBC_VNODE_FLAGS(vp)))) | |
648 | break; | 648 | break; | |
649 | DPRINTF("write %zubyte\n", sz); | 649 | DPRINTF("write %zubyte\n", sz); | |
650 | } | 650 | } | |
651 | v7node->update_mtime = true; | 651 | v7node->update_mtime = true; | |
652 | 652 | |||
653 | return error; | 653 | return error; | |
654 | } | 654 | } | |
655 | 655 | |||
656 | int | 656 | int | |
657 | v7fs_fsync(void *v) | 657 | v7fs_fsync(void *v) | |
658 | { | 658 | { | |
659 | struct vop_fsync_args /* { | 659 | struct vop_fsync_args /* { | |
660 | struct vnode *a_vp; | 660 | struct vnode *a_vp; |
--- src/sys/nfs/nfs_bio.c 2020/03/22 18:32:42 1.195
+++ src/sys/nfs/nfs_bio.c 2020/04/23 21:47:08 1.196
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: nfs_bio.c,v 1.195 2020/03/22 18:32:42 ad Exp $ */ | 1 | /* $NetBSD: nfs_bio.c,v 1.196 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1989, 1993 | 4 | * Copyright (c) 1989, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Rick Macklem at The University of Guelph. | 8 | * Rick Macklem at The University of Guelph. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | * SUCH DAMAGE. | 32 | * SUCH DAMAGE. | |
33 | * | 33 | * | |
34 | * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 | 34 | * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.195 2020/03/22 18:32:42 ad Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.196 2020/04/23 21:47:08 ad Exp $"); | |
39 | 39 | |||
40 | #ifdef _KERNEL_OPT | 40 | #ifdef _KERNEL_OPT | |
41 | #include "opt_nfs.h" | 41 | #include "opt_nfs.h" | |
42 | #include "opt_ddb.h" | 42 | #include "opt_ddb.h" | |
43 | #endif | 43 | #endif | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/resourcevar.h> | 47 | #include <sys/resourcevar.h> | |
48 | #include <sys/signalvar.h> | 48 | #include <sys/signalvar.h> | |
49 | #include <sys/proc.h> | 49 | #include <sys/proc.h> | |
50 | #include <sys/buf.h> | 50 | #include <sys/buf.h> | |
51 | #include <sys/vnode.h> | 51 | #include <sys/vnode.h> | |
@@ -148,27 +148,27 @@ nfs_bioread(struct vnode *vp, struct uio | @@ -148,27 +148,27 @@ nfs_bioread(struct vnode *vp, struct uio | |||
148 | 148 | |||
149 | advice = IO_ADV_DECODE(ioflag); | 149 | advice = IO_ADV_DECODE(ioflag); | |
150 | error = 0; | 150 | error = 0; | |
151 | while (uio->uio_resid > 0) { | 151 | while (uio->uio_resid > 0) { | |
152 | vsize_t bytelen; | 152 | vsize_t bytelen; | |
153 | 153 | |||
154 | nfs_delayedtruncate(vp); | 154 | nfs_delayedtruncate(vp); | |
155 | if (np->n_size <= uio->uio_offset) { | 155 | if (np->n_size <= uio->uio_offset) { | |
156 | break; | 156 | break; | |
157 | } | 157 | } | |
158 | bytelen = | 158 | bytelen = | |
159 | MIN(np->n_size - uio->uio_offset, uio->uio_resid); | 159 | MIN(np->n_size - uio->uio_offset, uio->uio_resid); | |
160 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 160 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
161 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 161 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
162 | if (error) { | 162 | if (error) { | |
163 | /* | 163 | /* | |
164 | * XXXkludge | 164 | * XXXkludge | |
165 | * the file has been truncated on the server. | 165 | * the file has been truncated on the server. | |
166 | * there isn't much we can do. | 166 | * there isn't much we can do. | |
167 | */ | 167 | */ | |
168 | if (uio->uio_offset >= np->n_size) { | 168 | if (uio->uio_offset >= np->n_size) { | |
169 | /* end of file */ | 169 | /* end of file */ | |
170 | error = 0; | 170 | error = 0; | |
171 | } else { | 171 | } else { | |
172 | break; | 172 | break; | |
173 | } | 173 | } | |
174 | } | 174 | } | |
@@ -521,27 +521,27 @@ nfs_write(void *v) | @@ -521,27 +521,27 @@ nfs_write(void *v) | |||
521 | bytelen = trunc_page(bytelen); | 521 | bytelen = trunc_page(bytelen); | |
522 | overwrite = true; | 522 | overwrite = true; | |
523 | } else if ((bytelen & PAGE_MASK) == 0 && | 523 | } else if ((bytelen & PAGE_MASK) == 0 && | |
524 | uio->uio_offset >= vp->v_size) { | 524 | uio->uio_offset >= vp->v_size) { | |
525 | overwrite = true; | 525 | overwrite = true; | |
526 | } | 526 | } | |
527 | } | 527 | } | |
528 | if (vp->v_size < uio->uio_offset + bytelen) { | 528 | if (vp->v_size < uio->uio_offset + bytelen) { | |
529 | uvm_vnp_setwritesize(vp, uio->uio_offset + bytelen); | 529 | uvm_vnp_setwritesize(vp, uio->uio_offset + bytelen); | |
530 | } | 530 | } | |
531 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | 531 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | |
532 | UVM_ADV_RANDOM, UBC_WRITE | UBC_PARTIALOK | | 532 | UVM_ADV_RANDOM, UBC_WRITE | UBC_PARTIALOK | | |
533 | (overwrite ? UBC_FAULTBUSY : 0) | | 533 | (overwrite ? UBC_FAULTBUSY : 0) | | |
534 | UBC_UNMAP_FLAG(vp)); | 534 | UBC_VNODE_FLAGS(vp)); | |
535 | if (error) { | 535 | if (error) { | |
536 | uvm_vnp_setwritesize(vp, vp->v_size); | 536 | uvm_vnp_setwritesize(vp, vp->v_size); | |
537 | if (overwrite && np->n_size != oldsize) { | 537 | if (overwrite && np->n_size != oldsize) { | |
538 | /* | 538 | /* | |
539 | * backout size and free pages past eof. | 539 | * backout size and free pages past eof. | |
540 | */ | 540 | */ | |
541 | np->n_size = oldsize; | 541 | np->n_size = oldsize; | |
542 | rw_enter(vp->v_uobj.vmobjlock, RW_WRITER); | 542 | rw_enter(vp->v_uobj.vmobjlock, RW_WRITER); | |
543 | (void)VOP_PUTPAGES(vp, round_page(vp->v_size), | 543 | (void)VOP_PUTPAGES(vp, round_page(vp->v_size), | |
544 | 0, PGO_SYNCIO | PGO_FREE); | 544 | 0, PGO_SYNCIO | PGO_FREE); | |
545 | } | 545 | } | |
546 | break; | 546 | break; | |
547 | } | 547 | } |
--- src/sys/rump/librump/rumpvfs/rumpfs.c 2020/04/13 19:23:20 1.156
+++ src/sys/rump/librump/rumpvfs/rumpfs.c 2020/04/23 21:47:08 1.157
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rumpfs.c,v 1.156 2020/04/13 19:23:20 ad Exp $ */ | 1 | /* $NetBSD: rumpfs.c,v 1.157 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved. | 4 | * Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -16,27 +16,27 @@ | @@ -16,27 +16,27 @@ | |||
16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
25 | * SUCH DAMAGE. | 25 | * SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | 27 | |||
28 | #include <sys/cdefs.h> | 28 | #include <sys/cdefs.h> | |
29 | __KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.156 2020/04/13 19:23:20 ad Exp $"); | 29 | __KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.157 2020/04/23 21:47:08 ad Exp $"); | |
30 | 30 | |||
31 | #include <sys/param.h> | 31 | #include <sys/param.h> | |
32 | #include <sys/atomic.h> | 32 | #include <sys/atomic.h> | |
33 | #include <sys/buf.h> | 33 | #include <sys/buf.h> | |
34 | #include <sys/dirent.h> | 34 | #include <sys/dirent.h> | |
35 | #include <sys/errno.h> | 35 | #include <sys/errno.h> | |
36 | #include <sys/filedesc.h> | 36 | #include <sys/filedesc.h> | |
37 | #include <sys/fcntl.h> | 37 | #include <sys/fcntl.h> | |
38 | #include <sys/kauth.h> | 38 | #include <sys/kauth.h> | |
39 | #include <sys/malloc.h> | 39 | #include <sys/malloc.h> | |
40 | #include <sys/module.h> | 40 | #include <sys/module.h> | |
41 | #include <sys/mount.h> | 41 | #include <sys/mount.h> | |
42 | #include <sys/namei.h> | 42 | #include <sys/namei.h> | |
@@ -1393,27 +1393,27 @@ rump_vop_read(void *v) | @@ -1393,27 +1393,27 @@ rump_vop_read(void *v) | |||
1393 | /* et op? */ | 1393 | /* et op? */ | |
1394 | if (rn->rn_flags & RUMPNODE_ET_PHONE_HOST) | 1394 | if (rn->rn_flags & RUMPNODE_ET_PHONE_HOST) | |
1395 | return etread(rn, uio); | 1395 | return etread(rn, uio); | |
1396 | 1396 | |||
1397 | getnanotime(&ts); | 1397 | getnanotime(&ts); | |
1398 | (void)rumpfs_update(RUMPFS_ACCESS, vp, &ts, &ts, &ts); | 1398 | (void)rumpfs_update(RUMPFS_ACCESS, vp, &ts, &ts, &ts); | |
1399 | 1399 | |||
1400 | /* otherwise, it's off to ubc with us */ | 1400 | /* otherwise, it's off to ubc with us */ | |
1401 | while (uio->uio_resid > 0) { | 1401 | while (uio->uio_resid > 0) { | |
1402 | chunk = MIN(uio->uio_resid, (off_t)rn->rn_dlen-uio->uio_offset); | 1402 | chunk = MIN(uio->uio_resid, (off_t)rn->rn_dlen-uio->uio_offset); | |
1403 | if (chunk == 0) | 1403 | if (chunk == 0) | |
1404 | break; | 1404 | break; | |
1405 | error = ubc_uiomove(&vp->v_uobj, uio, chunk, advice, | 1405 | error = ubc_uiomove(&vp->v_uobj, uio, chunk, advice, | |
1406 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 1406 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
1407 | if (error) | 1407 | if (error) | |
1408 | break; | 1408 | break; | |
1409 | } | 1409 | } | |
1410 | 1410 | |||
1411 | return error; | 1411 | return error; | |
1412 | } | 1412 | } | |
1413 | 1413 | |||
1414 | static int | 1414 | static int | |
1415 | etwrite(struct rumpfs_node *rn, struct uio *uio) | 1415 | etwrite(struct rumpfs_node *rn, struct uio *uio) | |
1416 | { | 1416 | { | |
1417 | struct rumpuser_iovec iov; | 1417 | struct rumpuser_iovec iov; | |
1418 | uint8_t *buf; | 1418 | uint8_t *buf; | |
1419 | size_t bufsize, n; | 1419 | size_t bufsize, n; | |
@@ -1495,27 +1495,27 @@ rump_vop_write(void *v) | @@ -1495,27 +1495,27 @@ rump_vop_write(void *v) | |||
1495 | memset(rn->rn_data, 0, newlen); | 1495 | memset(rn->rn_data, 0, newlen); | |
1496 | if (oldlen > 0) | 1496 | if (oldlen > 0) | |
1497 | memcpy(rn->rn_data, olddata, oldlen); | 1497 | memcpy(rn->rn_data, olddata, oldlen); | |
1498 | allocd = true; | 1498 | allocd = true; | |
1499 | uvm_vnp_setsize(vp, newlen); | 1499 | uvm_vnp_setsize(vp, newlen); | |
1500 | } | 1500 | } | |
1501 | 1501 | |||
1502 | /* ok, we have enough stooorage. write */ | 1502 | /* ok, we have enough stooorage. write */ | |
1503 | while (uio->uio_resid > 0) { | 1503 | while (uio->uio_resid > 0) { | |
1504 | chunk = MIN(uio->uio_resid, (off_t)rn->rn_dlen-uio->uio_offset); | 1504 | chunk = MIN(uio->uio_resid, (off_t)rn->rn_dlen-uio->uio_offset); | |
1505 | if (chunk == 0) | 1505 | if (chunk == 0) | |
1506 | break; | 1506 | break; | |
1507 | error = ubc_uiomove(&vp->v_uobj, uio, chunk, advice, | 1507 | error = ubc_uiomove(&vp->v_uobj, uio, chunk, advice, | |
1508 | UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 1508 | UBC_WRITE | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
1509 | if (error) | 1509 | if (error) | |
1510 | break; | 1510 | break; | |
1511 | } | 1511 | } | |
1512 | 1512 | |||
1513 | if (allocd) { | 1513 | if (allocd) { | |
1514 | if (error) { | 1514 | if (error) { | |
1515 | rump_hyperfree(rn->rn_data, newlen); | 1515 | rump_hyperfree(rn->rn_data, newlen); | |
1516 | rn->rn_data = olddata; | 1516 | rn->rn_data = olddata; | |
1517 | rn->rn_dlen = oldlen; | 1517 | rn->rn_dlen = oldlen; | |
1518 | uvm_vnp_setsize(vp, oldlen); | 1518 | uvm_vnp_setsize(vp, oldlen); | |
1519 | } else { | 1519 | } else { | |
1520 | if ((rn->rn_flags & RUMPNODE_EXTSTORAGE) == 0) { | 1520 | if ((rn->rn_flags & RUMPNODE_EXTSTORAGE) == 0) { | |
1521 | rump_hyperfree(olddata, oldlen); | 1521 | rump_hyperfree(olddata, oldlen); |
--- src/sys/ufs/chfs/chfs_subr.c 2019/12/31 13:07:13 1.11
+++ src/sys/ufs/chfs/chfs_subr.c 2020/04/23 21:47:08 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: chfs_subr.c,v 1.11 2019/12/31 13:07:13 ad Exp $ */ | 1 | /* $NetBSD: chfs_subr.c,v 1.12 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2010 Department of Software Engineering, | 4 | * Copyright (c) 2010 Department of Software Engineering, | |
5 | * University of Szeged, Hungary | 5 | * University of Szeged, Hungary | |
6 | * Copyright (C) 2010 Tamas Toth <ttoth@inf.u-szeged.hu> | 6 | * Copyright (C) 2010 Tamas Toth <ttoth@inf.u-szeged.hu> | |
7 | * Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org> | 7 | * Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org> | |
8 | * All rights reserved. | 8 | * All rights reserved. | |
9 | * | 9 | * | |
10 | * This code is derived from software contributed to The NetBSD Foundation | 10 | * This code is derived from software contributed to The NetBSD Foundation | |
11 | * by the Department of Software Engineering, University of Szeged, Hungary | 11 | * by the Department of Software Engineering, University of Szeged, Hungary | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -222,27 +222,27 @@ chfs_chsize(struct vnode *vp, u_quad_t s | @@ -222,27 +222,27 @@ chfs_chsize(struct vnode *vp, u_quad_t s | |||
222 | 222 | |||
223 | mutex_enter(&chmp->chm_lock_mountfields); | 223 | mutex_enter(&chmp->chm_lock_mountfields); | |
224 | 224 | |||
225 | if (ip->size < size) { | 225 | if (ip->size < size) { | |
226 | uvm_vnp_setsize(vp, size); | 226 | uvm_vnp_setsize(vp, size); | |
227 | chfs_set_vnode_size(vp, size); | 227 | chfs_set_vnode_size(vp, size); | |
228 | ip->iflag |= IN_CHANGE | IN_UPDATE; | 228 | ip->iflag |= IN_CHANGE | IN_UPDATE; | |
229 | 229 | |||
230 | mutex_exit(&chmp->chm_lock_mountfields); | 230 | mutex_exit(&chmp->chm_lock_mountfields); | |
231 | return 0; | 231 | return 0; | |
232 | } | 232 | } | |
233 | 233 | |||
234 | if (size != 0) { | 234 | if (size != 0) { | |
235 | ubc_zerorange(&vp->v_uobj, size, ip->size - size, UBC_UNMAP_FLAG(vp)); | 235 | ubc_zerorange(&vp->v_uobj, size, ip->size - size, UBC_VNODE_FLAGS(vp)); | |
236 | } | 236 | } | |
237 | 237 | |||
238 | /* drop unused fragments */ | 238 | /* drop unused fragments */ | |
239 | chfs_truncate_fragtree(ip->chmp, &ip->fragtree, size); | 239 | chfs_truncate_fragtree(ip->chmp, &ip->fragtree, size); | |
240 | 240 | |||
241 | uvm_vnp_setsize(vp, size); | 241 | uvm_vnp_setsize(vp, size); | |
242 | chfs_set_vnode_size(vp, size); | 242 | chfs_set_vnode_size(vp, size); | |
243 | ip->iflag |= IN_CHANGE | IN_UPDATE; | 243 | ip->iflag |= IN_CHANGE | IN_UPDATE; | |
244 | mutex_exit(&chmp->chm_lock_mountfields); | 244 | mutex_exit(&chmp->chm_lock_mountfields); | |
245 | return 0; | 245 | return 0; | |
246 | } | 246 | } | |
247 | 247 | |||
248 | /* | 248 | /* |
--- src/sys/ufs/chfs/chfs_vnops.c 2020/04/04 20:49:31 1.37
+++ src/sys/ufs/chfs/chfs_vnops.c 2020/04/23 21:47:08 1.38
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: chfs_vnops.c,v 1.37 2020/04/04 20:49:31 ad Exp $ */ | 1 | /* $NetBSD: chfs_vnops.c,v 1.38 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2010 Department of Software Engineering, | 4 | * Copyright (c) 2010 Department of Software Engineering, | |
5 | * University of Szeged, Hungary | 5 | * University of Szeged, Hungary | |
6 | * Copyright (C) 2010 Tamas Toth <ttoth@inf.u-szeged.hu> | 6 | * Copyright (C) 2010 Tamas Toth <ttoth@inf.u-szeged.hu> | |
7 | * Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org> | 7 | * Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org> | |
8 | * All rights reserved. | 8 | * All rights reserved. | |
9 | * | 9 | * | |
10 | * This code is derived from software contributed to The NetBSD Foundation | 10 | * This code is derived from software contributed to The NetBSD Foundation | |
11 | * by the Department of Software Engineering, University of Szeged, Hungary | 11 | * by the Department of Software Engineering, University of Szeged, Hungary | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -665,28 +665,27 @@ chfs_read(void *v) | @@ -665,28 +665,27 @@ chfs_read(void *v) | |||
665 | bytelen = 0; | 665 | bytelen = 0; | |
666 | if (usepc) { | 666 | if (usepc) { | |
667 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | 667 | const int advice = IO_ADV_DECODE(ap->a_ioflag); | |
668 | 668 | |||
669 | while (uio->uio_resid > 0) { | 669 | while (uio->uio_resid > 0) { | |
670 | if (ioflag & IO_DIRECT) { | 670 | if (ioflag & IO_DIRECT) { | |
671 | genfs_directio(vp, uio, ioflag); | 671 | genfs_directio(vp, uio, ioflag); | |
672 | } | 672 | } | |
673 | bytelen = MIN(ip->size - uio->uio_offset, | 673 | bytelen = MIN(ip->size - uio->uio_offset, | |
674 | uio->uio_resid); | 674 | uio->uio_resid); | |
675 | if (bytelen == 0) | 675 | if (bytelen == 0) | |
676 | break; | 676 | break; | |
677 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 677 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
678 | UBC_READ | UBC_PARTIALOK | | 678 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
679 | (UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0)); | |||
680 | if (error) | 679 | if (error) | |
681 | break; | 680 | break; | |
682 | 681 | |||
683 | } | 682 | } | |
684 | goto out; | 683 | goto out; | |
685 | } | 684 | } | |
686 | 685 | |||
687 | dbg("start reading\n"); | 686 | dbg("start reading\n"); | |
688 | for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) { | 687 | for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) { | |
689 | bytesinfile = ip->size - uio->uio_offset; | 688 | bytesinfile = ip->size - uio->uio_offset; | |
690 | if (bytesinfile <= 0) | 689 | if (bytesinfile <= 0) | |
691 | break; | 690 | break; | |
692 | lbn = chfs_lblkno(chmp, uio->uio_offset); | 691 | lbn = chfs_lblkno(chmp, uio->uio_offset); | |
@@ -923,27 +922,27 @@ chfs_write(void *v) | @@ -923,27 +922,27 @@ chfs_write(void *v) | |||
923 | genfs_node_wrlock(vp); | 922 | genfs_node_wrlock(vp); | |
924 | error = GOP_ALLOC(vp, uio->uio_offset, bytelen, | 923 | error = GOP_ALLOC(vp, uio->uio_offset, bytelen, | |
925 | aflag, cred); | 924 | aflag, cred); | |
926 | genfs_node_unlock(vp); | 925 | genfs_node_unlock(vp); | |
927 | if (error) | 926 | if (error) | |
928 | break; | 927 | break; | |
929 | ubc_flags |= UBC_FAULTBUSY; | 928 | ubc_flags |= UBC_FAULTBUSY; | |
930 | } | 929 | } | |
931 | 930 | |||
932 | /* | 931 | /* | |
933 | * copy the data. | 932 | * copy the data. | |
934 | */ | 933 | */ | |
935 | 934 | |||
936 | ubc_flags |= UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0; | 935 | ubc_flags |= UBC_VNODE_FLAGS(vp); | |
937 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | 936 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | |
938 | IO_ADV_DECODE(ioflag), ubc_flags); | 937 | IO_ADV_DECODE(ioflag), ubc_flags); | |
939 | 938 | |||
940 | /* | 939 | /* | |
941 | * update UVM's notion of the size now that we've | 940 | * update UVM's notion of the size now that we've | |
942 | * copied the data into the vnode's pages. | 941 | * copied the data into the vnode's pages. | |
943 | * | 942 | * | |
944 | * we should update the size even when uiomove failed. | 943 | * we should update the size even when uiomove failed. | |
945 | */ | 944 | */ | |
946 | 945 | |||
947 | if (vp->v_size < newoff) { | 946 | if (vp->v_size < newoff) { | |
948 | uvm_vnp_setsize(vp, newoff); | 947 | uvm_vnp_setsize(vp, newoff); | |
949 | extended = 1; | 948 | extended = 1; |
--- src/sys/ufs/ext2fs/ext2fs_inode.c 2017/05/26 14:34:20 1.88
+++ src/sys/ufs/ext2fs/ext2fs_inode.c 2020/04/23 21:47:08 1.89
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ext2fs_inode.c,v 1.88 2017/05/26 14:34:20 riastradh Exp $ */ | 1 | /* $NetBSD: ext2fs_inode.c,v 1.89 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1982, 1986, 1989, 1993 | 4 | * Copyright (c) 1982, 1986, 1989, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. 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. | |
@@ -50,27 +50,27 @@ | @@ -50,27 +50,27 @@ | |||
50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
57 | * | 57 | * | |
58 | * @(#)ffs_inode.c 8.8 (Berkeley) 10/19/94 | 58 | * @(#)ffs_inode.c 8.8 (Berkeley) 10/19/94 | |
59 | * Modified for ext2fs by Manuel Bouyer. | 59 | * Modified for ext2fs by Manuel Bouyer. | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | #include <sys/cdefs.h> | 62 | #include <sys/cdefs.h> | |
63 | __KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.88 2017/05/26 14:34:20 riastradh Exp $"); | 63 | __KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.89 2020/04/23 21:47:08 ad Exp $"); | |
64 | 64 | |||
65 | #include <sys/param.h> | 65 | #include <sys/param.h> | |
66 | #include <sys/systm.h> | 66 | #include <sys/systm.h> | |
67 | #include <sys/mount.h> | 67 | #include <sys/mount.h> | |
68 | #include <sys/proc.h> | 68 | #include <sys/proc.h> | |
69 | #include <sys/file.h> | 69 | #include <sys/file.h> | |
70 | #include <sys/buf.h> | 70 | #include <sys/buf.h> | |
71 | #include <sys/vnode.h> | 71 | #include <sys/vnode.h> | |
72 | #include <sys/kernel.h> | 72 | #include <sys/kernel.h> | |
73 | #include <sys/kmem.h> | 73 | #include <sys/kmem.h> | |
74 | #include <sys/trace.h> | 74 | #include <sys/trace.h> | |
75 | #include <sys/resourcevar.h> | 75 | #include <sys/resourcevar.h> | |
76 | #include <sys/kauth.h> | 76 | #include <sys/kauth.h> | |
@@ -350,27 +350,27 @@ ext2fs_truncate(struct vnode *ovp, off_t | @@ -350,27 +350,27 @@ ext2fs_truncate(struct vnode *ovp, off_t | |||
350 | /* | 350 | /* | |
351 | * Shorten the size of the file. If the file is not being | 351 | * Shorten the size of the file. If the file is not being | |
352 | * truncated to a block boundry, the contents of the | 352 | * truncated to a block boundry, the contents of the | |
353 | * partial block following the end of the file must be | 353 | * partial block following the end of the file must be | |
354 | * zero'ed in case it ever become accessible again because | 354 | * zero'ed in case it ever become accessible again because | |
355 | * of subsequent file growth. | 355 | * of subsequent file growth. | |
356 | */ | 356 | */ | |
357 | offset = ext2_blkoff(fs, length); | 357 | offset = ext2_blkoff(fs, length); | |
358 | if (offset != 0) { | 358 | if (offset != 0) { | |
359 | size = fs->e2fs_bsize; | 359 | size = fs->e2fs_bsize; | |
360 | 360 | |||
361 | /* XXXUBC we should handle more than just VREG */ | 361 | /* XXXUBC we should handle more than just VREG */ | |
362 | ubc_zerorange(&ovp->v_uobj, length, size - offset, | 362 | ubc_zerorange(&ovp->v_uobj, length, size - offset, | |
363 | UBC_UNMAP_FLAG(ovp)); | 363 | UBC_VNODE_FLAGS(ovp)); | |
364 | } | 364 | } | |
365 | (void)ext2fs_setsize(oip, length); | 365 | (void)ext2fs_setsize(oip, length); | |
366 | uvm_vnp_setsize(ovp, length); | 366 | uvm_vnp_setsize(ovp, length); | |
367 | /* | 367 | /* | |
368 | * Calculate index into inode's block list of | 368 | * Calculate index into inode's block list of | |
369 | * last direct and indirect blocks (if any) | 369 | * last direct and indirect blocks (if any) | |
370 | * which we want to keep. Lastblock is -1 when | 370 | * which we want to keep. Lastblock is -1 when | |
371 | * the file is truncated to 0. | 371 | * the file is truncated to 0. | |
372 | */ | 372 | */ | |
373 | lastblock = ext2_lblkno(fs, length + fs->e2fs_bsize - 1) - 1; | 373 | lastblock = ext2_lblkno(fs, length + fs->e2fs_bsize - 1) - 1; | |
374 | lastiblock[SINGLE] = lastblock - EXT2FS_NDADDR; | 374 | lastiblock[SINGLE] = lastblock - EXT2FS_NDADDR; | |
375 | lastiblock[DOUBLE] = lastiblock[SINGLE] - EXT2_NINDIR(fs); | 375 | lastiblock[DOUBLE] = lastiblock[SINGLE] - EXT2_NINDIR(fs); | |
376 | lastiblock[TRIPLE] = lastiblock[DOUBLE] - EXT2_NINDIR(fs) * EXT2_NINDIR(fs); | 376 | lastiblock[TRIPLE] = lastiblock[DOUBLE] - EXT2_NINDIR(fs) * EXT2_NINDIR(fs); |
--- src/sys/ufs/ext2fs/ext2fs_readwrite.c 2020/02/23 15:46:42 1.76
+++ src/sys/ufs/ext2fs/ext2fs_readwrite.c 2020/04/23 21:47:08 1.77
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ext2fs_readwrite.c,v 1.76 2020/02/23 15:46:42 ad Exp $ */ | 1 | /* $NetBSD: ext2fs_readwrite.c,v 1.77 2020/04/23 21:47:08 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1993 | 4 | * Copyright (c) 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. 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. | |
@@ -50,27 +50,27 @@ | @@ -50,27 +50,27 @@ | |||
50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
57 | * | 57 | * | |
58 | * @(#)ufs_readwrite.c 8.8 (Berkeley) 8/4/94 | 58 | * @(#)ufs_readwrite.c 8.8 (Berkeley) 8/4/94 | |
59 | * Modified for ext2fs by Manuel Bouyer. | 59 | * Modified for ext2fs by Manuel Bouyer. | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | #include <sys/cdefs.h> | 62 | #include <sys/cdefs.h> | |
63 | __KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.76 2020/02/23 15:46:42 ad Exp $"); | 63 | __KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.77 2020/04/23 21:47:08 ad Exp $"); | |
64 | 64 | |||
65 | #include <sys/param.h> | 65 | #include <sys/param.h> | |
66 | #include <sys/systm.h> | 66 | #include <sys/systm.h> | |
67 | #include <sys/resourcevar.h> | 67 | #include <sys/resourcevar.h> | |
68 | #include <sys/kernel.h> | 68 | #include <sys/kernel.h> | |
69 | #include <sys/file.h> | 69 | #include <sys/file.h> | |
70 | #include <sys/stat.h> | 70 | #include <sys/stat.h> | |
71 | #include <sys/buf.h> | 71 | #include <sys/buf.h> | |
72 | #include <sys/proc.h> | 72 | #include <sys/proc.h> | |
73 | #include <sys/mount.h> | 73 | #include <sys/mount.h> | |
74 | #include <sys/vnode.h> | 74 | #include <sys/vnode.h> | |
75 | #include <sys/signalvar.h> | 75 | #include <sys/signalvar.h> | |
76 | #include <sys/kauth.h> | 76 | #include <sys/kauth.h> | |
@@ -125,27 +125,27 @@ ext2fs_read(void *v) | @@ -125,27 +125,27 @@ ext2fs_read(void *v) | |||
125 | return 0; | 125 | return 0; | |
126 | if (uio->uio_offset >= ext2fs_size(ip)) | 126 | if (uio->uio_offset >= ext2fs_size(ip)) | |
127 | goto out; | 127 | goto out; | |
128 | 128 | |||
129 | KASSERT(vp->v_type == VREG); | 129 | KASSERT(vp->v_type == VREG); | |
130 | advice = IO_ADV_DECODE(ap->a_ioflag); | 130 | advice = IO_ADV_DECODE(ap->a_ioflag); | |
131 | while (uio->uio_resid > 0) { | 131 | while (uio->uio_resid > 0) { | |
132 | bytelen = MIN(ext2fs_size(ip) - uio->uio_offset, | 132 | bytelen = MIN(ext2fs_size(ip) - uio->uio_offset, | |
133 | uio->uio_resid); | 133 | uio->uio_resid); | |
134 | if (bytelen == 0) | 134 | if (bytelen == 0) | |
135 | break; | 135 | break; | |
136 | 136 | |||
137 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 137 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
138 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 138 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
139 | if (error) | 139 | if (error) | |
140 | break; | 140 | break; | |
141 | } | 141 | } | |
142 | 142 | |||
143 | out: | 143 | out: | |
144 | error = ext2fs_post_read_update(vp, ap->a_ioflag, error); | 144 | error = ext2fs_post_read_update(vp, ap->a_ioflag, error); | |
145 | return error; | 145 | return error; | |
146 | } | 146 | } | |
147 | 147 | |||
148 | /* | 148 | /* | |
149 | * UFS op for reading via the buffer cache | 149 | * UFS op for reading via the buffer cache | |
150 | */ | 150 | */ | |
151 | int | 151 | int | |
@@ -306,27 +306,27 @@ ext2fs_write(void *v) | @@ -306,27 +306,27 @@ ext2fs_write(void *v) | |||
306 | while (uio->uio_resid > 0) { | 306 | while (uio->uio_resid > 0) { | |
307 | oldoff = uio->uio_offset; | 307 | oldoff = uio->uio_offset; | |
308 | blkoffset = ext2_blkoff(fs, uio->uio_offset); | 308 | blkoffset = ext2_blkoff(fs, uio->uio_offset); | |
309 | bytelen = MIN(fs->e2fs_bsize - blkoffset, uio->uio_resid); | 309 | bytelen = MIN(fs->e2fs_bsize - blkoffset, uio->uio_resid); | |
310 | 310 | |||
311 | if (vp->v_size < oldoff + bytelen) { | 311 | if (vp->v_size < oldoff + bytelen) { | |
312 | uvm_vnp_setwritesize(vp, oldoff + bytelen); | 312 | uvm_vnp_setwritesize(vp, oldoff + bytelen); | |
313 | } | 313 | } | |
314 | error = ufs_balloc_range(vp, uio->uio_offset, bytelen, | 314 | error = ufs_balloc_range(vp, uio->uio_offset, bytelen, | |
315 | ap->a_cred, 0); | 315 | ap->a_cred, 0); | |
316 | if (error) | 316 | if (error) | |
317 | break; | 317 | break; | |
318 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 318 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
319 | UBC_WRITE | UBC_UNMAP_FLAG(vp)); | 319 | UBC_WRITE | UBC_VNODE_FLAGS(vp)); | |
320 | if (error) | 320 | if (error) | |
321 | break; | 321 | break; | |
322 | 322 | |||
323 | /* | 323 | /* | |
324 | * update UVM's notion of the size now that we've | 324 | * update UVM's notion of the size now that we've | |
325 | * copied the data into the vnode's pages. | 325 | * copied the data into the vnode's pages. | |
326 | */ | 326 | */ | |
327 | 327 | |||
328 | if (vp->v_size < uio->uio_offset) { | 328 | if (vp->v_size < uio->uio_offset) { | |
329 | uvm_vnp_setsize(vp, uio->uio_offset); | 329 | uvm_vnp_setsize(vp, uio->uio_offset); | |
330 | extended = 1; | 330 | extended = 1; | |
331 | } | 331 | } | |
332 | 332 |
--- src/sys/ufs/ffs/ffs_inode.c 2020/04/18 19:18:34 1.127
+++ src/sys/ufs/ffs/ffs_inode.c 2020/04/23 21:47:09 1.128
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ffs_inode.c,v 1.127 2020/04/18 19:18:34 christos Exp $ */ | 1 | /* $NetBSD: ffs_inode.c,v 1.128 2020/04/23 21:47:09 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Wasabi Systems, Inc. | 8 | * by Wasabi Systems, Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -51,27 +51,27 @@ | @@ -51,27 +51,27 @@ | |||
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
58 | * SUCH DAMAGE. | 58 | * SUCH DAMAGE. | |
59 | * | 59 | * | |
60 | * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 | 60 | * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 | |
61 | */ | 61 | */ | |
62 | 62 | |||
63 | #include <sys/cdefs.h> | 63 | #include <sys/cdefs.h> | |
64 | __KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.127 2020/04/18 19:18:34 christos Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.128 2020/04/23 21:47:09 ad Exp $"); | |
65 | 65 | |||
66 | #if defined(_KERNEL_OPT) | 66 | #if defined(_KERNEL_OPT) | |
67 | #include "opt_ffs.h" | 67 | #include "opt_ffs.h" | |
68 | #include "opt_quota.h" | 68 | #include "opt_quota.h" | |
69 | #endif | 69 | #endif | |
70 | 70 | |||
71 | #include <sys/param.h> | 71 | #include <sys/param.h> | |
72 | #include <sys/systm.h> | 72 | #include <sys/systm.h> | |
73 | #include <sys/buf.h> | 73 | #include <sys/buf.h> | |
74 | #include <sys/file.h> | 74 | #include <sys/file.h> | |
75 | #include <sys/fstrans.h> | 75 | #include <sys/fstrans.h> | |
76 | #include <sys/kauth.h> | 76 | #include <sys/kauth.h> | |
77 | #include <sys/kernel.h> | 77 | #include <sys/kernel.h> | |
@@ -354,27 +354,27 @@ ffs_truncate(struct vnode *ovp, off_t le | @@ -354,27 +354,27 @@ ffs_truncate(struct vnode *ovp, off_t le | |||
354 | int size; | 354 | int size; | |
355 | 355 | |||
356 | if (offset != 0) { | 356 | if (offset != 0) { | |
357 | error = ufs_balloc_range(ovp, length - 1, 1, cred, | 357 | error = ufs_balloc_range(ovp, length - 1, 1, cred, | |
358 | aflag); | 358 | aflag); | |
359 | if (error) | 359 | if (error) | |
360 | return error; | 360 | return error; | |
361 | } | 361 | } | |
362 | lbn = ffs_lblkno(fs, length); | 362 | lbn = ffs_lblkno(fs, length); | |
363 | size = ffs_blksize(fs, oip, lbn); | 363 | size = ffs_blksize(fs, oip, lbn); | |
364 | eoz = MIN(MAX(ffs_lblktosize(fs, lbn) + size, round_page(pgoffset)), | 364 | eoz = MIN(MAX(ffs_lblktosize(fs, lbn) + size, round_page(pgoffset)), | |
365 | osize); | 365 | osize); | |
366 | ubc_zerorange(&ovp->v_uobj, length, eoz - length, | 366 | ubc_zerorange(&ovp->v_uobj, length, eoz - length, | |
367 | UBC_UNMAP_FLAG(ovp)); | 367 | UBC_VNODE_FLAGS(ovp)); | |
368 | if (round_page(eoz) > round_page(length)) { | 368 | if (round_page(eoz) > round_page(length)) { | |
369 | rw_enter(ovp->v_uobj.vmobjlock, RW_WRITER); | 369 | rw_enter(ovp->v_uobj.vmobjlock, RW_WRITER); | |
370 | error = VOP_PUTPAGES(ovp, round_page(length), | 370 | error = VOP_PUTPAGES(ovp, round_page(length), | |
371 | round_page(eoz), | 371 | round_page(eoz), | |
372 | PGO_CLEANIT | PGO_DEACTIVATE | PGO_JOURNALLOCKED | | 372 | PGO_CLEANIT | PGO_DEACTIVATE | PGO_JOURNALLOCKED | | |
373 | ((ioflag & IO_SYNC) ? PGO_SYNCIO : 0)); | 373 | ((ioflag & IO_SYNC) ? PGO_SYNCIO : 0)); | |
374 | if (error) | 374 | if (error) | |
375 | return error; | 375 | return error; | |
376 | } | 376 | } | |
377 | } | 377 | } | |
378 | 378 | |||
379 | genfs_node_wrlock(ovp); | 379 | genfs_node_wrlock(ovp); | |
380 | oip->i_size = length; | 380 | oip->i_size = length; |
--- src/sys/ufs/lfs/lfs_inode.c 2020/02/23 15:46:42 1.159
+++ src/sys/ufs/lfs/lfs_inode.c 2020/04/23 21:47:09 1.160
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lfs_inode.c,v 1.159 2020/02/23 15:46:42 ad Exp $ */ | 1 | /* $NetBSD: lfs_inode.c,v 1.160 2020/04/23 21:47:09 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Konrad E. Schroder <perseant@hhhh.org>. | 8 | * by Konrad E. Schroder <perseant@hhhh.org>. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -50,27 +50,27 @@ | @@ -50,27 +50,27 @@ | |||
50 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 50 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
53 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 53 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
55 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 55 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
56 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 56 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
57 | * SUCH DAMAGE. | 57 | * SUCH DAMAGE. | |
58 | * | 58 | * | |
59 | * @(#)lfs_inode.c 8.9 (Berkeley) 5/8/95 | 59 | * @(#)lfs_inode.c 8.9 (Berkeley) 5/8/95 | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | #include <sys/cdefs.h> | 62 | #include <sys/cdefs.h> | |
63 | __KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.159 2020/02/23 15:46:42 ad Exp $"); | 63 | __KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.160 2020/04/23 21:47:09 ad Exp $"); | |
64 | 64 | |||
65 | #if defined(_KERNEL_OPT) | 65 | #if defined(_KERNEL_OPT) | |
66 | #include "opt_quota.h" | 66 | #include "opt_quota.h" | |
67 | #endif | 67 | #endif | |
68 | 68 | |||
69 | #include <sys/param.h> | 69 | #include <sys/param.h> | |
70 | #include <sys/systm.h> | 70 | #include <sys/systm.h> | |
71 | #include <sys/mount.h> | 71 | #include <sys/mount.h> | |
72 | #include <sys/malloc.h> | 72 | #include <sys/malloc.h> | |
73 | #include <sys/proc.h> | 73 | #include <sys/proc.h> | |
74 | #include <sys/file.h> | 74 | #include <sys/file.h> | |
75 | #include <sys/buf.h> | 75 | #include <sys/buf.h> | |
76 | #include <sys/vnode.h> | 76 | #include <sys/vnode.h> | |
@@ -399,27 +399,27 @@ lfs_truncate(struct vnode *ovp, off_t le | @@ -399,27 +399,27 @@ lfs_truncate(struct vnode *ovp, off_t le | |||
399 | voff_t eoz; | 399 | voff_t eoz; | |
400 | 400 | |||
401 | aflags = ioflag & IO_SYNC ? B_SYNC : 0; | 401 | aflags = ioflag & IO_SYNC ? B_SYNC : 0; | |
402 | error = ulfs_balloc_range(ovp, length - 1, 1, cred, aflags); | 402 | error = ulfs_balloc_range(ovp, length - 1, 1, cred, aflags); | |
403 | if (error) { | 403 | if (error) { | |
404 | lfs_reserve(fs, ovp, NULL, | 404 | lfs_reserve(fs, ovp, NULL, | |
405 | -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs))); | 405 | -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs))); | |
406 | goto errout; | 406 | goto errout; | |
407 | } | 407 | } | |
408 | xlbn = lfs_lblkno(fs, length); | 408 | xlbn = lfs_lblkno(fs, length); | |
409 | size = lfs_blksize(fs, oip, xlbn); | 409 | size = lfs_blksize(fs, oip, xlbn); | |
410 | eoz = MIN(lfs_lblktosize(fs, xlbn) + size, osize); | 410 | eoz = MIN(lfs_lblktosize(fs, xlbn) + size, osize); | |
411 | ubc_zerorange(&ovp->v_uobj, length, eoz - length, | 411 | ubc_zerorange(&ovp->v_uobj, length, eoz - length, | |
412 | UBC_UNMAP_FLAG(ovp)); | 412 | UBC_VNODE_FLAGS(ovp)); | |
413 | if (round_page(eoz) > round_page(length)) { | 413 | if (round_page(eoz) > round_page(length)) { | |
414 | rw_enter(ovp->v_uobj.vmobjlock, RW_WRITER); | 414 | rw_enter(ovp->v_uobj.vmobjlock, RW_WRITER); | |
415 | error = VOP_PUTPAGES(ovp, round_page(length), | 415 | error = VOP_PUTPAGES(ovp, round_page(length), | |
416 | round_page(eoz), | 416 | round_page(eoz), | |
417 | PGO_CLEANIT | PGO_DEACTIVATE | | 417 | PGO_CLEANIT | PGO_DEACTIVATE | | |
418 | ((ioflag & IO_SYNC) ? PGO_SYNCIO : 0)); | 418 | ((ioflag & IO_SYNC) ? PGO_SYNCIO : 0)); | |
419 | if (error) { | 419 | if (error) { | |
420 | lfs_reserve(fs, ovp, NULL, | 420 | lfs_reserve(fs, ovp, NULL, | |
421 | -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs))); | 421 | -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs))); | |
422 | goto errout; | 422 | goto errout; | |
423 | } | 423 | } | |
424 | } | 424 | } | |
425 | } | 425 | } |
--- src/sys/ufs/lfs/ulfs_readwrite.c 2020/02/23 15:46:42 1.26
+++ src/sys/ufs/lfs/ulfs_readwrite.c 2020/04/23 21:47:09 1.27
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_readwrite.c,v 1.26 2020/02/23 15:46:42 ad Exp $ */ | 1 | /* $NetBSD: ulfs_readwrite.c,v 1.27 2020/04/23 21:47:09 ad Exp $ */ | |
2 | /* from NetBSD: ufs_readwrite.c,v 1.120 2015/04/12 22:48:38 riastradh Exp */ | 2 | /* from NetBSD: ufs_readwrite.c,v 1.120 2015/04/12 22:48:38 riastradh Exp */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 1993 | 5 | * Copyright (c) 1993 | |
6 | * The Regents of the University of California. All rights reserved. | 6 | * The Regents of the University of California. All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | * SUCH DAMAGE. | 30 | * SUCH DAMAGE. | |
31 | * | 31 | * | |
32 | * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95 | 32 | * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95 | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | __KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.26 2020/02/23 15:46:42 ad Exp $"); | 36 | __KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.27 2020/04/23 21:47:09 ad Exp $"); | |
37 | 37 | |||
38 | #define FS struct lfs | 38 | #define FS struct lfs | |
39 | #define I_FS i_lfs | 39 | #define I_FS i_lfs | |
40 | #define READ lfs_read | 40 | #define READ lfs_read | |
41 | #define READ_S "lfs_read" | 41 | #define READ_S "lfs_read" | |
42 | #define WRITE lfs_write | 42 | #define WRITE lfs_write | |
43 | #define WRITE_S "lfs_write" | 43 | #define WRITE_S "lfs_write" | |
44 | #define BUFRD lfs_bufrd | 44 | #define BUFRD lfs_bufrd | |
45 | #define BUFWR lfs_bufwr | 45 | #define BUFWR lfs_bufwr | |
46 | #define fs_sb_getbsize(fs) lfs_sb_getbsize(fs) | 46 | #define fs_sb_getbsize(fs) lfs_sb_getbsize(fs) | |
47 | #define fs_bmask lfs_bmask | 47 | #define fs_bmask lfs_bmask | |
48 | 48 | |||
49 | static int ulfs_post_read_update(struct vnode *, int, int); | 49 | static int ulfs_post_read_update(struct vnode *, int, int); | |
@@ -95,27 +95,27 @@ READ(void *v) | @@ -95,27 +95,27 @@ READ(void *v) | |||
95 | if (uio->uio_offset >= ip->i_size) | 95 | if (uio->uio_offset >= ip->i_size) | |
96 | goto out; | 96 | goto out; | |
97 | 97 | |||
98 | KASSERT(vp->v_type == VREG); | 98 | KASSERT(vp->v_type == VREG); | |
99 | advice = IO_ADV_DECODE(ap->a_ioflag); | 99 | advice = IO_ADV_DECODE(ap->a_ioflag); | |
100 | while (uio->uio_resid > 0) { | 100 | while (uio->uio_resid > 0) { | |
101 | if (ioflag & IO_DIRECT) { | 101 | if (ioflag & IO_DIRECT) { | |
102 | genfs_directio(vp, uio, ioflag); | 102 | genfs_directio(vp, uio, ioflag); | |
103 | } | 103 | } | |
104 | bytelen = MIN(ip->i_size - uio->uio_offset, uio->uio_resid); | 104 | bytelen = MIN(ip->i_size - uio->uio_offset, uio->uio_resid); | |
105 | if (bytelen == 0) | 105 | if (bytelen == 0) | |
106 | break; | 106 | break; | |
107 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 107 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
108 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 108 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
109 | if (error) | 109 | if (error) | |
110 | break; | 110 | break; | |
111 | } | 111 | } | |
112 | 112 | |||
113 | out: | 113 | out: | |
114 | error = ulfs_post_read_update(vp, ap->a_ioflag, error); | 114 | error = ulfs_post_read_update(vp, ap->a_ioflag, error); | |
115 | return (error); | 115 | return (error); | |
116 | } | 116 | } | |
117 | 117 | |||
118 | /* | 118 | /* | |
119 | * UFS op for reading via the buffer cache | 119 | * UFS op for reading via the buffer cache | |
120 | */ | 120 | */ | |
121 | int | 121 | int | |
@@ -363,27 +363,27 @@ WRITE(void *v) | @@ -363,27 +363,27 @@ WRITE(void *v) | |||
363 | error = GOP_ALLOC(vp, uio->uio_offset, bytelen, | 363 | error = GOP_ALLOC(vp, uio->uio_offset, bytelen, | |
364 | aflag, cred); | 364 | aflag, cred); | |
365 | genfs_node_unlock(vp); | 365 | genfs_node_unlock(vp); | |
366 | if (error) | 366 | if (error) | |
367 | break; | 367 | break; | |
368 | ubc_flags |= UBC_FAULTBUSY; | 368 | ubc_flags |= UBC_FAULTBUSY; | |
369 | } | 369 | } | |
370 | 370 | |||
371 | /* | 371 | /* | |
372 | * copy the data. | 372 | * copy the data. | |
373 | */ | 373 | */ | |
374 | 374 | |||
375 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | 375 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | |
376 | IO_ADV_DECODE(ioflag), ubc_flags | UBC_UNMAP_FLAG(vp)); | 376 | IO_ADV_DECODE(ioflag), ubc_flags | UBC_VNODE_FLAGS(vp)); | |
377 | 377 | |||
378 | /* | 378 | /* | |
379 | * update UVM's notion of the size now that we've | 379 | * update UVM's notion of the size now that we've | |
380 | * copied the data into the vnode's pages. | 380 | * copied the data into the vnode's pages. | |
381 | * | 381 | * | |
382 | * we should update the size even when uiomove failed. | 382 | * we should update the size even when uiomove failed. | |
383 | */ | 383 | */ | |
384 | 384 | |||
385 | if (vp->v_size < newoff) { | 385 | if (vp->v_size < newoff) { | |
386 | uvm_vnp_setsize(vp, newoff); | 386 | uvm_vnp_setsize(vp, newoff); | |
387 | extended = 1; | 387 | extended = 1; | |
388 | } | 388 | } | |
389 | 389 |
--- src/sys/ufs/ufs/ufs_readwrite.c 2020/02/23 15:46:43 1.125
+++ src/sys/ufs/ufs/ufs_readwrite.c 2020/04/23 21:47:09 1.126
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ufs_readwrite.c,v 1.125 2020/02/23 15:46:43 ad Exp $ */ | 1 | /* $NetBSD: ufs_readwrite.c,v 1.126 2020/04/23 21:47:09 ad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1993 | 4 | * Copyright (c) 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. 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. | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | * | 30 | * | |
31 | * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95 | 31 | * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95 | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.125 2020/02/23 15:46:43 ad Exp $"); | 35 | __KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.126 2020/04/23 21:47:09 ad Exp $"); | |
36 | 36 | |||
37 | #define FS struct fs | 37 | #define FS struct fs | |
38 | #define I_FS i_fs | 38 | #define I_FS i_fs | |
39 | #define READ ffs_read | 39 | #define READ ffs_read | |
40 | #define READ_S "ffs_read" | 40 | #define READ_S "ffs_read" | |
41 | #define WRITE ffs_write | 41 | #define WRITE ffs_write | |
42 | #define WRITE_S "ffs_write" | 42 | #define WRITE_S "ffs_write" | |
43 | #define BUFRD ffs_bufrd | 43 | #define BUFRD ffs_bufrd | |
44 | #define BUFWR ffs_bufwr | 44 | #define BUFWR ffs_bufwr | |
45 | #define ufs_blkoff ffs_blkoff | 45 | #define ufs_blkoff ffs_blkoff | |
46 | #define ufs_blksize ffs_blksize | 46 | #define ufs_blksize ffs_blksize | |
47 | #define ufs_lblkno ffs_lblkno | 47 | #define ufs_lblkno ffs_lblkno | |
48 | #define ufs_lblktosize ffs_lblktosize | 48 | #define ufs_lblktosize ffs_lblktosize | |
@@ -96,27 +96,27 @@ READ(void *v) | @@ -96,27 +96,27 @@ READ(void *v) | |||
96 | if (uio->uio_offset >= ip->i_size) | 96 | if (uio->uio_offset >= ip->i_size) | |
97 | goto out; | 97 | goto out; | |
98 | 98 | |||
99 | KASSERT(vp->v_type == VREG); | 99 | KASSERT(vp->v_type == VREG); | |
100 | advice = IO_ADV_DECODE(ap->a_ioflag); | 100 | advice = IO_ADV_DECODE(ap->a_ioflag); | |
101 | while (uio->uio_resid > 0) { | 101 | while (uio->uio_resid > 0) { | |
102 | if (ioflag & IO_DIRECT) { | 102 | if (ioflag & IO_DIRECT) { | |
103 | genfs_directio(vp, uio, ioflag); | 103 | genfs_directio(vp, uio, ioflag); | |
104 | } | 104 | } | |
105 | bytelen = MIN(ip->i_size - uio->uio_offset, uio->uio_resid); | 105 | bytelen = MIN(ip->i_size - uio->uio_offset, uio->uio_resid); | |
106 | if (bytelen == 0) | 106 | if (bytelen == 0) | |
107 | break; | 107 | break; | |
108 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | 108 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, | |
109 | UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); | 109 | UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); | |
110 | if (error) | 110 | if (error) | |
111 | break; | 111 | break; | |
112 | } | 112 | } | |
113 | 113 | |||
114 | out: | 114 | out: | |
115 | error = ufs_post_read_update(vp, ap->a_ioflag, error); | 115 | error = ufs_post_read_update(vp, ap->a_ioflag, error); | |
116 | return (error); | 116 | return (error); | |
117 | } | 117 | } | |
118 | 118 | |||
119 | /* | 119 | /* | |
120 | * UFS op for reading via the buffer cache | 120 | * UFS op for reading via the buffer cache | |
121 | */ | 121 | */ | |
122 | int | 122 | int | |
@@ -398,27 +398,27 @@ WRITE(void *v) | @@ -398,27 +398,27 @@ WRITE(void *v) | |||
398 | error = GOP_ALLOC(vp, uio->uio_offset, bytelen, | 398 | error = GOP_ALLOC(vp, uio->uio_offset, bytelen, | |
399 | aflag, cred); | 399 | aflag, cred); | |
400 | genfs_node_unlock(vp); | 400 | genfs_node_unlock(vp); | |
401 | if (error) | 401 | if (error) | |
402 | break; | 402 | break; | |
403 | ubc_flags |= UBC_FAULTBUSY; | 403 | ubc_flags |= UBC_FAULTBUSY; | |
404 | } | 404 | } | |
405 | 405 | |||
406 | /* | 406 | /* | |
407 | * copy the data. | 407 | * copy the data. | |
408 | */ | 408 | */ | |
409 | 409 | |||
410 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | 410 | error = ubc_uiomove(&vp->v_uobj, uio, bytelen, | |
411 | IO_ADV_DECODE(ioflag), ubc_flags | UBC_UNMAP_FLAG(vp)); | 411 | IO_ADV_DECODE(ioflag), ubc_flags | UBC_VNODE_FLAGS(vp)); | |
412 | 412 | |||
413 | /* | 413 | /* | |
414 | * update UVM's notion of the size now that we've | 414 | * update UVM's notion of the size now that we've | |
415 | * copied the data into the vnode's pages. | 415 | * copied the data into the vnode's pages. | |
416 | * | 416 | * | |
417 | * we should update the size even when uiomove failed. | 417 | * we should update the size even when uiomove failed. | |
418 | */ | 418 | */ | |
419 | 419 | |||
420 | if (vp->v_size < newoff) { | 420 | if (vp->v_size < newoff) { | |
421 | uvm_vnp_setsize(vp, newoff); | 421 | uvm_vnp_setsize(vp, newoff); | |
422 | extended = 1; | 422 | extended = 1; | |
423 | } | 423 | } | |
424 | 424 |
--- src/sys/uvm/uvm_bio.c 2020/04/23 21:12:06 1.109
+++ src/sys/uvm/uvm_bio.c 2020/04/23 21:47:09 1.110
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uvm_bio.c,v 1.109 2020/04/23 21:12:06 ad Exp $ */ | 1 | /* $NetBSD: uvm_bio.c,v 1.110 2020/04/23 21:47:09 ad 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,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
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.109 2020/04/23 21:12:06 ad Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.110 2020/04/23 21:47:09 ad 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 | #include <sys/vnode.h> | |
48 | 48 | |||
49 | #include <uvm/uvm.h> | 49 | #include <uvm/uvm.h> | |
50 | 50 | |||
@@ -724,45 +724,37 @@ ubc_release(void *va, int flags) | @@ -724,45 +724,37 @@ ubc_release(void *va, int flags) | |||
724 | int | 724 | int | |
725 | ubc_uiomove(struct uvm_object *uobj, struct uio *uio, vsize_t todo, int advice, | 725 | ubc_uiomove(struct uvm_object *uobj, struct uio *uio, vsize_t todo, int advice, | |
726 | int flags) | 726 | int flags) | |
727 | { | 727 | { | |
728 | const bool overwrite = (flags & UBC_FAULTBUSY) != 0; | 728 | const bool overwrite = (flags & UBC_FAULTBUSY) != 0; | |
729 | voff_t off; | 729 | voff_t off; | |
730 | int error; | 730 | int error; | |
731 | 731 | |||
732 | KASSERT(todo <= uio->uio_resid); | 732 | KASSERT(todo <= uio->uio_resid); | |
733 | KASSERT(((flags & UBC_WRITE) != 0 && uio->uio_rw == UIO_WRITE) || | 733 | KASSERT(((flags & UBC_WRITE) != 0 && uio->uio_rw == UIO_WRITE) || | |
734 | ((flags & UBC_READ) != 0 && uio->uio_rw == UIO_READ)); | 734 | ((flags & UBC_READ) != 0 && uio->uio_rw == UIO_READ)); | |
735 | 735 | |||
736 | #ifdef UBC_USE_PMAP_DIRECT | 736 | #ifdef UBC_USE_PMAP_DIRECT | |
737 | if (ubc_direct && UVM_OBJ_IS_VNODE(uobj)) { | 737 | /* | |
738 | /* | 738 | * during direct access pages need to be held busy to prevent them | |
739 | * during direct access pages need to be held busy to | 739 | * changing identity, and therefore if we read or write an object | |
740 | * prevent them disappearing. if the LWP reads or writes | 740 | * into a mapped view of same we could deadlock while faulting. | |
741 | * a vnode into a mapped view of same it could deadlock. | 741 | * | |
742 | * prevent this by disallowing direct access if the vnode | 742 | * avoid the problem by disallowing direct access if the object | |
743 | * is visible somewhere via mmap(). | 743 | * might be visible somewhere via mmap(). | |
744 | * | 744 | */ | |
745 | * the vnode flags are tested here, but at all points UBC is | |||
746 | * called for vnodes, the vnode is locked (thus preventing a | |||
747 | * new mapping via mmap() while busy here). | |||
748 | */ | |||
749 | 745 | |||
750 | struct vnode *vp = (struct vnode *)uobj; | 746 | if (ubc_direct && (flags & UBC_ISMAPPED) == 0) { | |
751 | KASSERT(VOP_ISLOCKED(vp) != LK_NONE); | 747 | return ubc_uiomove_direct(uobj, uio, todo, advice, flags); | |
752 | if ((vp->v_vflag & VV_MAPPED) == 0) { | |||
753 | return ubc_uiomove_direct(uobj, uio, todo, advice, | |||
754 | flags); | |||
755 | } | |||
756 | } | 748 | } | |
757 | #endif | 749 | #endif | |
758 | 750 | |||
759 | off = uio->uio_offset; | 751 | off = uio->uio_offset; | |
760 | error = 0; | 752 | error = 0; | |
761 | while (todo > 0) { | 753 | while (todo > 0) { | |
762 | vsize_t bytelen = todo; | 754 | vsize_t bytelen = todo; | |
763 | void *win; | 755 | void *win; | |
764 | 756 | |||
765 | win = ubc_alloc(uobj, off, &bytelen, advice, flags); | 757 | win = ubc_alloc(uobj, off, &bytelen, advice, flags); | |
766 | if (error == 0) { | 758 | if (error == 0) { | |
767 | error = uiomove(win, bytelen, uio); | 759 | error = uiomove(win, bytelen, uio); | |
768 | } | 760 | } |
--- src/sys/uvm/uvm_extern.h 2020/04/18 03:27:13 1.223
+++ src/sys/uvm/uvm_extern.h 2020/04/23 21:47:09 1.224
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uvm_extern.h,v 1.223 2020/04/18 03:27:13 thorpej Exp $ */ | 1 | /* $NetBSD: uvm_extern.h,v 1.224 2020/04/23 21:47:09 ad 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 | * 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. | |
@@ -216,26 +216,27 @@ b\32UNMAP\0\ | @@ -216,26 +216,27 @@ b\32UNMAP\0\ | |||
216 | * flags for uvm_pagealloc_strat() | 216 | * flags for uvm_pagealloc_strat() | |
217 | */ | 217 | */ | |
218 | #define UVM_PGA_USERESERVE 0x0001 /* ok to use reserve pages */ | 218 | #define UVM_PGA_USERESERVE 0x0001 /* ok to use reserve pages */ | |
219 | #define UVM_PGA_ZERO 0x0002 /* returned page must be zero'd */ | 219 | #define UVM_PGA_ZERO 0x0002 /* returned page must be zero'd */ | |
220 | 220 | |||
221 | /* | 221 | /* | |
222 | * flags for ubc_uiomove() | 222 | * flags for ubc_uiomove() | |
223 | */ | 223 | */ | |
224 | #define UBC_READ 0x001 /* reading from object */ | 224 | #define UBC_READ 0x001 /* reading from object */ | |
225 | #define UBC_WRITE 0x002 /* writing to object */ | 225 | #define UBC_WRITE 0x002 /* writing to object */ | |
226 | #define UBC_FAULTBUSY 0x004 /* nobody else is using these pages, so busy | 226 | #define UBC_FAULTBUSY 0x004 /* nobody else is using these pages, so busy | |
227 | * them at alloc and unbusy at release (e.g., | 227 | * them at alloc and unbusy at release (e.g., | |
228 | * for writes extending a file) */ | 228 | * for writes extending a file) */ | |
229 | #define UBC_ISMAPPED 0x008 /* object may be mapped by a process */ | |||
229 | 230 | |||
230 | /* | 231 | /* | |
231 | * flags for ubc_release() | 232 | * flags for ubc_release() | |
232 | */ | 233 | */ | |
233 | #define UBC_UNMAP 0x010 /* unmap pages now -- don't leave the | 234 | #define UBC_UNMAP 0x010 /* unmap pages now -- don't leave the | |
234 | * mappings cached indefinitely */ | 235 | * mappings cached indefinitely */ | |
235 | 236 | |||
236 | /* | 237 | /* | |
237 | * flags for ubc_uiomove() | 238 | * flags for ubc_uiomove() | |
238 | */ | 239 | */ | |
239 | #define UBC_PARTIALOK 0x100 /* return early on error; otherwise, zero all | 240 | #define UBC_PARTIALOK 0x100 /* return early on error; otherwise, zero all | |
240 | * remaining bytes after error */ | 241 | * remaining bytes after error */ | |
241 | 242 | |||
@@ -539,31 +540,33 @@ extern bool vm_page_zero_enable; | @@ -539,31 +540,33 @@ extern bool vm_page_zero_enable; | |||
539 | /* | 540 | /* | |
540 | * Include the uvm_hotplug(9) API unconditionally until | 541 | * Include the uvm_hotplug(9) API unconditionally until | |
541 | * uvm_page_physload() et. al. are obsoleted | 542 | * uvm_page_physload() et. al. are obsoleted | |
542 | * | 543 | * | |
543 | * After this, MD code will have to explicitly include it if needed. | 544 | * After this, MD code will have to explicitly include it if needed. | |
544 | */ | 545 | */ | |
545 | #include <uvm/uvm_physseg.h> | 546 | #include <uvm/uvm_physseg.h> | |
546 | #endif | 547 | #endif | |
547 | 548 | |||
548 | /* | 549 | /* | |
549 | * helpers for calling ubc_release() | 550 | * helpers for calling ubc_release() | |
550 | */ | 551 | */ | |
551 | #ifdef PMAP_CACHE_VIVT | 552 | #ifdef PMAP_CACHE_VIVT | |
552 | #define UBC_WANT_UNMAP(vp) (((vp)->v_iflag & VI_TEXT) != 0) | 553 | #define UBC_VNODE_FLAGS(vp) \ | |
554 | ((((vp)->v_iflag & VI_TEXT) != 0 ? UBC_UNMAP : 0) | | |||
555 | (((vp)->v_vflag & VV_MAPPED) != 0 ? UBC_ISMAPPED : 0)) | |||
553 | #else | 556 | #else | |
554 | #define UBC_WANT_UNMAP(vp) false | 557 | #define UBC_VNODE_FLAGS(vp) \ | |
558 | (((vp)->v_vflag & VV_MAPPED) != 0 ? UBC_ISMAPPED : 0) | |||
555 | #endif | 559 | #endif | |
556 | #define UBC_UNMAP_FLAG(vp) (UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0) | |||
557 | 560 | |||
558 | #if defined(_KERNEL) || defined(_KMEMUSER) | 561 | #if defined(_KERNEL) || defined(_KMEMUSER) | |
559 | /* | 562 | /* | |
560 | * Shareable process virtual address space. | 563 | * Shareable process virtual address space. | |
561 | * May eventually be merged with vm_map. | 564 | * May eventually be merged with vm_map. | |
562 | * Several fields are temporary (text, data stuff). | 565 | * Several fields are temporary (text, data stuff). | |
563 | */ | 566 | */ | |
564 | struct vmspace { | 567 | struct vmspace { | |
565 | struct vm_map vm_map; /* VM address map */ | 568 | struct vm_map vm_map; /* VM address map */ | |
566 | int vm_refcnt; /* number of references * | 569 | int vm_refcnt; /* number of references * | |
567 | * note: protected by vm_map.misc_lock */ | 570 | * note: protected by vm_map.misc_lock */ | |
568 | void * vm_shm; /* SYS5 shared memory private data XXX */ | 571 | void * vm_shm; /* SYS5 shared memory private data XXX */ | |
569 | /* we copy from vm_startcopy to the end of the structure on fork */ | 572 | /* we copy from vm_startcopy to the end of the structure on fork */ |