diff options
| author | hannken <hannken@NetBSD.org> | 2014-06-14 07:39:00 +0000 |
|---|---|---|
| committer | hannken <hannken@NetBSD.org> | 2014-06-14 07:39:00 +0000 |
| commit | 972c4e43674c8f7855eb1ff4ccb9c2ec3be05bc0 (patch) | |
| tree | e2c9bfd67c6e90a9ceb05b5d48bc465955949342 /sys/dev | |
| parent | 88f50c82d078baa660c1e8b3792370f7b177ce03 (diff) | |
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 (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ccd.c | 21 | ||||
| -rw-r--r-- | sys/dev/cgd.c | 15 | ||||
| -rw-r--r-- | sys/dev/dksubr.c | 31 | ||||
| -rw-r--r-- | sys/dev/dm/dm.h | 4 | ||||
| -rw-r--r-- | sys/dev/dm/dm_target_linear.c | 14 | ||||
| -rw-r--r-- | sys/dev/dm/dm_target_snapshot.c | 25 | ||||
| -rw-r--r-- | sys/dev/dm/dm_target_stripe.c | 14 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_copyback.c | 16 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_disks.c | 16 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_reconstruct.c | 23 |
10 files changed, 60 insertions, 119 deletions
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c index e8cef30b543..f17a3b2fc99 100644 --- a/sys/dev/ccd.c +++ b/sys/dev/ccd.c @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.148 2014/04/06 00:56:39 joerg Exp $"); #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 @@ ccdinit(struct ccd_softc *cs, char **cpaths, struct vnode **vpp, { 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 @@ ccdinit(struct ccd_softc *cs, char **cpaths, struct vnode **vpp, /* * 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 --git a/sys/dev/cgd.c b/sys/dev/cgd.c index a77209c008c..00dc83e7850 100644 --- a/sys/dev/cgd.c +++ b/sys/dev/cgd.c @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.87 2014/05/25 19:23:49 bouyer Exp $"); #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 @@ cgdinit(struct cgd_softc *cs, const char *cpath, struct vnode *vp, struct lwp *l) { struct disk_geom *dg; - struct vattr va; int ret; char *tmppath; uint64_t psize; @@ -826,13 +827,7 @@ cgdinit(struct cgd_softc *cs, const char *cpath, struct vnode *vp, 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 --git a/sys/dev/dksubr.c b/sys/dev/dksubr.c index 24be3f693cb..3ae1e3032c9 100644 --- a/sys/dev/dksubr.c +++ b/sys/dev/dksubr.c @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.50 2014/05/25 19:23:49 bouyer Exp $"); #include <sys/module.h> #include <dev/dkvar.h> +#include <miscfs/specfs/specdev.h> /* for v_rdev */ int dkdebug = 0; @@ -621,7 +622,6 @@ dk_lookup(struct pathbuf *pb, struct lwp *l, struct vnode **vpp) { struct nameidata nd; struct vnode *vp; - struct vattr va; int error; if (l == NULL) @@ -635,22 +635,29 @@ dk_lookup(struct pathbuf *pb, struct lwp *l, struct vnode **vpp) } 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)); + if (vp->v_type != VBLK) { + error = ENOTBLK; goto out; } - /* XXX: eventually we should handle VREG, too. */ - if (va.va_type != VBLK) { - error = ENOTBLK; + /* 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); - IFDEBUG(DKDB_VNODE, vprint("dk_lookup: vnode info", vp)); + IFDEBUG(DKDB_VNODE, vprint("dk_lookup: vnode info", *vpp)); - VOP_UNLOCK(vp); - *vpp = vp; return 0; out: VOP_UNLOCK(vp); diff --git a/sys/dev/dm/dm.h b/sys/dev/dm/dm.h index a2e6b561fa1..a9167c1336c 100644 --- a/sys/dev/dm/dm.h +++ b/sys/dev/dm/dm.h @@ -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 --git a/sys/dev/dm/dm_target_linear.c b/sys/dev/dm/dm_target_linear.c index 7a03f173fe2..098445be784 100644 --- a/sys/dev/dm/dm_target_linear.c +++ b/sys/dev/dm/dm_target_linear.c @@ -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 @@ int 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 --git a/sys/dev/dm/dm_target_snapshot.c b/sys/dev/dm/dm_target_snapshot.c index 72d7cd43848..685e94ac6f3 100644 --- a/sys/dev/dm/dm_target_snapshot.c +++ b/sys/dev/dm/dm_target_snapshot.c @@ -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 @@ dm_target_snapshot_deps(dm_table_entry_t * table_en, 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 --git a/sys/dev/dm/dm_target_stripe.c b/sys/dev/dm/dm_target_stripe.c index 8bd4c8c1a98..de5352a8d01 100644 --- a/sys/dev/dm/dm_target_stripe.c +++ b/sys/dev/dm/dm_target_stripe.c @@ -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_deps(dm_table_entry_t * table_en, prop_array_t prop_array) { 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 @@ dm_target_stripe_deps(dm_table_entry_t * table_en, prop_array_t prop_array) tsc = table_en->target_config; TAILQ_FOREACH(tlc, &tsc->stripe_devs, entries) { - 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 --git a/sys/dev/raidframe/rf_copyback.c b/sys/dev/raidframe/rf_copyback.c index 656d5fb1e78..8c5d5175041 100644 --- a/sys/dev/raidframe/rf_copyback.c +++ b/sys/dev/raidframe/rf_copyback.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_copyback.c,v 1.49 2011/10/14 09:23:30 hannken Exp $ */ +/* $NetBSD: rf_copyback.c,v 1.50 2014/06/14 07:39:00 hannken Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -38,7 +38,7 @@ ****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.49 2011/10/14 09:23:30 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.50 2014/06/14 07:39:00 hannken Exp $"); #include <dev/raidframe/raidframevar.h> @@ -83,6 +83,8 @@ rf_ConfigureCopyback(RF_ShutdownList_t **listp) #include <sys/vnode.h> #include <sys/namei.h> /* for pathbuf */ +#include <miscfs/specfs/specdev.h> /* for v_rdev */ + /* do a complete copyback */ void rf_CopybackReconstructedData(RF_Raid_t *raidPtr) @@ -96,7 +98,6 @@ rf_CopybackReconstructedData(RF_Raid_t *raidPtr) struct pathbuf *dev_pb; struct vnode *vp; - struct vattr va; int ac; @@ -160,20 +161,15 @@ rf_CopybackReconstructedData(RF_Raid_t *raidPtr) /* Ok, so we can at least do a lookup... How about actually * getting a vp for it? */ - vn_lock(vp, LK_SHARED | LK_RETRY); - retcode = VOP_GETATTR(vp, &va, curlwp->l_cred); - VOP_UNLOCK(vp); - if (retcode != 0) - return; retcode = rf_getdisksize(vp, &raidPtr->Disks[fcol]); if (retcode) { return; } raidPtr->raid_cinfo[fcol].ci_vp = vp; - raidPtr->raid_cinfo[fcol].ci_dev = va.va_rdev; + raidPtr->raid_cinfo[fcol].ci_dev = vp->v_rdev; - raidPtr->Disks[fcol].dev = va.va_rdev; /* XXX or the above? */ + raidPtr->Disks[fcol].dev = vp->v_rdev; /* XXX or the above? */ /* we allow the user to specify that only a fraction of the * disks should be used this is just for debug: it speeds up diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c index d16440c96a4..8769d4ad116 100644 --- a/sys/dev/raidframe/rf_disks.c +++ b/sys/dev/raidframe/rf_disks.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_disks.c,v 1.85 2014/03/25 16:19:14 christos Exp $ */ +/* $NetBSD: rf_disks.c,v 1.86 2014/06/14 07:39:00 hannken Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -60,7 +60,7 @@ ***************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.85 2014/03/25 16:19:14 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.86 2014/06/14 07:39:00 hannken Exp $"); #include <dev/raidframe/raidframevar.h> @@ -80,6 +80,7 @@ __KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.85 2014/03/25 16:19:14 christos Exp $ #include <sys/vnode.h> #include <sys/namei.h> /* for pathbuf */ #include <sys/kauth.h> +#include <miscfs/specfs/specdev.h> /* for v_rdev */ static int rf_AllocDiskStructures(RF_Raid_t *, RF_Config_t *); static void rf_print_label_status( RF_Raid_t *, int, char *, @@ -576,7 +577,6 @@ rf_ConfigureDisk(RF_Raid_t *raidPtr, char *bf, RF_RaidDisk_t *diskPtr, char *p; struct pathbuf *pb; struct vnode *vp; - struct vattr va; int error; p = rf_find_non_white(bf); @@ -631,18 +631,12 @@ rf_ConfigureDisk(RF_Raid_t *raidPtr, char *bf, RF_RaidDisk_t *diskPtr, raidPtr->bytesPerSector = diskPtr->blockSize; if (diskPtr->status == rf_ds_optimal) { - vn_lock(vp, LK_SHARED | LK_RETRY); - error = VOP_GETATTR(vp, &va, curlwp->l_cred); - VOP_UNLOCK(vp); - if (error != 0) - return (error); - raidPtr->raid_cinfo[col].ci_vp = vp; - raidPtr->raid_cinfo[col].ci_dev = va.va_rdev; + raidPtr->raid_cinfo[col].ci_dev = vp->v_rdev; /* This component was not automatically configured */ diskPtr->auto_configured = 0; - diskPtr->dev = va.va_rdev; + diskPtr->dev = vp->v_rdev; /* we allow the user to specify that only a fraction of the * disks should be used this is just for debug: it speeds up diff --git a/sys/dev/raidframe/rf_reconstruct.c b/sys/dev/raidframe/rf_reconstruct.c index 572e1e1bcb9..17a507e9489 100644 --- a/sys/dev/raidframe/rf_reconstruct.c +++ b/sys/dev/raidframe/rf_reconstruct.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_reconstruct.c,v 1.119 2013/03/06 11:38:15 yamt Exp $ */ +/* $NetBSD: rf_reconstruct.c,v 1.120 2014/06/14 07:39:00 hannken Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -33,7 +33,7 @@ ************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.119 2013/03/06 11:38:15 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.120 2014/06/14 07:39:00 hannken Exp $"); #include <sys/param.h> #include <sys/time.h> @@ -47,6 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.119 2013/03/06 11:38:15 yamt Ex #include <sys/namei.h> /* for pathbuf */ #include <dev/raidframe/raidframevar.h> +#include <miscfs/specfs/specdev.h> /* for v_rdev */ + #include "rf_raid.h" #include "rf_reconutil.h" #include "rf_revent.h" @@ -352,7 +354,6 @@ rf_ReconstructInPlace(RF_Raid_t *raidPtr, RF_RowCol_t col) unsigned int secsize; struct pathbuf *pb; struct vnode *vp; - struct vattr va; int retcode; int ac; @@ -456,18 +457,6 @@ rf_ReconstructInPlace(RF_Raid_t *raidPtr, RF_RowCol_t col) /* Ok, so we can at least do a lookup... How about actually getting a vp for it? */ - vn_lock(vp, LK_SHARED | LK_RETRY); - retcode = VOP_GETATTR(vp, &va, curlwp->l_cred); - VOP_UNLOCK(vp); - if (retcode != 0) { - vn_close(vp, FREAD | FWRITE, kauth_cred_get()); - rf_lock_mutex2(raidPtr->mutex); - raidPtr->reconInProgress--; - rf_signal_cond2(raidPtr->waitForReconCond); - rf_unlock_mutex2(raidPtr->mutex); - return(retcode); - } - retcode = getdisksize(vp, &numsec, &secsize); if (retcode) { vn_close(vp, FREAD | FWRITE, kauth_cred_get()); @@ -482,9 +471,9 @@ rf_ReconstructInPlace(RF_Raid_t *raidPtr, RF_RowCol_t col) raidPtr->Disks[col].numBlocks = numsec - rf_protectedSectors; raidPtr->raid_cinfo[col].ci_vp = vp; - raidPtr->raid_cinfo[col].ci_dev = va.va_rdev; + raidPtr->raid_cinfo[col].ci_dev = vp->v_rdev; - raidPtr->Disks[col].dev = va.va_rdev; + raidPtr->Disks[col].dev = vp->v_rdev; /* we allow the user to specify that only a fraction of the disks should be used this is just for debug: |
