Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/miscfs/specfs specfs: sn_gone cannot be set while we hol...
details: https://anonhg.NetBSD.org/src/rev/c0cd4362062a
branches: trunk
changeset: 364505:c0cd4362062a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Mar 28 12:35:44 2022 +0000
description:
specfs: sn_gone cannot be set while we hold the vnode lock.
Revoke runs with the vnode lock too, which is exclusive. Add an
assertion to this effect in spec_node_revoke to make it clear.
diffstat:
sys/miscfs/specfs/spec_vnops.c | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
diffs (65 lines):
diff -r 60c601c53d5c -r c0cd4362062a sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c Mon Mar 28 12:35:35 2022 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c Mon Mar 28 12:35:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spec_vnops.c,v 1.194 2022/03/28 12:35:35 riastradh Exp $ */
+/* $NetBSD: spec_vnops.c,v 1.195 2022/03/28 12:35:44 riastradh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.194 2022/03/28 12:35:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.195 2022/03/28 12:35:44 riastradh Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -402,6 +402,8 @@
specnode_t *sn;
specdev_t *sd;
+ KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
+
sn = vp->v_specnode;
sd = sn->sn_dev;
@@ -552,11 +554,8 @@
/*
* Acquire an open reference -- as long as we hold onto it, and
- * the vnode isn't revoked, it can't be closed.
- *
- * But first check whether it has been revoked -- if so, we
- * can't acquire more open references and we must fail
- * immediately with EBADF.
+ * the vnode isn't revoked, it can't be closed, and the vnode
+ * can't be revoked until we release the vnode lock.
*/
mutex_enter(&device_lock);
switch (vp->v_type) {
@@ -565,10 +564,7 @@
* Character devices can accept opens from multiple
* vnodes.
*/
- if (sn->sn_gone) {
- error = EBADF;
- break;
- }
+ KASSERT(!sn->sn_gone);
sd->sd_opencnt++;
sn->sn_opencnt++;
break;
@@ -581,10 +577,7 @@
* Treat zero opencnt with non-NULL mountpoint as open.
* This may happen after forced detach of a mounted device.
*/
- if (sn->sn_gone) {
- error = EBADF;
- break;
- }
+ KASSERT(!sn->sn_gone);
if (sd->sd_opencnt != 0 || sd->sd_mountpoint != NULL) {
error = EBUSY;
break;
Home |
Main Index |
Thread Index |
Old Index