Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Change dk_lookup() to return an anonymous vnode not asso...
details: https://anonhg.NetBSD.org/src/rev/d343eb3f3b61
branches: trunk
changeset: 329927:d343eb3f3b61
user: hannken <hannken%NetBSD.org@localhost>
date: Sat Jun 14 07:39:00 2014 +0000
description:
Change dk_lookup() to return an anonymous vnode not associated with
any file system. Change all consumers of dk_lookup() to get the
device from "v_rdev" instead of VOP_GETATTR() as specfs does not
support VOP_GETATTR(). Devices obtained with dk_lookup() will no
longer disappear on forced unmounts.
Fix for PR kern/48849 (root mirror raid fails on shutdown)
Welcome to 6.99.44
diffstat:
sys/dev/ccd.c | 21 +++++----------------
sys/dev/cgd.c | 15 +++++----------
sys/dev/dksubr.c | 35 +++++++++++++++++++++--------------
sys/dev/dm/dm.h | 4 +++-
sys/dev/dm/dm_target_linear.c | 14 +++-----------
sys/dev/dm/dm_target_snapshot.c | 25 +++++--------------------
sys/dev/dm/dm_target_stripe.c | 14 +++-----------
sys/dev/raidframe/rf_copyback.c | 16 ++++++----------
sys/dev/raidframe/rf_disks.c | 16 +++++-----------
sys/dev/raidframe/rf_reconstruct.c | 23 ++++++-----------------
sys/sys/param.h | 4 ++--
11 files changed, 64 insertions(+), 123 deletions(-)
diffs (truncated from 512 to 300 lines):
diff -r 76b267c6b949 -r d343eb3f3b61 sys/dev/ccd.c
--- a/sys/dev/ccd.c Sat Jun 14 04:06:54 2014 +0000
+++ b/sys/dev/ccd.c Sat Jun 14 07:39:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ccd.c,v 1.148 2014/04/06 00:56:39 joerg Exp $ */
+/* $NetBSD: ccd.c,v 1.149 2014/06/14 07:39:00 hannken Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.148 2014/04/06 00:56:39 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.149 2014/06/14 07:39:00 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -121,6 +121,8 @@
#include <dev/ccdvar.h>
#include <dev/dkvar.h>
+#include <miscfs/specfs/specdev.h> /* for v_rdev */
+
#if defined(CCDDEBUG) && !defined(DEBUG)
#define DEBUG
#endif
@@ -292,7 +294,6 @@
{
struct ccdcinfo *ci = NULL;
int ix;
- struct vattr va;
struct ccdgeom *ccg = &cs->sc_geom;
char *tmppath;
int error, path_alloced;
@@ -344,19 +345,7 @@
/*
* XXX: Cache the component's dev_t.
*/
- vn_lock(vpp[ix], LK_SHARED | LK_RETRY);
- error = VOP_GETATTR(vpp[ix], &va, l->l_cred);
- VOP_UNLOCK(vpp[ix]);
- if (error != 0) {
-#ifdef DEBUG
- if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("%s: %s: getattr failed %s = %d\n",
- cs->sc_xname, ci->ci_path,
- "error", error);
-#endif
- goto out;
- }
- ci->ci_dev = va.va_rdev;
+ ci->ci_dev = vpp[ix]->v_rdev;
/*
* Get partition information for the component.
diff -r 76b267c6b949 -r d343eb3f3b61 sys/dev/cgd.c
--- a/sys/dev/cgd.c Sat Jun 14 04:06:54 2014 +0000
+++ b/sys/dev/cgd.c Sat Jun 14 07:39:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.87 2014/05/25 19:23:49 bouyer Exp $ */
+/* $NetBSD: cgd.c,v 1.88 2014/06/14 07:39:00 hannken Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.87 2014/05/25 19:23:49 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.88 2014/06/14 07:39:00 hannken Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -55,6 +55,8 @@
#include <dev/dkvar.h>
#include <dev/cgdvar.h>
+#include <miscfs/specfs/specdev.h> /* for v_rdev */
+
/* Entry Point Functions */
void cgdattach(int);
@@ -809,7 +811,6 @@
struct lwp *l)
{
struct disk_geom *dg;
- struct vattr va;
int ret;
char *tmppath;
uint64_t psize;
@@ -826,13 +827,7 @@
cs->sc_tpath = malloc(cs->sc_tpathlen, M_DEVBUF, M_WAITOK);
memcpy(cs->sc_tpath, tmppath, cs->sc_tpathlen);
- vn_lock(vp, LK_SHARED | LK_RETRY);
- ret = VOP_GETATTR(vp, &va, l->l_cred);
- VOP_UNLOCK(vp);
- if (ret != 0)
- goto bail;
-
- cs->sc_tdev = va.va_rdev;
+ cs->sc_tdev = vp->v_rdev;
if ((ret = getdisksize(vp, &psize, &secsize)) != 0)
goto bail;
diff -r 76b267c6b949 -r d343eb3f3b61 sys/dev/dksubr.c
--- a/sys/dev/dksubr.c Sat Jun 14 04:06:54 2014 +0000
+++ b/sys/dev/dksubr.c Sat Jun 14 07:39:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.50 2014/05/25 19:23:49 bouyer Exp $ */
+/* $NetBSD: dksubr.c,v 1.51 2014/06/14 07:39:00 hannken Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.50 2014/05/25 19:23:49 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.51 2014/06/14 07:39:00 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -48,6 +48,7 @@
#include <sys/module.h>
#include <dev/dkvar.h>
+#include <miscfs/specfs/specdev.h> /* for v_rdev */
int dkdebug = 0;
@@ -621,7 +622,6 @@
{
struct nameidata nd;
struct vnode *vp;
- struct vattr va;
int error;
if (l == NULL)
@@ -635,22 +635,29 @@
}
vp = nd.ni_vp;
- if ((error = VOP_GETATTR(vp, &va, l->l_cred)) != 0) {
- DPRINTF((DKDB_FOLLOW|DKDB_INIT),
- ("dk_lookup: getattr error = %d\n", error));
- goto out;
- }
-
- /* XXX: eventually we should handle VREG, too. */
- if (va.va_type != VBLK) {
+ if (vp->v_type != VBLK) {
error = ENOTBLK;
goto out;
}
- IFDEBUG(DKDB_VNODE, vprint("dk_lookup: vnode info", vp));
+ /* Reopen as anonymous vnode to protect against forced unmount. */
+ if ((error = bdevvp(vp->v_rdev, vpp)) != 0)
+ goto out;
+ VOP_UNLOCK(vp);
+ if ((error = vn_close(vp, FREAD | FWRITE, l->l_cred)) != 0) {
+ vrele(*vpp);
+ return error;
+ }
+ if ((error = VOP_OPEN(*vpp, FREAD | FWRITE, l->l_cred)) != 0) {
+ vrele(*vpp);
+ return error;
+ }
+ mutex_enter((*vpp)->v_interlock);
+ (*vpp)->v_writecount++;
+ mutex_exit((*vpp)->v_interlock);
- VOP_UNLOCK(vp);
- *vpp = vp;
+ IFDEBUG(DKDB_VNODE, vprint("dk_lookup: vnode info", *vpp));
+
return 0;
out:
VOP_UNLOCK(vp);
diff -r 76b267c6b949 -r d343eb3f3b61 sys/dev/dm/dm.h
--- a/sys/dev/dm/dm.h Sat Jun 14 04:06:54 2014 +0000
+++ b/sys/dev/dm/dm.h Sat Jun 14 07:39:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm.h,v 1.25 2013/12/09 09:35:16 wiz Exp $ */
+/* $NetBSD: dm.h,v 1.26 2014/06/14 07:39:00 hannken Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -49,6 +49,8 @@
#include <sys/disk.h>
#include <sys/disklabel.h>
+#include <miscfs/specfs/specdev.h> /* for v_rdev */
+
#include <prop/proplib.h>
#define DM_MAX_TYPE_NAME 16
diff -r 76b267c6b949 -r d343eb3f3b61 sys/dev/dm/dm_target_linear.c
--- a/sys/dev/dm/dm_target_linear.c Sat Jun 14 04:06:54 2014 +0000
+++ b/sys/dev/dm/dm_target_linear.c Sat Jun 14 07:39:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_target_linear.c,v 1.13 2011/10/14 09:23:30 hannken Exp $ */
+/* $NetBSD: dm_target_linear.c,v 1.14 2014/06/14 07:39:00 hannken Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -192,22 +192,14 @@
dm_target_linear_deps(dm_table_entry_t * table_en, prop_array_t prop_array)
{
dm_target_linear_config_t *tlc;
- struct vattr va;
-
- int error;
if (table_en->target_config == NULL)
return ENOENT;
tlc = table_en->target_config;
- vn_lock(tlc->pdev->pdev_vnode, LK_SHARED | LK_RETRY);
- error = VOP_GETATTR(tlc->pdev->pdev_vnode, &va, curlwp->l_cred);
- VOP_UNLOCK(tlc->pdev->pdev_vnode);
- if (error != 0)
- return error;
-
- prop_array_add_uint64(prop_array, (uint64_t) va.va_rdev);
+ prop_array_add_uint64(prop_array,
+ (uint64_t) tlc->pdev->pdev_vnode->v_rdev);
return 0;
}
diff -r 76b267c6b949 -r d343eb3f3b61 sys/dev/dm/dm_target_snapshot.c
--- a/sys/dev/dm/dm_target_snapshot.c Sat Jun 14 04:06:54 2014 +0000
+++ b/sys/dev/dm/dm_target_snapshot.c Sat Jun 14 07:39:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_target_snapshot.c,v 1.15 2011/10/14 09:23:30 hannken Exp $ */
+/* $NetBSD: dm_target_snapshot.c,v 1.16 2014/06/14 07:39:00 hannken Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -348,33 +348,18 @@
prop_array_t prop_array)
{
dm_target_snapshot_config_t *tsc;
- struct vattr va;
-
- int error;
if (table_en->target_config == NULL)
return 0;
tsc = table_en->target_config;
- vn_lock(tsc->tsc_snap_dev->pdev_vnode, LK_SHARED | LK_RETRY);
- error = VOP_GETATTR(tsc->tsc_snap_dev->pdev_vnode, &va, curlwp->l_cred);
- VOP_UNLOCK(tsc->tsc_snap_dev->pdev_vnode);
- if (error != 0)
- return error;
-
- prop_array_add_uint64(prop_array, (uint64_t) va.va_rdev);
+ prop_array_add_uint64(prop_array,
+ (uint64_t) tsc->tsc_snap_dev->pdev_vnode->v_rdev);
if (tsc->tsc_persistent_dev) {
-
- vn_lock(tsc->tsc_cow_dev->pdev_vnode, LK_SHARED | LK_RETRY);
- error = VOP_GETATTR(tsc->tsc_cow_dev->pdev_vnode, &va,
- curlwp->l_cred);
- VOP_UNLOCK(tsc->tsc_cow_dev->pdev_vnode);
- if (error != 0)
- return error;
-
- prop_array_add_uint64(prop_array, (uint64_t) va.va_rdev);
+ prop_array_add_uint64(prop_array,
+ (uint64_t) tsc->tsc_cow_dev->pdev_vnode->v_rdev);
}
return 0;
diff -r 76b267c6b949 -r d343eb3f3b61 sys/dev/dm/dm_target_stripe.c
--- a/sys/dev/dm/dm_target_stripe.c Sat Jun 14 04:06:54 2014 +0000
+++ b/sys/dev/dm/dm_target_stripe.c Sat Jun 14 07:39:00 2014 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_stripe.c,v 1.18 2012/08/07 16:11:11 haad Exp $*/
+/*$NetBSD: dm_target_stripe.c,v 1.19 2014/06/14 07:39:00 hannken Exp $*/
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -319,9 +319,6 @@
{
dm_target_stripe_config_t *tsc;
dm_target_linear_config_t *tlc;
- struct vattr va;
-
- int error;
if (table_en->target_config == NULL)
return ENOENT;
@@ -329,13 +326,8 @@
Home |
Main Index |
Thread Index |
Old Index