Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern It is impossible for VOP_LOCK() to return ENOENT wi...
details: https://anonhg.NetBSD.org/src/rev/c26689b257ce
branches: trunk
changeset: 364441:c26689b257ce
user: hannken <hannken%NetBSD.org@localhost>
date: Fri Mar 25 08:57:15 2022 +0000
description:
It is impossible for VOP_LOCK() to return ENOENT with LK_RETRY flag.
Remove the second call to VOP_LOCK().
Enable assertion "vrefcnt(vp) > 0" and assert all possible errors
for all LK_RETRY/LK_NOWAIT combinations.
diffstat:
sys/kern/vfs_vnops.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diffs (57 lines):
diff -r 42e8b054a849 -r c26689b257ce sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c Fri Mar 25 08:56:36 2022 +0000
+++ b/sys/kern/vfs_vnops.c Fri Mar 25 08:57:15 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnops.c,v 1.226 2022/03/19 13:50:02 hannken Exp $ */
+/* $NetBSD: vfs_vnops.c,v 1.227 2022/03/25 08:57:15 hannken Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.226 2022/03/19 13:50:02 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.227 2022/03/25 08:57:15 hannken Exp $");
#include "veriexec.h"
@@ -1192,9 +1192,7 @@
struct lwp *l;
int error;
-#if 0
- KASSERT(vrefcnt(vp) > 0 || (vp->v_iflag & VI_ONWORKLST) != 0);
-#endif
+ KASSERT(vrefcnt(vp) > 0);
KASSERT((flags & ~(LK_SHARED|LK_EXCLUSIVE|LK_NOWAIT|LK_RETRY|
LK_UPGRADE|LK_DOWNGRADE)) == 0);
KASSERT((flags & LK_NOWAIT) != 0 || !mutex_owned(vp->v_interlock));
@@ -1210,13 +1208,23 @@
l->l_rwcallsite = (uintptr_t)__builtin_return_address(0);
error = VOP_LOCK(vp, flags);
- if ((flags & LK_RETRY) != 0 && error == ENOENT)
- error = VOP_LOCK(vp, flags);
l->l_rwcallsite = 0;
- KASSERT((flags & LK_RETRY) == 0 || (flags & LK_NOWAIT) != 0 ||
- error == 0);
+ switch (flags & (LK_RETRY | LK_NOWAIT)) {
+ case 0:
+ KASSERT(error == 0 || error == ENOENT);
+ break;
+ case LK_RETRY:
+ KASSERT(error == 0);
+ break;
+ case LK_NOWAIT:
+ KASSERT(error == 0 || error == EBUSY || error == ENOENT);
+ break;
+ case LK_RETRY | LK_NOWAIT:
+ KASSERT(error == 0 || error == EBUSY);
+ break;
+ }
return error;
}
Home |
Main Index |
Thread Index |
Old Index