Make vget always return vnode unlocked. Convert callers who want locks to use vn_lock afterward. Add extra argument so the compiler will report stragglers.diff -r1.73 -r1.74 src/sys/fs/adosfs/advfsops.c
(riastradh)
--- src/sys/fs/adosfs/advfsops.c 2015/03/28 19:24:05 1.73
+++ src/sys/fs/adosfs/advfsops.c 2015/04/20 13:44:16 1.74
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: advfsops.c,v 1.73 2015/03/28 19:24:05 maxv Exp $ */ | 1 | /* $NetBSD: advfsops.c,v 1.74 2015/04/20 13:44:16 riastradh 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: advfsops.c,v 1.73 2015/03/28 19:24:05 maxv Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.74 2015/04/20 13:44:16 riastradh Exp $"); | |
36 | 36 | |||
37 | #if defined(_KERNEL_OPT) | 37 | #if defined(_KERNEL_OPT) | |
38 | #include "opt_compat_netbsd.h" | 38 | #include "opt_compat_netbsd.h" | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/sysctl.h> | 43 | #include <sys/sysctl.h> | |
44 | #include <sys/vnode.h> | 44 | #include <sys/vnode.h> | |
45 | #include <sys/mount.h> | 45 | #include <sys/mount.h> | |
46 | #include <sys/proc.h> | 46 | #include <sys/proc.h> | |
47 | #include <sys/time.h> | 47 | #include <sys/time.h> | |
48 | #include <sys/malloc.h> | 48 | #include <sys/malloc.h> | |
@@ -354,27 +354,27 @@ adosfs_statvfs(struct mount *mp, struct | @@ -354,27 +354,27 @@ adosfs_statvfs(struct mount *mp, struct | |||
354 | sbp->f_bfree = amp->freeblks; | 354 | sbp->f_bfree = amp->freeblks; | |
355 | sbp->f_bavail = amp->freeblks; | 355 | sbp->f_bavail = amp->freeblks; | |
356 | sbp->f_bresvd = 0; | 356 | sbp->f_bresvd = 0; | |
357 | sbp->f_files = 0; /* who knows */ | 357 | sbp->f_files = 0; /* who knows */ | |
358 | sbp->f_ffree = 0; /* " " */ | 358 | sbp->f_ffree = 0; /* " " */ | |
359 | sbp->f_favail = 0; /* " " */ | 359 | sbp->f_favail = 0; /* " " */ | |
360 | sbp->f_fresvd = 0; | 360 | sbp->f_fresvd = 0; | |
361 | copy_statvfs_info(sbp, mp); | 361 | copy_statvfs_info(sbp, mp); | |
362 | return (0); | 362 | return (0); | |
363 | } | 363 | } | |
364 | 364 | |||
365 | /* | 365 | /* | |
366 | * lookup an anode, if not found, create | 366 | * lookup an anode, if not found, create | |
367 | * return locked and referenced al la vget(vp, LK_EXCLUSIVE); | 367 | * return locked and referenced | |
368 | */ | 368 | */ | |
369 | int | 369 | int | |
370 | adosfs_vget(struct mount *mp, ino_t an, struct vnode **vpp) | 370 | adosfs_vget(struct mount *mp, ino_t an, struct vnode **vpp) | |
371 | { | 371 | { | |
372 | int error; | 372 | int error; | |
373 | 373 | |||
374 | error = vcache_get(mp, &an, sizeof(an), vpp); | 374 | error = vcache_get(mp, &an, sizeof(an), vpp); | |
375 | if (error) | 375 | if (error) | |
376 | return error; | 376 | return error; | |
377 | error = vn_lock(*vpp, LK_EXCLUSIVE); | 377 | error = vn_lock(*vpp, LK_EXCLUSIVE); | |
378 | if (error) { | 378 | if (error) { | |
379 | vrele(*vpp); | 379 | vrele(*vpp); | |
380 | *vpp = NULL; | 380 | *vpp = NULL; |
--- src/sys/fs/tmpfs/tmpfs_subr.c 2014/09/08 14:49:46 1.97
+++ src/sys/fs/tmpfs/tmpfs_subr.c 2015/04/20 13:44:16 1.98
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tmpfs_subr.c,v 1.97 2014/09/08 14:49:46 gson Exp $ */ | 1 | /* $NetBSD: tmpfs_subr.c,v 1.98 2015/04/20 13:44:16 riastradh 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 | |
@@ -64,27 +64,27 @@ | @@ -64,27 +64,27 @@ | |||
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 tmpfs_vnode_get() to associate a new vnode. | 67 | * tmpfs_lookup() and thus tmpfs_vnode_get() to associate a new vnode. | |
68 | * | 68 | * | |
69 | * Lock order | 69 | * Lock order | |
70 | * | 70 | * | |
71 | * tmpfs_node_t::tn_vlock -> | 71 | * tmpfs_node_t::tn_vlock -> | |
72 | * vnode_t::v_vlock -> | 72 | * vnode_t::v_vlock -> | |
73 | * vnode_t::v_interlock | 73 | * vnode_t::v_interlock | |
74 | */ | 74 | */ | |
75 | 75 | |||
76 | #include <sys/cdefs.h> | 76 | #include <sys/cdefs.h> | |
77 | __KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.97 2014/09/08 14:49:46 gson Exp $"); | 77 | __KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.98 2015/04/20 13:44:16 riastradh Exp $"); | |
78 | 78 | |||
79 | #include <sys/param.h> | 79 | #include <sys/param.h> | |
80 | #include <sys/cprng.h> | 80 | #include <sys/cprng.h> | |
81 | #include <sys/dirent.h> | 81 | #include <sys/dirent.h> | |
82 | #include <sys/event.h> | 82 | #include <sys/event.h> | |
83 | #include <sys/kmem.h> | 83 | #include <sys/kmem.h> | |
84 | #include <sys/mount.h> | 84 | #include <sys/mount.h> | |
85 | #include <sys/namei.h> | 85 | #include <sys/namei.h> | |
86 | #include <sys/time.h> | 86 | #include <sys/time.h> | |
87 | #include <sys/stat.h> | 87 | #include <sys/stat.h> | |
88 | #include <sys/systm.h> | 88 | #include <sys/systm.h> | |
89 | #include <sys/vnode.h> | 89 | #include <sys/vnode.h> | |
90 | #include <sys/kauth.h> | 90 | #include <sys/kauth.h> | |
@@ -272,31 +272,32 @@ tmpfs_free_node(tmpfs_mount_t *tmp, tmpf | @@ -272,31 +272,32 @@ tmpfs_free_node(tmpfs_mount_t *tmp, tmpf | |||
272 | */ | 272 | */ | |
273 | int | 273 | int | |
274 | tmpfs_vnode_get(struct mount *mp, tmpfs_node_t *node, vnode_t **vpp) | 274 | tmpfs_vnode_get(struct mount *mp, tmpfs_node_t *node, vnode_t **vpp) | |
275 | { | 275 | { | |
276 | vnode_t *vp; | 276 | vnode_t *vp; | |
277 | kmutex_t *slock; | 277 | kmutex_t *slock; | |
278 | int error; | 278 | int error; | |
279 | again: | 279 | again: | |
280 | /* If there is already a vnode, try to reclaim it. */ | 280 | /* If there is already a vnode, try to reclaim it. */ | |
281 | if ((vp = node->tn_vnode) != NULL) { | 281 | if ((vp = node->tn_vnode) != NULL) { | |
282 | atomic_or_32(&node->tn_gen, TMPFS_RECLAIMING_BIT); | 282 | atomic_or_32(&node->tn_gen, TMPFS_RECLAIMING_BIT); | |
283 | mutex_enter(vp->v_interlock); | 283 | mutex_enter(vp->v_interlock); | |
284 | mutex_exit(&node->tn_vlock); | 284 | mutex_exit(&node->tn_vlock); | |
285 | error = vget(vp, LK_EXCLUSIVE); | 285 | error = vget(vp, 0, true /* wait */); | |
286 | if (error == ENOENT) { | 286 | if (error == ENOENT) { | |
287 | mutex_enter(&node->tn_vlock); | 287 | mutex_enter(&node->tn_vlock); | |
288 | goto again; | 288 | goto again; | |
289 | } | 289 | } | |
290 | vn_lock(vp, LK_EXCLUSIVE); | |||
290 | atomic_and_32(&node->tn_gen, ~TMPFS_RECLAIMING_BIT); | 291 | atomic_and_32(&node->tn_gen, ~TMPFS_RECLAIMING_BIT); | |
291 | *vpp = vp; | 292 | *vpp = vp; | |
292 | return error; | 293 | return error; | |
293 | } | 294 | } | |
294 | if (TMPFS_NODE_RECLAIMING(node)) { | 295 | if (TMPFS_NODE_RECLAIMING(node)) { | |
295 | atomic_and_32(&node->tn_gen, ~TMPFS_RECLAIMING_BIT); | 296 | atomic_and_32(&node->tn_gen, ~TMPFS_RECLAIMING_BIT); | |
296 | } | 297 | } | |
297 | 298 | |||
298 | /* | 299 | /* | |
299 | * Get a new vnode and associate it with our inode. Share the | 300 | * Get a new vnode and associate it with our inode. Share the | |
300 | * lock with underlying UVM object, if there is one (VREG case). | 301 | * lock with underlying UVM object, if there is one (VREG case). | |
301 | */ | 302 | */ | |
302 | if (node->tn_type == VREG) { | 303 | if (node->tn_type == VREG) { |
--- src/sys/fs/udf/udf_subr.c 2015/04/06 08:39:23 1.129
+++ src/sys/fs/udf/udf_subr.c 2015/04/20 13:44:16 1.130
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: udf_subr.c,v 1.129 2015/04/06 08:39:23 hannken Exp $ */ | 1 | /* $NetBSD: udf_subr.c,v 1.130 2015/04/20 13:44:16 riastradh 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. | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
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 | 29 | |||
30 | #include <sys/cdefs.h> | 30 | #include <sys/cdefs.h> | |
31 | #ifndef lint | 31 | #ifndef lint | |
32 | __KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.129 2015/04/06 08:39:23 hannken Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.130 2015/04/20 13:44:16 riastradh Exp $"); | |
33 | #endif /* not lint */ | 33 | #endif /* not lint */ | |
34 | 34 | |||
35 | 35 | |||
36 | #if defined(_KERNEL_OPT) | 36 | #if defined(_KERNEL_OPT) | |
37 | #include "opt_compat_netbsd.h" | 37 | #include "opt_compat_netbsd.h" | |
38 | #endif | 38 | #endif | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/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> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
@@ -6351,34 +6351,42 @@ derailed: | @@ -6351,34 +6351,42 @@ derailed: | |||
6351 | /* check if its dirty enough to even try */ | 6351 | /* check if its dirty enough to even try */ | |
6352 | on_type = (waitfor == MNT_LAZY || vp->v_type == VNON); | 6352 | on_type = (waitfor == MNT_LAZY || vp->v_type == VNON); | |
6353 | on_flags = ((udf_node->i_flags & | 6353 | on_flags = ((udf_node->i_flags & | |
6354 | (IN_ACCESSED | IN_UPDATE | IN_MODIFIED)) == 0); | 6354 | (IN_ACCESSED | IN_UPDATE | IN_MODIFIED)) == 0); | |
6355 | on_vnode = LIST_EMPTY(&vp->v_dirtyblkhd) | 6355 | on_vnode = LIST_EMPTY(&vp->v_dirtyblkhd) | |
6356 | && UVM_OBJ_IS_CLEAN(&vp->v_uobj); | 6356 | && UVM_OBJ_IS_CLEAN(&vp->v_uobj); | |
6357 | if (on_type || (on_flags || on_vnode)) { /* XXX */ | 6357 | if (on_type || (on_flags || on_vnode)) { /* XXX */ | |
6358 | /* not dirty (enough?) */ | 6358 | /* not dirty (enough?) */ | |
6359 | mutex_exit(vp->v_interlock); | 6359 | mutex_exit(vp->v_interlock); | |
6360 | continue; | 6360 | continue; | |
6361 | } | 6361 | } | |
6362 | 6362 | |||
6363 | mutex_exit(&mntvnode_lock); | 6363 | mutex_exit(&mntvnode_lock); | |
6364 | error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT); | 6364 | error = vget(vp, LK_NOWAIT, false /* !wait */); | |
6365 | if (error) { | 6365 | if (error) { | |
6366 | mutex_enter(&mntvnode_lock); | 6366 | mutex_enter(&mntvnode_lock); | |
6367 | if (error == ENOENT) | 6367 | if (error == ENOENT) | |
6368 | goto derailed; | 6368 | goto derailed; | |
6369 | *ndirty += 1; | 6369 | *ndirty += 1; | |
6370 | continue; | 6370 | continue; | |
6371 | } | 6371 | } | |
6372 | error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT); | |||
6373 | if (error) { | |||
6374 | KASSERT(error == EBUSY); | |||
6375 | vrele(vp); | |||
6376 | mutex_enter(&mntvnode_lock); | |||
6377 | *ndirty += 1; | |||
6378 | continue; | |||
6379 | } | |||
6372 | 6380 | |||
6373 | switch (pass) { | 6381 | switch (pass) { | |
6374 | case 1: | 6382 | case 1: | |
6375 | VOP_FSYNC(vp, cred, 0 | FSYNC_DATAONLY,0,0); | 6383 | VOP_FSYNC(vp, cred, 0 | FSYNC_DATAONLY,0,0); | |
6376 | break; | 6384 | break; | |
6377 | case 2: | 6385 | case 2: | |
6378 | vdirty = vp->v_numoutput; | 6386 | vdirty = vp->v_numoutput; | |
6379 | if (vp->v_tag == VT_UDF) | 6387 | if (vp->v_tag == VT_UDF) | |
6380 | vdirty += udf_node->outstanding_bufs + | 6388 | vdirty += udf_node->outstanding_bufs + | |
6381 | udf_node->outstanding_nodedscr; | 6389 | udf_node->outstanding_nodedscr; | |
6382 | if (vdirty == 0) | 6390 | if (vdirty == 0) | |
6383 | VOP_FSYNC(vp, cred, 0,0,0); | 6391 | VOP_FSYNC(vp, cred, 0,0,0); | |
6384 | *ndirty += vdirty; | 6392 | *ndirty += vdirty; |
--- src/sys/fs/union/union_subr.c 2015/02/24 16:08:01 1.71
+++ src/sys/fs/union/union_subr.c 2015/04/20 13:44:16 1.72
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: union_subr.c,v 1.71 2015/02/24 16:08:01 hannken Exp $ */ | 1 | /* $NetBSD: union_subr.c,v 1.72 2015/04/20 13:44:16 riastradh 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 by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Jan-Simon Pendry. | 8 | * Jan-Simon Pendry. | |
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. | |
@@ -62,27 +62,27 @@ | @@ -62,27 +62,27 @@ | |||
62 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 62 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
63 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 63 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
64 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 64 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
65 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 65 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
66 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 66 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
67 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 67 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
68 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 68 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
69 | * SUCH DAMAGE. | 69 | * SUCH DAMAGE. | |
70 | * | 70 | * | |
71 | * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 | 71 | * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 | |
72 | */ | 72 | */ | |
73 | 73 | |||
74 | #include <sys/cdefs.h> | 74 | #include <sys/cdefs.h> | |
75 | __KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.71 2015/02/24 16:08:01 hannken Exp $"); | 75 | __KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.72 2015/04/20 13:44:16 riastradh Exp $"); | |
76 | 76 | |||
77 | #include <sys/param.h> | 77 | #include <sys/param.h> | |
78 | #include <sys/systm.h> | 78 | #include <sys/systm.h> | |
79 | #include <sys/proc.h> | 79 | #include <sys/proc.h> | |
80 | #include <sys/time.h> | 80 | #include <sys/time.h> | |
81 | #include <sys/kernel.h> | 81 | #include <sys/kernel.h> | |
82 | #include <sys/vnode.h> | 82 | #include <sys/vnode.h> | |
83 | #include <sys/namei.h> | 83 | #include <sys/namei.h> | |
84 | #include <sys/malloc.h> | 84 | #include <sys/malloc.h> | |
85 | #include <sys/dirent.h> | 85 | #include <sys/dirent.h> | |
86 | #include <sys/file.h> | 86 | #include <sys/file.h> | |
87 | #include <sys/filedesc.h> | 87 | #include <sys/filedesc.h> | |
88 | #include <sys/queue.h> | 88 | #include <sys/queue.h> | |
@@ -981,27 +981,27 @@ union_removed_upper(struct union_node *u | @@ -981,27 +981,27 @@ union_removed_upper(struct union_node *u | |||
981 | LIST_REMOVE(un, un_cache); | 981 | LIST_REMOVE(un, un_cache); | |
982 | } | 982 | } | |
983 | mutex_exit(&uhash_lock); | 983 | mutex_exit(&uhash_lock); | |
984 | } | 984 | } | |
985 | 985 | |||
986 | #if 0 | 986 | #if 0 | |
987 | struct vnode * | 987 | struct vnode * | |
988 | union_lowervp(struct vnode *vp) | 988 | union_lowervp(struct vnode *vp) | |
989 | { | 989 | { | |
990 | struct union_node *un = VTOUNION(vp); | 990 | struct union_node *un = VTOUNION(vp); | |
991 | 991 | |||
992 | if ((un->un_lowervp != NULLVP) && | 992 | if ((un->un_lowervp != NULLVP) && | |
993 | (vp->v_type == un->un_lowervp->v_type)) { | 993 | (vp->v_type == un->un_lowervp->v_type)) { | |
994 | if (vget(un->un_lowervp, 0) == 0) | 994 | if (vget(un->un_lowervp, 0, true /* wait */) == 0) | |
995 | return (un->un_lowervp); | 995 | return (un->un_lowervp); | |
996 | } | 996 | } | |
997 | 997 | |||
998 | return (NULLVP); | 998 | return (NULLVP); | |
999 | } | 999 | } | |
1000 | #endif | 1000 | #endif | |
1001 | 1001 | |||
1002 | /* | 1002 | /* | |
1003 | * determine whether a whiteout is needed | 1003 | * determine whether a whiteout is needed | |
1004 | * during a remove/rmdir operation. | 1004 | * during a remove/rmdir operation. | |
1005 | */ | 1005 | */ | |
1006 | int | 1006 | int | |
1007 | union_dowhiteout(struct union_node *un, kauth_cred_t cred) | 1007 | union_dowhiteout(struct union_node *un, kauth_cred_t cred) |
--- src/sys/kern/vfs_cache.c 2015/01/16 20:10:25 1.105
+++ src/sys/kern/vfs_cache.c 2015/04/20 13:44:16 1.106
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfs_cache.c,v 1.105 2015/01/16 20:10:25 dennis Exp $ */ | 1 | /* $NetBSD: vfs_cache.c,v 1.106 2015/04/20 13:44:16 riastradh 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 | * 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. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
55 | * SUCH DAMAGE. | 55 | * SUCH DAMAGE. | |
56 | * | 56 | * | |
57 | * @(#)vfs_cache.c 8.3 (Berkeley) 8/22/94 | 57 | * @(#)vfs_cache.c 8.3 (Berkeley) 8/22/94 | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.105 2015/01/16 20:10:25 dennis Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.106 2015/04/20 13:44:16 riastradh Exp $"); | |
62 | 62 | |||
63 | #include "opt_ddb.h" | 63 | #include "opt_ddb.h" | |
64 | #include "opt_revcache.h" | 64 | #include "opt_revcache.h" | |
65 | 65 | |||
66 | #include <sys/param.h> | 66 | #include <sys/param.h> | |
67 | #include <sys/systm.h> | 67 | #include <sys/systm.h> | |
68 | #include <sys/sysctl.h> | 68 | #include <sys/sysctl.h> | |
69 | #include <sys/time.h> | 69 | #include <sys/time.h> | |
70 | #include <sys/mount.h> | 70 | #include <sys/mount.h> | |
71 | #include <sys/vnode.h> | 71 | #include <sys/vnode.h> | |
72 | #include <sys/namei.h> | 72 | #include <sys/namei.h> | |
73 | #include <sys/errno.h> | 73 | #include <sys/errno.h> | |
74 | #include <sys/pool.h> | 74 | #include <sys/pool.h> | |
@@ -545,27 +545,27 @@ cache_lookup(struct vnode *dvp, const ch | @@ -545,27 +545,27 @@ cache_lookup(struct vnode *dvp, const ch | |||
545 | mutex_exit(&ncp->nc_lock); | 545 | mutex_exit(&ncp->nc_lock); | |
546 | mutex_exit(&cpup->cpu_lock); | 546 | mutex_exit(&cpup->cpu_lock); | |
547 | return ret_value; | 547 | return ret_value; | |
548 | } | 548 | } | |
549 | 549 | |||
550 | vp = ncp->nc_vp; | 550 | vp = ncp->nc_vp; | |
551 | mutex_enter(vp->v_interlock); | 551 | mutex_enter(vp->v_interlock); | |
552 | mutex_exit(&ncp->nc_lock); | 552 | mutex_exit(&ncp->nc_lock); | |
553 | mutex_exit(&cpup->cpu_lock); | 553 | mutex_exit(&cpup->cpu_lock); | |
554 | 554 | |||
555 | /* | 555 | /* | |
556 | * Unlocked except for the vnode interlock. Call vget(). | 556 | * Unlocked except for the vnode interlock. Call vget(). | |
557 | */ | 557 | */ | |
558 | error = vget(vp, LK_NOWAIT); | 558 | error = vget(vp, LK_NOWAIT, false /* !wait */); | |
559 | if (error) { | 559 | if (error) { | |
560 | KASSERT(error == EBUSY); | 560 | KASSERT(error == EBUSY); | |
561 | /* | 561 | /* | |
562 | * This vnode is being cleaned out. | 562 | * This vnode is being cleaned out. | |
563 | * XXX badhits? | 563 | * XXX badhits? | |
564 | */ | 564 | */ | |
565 | COUNT_UNL(cpup, ncs_falsehits); | 565 | COUNT_UNL(cpup, ncs_falsehits); | |
566 | /* found nothing */ | 566 | /* found nothing */ | |
567 | return 0; | 567 | return 0; | |
568 | } | 568 | } | |
569 | 569 | |||
570 | COUNT_UNL(cpup, ncs_goodhits); | 570 | COUNT_UNL(cpup, ncs_goodhits); | |
571 | /* found it */ | 571 | /* found it */ | |
@@ -626,27 +626,27 @@ cache_lookup_raw(struct vnode *dvp, cons | @@ -626,27 +626,27 @@ cache_lookup_raw(struct vnode *dvp, cons | |||
626 | COUNT(cpup, ncs_neghits); | 626 | COUNT(cpup, ncs_neghits); | |
627 | mutex_exit(&ncp->nc_lock); | 627 | mutex_exit(&ncp->nc_lock); | |
628 | mutex_exit(&cpup->cpu_lock); | 628 | mutex_exit(&cpup->cpu_lock); | |
629 | /* found negative entry; vn is already null from above */ | 629 | /* found negative entry; vn is already null from above */ | |
630 | return 1; | 630 | return 1; | |
631 | } | 631 | } | |
632 | mutex_enter(vp->v_interlock); | 632 | mutex_enter(vp->v_interlock); | |
633 | mutex_exit(&ncp->nc_lock); | 633 | mutex_exit(&ncp->nc_lock); | |
634 | mutex_exit(&cpup->cpu_lock); | 634 | mutex_exit(&cpup->cpu_lock); | |
635 | 635 | |||
636 | /* | 636 | /* | |
637 | * Unlocked except for the vnode interlock. Call vget(). | 637 | * Unlocked except for the vnode interlock. Call vget(). | |
638 | */ | 638 | */ | |
639 | error = vget(vp, LK_NOWAIT); | 639 | error = vget(vp, LK_NOWAIT, false /* !wait */); | |
640 | if (error) { | 640 | if (error) { | |
641 | KASSERT(error == EBUSY); | 641 | KASSERT(error == EBUSY); | |
642 | /* | 642 | /* | |
643 | * This vnode is being cleaned out. | 643 | * This vnode is being cleaned out. | |
644 | * XXX badhits? | 644 | * XXX badhits? | |
645 | */ | 645 | */ | |
646 | COUNT_UNL(cpup, ncs_falsehits); | 646 | COUNT_UNL(cpup, ncs_falsehits); | |
647 | /* found nothing */ | 647 | /* found nothing */ | |
648 | return 0; | 648 | return 0; | |
649 | } | 649 | } | |
650 | 650 | |||
651 | COUNT_UNL(cpup, ncs_goodhits); /* XXX can be "badhits" */ | 651 | COUNT_UNL(cpup, ncs_goodhits); /* XXX can be "badhits" */ | |
652 | /* found it */ | 652 | /* found it */ | |
@@ -714,27 +714,27 @@ cache_revlookup(struct vnode *vp, struct | @@ -714,27 +714,27 @@ cache_revlookup(struct vnode *vp, struct | |||
714 | if (bp <= bufp) { | 714 | if (bp <= bufp) { | |
715 | *dvpp = NULL; | 715 | *dvpp = NULL; | |
716 | mutex_exit(&ncp->nc_lock); | 716 | mutex_exit(&ncp->nc_lock); | |
717 | mutex_exit(namecache_lock); | 717 | mutex_exit(namecache_lock); | |
718 | return (ERANGE); | 718 | return (ERANGE); | |
719 | } | 719 | } | |
720 | memcpy(bp, ncp->nc_name, nlen); | 720 | memcpy(bp, ncp->nc_name, nlen); | |
721 | *bpp = bp; | 721 | *bpp = bp; | |
722 | } | 722 | } | |
723 | 723 | |||
724 | mutex_enter(dvp->v_interlock); | 724 | mutex_enter(dvp->v_interlock); | |
725 | mutex_exit(&ncp->nc_lock); | 725 | mutex_exit(&ncp->nc_lock); | |
726 | mutex_exit(namecache_lock); | 726 | mutex_exit(namecache_lock); | |
727 | error = vget(dvp, LK_NOWAIT); | 727 | error = vget(dvp, LK_NOWAIT, false /* !wait */); | |
728 | if (error) { | 728 | if (error) { | |
729 | KASSERT(error == EBUSY); | 729 | KASSERT(error == EBUSY); | |
730 | if (bufp) | 730 | if (bufp) | |
731 | (*bpp) += nlen; | 731 | (*bpp) += nlen; | |
732 | *dvpp = NULL; | 732 | *dvpp = NULL; | |
733 | return -1; | 733 | return -1; | |
734 | } | 734 | } | |
735 | *dvpp = dvp; | 735 | *dvpp = dvp; | |
736 | return (0); | 736 | return (0); | |
737 | } | 737 | } | |
738 | mutex_exit(&ncp->nc_lock); | 738 | mutex_exit(&ncp->nc_lock); | |
739 | } | 739 | } | |
740 | COUNT(cpup, ncs_revmiss); | 740 | COUNT(cpup, ncs_revmiss); |
--- src/sys/kern/vfs_mount.c 2015/03/09 15:35:11 1.33
+++ src/sys/kern/vfs_mount.c 2015/04/20 13:44:16 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfs_mount.c,v 1.33 2015/03/09 15:35:11 pooka Exp $ */ | 1 | /* $NetBSD: vfs_mount.c,v 1.34 2015/04/20 13:44:16 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997-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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center, by Charles M. Hannum, and by Andrew Doran. | 9 | * NASA Ames Research Center, by Charles M. Hannum, and by Andrew Doran. | |
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 | |
@@ -57,27 +57,27 @@ | @@ -57,27 +57,27 @@ | |||
57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
64 | * SUCH DAMAGE. | 64 | * SUCH DAMAGE. | |
65 | * | 65 | * | |
66 | * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 | 66 | * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 | |
67 | */ | 67 | */ | |
68 | 68 | |||
69 | #include <sys/cdefs.h> | 69 | #include <sys/cdefs.h> | |
70 | __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.33 2015/03/09 15:35:11 pooka Exp $"); | 70 | __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.34 2015/04/20 13:44:16 riastradh Exp $"); | |
71 | 71 | |||
72 | #define _VFS_VNODE_PRIVATE | 72 | #define _VFS_VNODE_PRIVATE | |
73 | 73 | |||
74 | #include <sys/param.h> | 74 | #include <sys/param.h> | |
75 | #include <sys/kernel.h> | 75 | #include <sys/kernel.h> | |
76 | 76 | |||
77 | #include <sys/atomic.h> | 77 | #include <sys/atomic.h> | |
78 | #include <sys/buf.h> | 78 | #include <sys/buf.h> | |
79 | #include <sys/conf.h> | 79 | #include <sys/conf.h> | |
80 | #include <sys/fcntl.h> | 80 | #include <sys/fcntl.h> | |
81 | #include <sys/filedesc.h> | 81 | #include <sys/filedesc.h> | |
82 | #include <sys/device.h> | 82 | #include <sys/device.h> | |
83 | #include <sys/kauth.h> | 83 | #include <sys/kauth.h> | |
@@ -394,27 +394,27 @@ again: | @@ -394,27 +394,27 @@ again: | |||
394 | return NULL; | 394 | return NULL; | |
395 | } | 395 | } | |
396 | mutex_enter(vp->v_interlock); | 396 | mutex_enter(vp->v_interlock); | |
397 | if (ISSET(vp->v_iflag, VI_MARKER) || | 397 | if (ISSET(vp->v_iflag, VI_MARKER) || | |
398 | (f && !ISSET(vp->v_iflag, VI_XLOCK) && !(*f)(cl, vp))) { | 398 | (f && !ISSET(vp->v_iflag, VI_XLOCK) && !(*f)(cl, vp))) { | |
399 | mutex_exit(vp->v_interlock); | 399 | mutex_exit(vp->v_interlock); | |
400 | vp = TAILQ_NEXT(vp, v_mntvnodes); | 400 | vp = TAILQ_NEXT(vp, v_mntvnodes); | |
401 | goto again; | 401 | goto again; | |
402 | } | 402 | } | |
403 | 403 | |||
404 | TAILQ_INSERT_AFTER(&mp->mnt_vnodelist, vp, mvp, v_mntvnodes); | 404 | TAILQ_INSERT_AFTER(&mp->mnt_vnodelist, vp, mvp, v_mntvnodes); | |
405 | mvp->v_usecount = 1; | 405 | mvp->v_usecount = 1; | |
406 | mutex_exit(&mntvnode_lock); | 406 | mutex_exit(&mntvnode_lock); | |
407 | error = vget(vp, 0); | 407 | error = vget(vp, 0, true /* wait */); | |
408 | KASSERT(error == 0 || error == ENOENT); | 408 | KASSERT(error == 0 || error == ENOENT); | |
409 | } while (error != 0); | 409 | } while (error != 0); | |
410 | 410 | |||
411 | return vp; | 411 | return vp; | |
412 | } | 412 | } | |
413 | 413 | |||
414 | /* | 414 | /* | |
415 | * Move a vnode from one mount queue to another. | 415 | * Move a vnode from one mount queue to another. | |
416 | */ | 416 | */ | |
417 | void | 417 | void | |
418 | vfs_insmntque(vnode_t *vp, struct mount *mp) | 418 | vfs_insmntque(vnode_t *vp, struct mount *mp) | |
419 | { | 419 | { | |
420 | struct mount *omp; | 420 | struct mount *omp; |
--- src/sys/kern/vfs_vnode.c 2015/03/17 09:38:21 1.40
+++ src/sys/kern/vfs_vnode.c 2015/04/20 13:44:16 1.41
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfs_vnode.c,v 1.40 2015/03/17 09:38:21 hannken Exp $ */ | 1 | /* $NetBSD: vfs_vnode.c,v 1.41 2015/04/20 13:44:16 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997-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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center, by Charles M. Hannum, and by Andrew Doran. | 9 | * NASA Ames Research Center, by Charles M. Hannum, and by Andrew Doran. | |
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 | |
@@ -106,27 +106,27 @@ | @@ -106,27 +106,27 @@ | |||
106 | * from zero, the interlock must be held. To change from a non-zero | 106 | * from zero, the interlock must be held. To change from a non-zero | |
107 | * value to zero, again the interlock must be held. | 107 | * value to zero, again the interlock must be held. | |
108 | * | 108 | * | |
109 | * Changing the usecount from a non-zero value to a non-zero value can | 109 | * Changing the usecount from a non-zero value to a non-zero value can | |
110 | * safely be done using atomic operations, without the interlock held. | 110 | * safely be done using atomic operations, without the interlock held. | |
111 | * | 111 | * | |
112 | * Note: if VI_CLEAN is set, vnode_t::v_interlock will be released while | 112 | * Note: if VI_CLEAN is set, vnode_t::v_interlock will be released while | |
113 | * mntvnode_lock is still held. | 113 | * mntvnode_lock is still held. | |
114 | * | 114 | * | |
115 | * See PR 41374. | 115 | * See PR 41374. | |
116 | */ | 116 | */ | |
117 | 117 | |||
118 | #include <sys/cdefs.h> | 118 | #include <sys/cdefs.h> | |
119 | __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.40 2015/03/17 09:38:21 hannken Exp $"); | 119 | __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.41 2015/04/20 13:44:16 riastradh Exp $"); | |
120 | 120 | |||
121 | #define _VFS_VNODE_PRIVATE | 121 | #define _VFS_VNODE_PRIVATE | |
122 | 122 | |||
123 | #include <sys/param.h> | 123 | #include <sys/param.h> | |
124 | #include <sys/kernel.h> | 124 | #include <sys/kernel.h> | |
125 | 125 | |||
126 | #include <sys/atomic.h> | 126 | #include <sys/atomic.h> | |
127 | #include <sys/buf.h> | 127 | #include <sys/buf.h> | |
128 | #include <sys/conf.h> | 128 | #include <sys/conf.h> | |
129 | #include <sys/device.h> | 129 | #include <sys/device.h> | |
130 | #include <sys/hash.h> | 130 | #include <sys/hash.h> | |
131 | #include <sys/kauth.h> | 131 | #include <sys/kauth.h> | |
132 | #include <sys/kmem.h> | 132 | #include <sys/kmem.h> | |
@@ -508,33 +508,34 @@ vremfree(vnode_t *vp) | @@ -508,33 +508,34 @@ vremfree(vnode_t *vp) | |||
508 | 508 | |||
509 | /* | 509 | /* | |
510 | * vget: get a particular vnode from the free list, increment its reference | 510 | * vget: get a particular vnode from the free list, increment its reference | |
511 | * count and lock it. | 511 | * count and lock it. | |
512 | * | 512 | * | |
513 | * => Should be called with v_interlock held. | 513 | * => Should be called with v_interlock held. | |
514 | * | 514 | * | |
515 | * If VI_CHANGING is set, the vnode may be eliminated in vgone()/vclean(). | 515 | * If VI_CHANGING is set, the vnode may be eliminated in vgone()/vclean(). | |
516 | * In that case, we cannot grab the vnode, so the process is awakened when | 516 | * In that case, we cannot grab the vnode, so the process is awakened when | |
517 | * the transition is completed, and an error returned to indicate that the | 517 | * the transition is completed, and an error returned to indicate that the | |
518 | * vnode is no longer usable. | 518 | * vnode is no longer usable. | |
519 | */ | 519 | */ | |
520 | int | 520 | int | |
521 | vget(vnode_t *vp, int flags) | 521 | vget(vnode_t *vp, int flags, bool waitok) | |
522 | { | 522 | { | |
523 | int error = 0; | 523 | int error = 0; | |
524 | 524 | |||
525 | KASSERT((vp->v_iflag & VI_MARKER) == 0); | 525 | KASSERT((vp->v_iflag & VI_MARKER) == 0); | |
526 | KASSERT(mutex_owned(vp->v_interlock)); | 526 | KASSERT(mutex_owned(vp->v_interlock)); | |
527 | KASSERT((flags & ~(LK_SHARED|LK_EXCLUSIVE|LK_NOWAIT)) == 0); | 527 | KASSERT((flags & ~LK_NOWAIT) == 0); | |
528 | KASSERT(waitok == ((flags & LK_NOWAIT) == 0)); | |||
528 | 529 | |||
529 | /* | 530 | /* | |
530 | * Before adding a reference, we must remove the vnode | 531 | * Before adding a reference, we must remove the vnode | |
531 | * from its freelist. | 532 | * from its freelist. | |
532 | */ | 533 | */ | |
533 | if (vp->v_usecount == 0) { | 534 | if (vp->v_usecount == 0) { | |
534 | vremfree(vp); | 535 | vremfree(vp); | |
535 | vp->v_usecount = 1; | 536 | vp->v_usecount = 1; | |
536 | } else { | 537 | } else { | |
537 | atomic_inc_uint(&vp->v_usecount); | 538 | atomic_inc_uint(&vp->v_usecount); | |
538 | } | 539 | } | |
539 | 540 | |||
540 | /* | 541 | /* | |
@@ -545,36 +546,30 @@ vget(vnode_t *vp, int flags) | @@ -545,36 +546,30 @@ vget(vnode_t *vp, int flags) | |||
545 | if ((vp->v_iflag & VI_CHANGING) != 0) { | 546 | if ((vp->v_iflag & VI_CHANGING) != 0) { | |
546 | if ((flags & LK_NOWAIT) != 0) { | 547 | if ((flags & LK_NOWAIT) != 0) { | |
547 | vrelel(vp, 0); | 548 | vrelel(vp, 0); | |
548 | return EBUSY; | 549 | return EBUSY; | |
549 | } | 550 | } | |
550 | vwait(vp, VI_CHANGING); | 551 | vwait(vp, VI_CHANGING); | |
551 | if ((vp->v_iflag & VI_CLEAN) != 0) { | 552 | if ((vp->v_iflag & VI_CLEAN) != 0) { | |
552 | vrelel(vp, 0); | 553 | vrelel(vp, 0); | |
553 | return ENOENT; | 554 | return ENOENT; | |
554 | } | 555 | } | |
555 | } | 556 | } | |
556 | 557 | |||
557 | /* | 558 | /* | |
558 | * Ok, we got it in good shape. Just locking left. | 559 | * Ok, we got it in good shape. | |
559 | */ | 560 | */ | |
560 | KASSERT((vp->v_iflag & VI_CLEAN) == 0); | 561 | KASSERT((vp->v_iflag & VI_CLEAN) == 0); | |
561 | mutex_exit(vp->v_interlock); | 562 | mutex_exit(vp->v_interlock); | |
562 | if (flags & (LK_EXCLUSIVE | LK_SHARED)) { | |||
563 | error = vn_lock(vp, flags); | |||
564 | if (error != 0) { | |||
565 | vrele(vp); | |||
566 | } | |||
567 | } | |||
568 | return error; | 563 | return error; | |
569 | } | 564 | } | |
570 | 565 | |||
571 | /* | 566 | /* | |
572 | * vput: unlock and release the reference. | 567 | * vput: unlock and release the reference. | |
573 | */ | 568 | */ | |
574 | void | 569 | void | |
575 | vput(vnode_t *vp) | 570 | vput(vnode_t *vp) | |
576 | { | 571 | { | |
577 | 572 | |||
578 | KASSERT((vp->v_iflag & VI_MARKER) == 0); | 573 | KASSERT((vp->v_iflag & VI_MARKER) == 0); | |
579 | 574 | |||
580 | VOP_UNLOCK(vp); | 575 | VOP_UNLOCK(vp); | |
@@ -1237,27 +1232,27 @@ vcache_get(struct mount *mp, const void | @@ -1237,27 +1232,27 @@ vcache_get(struct mount *mp, const void | |||
1237 | vcache_key.vk_key = key; | 1232 | vcache_key.vk_key = key; | |
1238 | vcache_key.vk_key_len = key_len; | 1233 | vcache_key.vk_key_len = key_len; | |
1239 | hash = vcache_hash(&vcache_key); | 1234 | hash = vcache_hash(&vcache_key); | |
1240 | 1235 | |||
1241 | again: | 1236 | again: | |
1242 | mutex_enter(&vcache.lock); | 1237 | mutex_enter(&vcache.lock); | |
1243 | node = vcache_hash_lookup(&vcache_key, hash); | 1238 | node = vcache_hash_lookup(&vcache_key, hash); | |
1244 | 1239 | |||
1245 | /* If found, take a reference or retry. */ | 1240 | /* If found, take a reference or retry. */ | |
1246 | if (__predict_true(node != NULL && node->vn_vnode != NULL)) { | 1241 | if (__predict_true(node != NULL && node->vn_vnode != NULL)) { | |
1247 | vp = node->vn_vnode; | 1242 | vp = node->vn_vnode; | |
1248 | mutex_enter(vp->v_interlock); | 1243 | mutex_enter(vp->v_interlock); | |
1249 | mutex_exit(&vcache.lock); | 1244 | mutex_exit(&vcache.lock); | |
1250 | error = vget(vp, 0); | 1245 | error = vget(vp, 0, true /* wait */); | |
1251 | if (error == ENOENT) | 1246 | if (error == ENOENT) | |
1252 | goto again; | 1247 | goto again; | |
1253 | if (error == 0) | 1248 | if (error == 0) | |
1254 | *vpp = vp; | 1249 | *vpp = vp; | |
1255 | KASSERT((error != 0) == (*vpp == NULL)); | 1250 | KASSERT((error != 0) == (*vpp == NULL)); | |
1256 | return error; | 1251 | return error; | |
1257 | } | 1252 | } | |
1258 | 1253 | |||
1259 | /* If another thread loads this node, wait and retry. */ | 1254 | /* If another thread loads this node, wait and retry. */ | |
1260 | if (node != NULL) { | 1255 | if (node != NULL) { | |
1261 | KASSERT(node->vn_vnode == NULL); | 1256 | KASSERT(node->vn_vnode == NULL); | |
1262 | mutex_exit(&vcache.lock); | 1257 | mutex_exit(&vcache.lock); | |
1263 | kpause("vcache", false, mstohz(20), NULL); | 1258 | kpause("vcache", false, mstohz(20), NULL); |
--- src/sys/miscfs/specfs/spec_vnops.c 2015/03/28 19:24:06 1.146
+++ src/sys/miscfs/specfs/spec_vnops.c 2015/04/20 13:44:16 1.147
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: spec_vnops.c,v 1.146 2015/03/28 19:24:06 maxv Exp $ */ | 1 | /* $NetBSD: spec_vnops.c,v 1.147 2015/04/20 13:44:16 riastradh 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 | * 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. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
55 | * SUCH DAMAGE. | 55 | * SUCH DAMAGE. | |
56 | * | 56 | * | |
57 | * @(#)spec_vnops.c 8.15 (Berkeley) 7/14/95 | 57 | * @(#)spec_vnops.c 8.15 (Berkeley) 7/14/95 | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.146 2015/03/28 19:24:06 maxv Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.147 2015/04/20 13:44:16 riastradh Exp $"); | |
62 | 62 | |||
63 | #include <sys/param.h> | 63 | #include <sys/param.h> | |
64 | #include <sys/proc.h> | 64 | #include <sys/proc.h> | |
65 | #include <sys/systm.h> | 65 | #include <sys/systm.h> | |
66 | #include <sys/kernel.h> | 66 | #include <sys/kernel.h> | |
67 | #include <sys/conf.h> | 67 | #include <sys/conf.h> | |
68 | #include <sys/buf.h> | 68 | #include <sys/buf.h> | |
69 | #include <sys/mount.h> | 69 | #include <sys/mount.h> | |
70 | #include <sys/namei.h> | 70 | #include <sys/namei.h> | |
71 | #include <sys/vnode.h> | 71 | #include <sys/vnode.h> | |
72 | #include <sys/stat.h> | 72 | #include <sys/stat.h> | |
73 | #include <sys/errno.h> | 73 | #include <sys/errno.h> | |
74 | #include <sys/ioctl.h> | 74 | #include <sys/ioctl.h> | |
@@ -299,27 +299,27 @@ spec_node_lookup_by_dev(enum vtype type, | @@ -299,27 +299,27 @@ spec_node_lookup_by_dev(enum vtype type, | |||
299 | if (vp == NULL) { | 299 | if (vp == NULL) { | |
300 | mutex_exit(&device_lock); | 300 | mutex_exit(&device_lock); | |
301 | return ENOENT; | 301 | return ENOENT; | |
302 | } | 302 | } | |
303 | /* | 303 | /* | |
304 | * If it is an opened block device return the opened vnode. | 304 | * If it is an opened block device return the opened vnode. | |
305 | */ | 305 | */ | |
306 | if (type == VBLK && vp->v_specnode->sn_dev->sd_bdevvp != NULL) { | 306 | if (type == VBLK && vp->v_specnode->sn_dev->sd_bdevvp != NULL) { | |
307 | mutex_exit(vp->v_interlock); | 307 | mutex_exit(vp->v_interlock); | |
308 | vp = vp->v_specnode->sn_dev->sd_bdevvp; | 308 | vp = vp->v_specnode->sn_dev->sd_bdevvp; | |
309 | mutex_enter(vp->v_interlock); | 309 | mutex_enter(vp->v_interlock); | |
310 | } | 310 | } | |
311 | mutex_exit(&device_lock); | 311 | mutex_exit(&device_lock); | |
312 | error = vget(vp, 0); | 312 | error = vget(vp, 0, true /* wait */); | |
313 | if (error != 0) | 313 | if (error != 0) | |
314 | return error; | 314 | return error; | |
315 | *vpp = vp; | 315 | *vpp = vp; | |
316 | 316 | |||
317 | return 0; | 317 | return 0; | |
318 | } | 318 | } | |
319 | 319 | |||
320 | /* | 320 | /* | |
321 | * Lookup a vnode by file system mounted on and return it referenced. | 321 | * Lookup a vnode by file system mounted on and return it referenced. | |
322 | */ | 322 | */ | |
323 | int | 323 | int | |
324 | spec_node_lookup_by_mount(struct mount *mp, vnode_t **vpp) | 324 | spec_node_lookup_by_mount(struct mount *mp, vnode_t **vpp) | |
325 | { | 325 | { | |
@@ -334,27 +334,27 @@ spec_node_lookup_by_mount(struct mount * | @@ -334,27 +334,27 @@ spec_node_lookup_by_mount(struct mount * | |||
334 | vq = vp->v_specnode->sn_dev->sd_bdevvp; | 334 | vq = vp->v_specnode->sn_dev->sd_bdevvp; | |
335 | if (vq != NULL && | 335 | if (vq != NULL && | |
336 | vq->v_specnode->sn_dev->sd_mountpoint == mp) | 336 | vq->v_specnode->sn_dev->sd_mountpoint == mp) | |
337 | break; | 337 | break; | |
338 | vq = NULL; | 338 | vq = NULL; | |
339 | } | 339 | } | |
340 | } | 340 | } | |
341 | if (vq == NULL) { | 341 | if (vq == NULL) { | |
342 | mutex_exit(&device_lock); | 342 | mutex_exit(&device_lock); | |
343 | return ENOENT; | 343 | return ENOENT; | |
344 | } | 344 | } | |
345 | mutex_enter(vq->v_interlock); | 345 | mutex_enter(vq->v_interlock); | |
346 | mutex_exit(&device_lock); | 346 | mutex_exit(&device_lock); | |
347 | error = vget(vq, 0); | 347 | error = vget(vq, 0, true /* wait */); | |
348 | if (error != 0) | 348 | if (error != 0) | |
349 | return error; | 349 | return error; | |
350 | *vpp = vq; | 350 | *vpp = vq; | |
351 | 351 | |||
352 | return 0; | 352 | return 0; | |
353 | 353 | |||
354 | } | 354 | } | |
355 | 355 | |||
356 | /* | 356 | /* | |
357 | * Get the file system mounted on this block device. | 357 | * Get the file system mounted on this block device. | |
358 | */ | 358 | */ | |
359 | struct mount * | 359 | struct mount * | |
360 | spec_node_getmountedfs(vnode_t *devvp) | 360 | spec_node_getmountedfs(vnode_t *devvp) |
--- src/sys/miscfs/syncfs/Attic/sync_subr.c 2014/02/25 18:30:11 1.49
+++ src/sys/miscfs/syncfs/Attic/sync_subr.c 2015/04/20 13:44:16 1.50
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sync_subr.c,v 1.49 2014/02/25 18:30:11 pooka Exp $ */ | 1 | /* $NetBSD: sync_subr.c,v 1.50 2015/04/20 13:44:16 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2009 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 Andrew Doran. | 8 | * by Andrew Doran. | |
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. | |
@@ -80,27 +80,27 @@ | @@ -80,27 +80,27 @@ | |||
80 | * this queue: | 80 | * this queue: | |
81 | * | 81 | * | |
82 | * syncer_workitem_pending[syncer_delayno] | 82 | * syncer_workitem_pending[syncer_delayno] | |
83 | * | 83 | * | |
84 | * A delay of e.g. fifteen seconds is done by placing the request fifteen | 84 | * A delay of e.g. fifteen seconds is done by placing the request fifteen | |
85 | * entries later in the queue: | 85 | * entries later in the queue: | |
86 | * | 86 | * | |
87 | * syncer_workitem_pending[(syncer_delayno + 15) & syncer_mask] | 87 | * syncer_workitem_pending[(syncer_delayno + 15) & syncer_mask] | |
88 | * | 88 | * | |
89 | * Flag VI_ONWORKLST indicates that vnode is added into the queue. | 89 | * Flag VI_ONWORKLST indicates that vnode is added into the queue. | |
90 | */ | 90 | */ | |
91 | 91 | |||
92 | #include <sys/cdefs.h> | 92 | #include <sys/cdefs.h> | |
93 | __KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.49 2014/02/25 18:30:11 pooka Exp $"); | 93 | __KERNEL_RCSID(0, "$NetBSD: sync_subr.c,v 1.50 2015/04/20 13:44:16 riastradh Exp $"); | |
94 | 94 | |||
95 | #include <sys/param.h> | 95 | #include <sys/param.h> | |
96 | #include <sys/systm.h> | 96 | #include <sys/systm.h> | |
97 | #include <sys/sysctl.h> | 97 | #include <sys/sysctl.h> | |
98 | #include <sys/kernel.h> | 98 | #include <sys/kernel.h> | |
99 | #include <sys/proc.h> | 99 | #include <sys/proc.h> | |
100 | #include <sys/mount.h> | 100 | #include <sys/mount.h> | |
101 | #include <sys/time.h> | 101 | #include <sys/time.h> | |
102 | #include <sys/vnode.h> | 102 | #include <sys/vnode.h> | |
103 | #include <sys/buf.h> | 103 | #include <sys/buf.h> | |
104 | #include <sys/errno.h> | 104 | #include <sys/errno.h> | |
105 | #include <sys/kmem.h> | 105 | #include <sys/kmem.h> | |
106 | 106 | |||
@@ -229,31 +229,37 @@ sched_sync(void *arg) | @@ -229,31 +229,37 @@ sched_sync(void *arg) | |||
229 | /* | 229 | /* | |
230 | * Push files whose dirty time has expired. | 230 | * Push files whose dirty time has expired. | |
231 | */ | 231 | */ | |
232 | slp = &syncer_workitem_pending[syncer_delayno]; | 232 | slp = &syncer_workitem_pending[syncer_delayno]; | |
233 | syncer_delayno += 1; | 233 | syncer_delayno += 1; | |
234 | if (syncer_delayno >= syncer_last) | 234 | if (syncer_delayno >= syncer_last) | |
235 | syncer_delayno = 0; | 235 | syncer_delayno = 0; | |
236 | 236 | |||
237 | while ((vp = TAILQ_FIRST(slp)) != NULL) { | 237 | while ((vp = TAILQ_FIRST(slp)) != NULL) { | |
238 | /* We are locking in the wrong direction. */ | 238 | /* We are locking in the wrong direction. */ | |
239 | synced = false; | 239 | synced = false; | |
240 | if (mutex_tryenter(vp->v_interlock)) { | 240 | if (mutex_tryenter(vp->v_interlock)) { | |
241 | mutex_exit(&syncer_data_lock); | 241 | mutex_exit(&syncer_data_lock); | |
242 | if (vget(vp, LK_EXCLUSIVE | LK_NOWAIT) == 0) { | 242 | if (vget(vp, LK_NOWAIT, false /* !wait */) | |
243 | synced = true; | 243 | == 0) { | |
244 | (void) VOP_FSYNC(vp, curlwp->l_cred, | 244 | if (vn_lock(vp, LK_EXCLUSIVE|LK_NOWAIT) | |
245 | FSYNC_LAZY, 0, 0); | 245 | == 0) { | |
246 | vput(vp); | 246 | synced = true; | |
247 | (void) VOP_FSYNC(vp, | |||
248 | curlwp->l_cred, FSYNC_LAZY, | |||
249 | 0, 0); | |||
250 | VOP_UNLOCK(vp); | |||
251 | } | |||
252 | vrele(vp); | |||
247 | } | 253 | } | |
248 | mutex_enter(&syncer_data_lock); | 254 | mutex_enter(&syncer_data_lock); | |
249 | } | 255 | } | |
250 | 256 | |||
251 | /* | 257 | /* | |
252 | * XXX The vnode may have been recycled, in which | 258 | * XXX The vnode may have been recycled, in which | |
253 | * case it may have a new identity. | 259 | * case it may have a new identity. | |
254 | */ | 260 | */ | |
255 | if (TAILQ_FIRST(slp) == vp) { | 261 | if (TAILQ_FIRST(slp) == vp) { | |
256 | /* | 262 | /* | |
257 | * Put us back on the worklist. The worklist | 263 | * Put us back on the worklist. The worklist | |
258 | * routine will remove us from our current | 264 | * routine will remove us from our current | |
259 | * position and then add us back in at a later | 265 | * position and then add us back in at a later |
--- src/sys/sys/vnode.h 2015/04/20 13:12:24 1.251
+++ src/sys/sys/vnode.h 2015/04/20 13:44:16 1.252
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vnode.h,v 1.251 2015/04/20 13:12:24 riastradh Exp $ */ | 1 | /* $NetBSD: vnode.h,v 1.252 2015/04/20 13:44:16 riastradh 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 | * 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. | |
@@ -523,27 +523,27 @@ struct vnode; | @@ -523,27 +523,27 @@ struct vnode; | |||
523 | /* see vnode(9) */ | 523 | /* see vnode(9) */ | |
524 | void vfs_vnode_sysinit(void); | 524 | void vfs_vnode_sysinit(void); | |
525 | int bdevvp(dev_t, struct vnode **); | 525 | int bdevvp(dev_t, struct vnode **); | |
526 | int cdevvp(dev_t, struct vnode **); | 526 | int cdevvp(dev_t, struct vnode **); | |
527 | int getnewvnode(enum vtagtype, struct mount *, int (**)(void *), | 527 | int getnewvnode(enum vtagtype, struct mount *, int (**)(void *), | |
528 | kmutex_t *, struct vnode **); | 528 | kmutex_t *, struct vnode **); | |
529 | void ungetnewvnode(struct vnode *); | 529 | void ungetnewvnode(struct vnode *); | |
530 | int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t); | 530 | int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t); | |
531 | void vattr_null(struct vattr *); | 531 | void vattr_null(struct vattr *); | |
532 | void vdevgone(int, int, int, enum vtype); | 532 | void vdevgone(int, int, int, enum vtype); | |
533 | int vfinddev(dev_t, enum vtype, struct vnode **); | 533 | int vfinddev(dev_t, enum vtype, struct vnode **); | |
534 | int vflush(struct mount *, struct vnode *, int); | 534 | int vflush(struct mount *, struct vnode *, int); | |
535 | int vflushbuf(struct vnode *, int); | 535 | int vflushbuf(struct vnode *, int); | |
536 | int vget(struct vnode *, int); | 536 | int vget(struct vnode *, int, bool); | |
537 | void vgone(struct vnode *); | 537 | void vgone(struct vnode *); | |
538 | int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int); | 538 | int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int); | |
539 | void vprint(const char *, struct vnode *); | 539 | void vprint(const char *, struct vnode *); | |
540 | void vput(struct vnode *); | 540 | void vput(struct vnode *); | |
541 | bool vrecycle(struct vnode *); | 541 | bool vrecycle(struct vnode *); | |
542 | void vrele(struct vnode *); | 542 | void vrele(struct vnode *); | |
543 | void vrele_async(struct vnode *); | 543 | void vrele_async(struct vnode *); | |
544 | void vrele_flush(void); | 544 | void vrele_flush(void); | |
545 | int vtruncbuf(struct vnode *, daddr_t, bool, int); | 545 | int vtruncbuf(struct vnode *, daddr_t, bool, int); | |
546 | void vwakeup(struct buf *); | 546 | void vwakeup(struct buf *); | |
547 | int vdead_check(struct vnode *, int); | 547 | int vdead_check(struct vnode *, int); | |
548 | void vrevoke(struct vnode *); | 548 | void vrevoke(struct vnode *); | |
549 | struct vnode * | 549 | struct vnode * |
--- src/sys/ufs/lfs/lfs_segment.c 2015/03/28 19:24:05 1.237
+++ src/sys/ufs/lfs/lfs_segment.c 2015/04/20 13:44:16 1.238
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lfs_segment.c,v 1.237 2015/03/28 19:24:05 maxv Exp $ */ | 1 | /* $NetBSD: lfs_segment.c,v 1.238 2015/04/20 13:44:16 riastradh 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_segment.c 8.10 (Berkeley) 6/10/95 | 59 | * @(#)lfs_segment.c 8.10 (Berkeley) 6/10/95 | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | #include <sys/cdefs.h> | 62 | #include <sys/cdefs.h> | |
63 | __KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.237 2015/03/28 19:24:05 maxv Exp $"); | 63 | __KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.238 2015/04/20 13:44:16 riastradh Exp $"); | |
64 | 64 | |||
65 | #define _VFS_VNODE_PRIVATE /* XXX: check for VI_MARKER, this has to go */ | 65 | #define _VFS_VNODE_PRIVATE /* XXX: check for VI_MARKER, this has to go */ | |
66 | 66 | |||
67 | #ifdef DEBUG | 67 | #ifdef DEBUG | |
68 | # define vndebug(vp, str) do { \ | 68 | # define vndebug(vp, str) do { \ | |
69 | if (VTOI(vp)->i_flag & IN_CLEANING) \ | 69 | if (VTOI(vp)->i_flag & IN_CLEANING) \ | |
70 | DLOG((DLOG_WVNODE, "not writing ino %d because %s (op %d)\n", \ | 70 | DLOG((DLOG_WVNODE, "not writing ino %d because %s (op %d)\n", \ | |
71 | VTOI(vp)->i_number, (str), op)); \ | 71 | VTOI(vp)->i_number, (str), op)); \ | |
72 | } while(0) | 72 | } while(0) | |
73 | #else | 73 | #else | |
74 | # define vndebug(vp, str) | 74 | # define vndebug(vp, str) | |
75 | #endif | 75 | #endif | |
76 | #define ivndebug(vp, str) \ | 76 | #define ivndebug(vp, str) \ | |
@@ -2771,27 +2771,27 @@ lfs_vref(struct vnode *vp) | @@ -2771,27 +2771,27 @@ lfs_vref(struct vnode *vp) | |||
2771 | ASSERT_MAYBE_SEGLOCK(fs); | 2771 | ASSERT_MAYBE_SEGLOCK(fs); | |
2772 | 2772 | |||
2773 | /* | 2773 | /* | |
2774 | * If we return 1 here during a flush, we risk vinvalbuf() not | 2774 | * If we return 1 here during a flush, we risk vinvalbuf() not | |
2775 | * being able to flush all of the pages from this vnode, which | 2775 | * being able to flush all of the pages from this vnode, which | |
2776 | * will cause it to panic. So, return 0 if a flush is in progress. | 2776 | * will cause it to panic. So, return 0 if a flush is in progress. | |
2777 | */ | 2777 | */ | |
2778 | if (IS_FLUSHING(VTOI(vp)->i_lfs, vp)) { | 2778 | if (IS_FLUSHING(VTOI(vp)->i_lfs, vp)) { | |
2779 | ++fs->lfs_flushvp_fakevref; | 2779 | ++fs->lfs_flushvp_fakevref; | |
2780 | mutex_exit(vp->v_interlock); | 2780 | mutex_exit(vp->v_interlock); | |
2781 | return 0; | 2781 | return 0; | |
2782 | } | 2782 | } | |
2783 | 2783 | |||
2784 | return vget(vp, LK_NOWAIT); | 2784 | return vget(vp, LK_NOWAIT, false /* !wait */); | |
2785 | } | 2785 | } | |
2786 | 2786 | |||
2787 | /* | 2787 | /* | |
2788 | * This is vrele except that we do not want to VOP_INACTIVE this vnode. We | 2788 | * This is vrele except that we do not want to VOP_INACTIVE this vnode. We | |
2789 | * inline vrele here to avoid the vn_lock and VOP_INACTIVE call at the end. | 2789 | * inline vrele here to avoid the vn_lock and VOP_INACTIVE call at the end. | |
2790 | */ | 2790 | */ | |
2791 | void | 2791 | void | |
2792 | lfs_vunref(struct vnode *vp) | 2792 | lfs_vunref(struct vnode *vp) | |
2793 | { | 2793 | { | |
2794 | struct lfs *fs; | 2794 | struct lfs *fs; | |
2795 | 2795 | |||
2796 | fs = VTOI(vp)->i_lfs; | 2796 | fs = VTOI(vp)->i_lfs; | |
2797 | ASSERT_MAYBE_SEGLOCK(fs); | 2797 | ASSERT_MAYBE_SEGLOCK(fs); |
--- src/sys/ufs/lfs/lfs_syscalls.c 2015/03/28 19:24:05 1.156
+++ src/sys/ufs/lfs/lfs_syscalls.c 2015/04/20 13:44:16 1.157
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lfs_syscalls.c,v 1.156 2015/03/28 19:24:05 maxv Exp $ */ | 1 | /* $NetBSD: lfs_syscalls.c,v 1.157 2015/04/20 13:44:16 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008 | 4 | * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008 | |
5 | * The NetBSD Foundation, Inc. | 5 | * The NetBSD Foundation, Inc. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to The NetBSD Foundation | 8 | * This code is derived from software contributed to The NetBSD Foundation | |
9 | * by Konrad E. Schroder <perseant@hhhh.org>. | 9 | * by Konrad E. Schroder <perseant@hhhh.org>. | |
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 | |
@@ -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 | * @(#)lfs_syscalls.c 8.10 (Berkeley) 5/14/95 | 60 | * @(#)lfs_syscalls.c 8.10 (Berkeley) 5/14/95 | |
61 | */ | 61 | */ | |
62 | 62 | |||
63 | #include <sys/cdefs.h> | 63 | #include <sys/cdefs.h> | |
64 | __KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.156 2015/03/28 19:24:05 maxv Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.157 2015/04/20 13:44:16 riastradh Exp $"); | |
65 | 65 | |||
66 | #ifndef LFS | 66 | #ifndef LFS | |
67 | # define LFS /* for prototypes in syscallargs.h */ | 67 | # define LFS /* for prototypes in syscallargs.h */ | |
68 | #endif | 68 | #endif | |
69 | 69 | |||
70 | #include <sys/param.h> | 70 | #include <sys/param.h> | |
71 | #include <sys/systm.h> | 71 | #include <sys/systm.h> | |
72 | #include <sys/proc.h> | 72 | #include <sys/proc.h> | |
73 | #include <sys/buf.h> | 73 | #include <sys/buf.h> | |
74 | #include <sys/mount.h> | 74 | #include <sys/mount.h> | |
75 | #include <sys/vnode.h> | 75 | #include <sys/vnode.h> | |
76 | #include <sys/kernel.h> | 76 | #include <sys/kernel.h> | |
77 | #include <sys/kauth.h> | 77 | #include <sys/kauth.h> | |
@@ -704,27 +704,28 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp, | @@ -704,27 +704,28 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp, | |||
704 | * Get the IFILE entry (only once) and see if the file still | 704 | * Get the IFILE entry (only once) and see if the file still | |
705 | * exists. | 705 | * exists. | |
706 | */ | 706 | */ | |
707 | if (lastino != blkp->bi_inode) { | 707 | if (lastino != blkp->bi_inode) { | |
708 | /* | 708 | /* | |
709 | * Finish the old file, if there was one. The presence | 709 | * Finish the old file, if there was one. The presence | |
710 | * of a usable vnode in vp is signaled by a valid | 710 | * of a usable vnode in vp is signaled by a valid | |
711 | * v_daddr. | 711 | * v_daddr. | |
712 | */ | 712 | */ | |
713 | if (v_daddr != LFS_UNUSED_DADDR) { | 713 | if (v_daddr != LFS_UNUSED_DADDR) { | |
714 | lfs_vunref(vp); | 714 | lfs_vunref(vp); | |
715 | if (VTOI(vp)->i_lfs_iflags & LFSI_BMAP) { | 715 | if (VTOI(vp)->i_lfs_iflags & LFSI_BMAP) { | |
716 | mutex_enter(vp->v_interlock); | 716 | mutex_enter(vp->v_interlock); | |
717 | if (vget(vp, LK_NOWAIT) == 0) { | 717 | if (vget(vp, LK_NOWAIT, | |
718 | false /* !wait */) == 0) { | |||
718 | if (! vrecycle(vp)) | 719 | if (! vrecycle(vp)) | |
719 | vrele(vp); | 720 | vrele(vp); | |
720 | } | 721 | } | |
721 | } | 722 | } | |
722 | numrefed--; | 723 | numrefed--; | |
723 | } | 724 | } | |
724 | 725 | |||
725 | /* | 726 | /* | |
726 | * Start a new file | 727 | * Start a new file | |
727 | */ | 728 | */ | |
728 | lastino = blkp->bi_inode; | 729 | lastino = blkp->bi_inode; | |
729 | if (blkp->bi_inode == LFS_IFILE_INUM) | 730 | if (blkp->bi_inode == LFS_IFILE_INUM) | |
730 | v_daddr = fs->lfs_idaddr; | 731 | v_daddr = fs->lfs_idaddr; | |
@@ -822,27 +823,27 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp, | @@ -822,27 +823,27 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp, | |||
822 | blkp->bi_size = fs->lfs_bsize; | 823 | blkp->bi_size = fs->lfs_bsize; | |
823 | } | 824 | } | |
824 | } | 825 | } | |
825 | 826 | |||
826 | /* | 827 | /* | |
827 | * Finish the old file, if there was one. The presence | 828 | * Finish the old file, if there was one. The presence | |
828 | * of a usable vnode in vp is signaled by a valid v_daddr. | 829 | * of a usable vnode in vp is signaled by a valid v_daddr. | |
829 | */ | 830 | */ | |
830 | if (v_daddr != LFS_UNUSED_DADDR) { | 831 | if (v_daddr != LFS_UNUSED_DADDR) { | |
831 | lfs_vunref(vp); | 832 | lfs_vunref(vp); | |
832 | /* Recycle as above. */ | 833 | /* Recycle as above. */ | |
833 | if (ip->i_lfs_iflags & LFSI_BMAP) { | 834 | if (ip->i_lfs_iflags & LFSI_BMAP) { | |
834 | mutex_enter(vp->v_interlock); | 835 | mutex_enter(vp->v_interlock); | |
835 | if (vget(vp, LK_NOWAIT) == 0) { | 836 | if (vget(vp, LK_NOWAIT, false /* !wait */) == 0) { | |
836 | if (! vrecycle(vp)) | 837 | if (! vrecycle(vp)) | |
837 | vrele(vp); | 838 | vrele(vp); | |
838 | } | 839 | } | |
839 | } | 840 | } | |
840 | numrefed--; | 841 | numrefed--; | |
841 | } | 842 | } | |
842 | 843 | |||
843 | #ifdef DIAGNOSTIC | 844 | #ifdef DIAGNOSTIC | |
844 | if (numrefed != 0) | 845 | if (numrefed != 0) | |
845 | panic("lfs_bmapv: numrefed=%d", numrefed); | 846 | panic("lfs_bmapv: numrefed=%d", numrefed); | |
846 | #endif | 847 | #endif | |
847 | 848 | |||
848 | vfs_unbusy(mntp, false, NULL); | 849 | vfs_unbusy(mntp, false, NULL); |
--- src/sys/ufs/lfs/Attic/ulfs_ihash.c 2014/02/27 16:51:39 1.4
+++ src/sys/ufs/lfs/Attic/ulfs_ihash.c 2015/04/20 13:44:16 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_ihash.c,v 1.4 2014/02/27 16:51:39 hannken Exp $ */ | 1 | /* $NetBSD: ulfs_ihash.c,v 1.5 2015/04/20 13:44:16 riastradh Exp $ */ | |
2 | /* from NetBSD: ufs_ihash.c,v 1.31 2011/06/12 03:36:02 rmind Exp */ | 2 | /* from NetBSD: ufs_ihash.c,v 1.31 2011/06/12 03:36:02 rmind Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1982, 1986, 1989, 1991, 1993 | 5 | * Copyright (c) 1982, 1986, 1989, 1991, 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_ihash.c 8.7 (Berkeley) 5/17/95 | 32 | * @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95 | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | __KERNEL_RCSID(0, "$NetBSD: ulfs_ihash.c,v 1.4 2014/02/27 16:51:39 hannken Exp $"); | 36 | __KERNEL_RCSID(0, "$NetBSD: ulfs_ihash.c,v 1.5 2015/04/20 13:44:16 riastradh Exp $"); | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/vnode.h> | 40 | #include <sys/vnode.h> | |
41 | #include <sys/proc.h> | 41 | #include <sys/proc.h> | |
42 | #include <sys/mutex.h> | 42 | #include <sys/mutex.h> | |
43 | 43 | |||
44 | #include <ufs/lfs/ulfs_inode.h> | 44 | #include <ufs/lfs/ulfs_inode.h> | |
45 | #include <ufs/lfs/ulfs_extern.h> | 45 | #include <ufs/lfs/ulfs_extern.h> | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | * Structures associated with inode cacheing. | 48 | * Structures associated with inode cacheing. | |
49 | */ | 49 | */ | |
@@ -130,39 +130,47 @@ ulfs_ihashlookup(dev_t dev, ino_t inum) | @@ -130,39 +130,47 @@ ulfs_ihashlookup(dev_t dev, ino_t inum) | |||
130 | } | 130 | } | |
131 | 131 | |||
132 | /* | 132 | /* | |
133 | * Use the device/inum pair to find the incore inode, and return a pointer | 133 | * Use the device/inum pair to find the incore inode, and return a pointer | |
134 | * to it. If it is in core, but locked, wait for it. | 134 | * to it. If it is in core, but locked, wait for it. | |
135 | */ | 135 | */ | |
136 | struct vnode * | 136 | struct vnode * | |
137 | ulfs_ihashget(dev_t dev, ino_t inum, int flags) | 137 | ulfs_ihashget(dev_t dev, ino_t inum, int flags) | |
138 | { | 138 | { | |
139 | struct ihashhead *ipp; | 139 | struct ihashhead *ipp; | |
140 | struct inode *ip; | 140 | struct inode *ip; | |
141 | struct vnode *vp; | 141 | struct vnode *vp; | |
142 | 142 | |||
143 | KASSERT(flags == (flags & LK_EXCLUSIVE)); | |||
144 | ||||
143 | loop: | 145 | loop: | |
144 | mutex_enter(&ulfs_ihash_lock); | 146 | mutex_enter(&ulfs_ihash_lock); | |
145 | ipp = &ihashtbl[INOHASH(dev, inum)]; | 147 | ipp = &ihashtbl[INOHASH(dev, inum)]; | |
146 | LIST_FOREACH(ip, ipp, i_hash) { | 148 | LIST_FOREACH(ip, ipp, i_hash) { | |
147 | if (inum == ip->i_number && dev == ip->i_dev) { | 149 | if (inum == ip->i_number && dev == ip->i_dev) { | |
148 | vp = ITOV(ip); | 150 | vp = ITOV(ip); | |
149 | if (flags == 0) { | 151 | if (flags == 0) { | |
150 | mutex_exit(&ulfs_ihash_lock); | 152 | mutex_exit(&ulfs_ihash_lock); | |
151 | } else { | 153 | } else { | |
152 | mutex_enter(vp->v_interlock); | 154 | mutex_enter(vp->v_interlock); | |
153 | mutex_exit(&ulfs_ihash_lock); | 155 | mutex_exit(&ulfs_ihash_lock); | |
154 | if (vget(vp, flags)) | 156 | if (vget(vp, 0, true /* wait */) != 0) | |
155 | goto loop; | 157 | goto loop; | |
158 | if (flags & LK_EXCLUSIVE) { | |||
159 | if (vn_lock(vp, LK_EXCLUSIVE) != 0) { | |||
160 | vrele(vp); | |||
161 | goto loop; | |||
162 | } | |||
163 | } | |||
156 | } | 164 | } | |
157 | return (vp); | 165 | return (vp); | |
158 | } | 166 | } | |
159 | } | 167 | } | |
160 | mutex_exit(&ulfs_ihash_lock); | 168 | mutex_exit(&ulfs_ihash_lock); | |
161 | return (NULL); | 169 | return (NULL); | |
162 | } | 170 | } | |
163 | 171 | |||
164 | /* | 172 | /* | |
165 | * Insert the inode into the hash table, and return it locked. | 173 | * Insert the inode into the hash table, and return it locked. | |
166 | */ | 174 | */ | |
167 | void | 175 | void | |
168 | ulfs_ihashins(struct inode *ip) | 176 | ulfs_ihashins(struct inode *ip) |