Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Lock vnode across VOP_OPEN.
details: https://anonhg.NetBSD.org/src/rev/ab1309dad3b5
branches: trunk
changeset: 364368:ab1309dad3b5
user: hannken <hannken%NetBSD.org@localhost>
date: Sat Mar 19 13:50:02 2022 +0000
description:
Lock vnode across VOP_OPEN.
diffstat:
sys/dev/ata/ata_raid_adaptec.c | 5 +++--
sys/dev/ata/ata_raid_intel.c | 5 +++--
sys/dev/ata/ata_raid_jmicron.c | 5 +++--
sys/dev/ata/ata_raid_nvidia.c | 5 +++--
sys/dev/ata/ata_raid_promise.c | 5 +++--
sys/dev/ata/ata_raid_subr.c | 6 +++---
sys/dev/ata/ata_raid_via.c | 5 +++--
sys/kern/vfs_mount.c | 6 ++++--
sys/kern/vfs_vnops.c | 8 +++++---
9 files changed, 30 insertions(+), 20 deletions(-)
diffs (252 lines):
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/dev/ata/ata_raid_adaptec.c
--- a/sys/dev/ata/ata_raid_adaptec.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/dev/ata/ata_raid_adaptec.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_adaptec.c,v 1.11 2018/10/22 19:38:06 jdolecek Exp $ */
+/* $NetBSD: ata_raid_adaptec.c,v 1.12 2022/03/19 13:51:01 hannken Exp $ */
/*-
* Copyright (c) 2000,2001,2002 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.11 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.12 2022/03/19 13:51:01 hannken Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -86,6 +86,7 @@
if (error)
goto out;
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(vp, FREAD, NOCRED);
if (error) {
vput(vp);
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/dev/ata/ata_raid_intel.c
--- a/sys/dev/ata/ata_raid_intel.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/dev/ata/ata_raid_intel.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_intel.c,v 1.10 2019/10/04 12:24:32 mrg Exp $ */
+/* $NetBSD: ata_raid_intel.c,v 1.11 2022/03/19 13:51:01 hannken Exp $ */
/*-
* Copyright (c) 2000-2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.10 2019/10/04 12:24:32 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.11 2022/03/19 13:51:01 hannken Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -158,6 +158,7 @@
if (error)
goto out;
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(vp, FREAD, NOCRED);
if (error) {
vput(vp);
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/dev/ata/ata_raid_jmicron.c
--- a/sys/dev/ata/ata_raid_jmicron.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/dev/ata/ata_raid_jmicron.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_jmicron.c,v 1.7 2018/10/22 19:38:06 jdolecek Exp $ */
+/* $NetBSD: ata_raid_jmicron.c,v 1.8 2022/03/19 13:51:01 hannken Exp $ */
/*-
* Copyright (c) 2000-2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.7 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.8 2022/03/19 13:51:01 hannken Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -139,6 +139,7 @@
if (error)
goto out;
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(vp, FREAD, NOCRED);
if (error) {
vput(vp);
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/dev/ata/ata_raid_nvidia.c
--- a/sys/dev/ata/ata_raid_nvidia.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/dev/ata/ata_raid_nvidia.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_nvidia.c,v 1.4 2018/10/22 19:38:06 jdolecek Exp $ */
+/* $NetBSD: ata_raid_nvidia.c,v 1.5 2022/03/19 13:51:01 hannken Exp $ */
/*-
* Copyright (c) 2000 - 2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.4 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.5 2022/03/19 13:51:01 hannken Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -145,6 +145,7 @@
if (error)
goto out;
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(vp, FREAD, NOCRED);
if (error) {
vput(vp);
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/dev/ata/ata_raid_promise.c
--- a/sys/dev/ata/ata_raid_promise.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/dev/ata/ata_raid_promise.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_promise.c,v 1.13 2018/10/22 19:38:06 jdolecek Exp $ */
+/* $NetBSD: ata_raid_promise.c,v 1.14 2022/03/19 13:51:01 hannken Exp $ */
/*-
* Copyright (c) 2000,2001,2002 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_promise.c,v 1.13 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_promise.c,v 1.14 2022/03/19 13:51:01 hannken Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -86,6 +86,7 @@
if (error)
goto out;
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(vp, FREAD, NOCRED);
if (error) {
vput(vp);
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/dev/ata/ata_raid_subr.c
--- a/sys/dev/ata/ata_raid_subr.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/dev/ata/ata_raid_subr.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_subr.c,v 1.3 2017/06/25 12:29:32 maxv Exp $ */
+/* $NetBSD: ata_raid_subr.c,v 1.4 2022/03/19 13:51:01 hannken Exp $ */
/*-
* Copyright (c) 2008 Juan Romero Pardines.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_subr.c,v 1.3 2017/06/25 12:29:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_subr.c,v 1.4 2022/03/19 13:51:01 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -82,13 +82,13 @@
kmem_free(adv, sizeof(struct ataraid_disk_vnode));
return NULL;
}
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(vp, FREAD|FWRITE, NOCRED);
if (error) {
vput(vp);
kmem_free(adv, sizeof(struct ataraid_disk_vnode));
return NULL;
}
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
VOP_UNLOCK(vp);
adv->adv_adi = adi;
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/dev/ata/ata_raid_via.c
--- a/sys/dev/ata/ata_raid_via.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/dev/ata/ata_raid_via.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_via.c,v 1.9 2018/10/22 19:38:06 jdolecek Exp $ */
+/* $NetBSD: ata_raid_via.c,v 1.10 2022/03/19 13:51:01 hannken Exp $ */
/*-
* Copyright (c) 2000,2001,2002 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_via.c,v 1.9 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_via.c,v 1.10 2022/03/19 13:51:01 hannken Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -135,6 +135,7 @@
if (error)
goto out;
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(vp, FREAD, NOCRED);
if (error) {
vput(vp);
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/kern/vfs_mount.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_mount.c,v 1.89 2022/03/16 20:31:02 andvar Exp $ */
+/* $NetBSD: vfs_mount.c,v 1.90 2022/03/19 13:50:28 hannken Exp $ */
/*-
* Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.89 2022/03/16 20:31:02 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.90 2022/03/19 13:50:28 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -1178,7 +1178,9 @@
panic("vfs_mountroot: rootdev not set for DV_DISK");
if (bdevvp(rootdev, &rootvp))
panic("vfs_mountroot: can't get vnode for rootdev");
+ vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(rootvp, FREAD, FSCRED);
+ VOP_UNLOCK(rootvp);
if (error) {
printf("vfs_mountroot: can't open root device\n");
return (error);
diff -r 5eb62733ab10 -r ab1309dad3b5 sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c Sat Mar 19 13:49:21 2022 +0000
+++ b/sys/kern/vfs_vnops.c Sat Mar 19 13:50:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnops.c,v 1.225 2022/03/13 13:52:53 riastradh Exp $ */
+/* $NetBSD: vfs_vnops.c,v 1.226 2022/03/19 13:50:02 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.225 2022/03/13 13:52:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.226 2022/03/19 13:50:02 hannken Exp $");
#include "veriexec.h"
@@ -1344,13 +1344,15 @@
if ((error = bdevvp(dev, vpp)) != 0)
return error;
+ vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY);
if ((error = VOP_OPEN(*vpp, FREAD | FWRITE, l->l_cred)) != 0) {
- vrele(*vpp);
+ vput(*vpp);
return error;
}
mutex_enter((*vpp)->v_interlock);
(*vpp)->v_writecount++;
mutex_exit((*vpp)->v_interlock);
+ VOP_UNLOCK(*vpp);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index