2007-12-05 11:39:46 +03:00
|
|
|
/* $NetBSD: rf_driver.c,v 1.115 2007/12/05 08:39:46 ad Exp $ */
|
1999-03-02 06:18:48 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Greg Oster
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1998-11-13 07:20:26 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Carnegie-Mellon University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Mark Holland, Khalil Amiri, Claudson Bornstein, William V. Courtright II,
|
|
|
|
* Robby Findler, Daniel Stodolsky, Rachad Youssef, Jim Zelenka
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* rf_driver.c -- main setup, teardown, and access routines for the RAID driver
|
|
|
|
*
|
|
|
|
* all routines are prefixed with rf_ (raidframe), to avoid conficts.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
2001-11-13 10:11:12 +03:00
|
|
|
#include <sys/cdefs.h>
|
2007-12-05 11:39:46 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.115 2007/12/05 08:39:46 ad Exp $");
|
2003-06-23 15:00:59 +04:00
|
|
|
|
|
|
|
#include "opt_raid_diagnostic.h"
|
2001-11-13 10:11:12 +03:00
|
|
|
|
1998-11-13 07:20:26 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "rf_archs.h"
|
|
|
|
#include "rf_threadstuff.h"
|
|
|
|
|
|
|
|
#include <sys/errno.h>
|
|
|
|
|
|
|
|
#include "rf_raid.h"
|
|
|
|
#include "rf_dag.h"
|
|
|
|
#include "rf_aselect.h"
|
|
|
|
#include "rf_diskqueue.h"
|
|
|
|
#include "rf_parityscan.h"
|
|
|
|
#include "rf_alloclist.h"
|
|
|
|
#include "rf_dagutils.h"
|
|
|
|
#include "rf_utils.h"
|
|
|
|
#include "rf_etimer.h"
|
|
|
|
#include "rf_acctrace.h"
|
|
|
|
#include "rf_general.h"
|
|
|
|
#include "rf_desc.h"
|
|
|
|
#include "rf_states.h"
|
|
|
|
#include "rf_decluster.h"
|
|
|
|
#include "rf_map.h"
|
|
|
|
#include "rf_revent.h"
|
|
|
|
#include "rf_callback.h"
|
|
|
|
#include "rf_engine.h"
|
|
|
|
#include "rf_mcpair.h"
|
|
|
|
#include "rf_nwayxor.h"
|
|
|
|
#include "rf_copyback.h"
|
|
|
|
#include "rf_driver.h"
|
|
|
|
#include "rf_options.h"
|
|
|
|
#include "rf_shutdown.h"
|
2000-01-09 04:29:27 +03:00
|
|
|
#include "rf_kintf.h"
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
#include <sys/buf.h>
|
|
|
|
|
2002-09-17 07:54:42 +04:00
|
|
|
#ifndef RF_ACCESS_DEBUG
|
|
|
|
#define RF_ACCESS_DEBUG 0
|
|
|
|
#endif
|
|
|
|
|
1998-11-13 07:20:26 +03:00
|
|
|
/* rad == RF_RaidAccessDesc_t */
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_DECLARE_MUTEX(rf_rad_lock)
|
1998-11-13 07:20:26 +03:00
|
|
|
#define RF_MAX_FREE_RAD 128
|
2004-03-05 05:53:55 +03:00
|
|
|
#define RF_MIN_FREE_RAD 32
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
/* debug variables */
|
1999-02-05 03:06:06 +03:00
|
|
|
char rf_panicbuf[2048]; /* a buffer to hold an error msg when we panic */
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
/* main configuration routines */
|
|
|
|
static int raidframe_booted = 0;
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
static void rf_ConfigureDebug(RF_Config_t * cfgPtr);
|
1998-11-13 07:20:26 +03:00
|
|
|
static void set_debug_option(char *name, long val);
|
|
|
|
static void rf_UnconfigureArray(void);
|
|
|
|
static void rf_ShutdownRDFreeList(void *);
|
|
|
|
static int rf_ConfigureRDFreeList(RF_ShutdownList_t **);
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_DECLARE_MUTEX(rf_printf_mutex) /* debug only: avoids interleaved
|
|
|
|
* printfs by different stripes */
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
#define SIGNAL_QUIESCENT_COND(_raid_) wakeup(&((_raid_)->accesses_suspended))
|
|
|
|
#define WAIT_FOR_QUIESCENCE(_raid_) \
|
2000-09-21 05:45:46 +04:00
|
|
|
ltsleep(&((_raid_)->accesses_suspended), PRIBIO, \
|
|
|
|
"raidframe quiesce", 0, &((_raid_)->access_suspend_mutex))
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-03-02 06:18:48 +03:00
|
|
|
static int configureCount = 0; /* number of active configurations */
|
|
|
|
static int isconfigged = 0; /* is basic raidframe (non per-array)
|
|
|
|
* stuff configged */
|
2002-08-08 06:55:36 +04:00
|
|
|
RF_DECLARE_LKMGR_STATIC_MUTEX(configureMutex) /* used to lock the configuration
|
1999-02-05 03:06:06 +03:00
|
|
|
* stuff */
|
1999-03-02 06:18:48 +03:00
|
|
|
static RF_ShutdownList_t *globalShutdown; /* non array-specific
|
|
|
|
* stuff */
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-03-02 06:18:48 +03:00
|
|
|
static int rf_ConfigureRDFreeList(RF_ShutdownList_t ** listp);
|
2004-06-27 07:15:18 +04:00
|
|
|
static int rf_AllocEmergBuffers(RF_Raid_t *);
|
|
|
|
static void rf_FreeEmergBuffers(RF_Raid_t *);
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
/* called at system boot time */
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
1999-02-24 02:55:29 +03:00
|
|
|
rf_BootRaidframe()
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if (raidframe_booted)
|
|
|
|
return (EBUSY);
|
|
|
|
raidframe_booted = 1;
|
2007-12-05 11:39:46 +03:00
|
|
|
mutex_init(&configureMutex, MUTEX_DEFAULT, IPL_NONE);
|
2003-12-29 09:30:42 +03:00
|
|
|
configureCount = 0;
|
1999-02-05 03:06:06 +03:00
|
|
|
isconfigged = 0;
|
|
|
|
globalShutdown = NULL;
|
|
|
|
return (0);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called whenever an array is shutdown
|
|
|
|
*/
|
2005-02-27 03:26:58 +03:00
|
|
|
static void
|
1999-02-05 03:06:06 +03:00
|
|
|
rf_UnconfigureArray()
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
|
|
|
|
2002-08-08 06:55:36 +04:00
|
|
|
RF_LOCK_LKMGR_MUTEX(configureMutex);
|
1999-02-05 03:06:06 +03:00
|
|
|
if (--configureCount == 0) { /* if no active configurations, shut
|
|
|
|
* everything down */
|
|
|
|
isconfigged = 0;
|
2004-03-09 05:15:33 +03:00
|
|
|
rf_ShutdownList(&globalShutdown);
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We must wait until now, because the AllocList module
|
|
|
|
* uses the DebugMem module.
|
|
|
|
*/
|
2002-09-17 03:40:57 +04:00
|
|
|
#if RF_DEBUG_MEM
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_memDebug)
|
|
|
|
rf_print_unfreed();
|
2002-09-17 03:40:57 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
2002-08-08 06:55:36 +04:00
|
|
|
RF_UNLOCK_LKMGR_MUTEX(configureMutex);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
1999-03-02 06:18:48 +03:00
|
|
|
|
1998-11-13 07:20:26 +03:00
|
|
|
/*
|
|
|
|
* Called to shut down an array.
|
|
|
|
*/
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_Shutdown(RF_Raid_t *raidPtr)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
2004-04-10 09:52:33 +04:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if (!raidPtr->valid) {
|
|
|
|
RF_ERRORMSG("Attempt to shut down unconfigured RAIDframe driver. Aborting shutdown\n");
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* wait for outstanding IOs to land
|
|
|
|
* As described in rf_raid.h, we use the rad_freelist lock
|
|
|
|
* to protect the per-array info about outstanding descs
|
|
|
|
* since we need to do freelist locking anyway, and this
|
|
|
|
* cuts down on the amount of serialization we've got going
|
|
|
|
* on.
|
|
|
|
*/
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_LOCK_MUTEX(rf_rad_lock);
|
1999-02-05 03:06:06 +03:00
|
|
|
if (raidPtr->waitShutdown) {
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_UNLOCK_MUTEX(rf_rad_lock);
|
1999-02-05 03:06:06 +03:00
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
raidPtr->waitShutdown = 1;
|
|
|
|
while (raidPtr->nAccOutstanding) {
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_WAIT_COND(raidPtr->outstandingCond, rf_rad_lock);
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_UNLOCK_MUTEX(rf_rad_lock);
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2000-05-28 07:00:31 +04:00
|
|
|
/* Wait for any parity re-writes to stop... */
|
|
|
|
while (raidPtr->parity_rewrite_in_progress) {
|
|
|
|
printf("Waiting for parity re-write to exit...\n");
|
|
|
|
tsleep(&raidPtr->parity_rewrite_in_progress, PRIBIO,
|
|
|
|
"rfprwshutdown", 0);
|
|
|
|
}
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
raidPtr->valid = 0;
|
|
|
|
|
2000-06-04 06:05:13 +04:00
|
|
|
rf_update_component_labels(raidPtr, RF_FINAL_COMPONENT_UPDATE);
|
1999-02-05 03:06:06 +03:00
|
|
|
|
1999-02-24 02:55:29 +03:00
|
|
|
rf_UnconfigureVnodes(raidPtr);
|
|
|
|
|
2004-06-27 07:15:18 +04:00
|
|
|
rf_FreeEmergBuffers(raidPtr);
|
2004-04-10 09:52:33 +04:00
|
|
|
|
1999-02-24 02:55:29 +03:00
|
|
|
rf_ShutdownList(&raidPtr->shutdownList);
|
|
|
|
|
|
|
|
rf_UnconfigureArray();
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
|
1998-11-13 07:20:26 +03:00
|
|
|
#define DO_INIT_CONFIGURE(f) { \
|
|
|
|
rc = f (&globalShutdown); \
|
|
|
|
if (rc) { \
|
|
|
|
RF_ERRORMSG2("RAIDFRAME: failed %s with %d\n", RF_STRING(f), rc); \
|
|
|
|
rf_ShutdownList(&globalShutdown); \
|
|
|
|
configureCount--; \
|
2002-08-08 06:55:36 +04:00
|
|
|
RF_UNLOCK_LKMGR_MUTEX(configureMutex); \
|
1998-11-13 07:20:26 +03:00
|
|
|
return(rc); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DO_RAID_FAIL() { \
|
1999-07-19 05:36:07 +04:00
|
|
|
rf_UnconfigureVnodes(raidPtr); \
|
2004-06-27 07:15:18 +04:00
|
|
|
rf_FreeEmergBuffers(raidPtr); \
|
1998-11-13 07:20:26 +03:00
|
|
|
rf_ShutdownList(&raidPtr->shutdownList); \
|
|
|
|
rf_UnconfigureArray(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DO_RAID_INIT_CONFIGURE(f) { \
|
|
|
|
rc = f (&raidPtr->shutdownList, raidPtr, cfgPtr); \
|
|
|
|
if (rc) { \
|
|
|
|
RF_ERRORMSG2("RAIDFRAME: failed %s with %d\n", RF_STRING(f), rc); \
|
|
|
|
DO_RAID_FAIL(); \
|
|
|
|
return(rc); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DO_RAID_MUTEX(_m_) { \
|
2003-12-29 08:22:16 +03:00
|
|
|
rf_mutex_init((_m_)); \
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
2003-12-29 05:38:17 +03:00
|
|
|
RF_RowCol_t col;
|
2004-06-27 07:15:18 +04:00
|
|
|
int rc;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2002-08-08 06:55:36 +04:00
|
|
|
RF_LOCK_LKMGR_MUTEX(configureMutex);
|
1999-02-05 03:06:06 +03:00
|
|
|
configureCount++;
|
|
|
|
if (isconfigged == 0) {
|
2003-12-29 08:22:16 +03:00
|
|
|
rf_mutex_init(&rf_printf_mutex);
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/* initialize globals */
|
|
|
|
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureAllocList);
|
2000-02-13 07:53:57 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/*
|
2000-02-13 07:53:57 +03:00
|
|
|
* Yes, this does make debugging general to the whole
|
2005-02-27 03:26:58 +03:00
|
|
|
* system instead of being array specific. Bummer, drag.
|
2000-02-13 07:53:57 +03:00
|
|
|
*/
|
1999-02-05 03:06:06 +03:00
|
|
|
rf_ConfigureDebug(cfgPtr);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureDebugMem);
|
2004-03-02 02:30:57 +03:00
|
|
|
#if RF_ACC_TRACE > 0
|
1999-02-05 03:06:06 +03:00
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureAccessTrace);
|
2004-03-02 02:30:57 +03:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureMapModule);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureReconEvent);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureCallback);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureRDFreeList);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureNWayXor);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureStripeLockFreeList);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureMCPair);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureDAGs);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureDAGFuncs);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureReconstruction);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureCopyback);
|
|
|
|
DO_INIT_CONFIGURE(rf_ConfigureDiskQueueSystem);
|
2006-02-14 04:13:33 +03:00
|
|
|
DO_INIT_CONFIGURE(rf_ConfigurePSStatus);
|
1999-02-05 03:06:06 +03:00
|
|
|
isconfigged = 1;
|
|
|
|
}
|
2002-08-08 06:55:36 +04:00
|
|
|
RF_UNLOCK_LKMGR_MUTEX(configureMutex);
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
DO_RAID_MUTEX(&raidPtr->mutex);
|
|
|
|
/* set up the cleanup list. Do this after ConfigureDebug so that
|
|
|
|
* value of memDebug will be set */
|
|
|
|
|
|
|
|
rf_MakeAllocList(raidPtr->cleanupList);
|
|
|
|
if (raidPtr->cleanupList == NULL) {
|
|
|
|
DO_RAID_FAIL();
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
2004-02-29 07:03:50 +03:00
|
|
|
rf_ShutdownCreate(&raidPtr->shutdownList,
|
|
|
|
(void (*) (void *)) rf_FreeAllocList,
|
|
|
|
raidPtr->cleanupList);
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
raidPtr->numCol = cfgPtr->numCol;
|
|
|
|
raidPtr->numSpare = cfgPtr->numSpare;
|
|
|
|
|
2003-12-29 05:38:17 +03:00
|
|
|
raidPtr->status = rf_rs_optimal;
|
|
|
|
raidPtr->reconControl = NULL;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2002-10-05 00:05:14 +04:00
|
|
|
TAILQ_INIT(&(raidPtr->iodone));
|
|
|
|
simple_lock_init(&(raidPtr->iodone_lock));
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine);
|
|
|
|
DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks);
|
|
|
|
|
2003-12-29 08:48:13 +03:00
|
|
|
raidPtr->outstandingCond = 0;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
raidPtr->nAccOutstanding = 0;
|
|
|
|
raidPtr->waitShutdown = 0;
|
|
|
|
|
|
|
|
DO_RAID_MUTEX(&raidPtr->access_suspend_mutex);
|
|
|
|
|
2003-12-29 08:48:13 +03:00
|
|
|
raidPtr->waitForReconCond = 0;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2000-02-13 07:53:57 +03:00
|
|
|
if (ac!=NULL) {
|
|
|
|
/* We have an AutoConfig structure.. Don't do the
|
|
|
|
normal disk configuration... call the auto config
|
|
|
|
stuff */
|
|
|
|
rf_AutoConfigureDisks(raidPtr, cfgPtr, ac);
|
|
|
|
} else {
|
|
|
|
DO_RAID_INIT_CONFIGURE(rf_ConfigureDisks);
|
|
|
|
DO_RAID_INIT_CONFIGURE(rf_ConfigureSpareDisks);
|
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
/* do this after ConfigureDisks & ConfigureSpareDisks to be sure dev
|
|
|
|
* no. is set */
|
|
|
|
DO_RAID_INIT_CONFIGURE(rf_ConfigureDiskQueues);
|
|
|
|
|
|
|
|
DO_RAID_INIT_CONFIGURE(rf_ConfigureLayout);
|
|
|
|
|
2006-02-14 04:13:33 +03:00
|
|
|
/* Initialize per-RAID PSS bits */
|
|
|
|
rf_InitPSStatus(raidPtr);
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2004-01-05 04:19:07 +03:00
|
|
|
#if RF_INCLUDE_CHAINDECLUSTER > 0
|
2003-12-29 05:38:17 +03:00
|
|
|
for (col = 0; col < raidPtr->numCol; col++) {
|
|
|
|
/*
|
|
|
|
* XXX better distribution
|
|
|
|
*/
|
|
|
|
raidPtr->hist_diskreq[col] = 0;
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
2004-01-05 04:19:07 +03:00
|
|
|
#endif
|
2000-02-23 06:44:02 +03:00
|
|
|
raidPtr->numNewFailures = 0;
|
2000-02-13 07:53:57 +03:00
|
|
|
raidPtr->copyback_in_progress = 0;
|
|
|
|
raidPtr->parity_rewrite_in_progress = 0;
|
2002-10-22 07:15:28 +04:00
|
|
|
raidPtr->adding_hot_spare = 0;
|
2000-02-13 07:53:57 +03:00
|
|
|
raidPtr->recon_in_progress = 0;
|
2000-02-23 05:04:21 +03:00
|
|
|
raidPtr->maxOutstanding = cfgPtr->maxOutstandingDiskReqs;
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
/* autoconfigure and root_partition will actually get filled in
|
2000-02-23 05:04:21 +03:00
|
|
|
after the config is done */
|
|
|
|
raidPtr->autoconfigure = 0;
|
|
|
|
raidPtr->root_partition = 0;
|
|
|
|
raidPtr->last_unit = raidPtr->raidid;
|
|
|
|
raidPtr->config_order = 0;
|
2000-02-13 07:53:57 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_keepAccTotals) {
|
|
|
|
raidPtr->keep_acc_totals = 1;
|
|
|
|
}
|
|
|
|
|
2004-03-20 07:22:05 +03:00
|
|
|
/* Allocate a bunch of buffers to be used in low-memory conditions */
|
|
|
|
raidPtr->iobuf = NULL;
|
2004-06-27 07:15:18 +04:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
rc = rf_AllocEmergBuffers(raidPtr);
|
2004-06-27 07:15:18 +04:00
|
|
|
if (rc) {
|
|
|
|
printf("raid%d: Unable to allocate emergency buffers.\n",
|
|
|
|
raidPtr->raidid);
|
|
|
|
DO_RAID_FAIL();
|
|
|
|
return(rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
raidPtr->valid = 1;
|
|
|
|
|
|
|
|
printf("raid%d: %s\n", raidPtr->raidid,
|
|
|
|
raidPtr->Layout.map->configName);
|
|
|
|
printf("raid%d: Components:", raidPtr->raidid);
|
|
|
|
|
|
|
|
for (col = 0; col < raidPtr->numCol; col++) {
|
|
|
|
printf(" %s", raidPtr->Disks[col].devname);
|
|
|
|
if (RF_DEAD_DISK(raidPtr->Disks[col].status)) {
|
|
|
|
printf("[**FAILED**]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
printf("raid%d: Total Sectors: %lu (%lu MB)\n",
|
|
|
|
raidPtr->raidid,
|
|
|
|
(unsigned long) raidPtr->totalSectors,
|
2005-02-27 03:26:58 +03:00
|
|
|
(unsigned long) (raidPtr->totalSectors / 1024 *
|
2004-06-27 07:15:18 +04:00
|
|
|
(1 << raidPtr->logBytesPerSector) / 1024));
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Routines to allocate and free the "emergency buffers" for a given
|
|
|
|
RAID set. These emergency buffers will be used when the kernel runs
|
2005-02-27 03:26:58 +03:00
|
|
|
out of kernel memory.
|
|
|
|
|
2004-06-27 07:15:18 +04:00
|
|
|
*/
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
static int
|
2004-06-27 07:15:18 +04:00
|
|
|
rf_AllocEmergBuffers(RF_Raid_t *raidPtr)
|
|
|
|
{
|
|
|
|
void *tmpbuf;
|
|
|
|
RF_VoidPointerListElem_t *vple;
|
|
|
|
int i;
|
|
|
|
|
2004-03-20 07:22:05 +03:00
|
|
|
/* XXX next line needs tuning... */
|
|
|
|
raidPtr->numEmergencyBuffers = 10 * raidPtr->numCol;
|
|
|
|
#if DEBUG
|
|
|
|
printf("raid%d: allocating %d buffers of %d bytes.\n",
|
|
|
|
raidPtr->raidid,
|
2005-02-27 03:26:58 +03:00
|
|
|
raidPtr->numEmergencyBuffers,
|
|
|
|
(int)(raidPtr->Layout.sectorsPerStripeUnit <<
|
2004-03-20 07:22:05 +03:00
|
|
|
raidPtr->logBytesPerSector));
|
|
|
|
#endif
|
|
|
|
for (i = 0; i < raidPtr->numEmergencyBuffers; i++) {
|
2005-02-27 03:26:58 +03:00
|
|
|
tmpbuf = malloc( raidPtr->Layout.sectorsPerStripeUnit <<
|
|
|
|
raidPtr->logBytesPerSector,
|
2006-10-07 21:42:53 +04:00
|
|
|
M_RAIDFRAME, M_WAITOK);
|
2004-03-20 07:22:05 +03:00
|
|
|
if (tmpbuf) {
|
2004-04-10 03:10:16 +04:00
|
|
|
vple = rf_AllocVPListElem();
|
|
|
|
vple->p= tmpbuf;
|
|
|
|
vple->next = raidPtr->iobuf;
|
|
|
|
raidPtr->iobuf = vple;
|
2004-03-20 07:22:05 +03:00
|
|
|
raidPtr->iobuf_count++;
|
|
|
|
} else {
|
|
|
|
printf("raid%d: failed to allocate emergency buffer!\n",
|
|
|
|
raidPtr->raidid);
|
2006-10-07 21:42:53 +04:00
|
|
|
return 1;
|
2004-03-20 07:22:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-10 03:10:16 +04:00
|
|
|
/* XXX next line needs tuning too... */
|
|
|
|
raidPtr->numEmergencyStripeBuffers = 10;
|
|
|
|
for (i = 0; i < raidPtr->numEmergencyStripeBuffers; i++) {
|
|
|
|
tmpbuf = malloc( raidPtr->numCol * (raidPtr->Layout.sectorsPerStripeUnit <<
|
|
|
|
raidPtr->logBytesPerSector),
|
2006-10-07 21:42:53 +04:00
|
|
|
M_RAIDFRAME, M_WAITOK);
|
2004-04-10 03:10:16 +04:00
|
|
|
if (tmpbuf) {
|
|
|
|
vple = rf_AllocVPListElem();
|
|
|
|
vple->p= tmpbuf;
|
|
|
|
vple->next = raidPtr->stripebuf;
|
|
|
|
raidPtr->stripebuf = vple;
|
|
|
|
raidPtr->stripebuf_count++;
|
|
|
|
} else {
|
|
|
|
printf("raid%d: failed to allocate emergency stripe buffer!\n",
|
|
|
|
raidPtr->raidid);
|
2006-10-07 21:42:53 +04:00
|
|
|
return 1;
|
2004-04-10 03:10:16 +04:00
|
|
|
}
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2004-06-27 07:15:18 +04:00
|
|
|
return (0);
|
|
|
|
}
|
2004-04-10 03:10:16 +04:00
|
|
|
|
2004-06-27 07:15:18 +04:00
|
|
|
static void
|
|
|
|
rf_FreeEmergBuffers(RF_Raid_t *raidPtr)
|
|
|
|
{
|
|
|
|
RF_VoidPointerListElem_t *tmp;
|
2004-04-10 03:10:16 +04:00
|
|
|
|
2004-06-27 07:15:18 +04:00
|
|
|
/* Free the emergency IO buffers */
|
|
|
|
while (raidPtr->iobuf != NULL) {
|
|
|
|
tmp = raidPtr->iobuf;
|
|
|
|
raidPtr->iobuf = raidPtr->iobuf->next;
|
|
|
|
free(tmp->p, M_RAIDFRAME);
|
|
|
|
rf_FreeVPListElem(tmp);
|
2002-08-03 04:55:54 +04:00
|
|
|
}
|
|
|
|
|
2004-06-27 07:15:18 +04:00
|
|
|
/* Free the emergency stripe buffers */
|
|
|
|
while (raidPtr->stripebuf != NULL) {
|
|
|
|
tmp = raidPtr->stripebuf;
|
|
|
|
raidPtr->stripebuf = raidPtr->stripebuf->next;
|
|
|
|
free(tmp->p, M_RAIDFRAME);
|
|
|
|
rf_FreeVPListElem(tmp);
|
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
|
2004-06-27 07:15:18 +04:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
static void
|
2006-11-16 04:32:37 +03:00
|
|
|
rf_ShutdownRDFreeList(void *ignored)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
2004-03-08 00:57:44 +03:00
|
|
|
pool_destroy(&rf_pools.rad);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
static int
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_ConfigureRDFreeList(RF_ShutdownList_t **listp)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
|
|
|
|
2004-03-08 00:57:44 +03:00
|
|
|
rf_pool_init(&rf_pools.rad, sizeof(RF_RaidAccessDesc_t),
|
|
|
|
"rf_rad_pl", RF_MIN_FREE_RAD, RF_MAX_FREE_RAD);
|
2004-02-29 07:03:50 +03:00
|
|
|
rf_ShutdownCreate(listp, rf_ShutdownRDFreeList, NULL);
|
2004-03-08 02:17:44 +03:00
|
|
|
simple_lock_init(&rf_rad_lock);
|
1999-02-05 03:06:06 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
RF_RaidAccessDesc_t *
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_AllocRaidAccDesc(RF_Raid_t *raidPtr, RF_IoType_t type,
|
|
|
|
RF_RaidAddr_t raidAddress, RF_SectorCount_t numBlocks,
|
2007-03-04 08:59:00 +03:00
|
|
|
void *bufPtr, void *bp, RF_RaidAccessFlags_t flags,
|
2004-06-03 02:58:28 +04:00
|
|
|
const RF_AccessState_t *states)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_RaidAccessDesc_t *desc;
|
|
|
|
|
2004-03-08 00:57:44 +03:00
|
|
|
desc = pool_get(&rf_pools.rad, PR_WAITOK);
|
2003-12-29 06:33:47 +03:00
|
|
|
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_LOCK_MUTEX(rf_rad_lock);
|
1999-02-05 03:06:06 +03:00
|
|
|
if (raidPtr->waitShutdown) {
|
|
|
|
/*
|
|
|
|
* Actually, we're shutting the array down. Free the desc
|
|
|
|
* and return NULL.
|
|
|
|
*/
|
2003-12-29 06:33:47 +03:00
|
|
|
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_UNLOCK_MUTEX(rf_rad_lock);
|
2004-03-08 00:57:44 +03:00
|
|
|
pool_put(&rf_pools.rad, desc);
|
1999-02-05 03:06:06 +03:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
raidPtr->nAccOutstanding++;
|
2003-12-29 06:33:47 +03:00
|
|
|
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_UNLOCK_MUTEX(rf_rad_lock);
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
desc->raidPtr = (void *) raidPtr;
|
|
|
|
desc->type = type;
|
|
|
|
desc->raidAddress = raidAddress;
|
|
|
|
desc->numBlocks = numBlocks;
|
|
|
|
desc->bufPtr = bufPtr;
|
|
|
|
desc->bp = bp;
|
|
|
|
desc->flags = flags;
|
|
|
|
desc->states = states;
|
|
|
|
desc->state = 0;
|
2004-04-10 03:10:16 +04:00
|
|
|
desc->dagList = NULL;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
desc->status = 0;
|
2004-11-16 19:45:51 +03:00
|
|
|
desc->numRetries = 0;
|
2004-03-02 02:30:57 +03:00
|
|
|
#if RF_ACC_TRACE > 0
|
2001-07-18 10:45:33 +04:00
|
|
|
memset((char *) &desc->tracerec, 0, sizeof(RF_AccTraceEntry_t));
|
2004-03-02 02:30:57 +03:00
|
|
|
#endif
|
2001-07-27 07:30:07 +04:00
|
|
|
desc->callbackFunc = NULL;
|
|
|
|
desc->callbackArg = NULL;
|
1999-02-05 03:06:06 +03:00
|
|
|
desc->next = NULL;
|
2004-04-10 03:10:16 +04:00
|
|
|
desc->iobufs = NULL;
|
|
|
|
desc->stripebufs = NULL;
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
return (desc);
|
|
|
|
}
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
void
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_FreeRaidAccDesc(RF_RaidAccessDesc_t *desc)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_Raid_t *raidPtr = desc->raidPtr;
|
2004-02-27 05:55:17 +03:00
|
|
|
RF_DagList_t *dagList, *temp;
|
2004-04-10 03:10:16 +04:00
|
|
|
RF_VoidPointerListElem_t *tmp;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ASSERT(desc);
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2004-02-27 05:55:17 +03:00
|
|
|
/* Cleanup the dagList(s) */
|
|
|
|
dagList = desc->dagList;
|
|
|
|
while(dagList != NULL) {
|
|
|
|
temp = dagList;
|
|
|
|
dagList = dagList->next;
|
|
|
|
rf_FreeDAGList(temp);
|
|
|
|
}
|
|
|
|
|
2004-04-10 03:10:16 +04:00
|
|
|
while (desc->iobufs) {
|
|
|
|
tmp = desc->iobufs;
|
|
|
|
desc->iobufs = desc->iobufs->next;
|
|
|
|
rf_FreeIOBuffer(raidPtr, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (desc->stripebufs) {
|
|
|
|
tmp = desc->stripebufs;
|
|
|
|
desc->stripebufs = desc->stripebufs->next;
|
|
|
|
rf_FreeStripeBuffer(raidPtr, tmp);
|
|
|
|
}
|
|
|
|
|
2004-03-08 00:57:44 +03:00
|
|
|
pool_put(&rf_pools.rad, desc);
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_LOCK_MUTEX(rf_rad_lock);
|
1999-02-05 03:06:06 +03:00
|
|
|
raidPtr->nAccOutstanding--;
|
|
|
|
if (raidPtr->waitShutdown) {
|
|
|
|
RF_SIGNAL_COND(raidPtr->outstandingCond);
|
|
|
|
}
|
2004-03-08 02:17:44 +03:00
|
|
|
RF_UNLOCK_MUTEX(rf_rad_lock);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
/*********************************************************************
|
|
|
|
* Main routine for performing an access.
|
|
|
|
* Accesses are retried until a DAG can not be selected. This occurs
|
|
|
|
* when either the DAG library is incomplete or there are too many
|
|
|
|
* failures in a parity group.
|
2003-12-30 22:28:26 +03:00
|
|
|
*
|
|
|
|
* type should be read or write async_flag should be RF_TRUE or
|
2007-03-04 08:59:00 +03:00
|
|
|
* RF_FALSE bp_in is a buf pointer. void *to facilitate ignoring it
|
2003-12-30 22:28:26 +03:00
|
|
|
* outside the kernel
|
1998-11-13 07:20:26 +03:00
|
|
|
********************************************************************/
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_DoAccess(RF_Raid_t * raidPtr, RF_IoType_t type, int async_flag,
|
|
|
|
RF_RaidAddr_t raidAddress, RF_SectorCount_t numBlocks,
|
2007-03-04 08:59:00 +03:00
|
|
|
void *bufPtr, struct buf *bp, RF_RaidAccessFlags_t flags)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_RaidAccessDesc_t *desc;
|
2007-03-04 08:59:00 +03:00
|
|
|
void *lbufPtr = bufPtr;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
raidAddress += rf_raidSectorOffset;
|
|
|
|
|
2002-09-17 07:54:42 +04:00
|
|
|
#if RF_ACCESS_DEBUG
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_accessDebug) {
|
|
|
|
|
|
|
|
printf("logBytes is: %d %d %d\n", raidPtr->raidid,
|
|
|
|
raidPtr->logBytesPerSector,
|
|
|
|
(int) rf_RaidAddressToByte(raidPtr, numBlocks));
|
2000-01-09 01:57:30 +03:00
|
|
|
printf("raid%d: %s raidAddr %d (stripeid %d-%d) numBlocks %d (%d bytes) buf 0x%lx\n", raidPtr->raidid,
|
1999-02-05 03:06:06 +03:00
|
|
|
(type == RF_IO_TYPE_READ) ? "READ" : "WRITE", (int) raidAddress,
|
|
|
|
(int) rf_RaidAddressToStripeID(&raidPtr->Layout, raidAddress),
|
|
|
|
(int) rf_RaidAddressToStripeID(&raidPtr->Layout, raidAddress + numBlocks - 1),
|
|
|
|
(int) numBlocks,
|
|
|
|
(int) rf_RaidAddressToByte(raidPtr, numBlocks),
|
|
|
|
(long) bufPtr);
|
|
|
|
}
|
2002-09-17 07:54:42 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
desc = rf_AllocRaidAccDesc(raidPtr, type, raidAddress,
|
2001-07-27 07:30:07 +04:00
|
|
|
numBlocks, lbufPtr, bp, flags, raidPtr->Layout.map->states);
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if (desc == NULL) {
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
2004-03-02 02:30:57 +03:00
|
|
|
#if RF_ACC_TRACE > 0
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ETIMER_START(desc->tracerec.tot_timer);
|
2004-03-02 02:30:57 +03:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
desc->async_flag = async_flag;
|
1999-01-15 20:55:52 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
rf_ContinueRaidAccess(desc);
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
return (0);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-01-07 04:58:03 +03:00
|
|
|
#if 0
|
1998-11-13 07:20:26 +03:00
|
|
|
/* force the array into reconfigured mode without doing reconstruction */
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_SetReconfiguredMode(RF_Raid_t *raidPtr, int col)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
if (!(raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE)) {
|
|
|
|
printf("Can't set reconfigured mode in dedicated-spare array\n");
|
|
|
|
RF_PANIC();
|
|
|
|
}
|
|
|
|
RF_LOCK_MUTEX(raidPtr->mutex);
|
|
|
|
raidPtr->numFailures++;
|
2003-12-29 05:38:17 +03:00
|
|
|
raidPtr->Disks[col].status = rf_ds_dist_spared;
|
|
|
|
raidPtr->status = rf_rs_reconfigured;
|
2000-06-04 06:05:13 +04:00
|
|
|
rf_update_component_labels(raidPtr, RF_NORMAL_COMPONENT_UPDATE);
|
1999-02-05 03:06:06 +03:00
|
|
|
/* install spare table only if declustering + distributed sparing
|
|
|
|
* architecture. */
|
|
|
|
if (raidPtr->Layout.map->flags & RF_BD_DECLUSTERED)
|
2003-12-29 05:38:17 +03:00
|
|
|
rf_InstallSpareTable(raidPtr, col);
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_UNLOCK_MUTEX(raidPtr->mutex);
|
|
|
|
return (0);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-01-07 04:58:03 +03:00
|
|
|
#endif
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_FailDisk(RF_Raid_t *raidPtr, int fcol, int initRecon)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
2004-03-22 00:08:08 +03:00
|
|
|
|
|
|
|
/* need to suspend IO's here -- if there are DAGs in flight
|
2005-02-27 03:26:58 +03:00
|
|
|
and we pull the rug out from under ci_vp, Bad Things
|
2004-03-22 00:08:08 +03:00
|
|
|
can happen. */
|
|
|
|
|
|
|
|
rf_SuspendNewRequestsAndWait(raidPtr);
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_LOCK_MUTEX(raidPtr->mutex);
|
2003-12-29 05:38:17 +03:00
|
|
|
if (raidPtr->Disks[fcol].status != rf_ds_failed) {
|
2002-11-14 06:04:20 +03:00
|
|
|
/* must be failing something that is valid, or else it's
|
2005-02-27 03:26:58 +03:00
|
|
|
already marked as failed (in which case we don't
|
2002-11-14 06:04:20 +03:00
|
|
|
want to mark it failed again!) */
|
|
|
|
raidPtr->numFailures++;
|
2003-12-29 05:38:17 +03:00
|
|
|
raidPtr->Disks[fcol].status = rf_ds_failed;
|
2005-02-27 03:26:58 +03:00
|
|
|
raidPtr->status = rf_rs_degraded;
|
2002-11-14 06:04:20 +03:00
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_UNLOCK_MUTEX(raidPtr->mutex);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2002-10-18 06:46:36 +04:00
|
|
|
rf_update_component_labels(raidPtr, RF_NORMAL_COMPONENT_UPDATE);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
|
|
|
/* Close the component, so that it's not "locked" if someone
|
2002-09-09 05:54:53 +04:00
|
|
|
else want's to use it! */
|
|
|
|
|
2003-12-29 05:38:17 +03:00
|
|
|
rf_close_component(raidPtr, raidPtr->raid_cinfo[fcol].ci_vp,
|
|
|
|
raidPtr->Disks[fcol].auto_configured);
|
2002-10-18 06:46:36 +04:00
|
|
|
|
|
|
|
RF_LOCK_MUTEX(raidPtr->mutex);
|
2003-12-29 05:38:17 +03:00
|
|
|
raidPtr->raid_cinfo[fcol].ci_vp = NULL;
|
2002-09-09 05:54:53 +04:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
/* Need to mark the component as not being auto_configured
|
2002-09-09 05:54:53 +04:00
|
|
|
(in case it was previously). */
|
|
|
|
|
2003-12-29 05:38:17 +03:00
|
|
|
raidPtr->Disks[fcol].auto_configured = 0;
|
2002-10-18 06:46:36 +04:00
|
|
|
RF_UNLOCK_MUTEX(raidPtr->mutex);
|
2004-03-22 00:08:08 +03:00
|
|
|
/* now we can allow IO to continue -- we'll be suspending it
|
|
|
|
again in rf_ReconstructFailedDisk() if we have to.. */
|
|
|
|
|
|
|
|
rf_ResumeNewRequests(raidPtr);
|
2002-09-09 05:54:53 +04:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if (initRecon)
|
2003-12-29 05:38:17 +03:00
|
|
|
rf_ReconstructFailedDisk(raidPtr, fcol);
|
1999-02-05 03:06:06 +03:00
|
|
|
return (0);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
/* releases a thread that is waiting for the array to become quiesced.
|
|
|
|
* access_suspend_mutex should be locked upon calling this
|
|
|
|
*/
|
2005-02-27 03:26:58 +03:00
|
|
|
void
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_SignalQuiescenceLock(RF_Raid_t *raidPtr)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
2002-09-17 07:54:42 +04:00
|
|
|
#if RF_DEBUG_QUIESCE
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_quiesceDebug) {
|
2005-02-27 03:26:58 +03:00
|
|
|
printf("raid%d: Signalling quiescence lock\n",
|
2000-01-09 01:57:30 +03:00
|
|
|
raidPtr->raidid);
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
2002-09-17 07:54:42 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
raidPtr->access_suspend_release = 1;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if (raidPtr->waiting_for_quiescence) {
|
|
|
|
SIGNAL_QUIESCENT_COND(raidPtr);
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
/* suspends all new requests to the array. No effect on accesses that are in flight. */
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_SuspendNewRequestsAndWait(RF_Raid_t *raidPtr)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
2002-09-17 07:54:42 +04:00
|
|
|
#if RF_DEBUG_QUIESCE
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_quiesceDebug)
|
2002-08-03 05:24:03 +04:00
|
|
|
printf("raid%d: Suspending new reqs\n", raidPtr->raidid);
|
2002-09-17 07:54:42 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
|
|
|
|
raidPtr->accesses_suspended++;
|
|
|
|
raidPtr->waiting_for_quiescence = (raidPtr->accs_in_flight == 0) ? 0 : 1;
|
|
|
|
|
|
|
|
if (raidPtr->waiting_for_quiescence) {
|
|
|
|
raidPtr->access_suspend_release = 0;
|
|
|
|
while (!raidPtr->access_suspend_release) {
|
2004-03-09 05:41:21 +03:00
|
|
|
#if RF_DEBUG_QUIESCE
|
2002-08-03 05:24:03 +04:00
|
|
|
printf("raid%d: Suspending: Waiting for Quiescence\n",
|
|
|
|
raidPtr->raidid);
|
2004-03-09 05:41:21 +03:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
WAIT_FOR_QUIESCENCE(raidPtr);
|
|
|
|
raidPtr->waiting_for_quiescence = 0;
|
|
|
|
}
|
|
|
|
}
|
2004-03-09 05:41:21 +03:00
|
|
|
#if RF_DEBUG_QUIESCE
|
2002-08-03 05:24:03 +04:00
|
|
|
printf("raid%d: Quiescence reached..\n", raidPtr->raidid);
|
2004-03-09 05:41:21 +03:00
|
|
|
#endif
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
|
|
|
|
return (raidPtr->waiting_for_quiescence);
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
/* wake up everyone waiting for quiescence to be released */
|
2005-02-27 03:26:58 +03:00
|
|
|
void
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_ResumeNewRequests(RF_Raid_t *raidPtr)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_CallbackDesc_t *t, *cb;
|
|
|
|
|
2002-09-17 07:54:42 +04:00
|
|
|
#if RF_DEBUG_QUIESCE
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_quiesceDebug)
|
|
|
|
printf("Resuming new reqs\n");
|
2002-09-17 07:54:42 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
|
|
|
|
raidPtr->accesses_suspended--;
|
|
|
|
if (raidPtr->accesses_suspended == 0)
|
|
|
|
cb = raidPtr->quiesce_wait_list;
|
|
|
|
else
|
|
|
|
cb = NULL;
|
|
|
|
raidPtr->quiesce_wait_list = NULL;
|
|
|
|
RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
|
|
|
|
|
|
|
|
while (cb) {
|
|
|
|
t = cb;
|
|
|
|
cb = cb->next;
|
|
|
|
(t->callbackFunc) (t->callbackArg);
|
|
|
|
rf_FreeCallbackDesc(t);
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
/*****************************************************************************************
|
|
|
|
*
|
|
|
|
* debug routines
|
|
|
|
*
|
|
|
|
****************************************************************************************/
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
static void
|
2003-12-30 22:28:26 +03:00
|
|
|
set_debug_option(char *name, long val)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_DebugName_t *p;
|
|
|
|
|
|
|
|
for (p = rf_debugNames; p->name; p++) {
|
|
|
|
if (!strcmp(p->name, name)) {
|
|
|
|
*(p->ptr) = val;
|
|
|
|
printf("[Set debug variable %s to %ld]\n", name, val);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RF_ERRORMSG1("Unknown debug string \"%s\"\n", name);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* would like to use sscanf here, but apparently not available in kernel */
|
|
|
|
/*ARGSUSED*/
|
2005-02-27 03:26:58 +03:00
|
|
|
static void
|
2003-12-30 22:28:26 +03:00
|
|
|
rf_ConfigureDebug(RF_Config_t *cfgPtr)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
char *val_p, *name_p, *white_p;
|
|
|
|
long val;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
rf_ResetDebugOptions();
|
|
|
|
for (i = 0; cfgPtr->debugVars[i][0] && i < RF_MAXDBGV; i++) {
|
|
|
|
name_p = rf_find_non_white(&cfgPtr->debugVars[i][0]);
|
|
|
|
white_p = rf_find_white(name_p); /* skip to start of 2nd
|
|
|
|
* word */
|
|
|
|
val_p = rf_find_non_white(white_p);
|
|
|
|
if (*val_p == '0' && *(val_p + 1) == 'x')
|
|
|
|
val = rf_htoi(val_p + 2);
|
|
|
|
else
|
|
|
|
val = rf_atoi(val_p);
|
|
|
|
*white_p = '\0';
|
|
|
|
set_debug_option(name_p, val);
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2000-12-15 05:12:58 +03:00
|
|
|
|
|
|
|
void
|
2005-05-30 02:03:09 +04:00
|
|
|
rf_print_panic_message(int line, const char *file)
|
2000-12-15 05:12:58 +03:00
|
|
|
{
|
2004-04-22 04:17:10 +04:00
|
|
|
snprintf(rf_panicbuf, sizeof(rf_panicbuf),
|
|
|
|
"raidframe error at line %d file %s", line, file);
|
2000-12-15 05:12:58 +03:00
|
|
|
}
|
|
|
|
|
2002-09-21 05:00:43 +04:00
|
|
|
#ifdef RAID_DIAGNOSTIC
|
2000-12-15 05:12:58 +03:00
|
|
|
void
|
2005-05-30 02:03:09 +04:00
|
|
|
rf_print_assert_panic_message(int line, const char *file, const char *condition)
|
2000-12-15 05:12:58 +03:00
|
|
|
{
|
2004-04-22 04:17:10 +04:00
|
|
|
snprintf(rf_panicbuf, sizeof(rf_panicbuf),
|
2000-12-15 05:12:58 +03:00
|
|
|
"raidframe error at line %d file %s (failed asserting %s)\n",
|
|
|
|
line, file, condition);
|
|
|
|
}
|
2002-09-21 05:00:43 +04:00
|
|
|
#endif
|
2002-09-14 21:53:57 +04:00
|
|
|
|
|
|
|
void
|
2005-05-30 02:03:09 +04:00
|
|
|
rf_print_unable_to_init_mutex(const char *file, int line, int rc)
|
2002-09-14 21:53:57 +04:00
|
|
|
{
|
|
|
|
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n",
|
|
|
|
file, line, rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-05-30 02:03:09 +04:00
|
|
|
rf_print_unable_to_add_shutdown(const char *file, int line, int rc)
|
2002-09-14 21:53:57 +04:00
|
|
|
{
|
|
|
|
RF_ERRORMSG3("Unable to add to shutdown list file %s line %d rc=%d\n",
|
|
|
|
file, line, rc);
|
|
|
|
}
|