summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPeter Galbavy <peter@cvs.openbsd.org>2000-01-07 14:50:24 +0000
committerPeter Galbavy <peter@cvs.openbsd.org>2000-01-07 14:50:24 +0000
commitd7921cbd0ec1beed703dd2b35ce6236d09fa0f12 (patch)
tree7193c433c334b83730ba6636e8b5e2007148d29f /sys
parent67a89310ea3a36e9b3d504382073e820f07a019a (diff)
sync with work by Greg Oster on NetBSD
Please note: This update has *only* been tested on i386 with IDE disks. Could someone with a spare box please make sure all is OK with SCSI and maybe other arches ? sparc testing will follow locally. * remove rf_sys.h * many changes to make it more stable * some performance increases * All raid threads now get their own kernel process and the calling raidctl(8) program will show status progress through a meter. * In theory FFS_SOFTUPDATES and RAIDframe will now work together - NOT TESTED YET See http://www.cs.usask.ca/staff/oster/raid.html This updates include Greg's changes to Jan 4th 2000. TODO: * some odd behaviour when running raictl -c on an already config'ed raid set - problem founf, fix being done * progress meter is in raidctl(8) - seperate commit, but could do with sync'ing with OpenBSD ftp version
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/raidframe/rf_acctrace.c5
-rw-r--r--sys/dev/raidframe/rf_alloclist.c5
-rw-r--r--sys/dev/raidframe/rf_archs.h23
-rw-r--r--sys/dev/raidframe/rf_copyback.c9
-rw-r--r--sys/dev/raidframe/rf_cpuutil.c5
-rw-r--r--sys/dev/raidframe/rf_cvscan.c5
-rw-r--r--sys/dev/raidframe/rf_dagdegrd.c5
-rw-r--r--sys/dev/raidframe/rf_dagdegwr.c5
-rw-r--r--sys/dev/raidframe/rf_dagdegwr.h13
-rw-r--r--sys/dev/raidframe/rf_dagffwr.c24
-rw-r--r--sys/dev/raidframe/rf_dagfuncs.c105
-rw-r--r--sys/dev/raidframe/rf_dagutils.c16
-rw-r--r--sys/dev/raidframe/rf_debugMem.c287
-rw-r--r--sys/dev/raidframe/rf_debugMem.h71
-rw-r--r--sys/dev/raidframe/rf_decluster.c5
-rw-r--r--sys/dev/raidframe/rf_desc.h6
-rw-r--r--sys/dev/raidframe/rf_disks.c18
-rw-r--r--sys/dev/raidframe/rf_driver.c62
-rw-r--r--sys/dev/raidframe/rf_engine.c10
-rw-r--r--sys/dev/raidframe/rf_etimer.h4
-rw-r--r--sys/dev/raidframe/rf_evenodd.c5
-rw-r--r--sys/dev/raidframe/rf_evenodd_dagfuncs.c5
-rw-r--r--sys/dev/raidframe/rf_general.h17
-rw-r--r--sys/dev/raidframe/rf_kintf.h21
-rw-r--r--sys/dev/raidframe/rf_map.c5
-rw-r--r--sys/dev/raidframe/rf_memchunk.c5
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c608
-rw-r--r--sys/dev/raidframe/rf_openbsdkintf.c695
-rw-r--r--sys/dev/raidframe/rf_optnames.h32
-rw-r--r--sys/dev/raidframe/rf_paritylog.c5
-rw-r--r--sys/dev/raidframe/rf_paritylogDiskMgr.c5
-rw-r--r--sys/dev/raidframe/rf_paritylogging.c6
-rw-r--r--sys/dev/raidframe/rf_parityscan.c37
-rw-r--r--sys/dev/raidframe/rf_pq.c56
-rw-r--r--sys/dev/raidframe/rf_pqdeg.c32
-rw-r--r--sys/dev/raidframe/rf_pqdegdags.c7
-rw-r--r--sys/dev/raidframe/rf_psstatus.c5
-rw-r--r--sys/dev/raidframe/rf_raid.h19
-rw-r--r--sys/dev/raidframe/rf_raid1.c5
-rw-r--r--sys/dev/raidframe/rf_raidframe.h22
-rw-r--r--sys/dev/raidframe/rf_reconmap.c7
-rw-r--r--sys/dev/raidframe/rf_reconstruct.c46
-rw-r--r--sys/dev/raidframe/rf_revent.c18
-rw-r--r--sys/dev/raidframe/rf_states.c58
-rw-r--r--sys/dev/raidframe/rf_sys.h40
-rw-r--r--sys/dev/raidframe/rf_threadstuff.c21
-rw-r--r--sys/dev/raidframe/rf_threadstuff.h8
-rw-r--r--sys/dev/raidframe/rf_types.h15
-rw-r--r--sys/dev/raidframe/rf_utils.c5
-rw-r--r--sys/dev/raidframe/rf_utils.h8
50 files changed, 965 insertions, 1536 deletions
diff --git a/sys/dev/raidframe/rf_acctrace.c b/sys/dev/raidframe/rf_acctrace.c
index 65e9365ba23..c570fce74e8 100644
--- a/sys/dev/raidframe/rf_acctrace.c
+++ b/sys/dev/raidframe/rf_acctrace.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_acctrace.c,v 1.2 1999/02/16 00:02:21 niklas Exp $ */
-/* $NetBSD: rf_acctrace.c,v 1.3 1999/02/05 00:06:06 oster Exp $ */
+/* $OpenBSD: rf_acctrace.c,v 1.3 2000/01/07 14:50:19 peter Exp $ */
+/* $NetBSD: rf_acctrace.c,v 1.4 1999/08/13 03:41:52 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -46,7 +46,6 @@
#include "rf_etimer.h"
#include "rf_hist.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
static long numTracesSoFar;
static int accessTraceBufCount = 0;
diff --git a/sys/dev/raidframe/rf_alloclist.c b/sys/dev/raidframe/rf_alloclist.c
index 26b4e135634..f0ddd462625 100644
--- a/sys/dev/raidframe/rf_alloclist.c
+++ b/sys/dev/raidframe/rf_alloclist.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_alloclist.c,v 1.2 1999/02/16 00:02:23 niklas Exp $ */
-/* $NetBSD: rf_alloclist.c,v 1.3 1999/02/05 00:06:06 oster Exp $ */
+/* $OpenBSD: rf_alloclist.c,v 1.3 2000/01/07 14:50:19 peter Exp $ */
+/* $NetBSD: rf_alloclist.c,v 1.4 1999/08/13 03:41:53 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -44,7 +44,6 @@
#include "rf_etimer.h"
#include "rf_general.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
RF_DECLARE_STATIC_MUTEX(alist_mutex)
static unsigned int fl_hit_count, fl_miss_count;
diff --git a/sys/dev/raidframe/rf_archs.h b/sys/dev/raidframe/rf_archs.h
index 7eb07bf39e1..2cb26be86f0 100644
--- a/sys/dev/raidframe/rf_archs.h
+++ b/sys/dev/raidframe/rf_archs.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_archs.h,v 1.2 1999/02/16 00:02:23 niklas Exp $ */
-/* $NetBSD: rf_archs.h,v 1.4 1999/02/05 00:06:06 oster Exp $ */
+/* $OpenBSD: rf_archs.h,v 1.3 2000/01/07 14:50:19 peter Exp $ */
+/* $NetBSD: rf_archs.h,v 1.6 1999/08/26 02:40:27 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -50,14 +50,6 @@
#define _RF__RF_ARCHS_H_
/*
- * Turn off if you do not have CMU PDL support compiled
- * into your kernel.
- */
-#ifndef RF_CMU_PDL
-#define RF_CMU_PDL 0
-#endif /* !RF_CMU_PDL */
-
-/*
* Khalil's performance-displaying demo stuff.
* Relies on CMU meter tools.
*/
@@ -84,17 +76,6 @@
#define RF_KEEP_DISKSTATS 1
-/* These two symbols enable nonstandard forms of error recovery.
- * These modes are only valid for performance measurements and
- * data corruption will occur if an error occurs when either
- * forward or backward error recovery are enabled. In general
- * both of the following two definitions should be commented
- * out--this forces RAIDframe to use roll-away error recovery
- * which does guarantee proper error recovery without data corruption
- */
-/* #define RF_FORWARD 1 */
-/* #define RF_BACKWARD 1 */
-
#include "rf_options.h"
#endif /* !_RF__RF_ARCHS_H_ */
diff --git a/sys/dev/raidframe/rf_copyback.c b/sys/dev/raidframe/rf_copyback.c
index 82984d89dc0..596fa8aa013 100644
--- a/sys/dev/raidframe/rf_copyback.c
+++ b/sys/dev/raidframe/rf_copyback.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_copyback.c,v 1.3 1999/07/30 14:45:32 peter Exp $ */
-/* $NetBSD: rf_copyback.c,v 1.7 1999/03/02 03:18:49 oster Exp $ */
+/* $OpenBSD: rf_copyback.c,v 1.4 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_copyback.c,v 1.10 2000/01/05 02:57:28 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -53,7 +53,6 @@
#include "rf_decluster.h"
#include "rf_driver.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
#define RF_COPYBACK_DATA 0
#define RF_COPYBACK_PARITY 1
@@ -127,7 +126,7 @@ rf_CopybackReconstructedData(raidPtr)
}
badDisk = &raidPtr->Disks[frow][fcol];
- proc = raidPtr->proc; /* XXX Yes, this is not nice.. */
+ proc = raidPtr->engine_thread;
/* This device may have been opened successfully the first time. Close
* it before trying to open it again.. */
@@ -275,6 +274,8 @@ rf_ContinueCopyback(desc)
old_pctg = (-1);
while (1) {
stripeAddr = desc->stripeAddr;
+ desc->raidPtr->copyback_stripes_done = stripeAddr
+ / desc->sectPerStripe;
if (rf_prReconSched) {
old_pctg = 100 * desc->stripeAddr / raidPtr->totalSectors;
}
diff --git a/sys/dev/raidframe/rf_cpuutil.c b/sys/dev/raidframe/rf_cpuutil.c
index d9b7ebb9802..72b301d765e 100644
--- a/sys/dev/raidframe/rf_cpuutil.c
+++ b/sys/dev/raidframe/rf_cpuutil.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_cpuutil.c,v 1.2 1999/02/16 00:02:27 niklas Exp $ */
-/* $NetBSD: rf_cpuutil.c,v 1.3 1999/02/05 00:06:07 oster Exp $ */
+/* $OpenBSD: rf_cpuutil.c,v 1.3 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_cpuutil.c,v 1.4 1999/08/13 03:41:53 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -37,7 +37,6 @@
#include "rf_types.h"
#include "rf_general.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
int
diff --git a/sys/dev/raidframe/rf_cvscan.c b/sys/dev/raidframe/rf_cvscan.c
index 61876309b4c..488e0501bcb 100644
--- a/sys/dev/raidframe/rf_cvscan.c
+++ b/sys/dev/raidframe/rf_cvscan.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_cvscan.c,v 1.3 1999/07/30 14:45:32 peter Exp $ */
-/* $NetBSD: rf_cvscan.c,v 1.4 1999/02/05 00:06:07 oster Exp $ */
+/* $OpenBSD: rf_cvscan.c,v 1.4 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_cvscan.c,v 1.5 1999/08/13 03:41:53 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -43,7 +43,6 @@
#include "rf_cvscan.h"
#include "rf_debugMem.h"
#include "rf_general.h"
-#include "rf_sys.h"
#define DO_CHECK_STATE(_hdr_) CheckCvscanState((_hdr_), __FILE__, __LINE__)
diff --git a/sys/dev/raidframe/rf_dagdegrd.c b/sys/dev/raidframe/rf_dagdegrd.c
index 652c9600012..eeae59e3a24 100644
--- a/sys/dev/raidframe/rf_dagdegrd.c
+++ b/sys/dev/raidframe/rf_dagdegrd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_dagdegrd.c,v 1.2 1999/02/16 00:02:29 niklas Exp $ */
-/* $NetBSD: rf_dagdegrd.c,v 1.3 1999/02/05 00:06:07 oster Exp $ */
+/* $OpenBSD: rf_dagdegrd.c,v 1.3 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_dagdegrd.c,v 1.4 1999/08/13 03:41:53 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -43,7 +43,6 @@
#include "rf_memchunk.h"
#include "rf_general.h"
#include "rf_dagdegrd.h"
-#include "rf_sys.h"
/******************************************************************************
diff --git a/sys/dev/raidframe/rf_dagdegwr.c b/sys/dev/raidframe/rf_dagdegwr.c
index 407e69cdac6..7e84a1512c2 100644
--- a/sys/dev/raidframe/rf_dagdegwr.c
+++ b/sys/dev/raidframe/rf_dagdegwr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_dagdegwr.c,v 1.2 1999/02/16 00:02:29 niklas Exp $ */
-/* $NetBSD: rf_dagdegwr.c,v 1.3 1999/02/05 00:06:07 oster Exp $ */
+/* $OpenBSD: rf_dagdegwr.c,v 1.3 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_dagdegwr.c,v 1.4 1999/08/13 03:41:53 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -44,7 +44,6 @@
#include "rf_memchunk.h"
#include "rf_general.h"
#include "rf_dagdegwr.h"
-#include "rf_sys.h"
/******************************************************************************
diff --git a/sys/dev/raidframe/rf_dagdegwr.h b/sys/dev/raidframe/rf_dagdegwr.h
index 5c58697f06e..7d24706f264 100644
--- a/sys/dev/raidframe/rf_dagdegwr.h
+++ b/sys/dev/raidframe/rf_dagdegwr.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_dagdegwr.h,v 1.2 1999/02/16 00:02:30 niklas Exp $ */
-/* $NetBSD: rf_dagdegwr.h,v 1.3 1999/02/05 00:06:07 oster Exp $ */
+/* $OpenBSD: rf_dagdegwr.h,v 1.3 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_dagdegwr.h,v 1.4 1999/08/15 02:36:03 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -32,19 +32,20 @@
#define _RF__RF_DAGDEGWR_H_
/* degraded write DAG creation routines */
-void
-rf_CreateDegradedWriteDAG(RF_Raid_t * raidPtr,
+void rf_CreateDegradedWriteDAG(RF_Raid_t * raidPtr,
RF_AccessStripeMap_t * asmap, RF_DagHeader_t * dag_h, void *bp,
RF_RaidAccessFlags_t flags, RF_AllocListElem_t * allocList);
-void
-rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t * raidPtr,
+
+void rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t * raidPtr,
RF_AccessStripeMap_t * asmap, RF_DagHeader_t * dag_h, void *bp,
RF_RaidAccessFlags_t flags, RF_AllocListElem_t * allocList,
int nfaults, int (*redFunc) (RF_DagNode_t *), int allowBufferRecycle);
+
void rf_WriteGenerateFailedAccessASMs(RF_Raid_t * raidPtr,
RF_AccessStripeMap_t * asmap, RF_PhysDiskAddr_t ** pdap,
int *nNodep, RF_PhysDiskAddr_t ** pqpdap,
int *nPQNodep, RF_AllocListElem_t * allocList);
+
void rf_DoubleDegSmallWrite(RF_Raid_t * raidPtr, RF_AccessStripeMap_t * asmap,
RF_DagHeader_t * dag_h, void *bp, RF_RaidAccessFlags_t flags,
RF_AllocListElem_t * allocList, char *redundantReadNodeName,
diff --git a/sys/dev/raidframe/rf_dagffwr.c b/sys/dev/raidframe/rf_dagffwr.c
index 49de3ccf554..218639b4951 100644
--- a/sys/dev/raidframe/rf_dagffwr.c
+++ b/sys/dev/raidframe/rf_dagffwr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_dagffwr.c,v 1.2 1999/02/16 00:02:31 niklas Exp $ */
-/* $NetBSD: rf_dagffwr.c,v 1.3 1999/02/05 00:06:07 oster Exp $ */
+/* $OpenBSD: rf_dagffwr.c,v 1.3 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_dagffwr.c,v 1.4 1999/08/26 02:40:28 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -111,19 +111,9 @@ rf_CreateSmallWriteDAG(
RF_RaidAccessFlags_t flags,
RF_AllocListElem_t * allocList)
{
-#if RF_FORWARD > 0
- rf_CommonCreateSmallWriteDAGFwd(raidPtr, asmap, dag_h, bp, flags, allocList,
- &rf_xorFuncs, NULL);
-#else /* RF_FORWARD > 0 */
-#if RF_BACKWARD > 0
- rf_CommonCreateSmallWriteDAGFwd(raidPtr, asmap, dag_h, bp, flags, allocList,
- &rf_xorFuncs, NULL);
-#else /* RF_BACKWARD > 0 */
/* "normal" rollaway */
rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
&rf_xorFuncs, NULL);
-#endif /* RF_BACKWARD > 0 */
-#endif /* RF_FORWARD > 0 */
}
void
@@ -135,19 +125,9 @@ rf_CreateLargeWriteDAG(
RF_RaidAccessFlags_t flags,
RF_AllocListElem_t * allocList)
{
-#if RF_FORWARD > 0
- rf_CommonCreateLargeWriteDAGFwd(raidPtr, asmap, dag_h, bp, flags, allocList,
- 1, rf_RegularXorFunc, RF_TRUE);
-#else /* RF_FORWARD > 0 */
-#if RF_BACKWARD > 0
- rf_CommonCreateLargeWriteDAGFwd(raidPtr, asmap, dag_h, bp, flags, allocList,
- 1, rf_RegularXorFunc, RF_TRUE);
-#else /* RF_BACKWARD > 0 */
/* "normal" rollaway */
rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
1, rf_RegularXorFunc, RF_TRUE);
-#endif /* RF_BACKWARD > 0 */
-#endif /* RF_FORWARD > 0 */
}
diff --git a/sys/dev/raidframe/rf_dagfuncs.c b/sys/dev/raidframe/rf_dagfuncs.c
index af2160f683b..741687a04d5 100644
--- a/sys/dev/raidframe/rf_dagfuncs.c
+++ b/sys/dev/raidframe/rf_dagfuncs.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_dagfuncs.c,v 1.3 1999/07/30 14:45:32 peter Exp $ */
-/* $NetBSD: rf_dagfuncs.c,v 1.4 1999/03/14 21:53:31 oster Exp $ */
+/* $OpenBSD: rf_dagfuncs.c,v 1.4 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_dagfuncs.c,v 1.5 1999/08/26 02:40:28 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -294,9 +294,6 @@ rf_DiskReadFuncForThreads(node)
RF_IoType_t iotype = (node->dagHdr->status == rf_enable) ? RF_IO_TYPE_READ : RF_IO_TYPE_NOP;
RF_DiskQueue_t **dqs = ((RF_Raid_t *) (node->dagHdr->raidPtr))->Queues;
void *b_proc = NULL;
-#if RF_BACKWARD > 0
- caddr_t undoBuf;
-#endif
if (node->dagHdr->bp)
b_proc = (void *) ((struct buf *) node->dagHdr->bp)->b_proc;
@@ -304,14 +301,7 @@ rf_DiskReadFuncForThreads(node)
RF_ASSERT(!(lock && unlock));
flags |= (lock) ? RF_LOCK_DISK_QUEUE : 0;
flags |= (unlock) ? RF_UNLOCK_DISK_QUEUE : 0;
-#if RF_BACKWARD > 0
- /* allocate and zero the undo buffer. this is equivalent to copying
- * the original buffer's contents to the undo buffer prior to
- * performing the disk read. XXX hardcoded 512 bytes per sector! */
- if (node->dagHdr->allocList == NULL)
- rf_MakeAllocList(node->dagHdr->allocList);
- RF_CallocAndAdd(undoBuf, 1, 512 * pda->numSector, (caddr_t), node->dagHdr->allocList);
-#endif /* RF_BACKWARD > 0 */
+
req = rf_CreateDiskQueueData(iotype, pda->startSector, pda->numSector,
buf, parityStripeID, which_ru,
(int (*) (void *, int)) node->wakeFunc,
@@ -346,59 +336,10 @@ rf_DiskWriteFuncForThreads(node)
RF_IoType_t iotype = (node->dagHdr->status == rf_enable) ? RF_IO_TYPE_WRITE : RF_IO_TYPE_NOP;
RF_DiskQueue_t **dqs = ((RF_Raid_t *) (node->dagHdr->raidPtr))->Queues;
void *b_proc = NULL;
-#if RF_BACKWARD > 0
- caddr_t undoBuf;
-#endif
if (node->dagHdr->bp)
b_proc = (void *) ((struct buf *) node->dagHdr->bp)->b_proc;
-#if RF_BACKWARD > 0
- /* This area is used only for backward error recovery experiments
- * First, schedule allocate a buffer and schedule a pre-read of the
- * disk After the pre-read, proceed with the normal disk write */
- if (node->status == rf_bwd2) {
- /* just finished undo logging, now perform real function */
- node->status = rf_fired;
- RF_ASSERT(!(lock && unlock));
- flags |= (lock) ? RF_LOCK_DISK_QUEUE : 0;
- flags |= (unlock) ? RF_UNLOCK_DISK_QUEUE : 0;
- req = rf_CreateDiskQueueData(iotype,
- pda->startSector, pda->numSector, buf, parityStripeID, which_ru,
- node->wakeFunc, (void *) node, NULL, node->dagHdr->tracerec,
- (void *) (node->dagHdr->raidPtr), flags, b_proc);
-
- if (!req) {
- (node->wakeFunc) (node, ENOMEM);
- } else {
- node->dagFuncData = (void *) req;
- rf_DiskIOEnqueue(&(dqs[pda->row][pda->col]), req, priority);
- }
- } else {
- /* node status should be rf_fired */
- /* schedule a disk pre-read */
- node->status = rf_bwd1;
- RF_ASSERT(!(lock && unlock));
- flags |= (lock) ? RF_LOCK_DISK_QUEUE : 0;
- flags |= (unlock) ? RF_UNLOCK_DISK_QUEUE : 0;
- if (node->dagHdr->allocList == NULL)
- rf_MakeAllocList(node->dagHdr->allocList);
- RF_CallocAndAdd(undoBuf, 1, 512 * pda->numSector, (caddr_t), node->dagHdr->allocList);
- req = rf_CreateDiskQueueData(RF_IO_TYPE_READ,
- pda->startSector, pda->numSector, undoBuf, parityStripeID, which_ru,
- node->wakeFunc, (void *) node, NULL, node->dagHdr->tracerec,
- (void *) (node->dagHdr->raidPtr), flags, b_proc);
-
- if (!req) {
- (node->wakeFunc) (node, ENOMEM);
- } else {
- node->dagFuncData = (void *) req;
- rf_DiskIOEnqueue(&(dqs[pda->row][pda->col]), req, priority);
- }
- }
- return (0);
-#endif /* RF_BACKWARD > 0 */
-
/* normal processing (rollaway or forward recovery) begins here */
RF_ASSERT(!(lock && unlock));
flags |= (lock) ? RF_LOCK_DISK_QUEUE : 0;
@@ -549,10 +490,6 @@ rf_RegularXorFunc(node)
RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;
RF_Etimer_t timer;
int i, retcode;
-#if RF_BACKWARD > 0
- RF_PhysDiskAddr_t *pda;
- caddr_t undoBuf;
-#endif
retcode = 0;
if (node->dagHdr->status == rf_enable) {
@@ -560,16 +497,6 @@ rf_RegularXorFunc(node)
RF_ETIMER_START(timer);
for (i = 0; i < node->numParams - 1; i += 2)
if (node->params[i + 1].p != node->results[0]) {
-#if RF_BACKWARD > 0
- /* This section mimics undo logging for
- * backward error recovery experiments b
- * allocating and initializing a buffer XXX
- * 512 byte sector size is hard coded! */
- pda = node->params[i].p;
- if (node->dagHdr->allocList == NULL)
- rf_MakeAllocList(node->dagHdr->allocList);
- RF_CallocAndAdd(undoBuf, 1, 512 * pda->numSector, (caddr_t), node->dagHdr->allocList);
-#endif /* RF_BACKWARD > 0 */
retcode = rf_XorIntoBuffer(raidPtr, (RF_PhysDiskAddr_t *) node->params[i].p,
(char *) node->params[i + 1].p, (char *) node->results[0], node->dagHdr->bp);
}
@@ -590,26 +517,12 @@ rf_SimpleXorFunc(node)
int i, retcode = 0;
RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;
RF_Etimer_t timer;
-#if RF_BACKWARD > 0
- RF_PhysDiskAddr_t *pda;
- caddr_t undoBuf;
-#endif
if (node->dagHdr->status == rf_enable) {
RF_ETIMER_START(timer);
/* don't do the XOR if the input is the same as the output */
for (i = 0; i < node->numParams - 1; i += 2)
if (node->params[i + 1].p != node->results[0]) {
-#if RF_BACKWARD > 0
- /* This section mimics undo logging for
- * backward error recovery experiments b
- * allocating and initializing a buffer XXX
- * 512 byte sector size is hard coded! */
- pda = node->params[i].p;
- if (node->dagHdr->allocList == NULL)
- rf_MakeAllocList(node->dagHdr->allocList);
- RF_CallocAndAdd(undoBuf, 1, 512 * pda->numSector, (caddr_t), node->dagHdr->allocList);
-#endif /* RF_BACKWARD > 0 */
retcode = rf_bxor((char *) node->params[i + 1].p, (char *) node->results[0],
rf_RaidAddressToByte(raidPtr, ((RF_PhysDiskAddr_t *) node->params[i].p)->numSector),
(struct buf *) node->dagHdr->bp);
@@ -642,24 +555,12 @@ rf_RecoveryXorFunc(node)
char *srcbuf, *destbuf;
RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;
RF_Etimer_t timer;
-#if RF_BACKWARD > 0
- caddr_t undoBuf;
-#endif
if (node->dagHdr->status == rf_enable) {
RF_ETIMER_START(timer);
for (i = 0; i < node->numParams - 2; i += 2)
if (node->params[i + 1].p != node->results[0]) {
pda = (RF_PhysDiskAddr_t *) node->params[i].p;
-#if RF_BACKWARD > 0
- /* This section mimics undo logging for
- * backward error recovery experiments b
- * allocating and initializing a buffer XXX
- * 512 byte sector size is hard coded! */
- if (node->dagHdr->allocList == NULL)
- rf_MakeAllocList(node->dagHdr->allocList);
- RF_CallocAndAdd(undoBuf, 1, 512 * pda->numSector, (caddr_t), node->dagHdr->allocList);
-#endif /* RF_BACKWARD > 0 */
srcbuf = (char *) node->params[i + 1].p;
suoffset = rf_StripeUnitOffset(layoutPtr, pda->startSector);
destbuf = ((char *) node->results[0]) + rf_RaidAddressToByte(raidPtr, suoffset - failedSUOffset);
diff --git a/sys/dev/raidframe/rf_dagutils.c b/sys/dev/raidframe/rf_dagutils.c
index b0d41a7c106..d2b0930be1d 100644
--- a/sys/dev/raidframe/rf_dagutils.c
+++ b/sys/dev/raidframe/rf_dagutils.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_dagutils.c,v 1.2 1999/02/16 00:02:33 niklas Exp $ */
-/* $NetBSD: rf_dagutils.c,v 1.3 1999/02/05 00:06:08 oster Exp $ */
+/* $OpenBSD: rf_dagutils.c,v 1.3 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_dagutils.c,v 1.6 1999/12/09 02:26:09 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -44,7 +44,6 @@
#include "rf_freelist.h"
#include "rf_map.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
#define SNUM_DIFF(_a_,_b_) (((_a_)>(_b_))?((_a_)-(_b_)):((_b_)-(_a_)))
@@ -1214,6 +1213,10 @@ rf_SelectMirrorDiskIdle(RF_DagNode_t * node)
if (RF_DEAD_DISK(disks[rowData][colData].status)) {
usemirror = 1;
} else
+ if (raidPtr->parity_good == RF_RAID_DIRTY) {
+ /* Trust only the main disk */
+ usemirror = 0;
+ } else
if (dataQueueLength < mirrorQueueLength) {
usemirror = 0;
} else
@@ -1271,8 +1274,13 @@ rf_SelectMirrorDiskPartition(RF_DagNode_t * node)
} else
if (RF_DEAD_DISK(disks[rowData][colData].status)) {
usemirror = 1;
+ } else
+ if (raidPtr->parity_good == RF_RAID_DIRTY) {
+ /* Trust only the main disk */
+ usemirror = 0;
} else
- if (data_pda->startSector < (disks[rowData][colData].numBlocks / 2)) {
+ if (data_pda->startSector <
+ (disks[rowData][colData].numBlocks / 2)) {
usemirror = 0;
} else {
usemirror = 1;
diff --git a/sys/dev/raidframe/rf_debugMem.c b/sys/dev/raidframe/rf_debugMem.c
index ec579d1f08d..688d9f0a165 100644
--- a/sys/dev/raidframe/rf_debugMem.c
+++ b/sys/dev/raidframe/rf_debugMem.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_debugMem.c,v 1.2 1999/02/16 00:02:33 niklas Exp $ */
-/* $NetBSD: rf_debugMem.c,v 1.3 1999/02/05 00:06:08 oster Exp $ */
+/* $OpenBSD: rf_debugMem.c,v 1.3 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_debugMem.c,v 1.6 1999/09/04 21:11:21 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -38,20 +38,14 @@
*/
#include "rf_types.h"
-#include "rf_sys.h"
-#if RF_UTILITY == 0
#include "rf_threadstuff.h"
#include "rf_threadid.h"
#include "rf_options.h"
-#else /* RF_UTILITY == 0 */
-#include "rf_utility.h"
-#endif /* RF_UTILITY == 0 */
-
#include "rf_debugMem.h"
#include "rf_general.h"
-static long tot_mem_in_use = 0, max_mem = 0;
+static long tot_mem_in_use = 0;
/* Hash table of information about memory allocations */
#define RF_MH_TABLESIZE 1000
@@ -71,275 +65,6 @@ RF_DECLARE_MUTEX(rf_debug_mem_mutex)
static void memory_hash_insert(void *addr, int size, int line, char *filen);
static int memory_hash_remove(void *addr, int sz);
-#ifndef _KERNEL /* no redzones or "real_" routines in the
- * kernel */
-
- static void rf_redzone_free_failed(void *ptr, int size, int line, char *file);
-
- void *rf_real_redzone_malloc(_size_)
- int _size_;
-{
- char *p;
-
- rf_validate_mh_table();
- p = malloc((_size_) + 16);
- if (p == NULL)
- return (p);
- RF_ASSERT(p);
- *((long *) p) = (_size_);
- ((char *) p)[(_size_) + 8] = '!';
- ((char *) p)[(_size_) + 15] = '!';
- p += 8;
- return (p);
-}
-
-void *
-rf_real_redzone_calloc(_n_, _size_)
- int _n_, _size_;
-{
- char *p;
- int _sz_;
-
- rf_validate_mh_table();
- _sz_ = (_n_) * (_size_);
- p = malloc((_sz_) + 16);
- if (p == NULL)
- return (p);
- bzero(p, (_sz_) + 16);
- *((long *) p) = (_sz_);
- ((char *) p)[(_sz_) + 8] = '!';
- ((char *) p)[(_sz_) + 15] = '!';
- p += 8;
- return (p);
-}
-
-void
-rf_real_redzone_free(p, line, filen)
- char *p;
- int line;
- char *filen;
-{
- unsigned long _size_;
-
- rf_validate_mh_table();
- p -= 8;
- _size_ = *((long *) p);
- if ((((char *) p)[(_size_) + 8] != '!') || (((char *) p)[(_size_) + 15] != '!'))
- rf_redzone_free_failed(p, (_size_), line, filen);
- free(p);
-}
-
-unsigned long rf_mem_alloc = 0;
-
-char *
-rf_real_Malloc(size, line, file)
- int size;
- int line;
- char *file;
-{
- void *pp;
- char *p;
- int tid;
-
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- rf_redzone_malloc(pp, size);
- p = pp;
- if (p == NULL) {
- RF_ERRORMSG3("Unable to malloc %d bytes at line %d file %s\n", size,
- line, file);
- }
- if (rf_memAmtDebug) {
- rf_mem_alloc += size;
- printf("%lu size %d %s:%d\n", rf_mem_alloc, size, file, line);
- }
-#if RF_UTILITY == 0
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] malloc 0x%lx - 0x%lx (%d) %s %d\n", tid, p, p + size, size,
- file, line);
- }
-#endif /* RF_UTILITY == 0 */
- if (rf_memDebug)
- rf_record_malloc(p, size, line, file);
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
- return (p);
-}
-#if RF_UTILITY == 0
-char *
-rf_real_MallocAndAdd(size, alist, line, file)
- int size;
- RF_AllocListElem_t *alist;
- int line;
- char *file;
-{
- void *pp;
- char *p;
- int tid;
-
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- rf_redzone_malloc(pp, size);
- p = pp;
- if (p == NULL) {
- RF_ERRORMSG3("Unable to malloc %d bytes at line %d file %s\n", size,
- line, file);
- }
- if (rf_memAmtDebug) {
- rf_mem_alloc += size;
- printf("%lu size %d %s:%d\n", rf_mem_alloc, size, file, line);
- }
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] malloc+add 0x%lx - 0x%lx (%d) %s %d\n", tid, p, p + size,
- size, file, line);
- }
- if (alist) {
- rf_real_AddToAllocList(alist, pp, size, 0);
- }
- if (rf_memDebug)
- rf_record_malloc(p, size, line, file);
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
- return (p);
-}
-#endif /* RF_UTILITY == 0 */
-
-char *
-rf_real_Calloc(nel, elsz, line, file)
- int nel;
- int elsz;
- int line;
- char *file;
-{
- int tid, size;
- void *pp;
- char *p;
-
- size = nel * elsz;
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- rf_redzone_calloc(pp, nel, elsz);
- p = pp;
- if (p == NULL) {
- RF_ERRORMSG4("Unable to calloc %d objects of size %d at line %d file %s\n",
- nel, elsz, line, file);
- return (NULL);
- }
- if (rf_memAmtDebug) {
- rf_mem_alloc += size;
- printf("%lu size %d %s:%d\n", rf_mem_alloc, size, file, line);
- }
-#if RF_UTILITY == 0
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] calloc 0x%lx - 0x%lx (%d,%d) %s %d\n", tid, p, p + size, nel,
- elsz, file, line);
- }
-#endif /* RF_UTILITY == 0 */
- if (rf_memDebug) {
- rf_record_malloc(p, size, line, file);
- }
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
- return (p);
-}
-#if RF_UTILITY == 0
-char *
-rf_real_CallocAndAdd(nel, elsz, alist, line, file)
- int nel;
- int elsz;
- RF_AllocListElem_t *alist;
- int line;
- char *file;
-{
- int tid, size;
- void *pp;
- char *p;
-
- size = nel * elsz;
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- rf_redzone_calloc(pp, nel, elsz);
- p = pp;
- if (p == NULL) {
- RF_ERRORMSG4("Unable to calloc %d objs of size %d at line %d file %s\n",
- nel, elsz, line, file);
- return (NULL);
- }
- if (rf_memAmtDebug) {
- rf_mem_alloc += size;
- printf("%lu size %d %s:%d\n", rf_mem_alloc, size, file, line);
- }
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] calloc+add 0x%lx - 0x%lx (%d,%d) %s %d\n", tid, p,
- p + size, nel, elsz, file, line);
- }
- if (alist) {
- rf_real_AddToAllocList(alist, pp, size, 0);
- }
- if (rf_memDebug)
- rf_record_malloc(p, size, line, file);
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
- return (p);
-}
-#endif /* RF_UTILITY == 0 */
-
-void
-rf_real_Free(p, sz, line, file)
- void *p;
- int sz;
- int line;
- char *file;
-{
- int tid;
-
-#if RF_UTILITY == 0
- if (rf_memDebug > 1) {
- rf_get_threadid(tid);
- printf("[%d] free 0x%lx - 0x%lx (%d) %s %d\n", tid, p, ((char *) p) + sz, sz,
- file, line);
- }
-#endif /* RF_UTILITY == 0 */
- RF_LOCK_MUTEX(rf_debug_mem_mutex);
- if (rf_memAmtDebug) {
- rf_mem_alloc -= sz;
- printf("%lu - size %d %s:%d\n", rf_mem_alloc, sz, file, line);
- }
- if (rf_memDebug) {
- rf_unrecord_malloc(p, sz);
- }
- rf_redzone_free(p);
- RF_UNLOCK_MUTEX(rf_debug_mem_mutex);
-}
-
-void
-rf_validate_mh_table()
-{
- int i, size;
- struct mh_struct *p;
- char *cp;
-
- return;
- for (i = 0; i < RF_MH_TABLESIZE; i++) {
- for (p = mh_table[i]; p; p = p->next)
- if (p->allocated) {
- cp = ((char *) p->address) - 8;
- size = *((long *) cp);
- if ((((char *) cp)[(size) + 8] != '!') || (((char *) cp)[(size) + 15] != '!')) {
- rf_redzone_free_failed(cp, (size), __LINE__, __FILE__);
- }
- }
- }
-}
-
-static void
-rf_redzone_free_failed(ptr, size, line, file)
- void *ptr;
- int size;
- int line;
- char *file;
-{
- RF_ERRORMSG4("Free of 0x%lx (recorded size %d) at %d of %s detected redzone overrun\n", ptr, size, line, file);
- RF_ASSERT(0);
-}
-#endif /* !_KERNEL */
-
void
rf_record_malloc(p, size, line, filen)
void *p;
@@ -475,9 +200,3 @@ memory_hash_remove(addr, sz)
p->allocated = 0;
return (p->size);
}
-
-void
-rf_ReportMaxMem()
-{
- printf("Max memory used: %d bytes\n", (int) max_mem);
-}
diff --git a/sys/dev/raidframe/rf_debugMem.h b/sys/dev/raidframe/rf_debugMem.h
index 392fcf0b82f..d189fb46224 100644
--- a/sys/dev/raidframe/rf_debugMem.h
+++ b/sys/dev/raidframe/rf_debugMem.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_debugMem.h,v 1.3 1999/08/04 13:10:54 peter Exp $ */
-/* $NetBSD: rf_debugMem.h,v 1.4 1999/02/05 00:06:08 oster Exp $ */
+/* $OpenBSD: rf_debugMem.h,v 1.4 2000/01/07 14:50:20 peter Exp $ */
+/* $NetBSD: rf_debugMem.h,v 1.7 1999/09/05 01:58:11 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -38,59 +38,12 @@
#ifndef _RF__RF_DEBUGMEM_H_
#define _RF__RF_DEBUGMEM_H_
-#include "rf_archs.h"
#include "rf_alloclist.h"
-#include "rf_options.h"
-
-#ifndef _KERNEL
-
-#if !defined(__NetBSD__) && !defined(__OpenBSD__)
-void *malloc(), *calloc();
-#endif
-RF_DECLARE_EXTERN_MUTEX(rf_debug_mem_mutex)
-/*
- * redzone malloc, calloc, and free allocate an extra 16 bytes on each
- * malloc/calloc call to allow tracking of overflows on free.
- */
-
-#if RF_MEMORY_REDZONES > 0
-#define rf_redzone_malloc(_p_,_size_) _p_ = rf_real_redzone_malloc(_size_)
-#define rf_redzone_calloc(_p_,_n_,_size_) _p_ = rf_real_redzone_calloc(_n_,_size_)
-#define rf_redzone_free(_p_) rf_real_redzone_free(_p_, __LINE__, __FILE__)
-#else /* RF_MEMORY_REDZONES > 0 */
-#define rf_redzone_malloc(_p_,_size_) _p_ = malloc(_size_)
-#define rf_redzone_calloc(_p_,_nel_,_size_) _p_ = calloc(_nel_,_size_)
-#define rf_redzone_free(_ptr_) free(_ptr_)
-#endif /* RF_MEMORY_REDZONES > 0 */
-
-#define RF_Malloc(_p_, _size_, _cast_) { \
- _p_ = _cast_ rf_real_Malloc(_size_, __LINE__, __FILE__); \
-}
-
-#define RF_MallocAndAdd(_p_, _size_, _cast_, _alist_) { \
- _p_ = _cast_ rf_real_MallocAndAdd(_size_, _alist_, __LINE__, __FILE__); \
-}
-
-#define RF_Calloc(_p_, _nel_, _elsz_, _cast_) { \
- _p_ = _cast_ rf_real_Calloc(_nel_, _elsz_, __LINE__, __FILE__); \
-}
-
-#define RF_CallocAndAdd(_p_, _nel_, _elsz_, _cast_, _alist_) { \
- _p_ = _cast_ rf_real_CallocAndAdd(_nel_, _elsz_, _alist_, __LINE__, __FILE__); \
-}
-
-#define RF_Free(__p_, _sz_) { \
- rf_real_Free(__p_, _sz_, __LINE__, __FILE__); \
-}
-
-#else /* _KERNEL */
+#ifdef _KERNEL
#include <sys/types.h>
-typedef u_int32_t U32;
#include <sys/malloc.h>
-
-
#define RF_Malloc(_p_, _size_, _cast_) \
{ \
_p_ = _cast_ malloc((u_long)_size_, M_RAIDFRAME, M_WAITOK); \
@@ -107,7 +60,6 @@ typedef u_int32_t U32;
#define RF_Calloc(_p_, _nel_, _elsz_, _cast_) \
{ \
RF_Malloc( _p_, (_nel_) * (_elsz_), _cast_); \
- bzero( (_p_), (_nel_) * (_elsz_) ); \
}
#define RF_CallocAndAdd(__p,__nel,__elsz,__cast,__alist) \
@@ -119,29 +71,14 @@ typedef u_int32_t U32;
#define RF_Free(_p_, _sz_) \
{ \
free((void *)(_p_), M_RAIDFRAME); \
- if (rf_memDebug) rf_unrecord_malloc(_p_, (U32) (_sz_)); \
+ if (rf_memDebug) rf_unrecord_malloc(_p_, (u_int32_t) (_sz_)); \
}
#endif /* _KERNEL */
-#ifndef _KERNEL
-void *rf_real_redzone_malloc(int size);
-void *rf_real_redzone_calloc(int n, int size);
-void rf_real_redzone_free(char *p, int line, char *filen);
-char *rf_real_Malloc(int size, int line, char *file);
-char *rf_real_Calloc(int nel, int elsz, int line, char *file);
-void rf_real_Free(void *p, int sz, int line, char *file);
-void rf_validate_mh_table(void);
-#if RF_UTILITY == 0
-char *rf_real_MallocAndAdd(int size, RF_AllocListElem_t * alist, int line, char *file);
-char *rf_real_CallocAndAdd(int nel, int elsz, RF_AllocListElem_t * alist, int line, char *file);
-#endif /* RF_UTILITY == 0 */
-#endif /* !KERNEL */
-
void rf_record_malloc(void *p, int size, int line, char *filen);
void rf_unrecord_malloc(void *p, int sz);
void rf_print_unfreed(void);
int rf_ConfigureDebugMem(RF_ShutdownList_t ** listp);
-void rf_ReportMaxMem(void);
#endif /* !_RF__RF_DEBUGMEM_H_ */
diff --git a/sys/dev/raidframe/rf_decluster.c b/sys/dev/raidframe/rf_decluster.c
index 73036456760..43a5f3a5c34 100644
--- a/sys/dev/raidframe/rf_decluster.c
+++ b/sys/dev/raidframe/rf_decluster.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_decluster.c,v 1.2 1999/02/16 00:02:34 niklas Exp $ */
-/* $NetBSD: rf_decluster.c,v 1.3 1999/02/05 00:06:08 oster Exp $ */
+/* $OpenBSD: rf_decluster.c,v 1.3 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_decluster.c,v 1.4 1999/08/13 03:41:56 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -58,7 +58,6 @@
#include "rf_alloclist.h"
#include "rf_general.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
extern int rf_copyback_in_progress; /* debug only */
diff --git a/sys/dev/raidframe/rf_desc.h b/sys/dev/raidframe/rf_desc.h
index 1a1be3ded7f..36f4b029894 100644
--- a/sys/dev/raidframe/rf_desc.h
+++ b/sys/dev/raidframe/rf_desc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rf_desc.h,v 1.3 1999/08/03 13:56:37 peter Exp $ */
+/* $OpenBSD: rf_desc.h,v 1.4 2000/01/07 14:50:21 peter Exp $ */
/* $NetBSD: rf_desc.h,v 1.4 1999/02/05 00:06:09 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
@@ -54,8 +54,8 @@ struct RF_RaidReconDesc_s {
*/
RF_Etimer_t recon_exec_timer;
RF_uint64 reconExecTimerRunning;
- RF_uint64 reconExecuSecs;
- RF_uint64 maxReconExecuSecs;
+ RF_uint64 reconExecTicks;
+ RF_uint64 maxReconExecTicks;
#if RF_RECON_STATS > 0
RF_uint64 hsStallCount; /* head sep stall count */
diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c
index 003b29e8ddf..14b00b84fac 100644
--- a/sys/dev/raidframe/rf_disks.c
+++ b/sys/dev/raidframe/rf_disks.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_disks.c,v 1.3 1999/07/30 14:45:32 peter Exp $ */
-/* $NetBSD: rf_disks.c,v 1.10 1999/06/04 02:02:39 oster Exp $ */
+/* $OpenBSD: rf_disks.c,v 1.4 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_disks.c,v 1.13 1999/08/14 03:10:03 oster Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -72,11 +72,7 @@
#include "rf_utils.h"
#include "rf_configure.h"
#include "rf_general.h"
-#if !defined(__NetBSD__) && !defined(__OpenBSD__)
-#include "rf_camlayer.h"
-#endif
#include "rf_options.h"
-#include "rf_sys.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -378,7 +374,11 @@ rf_ConfigureDisk(raidPtr, buf, diskPtr, row, col)
}
(void) strcpy(diskPtr->devname, p);
- proc = raidPtr->proc; /* XXX Yes, this is not nice.. */
+#if 0
+ proc = raidPtr->engine_thread;
+#else
+ proc = curproc;
+#endif
/* Let's start by claiming the component is fine and well... */
diskPtr->status = rf_ds_optimal;
@@ -444,8 +444,8 @@ rf_print_label_status( raidPtr, row, column, dev_name, ci_label )
printf(" Version: %d Serial Number: %d Mod Counter: %d\n",
ci_label->version, ci_label->serial_number,
ci_label->mod_counter);
- printf(" Clean: %d Status: %d\n",
- ci_label->clean, ci_label->status );
+ printf(" Clean: %s Status: %d\n",
+ ci_label->clean ? "Yes" : "No", ci_label->status );
}
static int rf_check_label_vitals( RF_Raid_t *, int, int, char *,
diff --git a/sys/dev/raidframe/rf_driver.c b/sys/dev/raidframe/rf_driver.c
index 683ad4ee29f..31ff4827589 100644
--- a/sys/dev/raidframe/rf_driver.c
+++ b/sys/dev/raidframe/rf_driver.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_driver.c,v 1.5 1999/08/04 13:10:54 peter Exp $ */
-/* $NetBSD: rf_driver.c,v 1.12 1999/07/19 01:36:07 oster Exp $ */
+/* $OpenBSD: rf_driver.c,v 1.6 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_driver.c,v 1.19 1999/12/07 02:54:08 oster Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -115,25 +115,13 @@
#include "rf_nwayxor.h"
#include "rf_debugprint.h"
#include "rf_copyback.h"
-#if !defined(__NetBSD__) && !defined(__OpenBSD__)
-#include "rf_camlayer.h"
-#endif
#include "rf_driver.h"
#include "rf_options.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
#include "rf_cpuutil.h"
#include <sys/buf.h>
-#if DKUSAGE > 0
-#include <sys/dkusage.h>
-#include <io/common/iotypes.h>
-#include <io/cam/dec_cam.h>
-#include <io/cam/cam.h>
-#include <io/cam/pdrv.h>
-#endif /* DKUSAGE > 0 */
-
/* rad == RF_RaidAccessDesc_t */
static RF_FreeList_t *rf_rad_freelist;
#define RF_MAX_FREE_RAD 128
@@ -171,23 +159,12 @@ RF_DECLARE_GLOBAL_THREADID /* declarations for threadid.h */
#define WAIT_FOR_QUIESCENCE(_raid_) \
tsleep(&((_raid_)->accesses_suspended),PRIBIO,"raidframe quiesce", 0);
-#if DKUSAGE > 0
-#define IO_BUF_ERR(bp, err, unit) { \
- bp->b_flags |= B_ERROR; \
- bp->b_resid = bp->b_bcount; \
- bp->b_error = err; \
- RF_DKU_END_IO(unit, bp); \
- biodone(bp); \
-}
-#else
#define IO_BUF_ERR(bp, err, unit) { \
bp->b_flags |= B_ERROR; \
bp->b_resid = bp->b_bcount; \
bp->b_error = err; \
- RF_DKU_END_IO(unit); \
biodone(bp); \
}
-#endif /* DKUSAGE > 0 */
static int configureCount = 0; /* number of active configurations */
static int isconfigged = 0; /* is basic raidframe (non per-array)
@@ -209,10 +186,6 @@ rf_BootRaidframe()
return (EBUSY);
raidframe_booted = 1;
-#if RF_DEBUG_ATOMIC > 0
- rf_atent_init();
-#endif /* RF_DEBUG_ATOMIC > 0 */
-
rf_setup_threadid();
rf_assign_threadid();
@@ -251,9 +224,6 @@ rf_UnbootRaidframe()
__LINE__, rc);
RF_PANIC();
}
-#if RF_DEBUG_ATOMIC > 0
- rf_atent_shutdown();
-#endif /* RF_DEBUG_ATOMIC > 0 */
return (0);
}
/*
@@ -336,7 +306,7 @@ rf_UnconfigureVnodes( raidPtr )
/* We take this opportunity to close the vnodes like we should.. */
- p = raidPtr->proc; /* XXX */
+ p = raidPtr->engine_thread;
for (r = 0; r < raidPtr->numRow; r++) {
for (c = 0; c < raidPtr->numCol; c++) {
@@ -419,7 +389,6 @@ rf_Configure(raidPtr, cfgPtr)
RF_RowCol_t row, col;
int i, rc;
int unit;
- struct proc *p;
if (raidPtr->valid) {
RF_ERRORMSG("RAIDframe configuration not shut down. Aborting configure.\n");
@@ -456,9 +425,6 @@ rf_Configure(raidPtr, cfgPtr)
DO_INIT_CONFIGURE(rf_ConfigureNWayXor);
DO_INIT_CONFIGURE(rf_ConfigureStripeLockFreeList);
DO_INIT_CONFIGURE(rf_ConfigureMCPair);
-#if !defined(__NetBSD__) && !defined(__OpenBSD__)
- DO_INIT_CONFIGURE(rf_ConfigureCamLayer);
-#endif
DO_INIT_CONFIGURE(rf_ConfigureDAGs);
DO_INIT_CONFIGURE(rf_ConfigureDAGFuncs);
DO_INIT_CONFIGURE(rf_ConfigureDebugPrint);
@@ -477,10 +443,8 @@ rf_Configure(raidPtr, cfgPtr)
/* XXX this clearing should be moved UP to outside of here.... that,
* or rf_Configure() needs to take more arguments... XXX */
unit = raidPtr->raidid;
- p = raidPtr->proc; /* XXX save these... */
bzero((char *) raidPtr, sizeof(RF_Raid_t));
raidPtr->raidid = unit;
- raidPtr->proc = p; /* XXX and then recover them.. */
DO_RAID_MUTEX(&raidPtr->mutex);
/* set up the cleanup list. Do this after ConfigureDebug so that
* value of memDebug will be set */
@@ -730,13 +694,6 @@ bp_in is a buf pointer. void * to facilitate ignoring it outside the kernel
RF_RaidAccessDesc_t *desc;
caddr_t lbufPtr = bufPtr;
struct buf *bp = (struct buf *) bp_in;
-#if DFSTRACE > 0
- struct {
- RF_uint64 raidAddr;
- int numBlocks;
- char type;
- } dfsrecord;
-#endif /* DFSTRACE > 0 */
raidAddress += rf_raidSectorOffset;
@@ -745,14 +702,6 @@ bp_in is a buf pointer. void * to facilitate ignoring it outside the kernel
IO_BUF_ERR(bp, EINVAL, raidPtr->raidid);
return (EINVAL);
}
-#if defined(_KERNEL) && DFSTRACE > 0
- if (rf_DFSTraceAccesses) {
- dfsrecord.raidAddr = raidAddress;
- dfsrecord.numBlocks = numBlocks;
- dfsrecord.type = type;
- dfs_log(DFS_NOTE, (char *) &dfsrecord, sizeof(dfsrecord), 0);
- }
-#endif /* _KERNEL && DFSTRACE > 0 */
rf_get_threadid(tid);
if (rf_accessDebug) {
@@ -773,13 +722,8 @@ bp_in is a buf pointer. void * to facilitate ignoring it outside the kernel
printf("DoAccess: raid addr %lu too large to access %lu sectors. Max legal addr is %lu\n",
(u_long) raidAddress, (u_long) numBlocks, (u_long) raidPtr->totalSectors);
- if (type == RF_IO_TYPE_READ) {
IO_BUF_ERR(bp, ENOSPC, raidPtr->raidid);
return (ENOSPC);
- } else {
- IO_BUF_ERR(bp, ENOSPC, raidPtr->raidid);
- return (ENOSPC);
- }
}
desc = rf_AllocRaidAccDesc(raidPtr, type, raidAddress,
numBlocks, lbufPtr, bp, paramDAG, paramASM,
diff --git a/sys/dev/raidframe/rf_engine.c b/sys/dev/raidframe/rf_engine.c
index 17fce1108a5..3e3235bc940 100644
--- a/sys/dev/raidframe/rf_engine.c
+++ b/sys/dev/raidframe/rf_engine.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_engine.c,v 1.3 1999/07/30 14:45:32 peter Exp $ */
-/* $NetBSD: rf_engine.c,v 1.5 1999/03/14 21:53:31 oster Exp $ */
+/* $OpenBSD: rf_engine.c,v 1.4 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_engine.c,v 1.6 2000/01/05 02:57:29 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -103,10 +103,6 @@ rf_ShutdownEngine(arg)
raidPtr = (RF_Raid_t *) arg;
raidPtr->shutdown_engine = 1;
DO_SIGNAL(raidPtr);
- /* XXX something is missing here... */
-#ifdef DEBUG
- printf("IGNORING WAIT_STOP\n");
-#endif
}
int
@@ -135,7 +131,7 @@ rf_ConfigureEngine(
if (rf_engineDebug) {
printf("[%d] Creating engine thread\n", tid);
}
- if (RF_CREATE_THREAD(raidPtr->engine_thread, DAGExecutionThread, raidPtr)) {
+ if (RF_CREATE_THREAD(raidPtr->engine_thread, DAGExecutionThread, raidPtr,"raid")) {
RF_ERRORMSG("RAIDFRAME: Unable to create engine thread\n");
return (ENOMEM);
}
diff --git a/sys/dev/raidframe/rf_etimer.h b/sys/dev/raidframe/rf_etimer.h
index 4ed503f4ec2..7531ade1471 100644
--- a/sys/dev/raidframe/rf_etimer.h
+++ b/sys/dev/raidframe/rf_etimer.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_etimer.h,v 1.4 1999/08/04 13:10:54 peter Exp $ */
-/* $NetBSD: rf_etimer.h,v 1.3 1999/02/05 00:06:11 oster Exp $ */
+/* $OpenBSD: rf_etimer.h,v 1.5 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_etimer.h,v 1.4 1999/08/13 03:26:55 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
diff --git a/sys/dev/raidframe/rf_evenodd.c b/sys/dev/raidframe/rf_evenodd.c
index 7b40675d9df..e37fb0f705b 100644
--- a/sys/dev/raidframe/rf_evenodd.c
+++ b/sys/dev/raidframe/rf_evenodd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_evenodd.c,v 1.2 1999/02/16 00:02:44 niklas Exp $ */
-/* $NetBSD: rf_evenodd.c,v 1.2 1999/02/05 00:06:11 oster Exp $ */
+/* $OpenBSD: rf_evenodd.c,v 1.3 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_evenodd.c,v 1.3 1999/08/13 03:41:56 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -56,7 +56,6 @@
#include "rf_map.h"
#include "rf_pq.h"
#include "rf_mcpair.h"
-#include "rf_sys.h"
#include "rf_evenodd.h"
#include "rf_evenodd_dagfuncs.h"
#include "rf_evenodd_dags.h"
diff --git a/sys/dev/raidframe/rf_evenodd_dagfuncs.c b/sys/dev/raidframe/rf_evenodd_dagfuncs.c
index dfbb36abc7e..dce6540648c 100644
--- a/sys/dev/raidframe/rf_evenodd_dagfuncs.c
+++ b/sys/dev/raidframe/rf_evenodd_dagfuncs.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_evenodd_dagfuncs.c,v 1.3 1999/10/29 08:57:17 todd Exp $ */
-/* $NetBSD: rf_evenodd_dagfuncs.c,v 1.2 1999/02/05 00:06:11 oster Exp $ */
+/* $OpenBSD: rf_evenodd_dagfuncs.c,v 1.4 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_evenodd_dagfuncs.c,v 1.3 1999/08/13 03:41:56 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -45,7 +45,6 @@
#include "rf_general.h"
#include "rf_configure.h"
#include "rf_parityscan.h"
-#include "rf_sys.h"
#include "rf_evenodd.h"
#include "rf_evenodd_dagfuncs.h"
diff --git a/sys/dev/raidframe/rf_general.h b/sys/dev/raidframe/rf_general.h
index 60ed42f550b..7e4b9a1ade6 100644
--- a/sys/dev/raidframe/rf_general.h
+++ b/sys/dev/raidframe/rf_general.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_general.h,v 1.2 1999/02/16 00:02:47 niklas Exp $ */
-/* $NetBSD: rf_general.h,v 1.3 1999/02/05 00:06:12 oster Exp $ */
+/* $OpenBSD: rf_general.h,v 1.3 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_general.h,v 1.4 1999/12/07 02:40:28 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -96,19 +96,6 @@ extern char rf_panicbuf[];
#define RF_BLIP(x) (NBPG - (RF_UL(x) & RF_PGMASK)) /* bytes left in page */
#define RF_PAGE_ALIGNED(x) ((RF_UL(x) & RF_PGMASK) == 0)
-#if DKUSAGE > 0
-#define RF_DKU_END_IO(_unit_,_bp_) { \
- int s = splbio(); \
- dku_end_io(DKU_RAIDFRAME_BUS, _unit_, 0, \
- (((_bp_)->b_flags&(B_READ|B_WRITE) == B_READ) ? \
- CAM_DIR_IN : CAM_DIR_OUT), \
- (_bp_)->b_bcount); \
- splx(s); \
-}
-#else /* DKUSAGE > 0 */
-#define RF_DKU_END_IO(unit) { /* noop */ }
-#endif /* DKUSAGE > 0 */
-
#ifdef __STDC__
#define RF_STRING(_str_) #_str_
#else /* __STDC__ */
diff --git a/sys/dev/raidframe/rf_kintf.h b/sys/dev/raidframe/rf_kintf.h
index 5b36487b095..19a2d30b6c2 100644
--- a/sys/dev/raidframe/rf_kintf.h
+++ b/sys/dev/raidframe/rf_kintf.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_kintf.h,v 1.3 1999/07/30 14:45:32 peter Exp $ */
-/* $NetBSD: rf_kintf.h,v 1.4 1999/03/09 03:52:41 oster Exp $ */
+/* $OpenBSD: rf_kintf.h,v 1.4 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_kintf.h,v 1.6 2000/01/05 02:57:29 oster Exp $ */
/*
* rf_kintf.h
*
@@ -37,21 +37,8 @@
#include "rf_types.h"
-int rf_boot(void);
-int rf_open(dev_t dev, int flag, int fmt);
-int rf_close(dev_t dev, int flag, int fmt);
-void rf_strategy(struct buf * bp);
-void rf_minphys(struct buf * bp);
-int rf_read(dev_t dev, struct uio * uio);
-int rf_write(dev_t dev, struct uio * uio);
-int rf_size(dev_t dev);
-int rf_ioctl(dev_t dev, int cmd, caddr_t data, int flag);
-void rf_ReconKernelThread(void);
int rf_GetSpareTableFromDaemon(RF_SparetWait_t * req);
-caddr_t rf_MapToKernelSpace(struct buf * bp, caddr_t addr);
-int rf_BzeroWithRemap(struct buf * bp, char *databuf, int len);
-int rf_DoAccessKernel(RF_Raid_t * raidPtr, struct buf * bp,
- RF_RaidAccessFlags_t flags, void (*cbFunc) (struct buf *), void *cbArg);
- int rf_DispatchKernelIO(RF_DiskQueue_t * queue, RF_DiskQueueData_t * req);
+void raidstart(RF_Raid_t * raidPtr);
+int rf_DispatchKernelIO(RF_DiskQueue_t * queue, RF_DiskQueueData_t * req);
#endif /* _RF__RF_KINTF_H_ */
diff --git a/sys/dev/raidframe/rf_map.c b/sys/dev/raidframe/rf_map.c
index 9d426580784..afe37457e99 100644
--- a/sys/dev/raidframe/rf_map.c
+++ b/sys/dev/raidframe/rf_map.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_map.c,v 1.2 1999/02/16 00:02:55 niklas Exp $ */
-/* $NetBSD: rf_map.c,v 1.3 1999/02/05 00:06:12 oster Exp $ */
+/* $OpenBSD: rf_map.c,v 1.3 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_map.c,v 1.4 1999/08/13 03:41:56 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -40,7 +40,6 @@
#include "rf_map.h"
#include "rf_freelist.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
static void rf_FreePDAList(RF_PhysDiskAddr_t * start, RF_PhysDiskAddr_t * end, int count);
static void
diff --git a/sys/dev/raidframe/rf_memchunk.c b/sys/dev/raidframe/rf_memchunk.c
index 54c6ac95f3b..a9bea6f29ef 100644
--- a/sys/dev/raidframe/rf_memchunk.c
+++ b/sys/dev/raidframe/rf_memchunk.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_memchunk.c,v 1.2 1999/02/16 00:02:57 niklas Exp $ */
-/* $NetBSD: rf_memchunk.c,v 1.3 1999/02/05 00:06:13 oster Exp $ */
+/* $OpenBSD: rf_memchunk.c,v 1.3 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_memchunk.c,v 1.4 1999/08/13 03:41:56 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -66,7 +66,6 @@
#include "rf_general.h"
#include "rf_options.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
typedef struct RF_ChunkHdr_s RF_ChunkHdr_t;
struct RF_ChunkHdr_s {
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index e69a4601e2d..9a23d1f0c09 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.21 1999/07/21 03:15:26 oster Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.39 2000/01/06 02:06:41 oster Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -153,11 +153,6 @@
int rf_kdebug_level = 0;
-#define RFK_BOOT_NONE 0
-#define RFK_BOOT_GOOD 1
-#define RFK_BOOT_BAD 2
-static int rf_kbooted = RFK_BOOT_NONE;
-
#ifdef DEBUG
#define db0_printf(a) printf a
#define db_printf(a) if (rf_kdebug_level > 0) printf a
@@ -184,15 +179,6 @@ static RF_SparetWait_t *rf_sparet_wait_queue; /* requests to install a
static RF_SparetWait_t *rf_sparet_resp_queue; /* responses from
* installation process */
-static struct rf_recon_req *recon_queue = NULL; /* used to communicate
- * reconstruction
- * requests */
-
-
-decl_simple_lock_data(, recon_queue_mutex)
-#define LOCK_RECON_Q_MUTEX() simple_lock(&recon_queue_mutex)
-#define UNLOCK_RECON_Q_MUTEX() simple_unlock(&recon_queue_mutex)
-
/* prototypes */
static void KernelWakeupFunc(struct buf * bp);
static void InitBP(struct buf * bp, struct vnode *, unsigned rw_flag,
@@ -201,15 +187,6 @@ static void InitBP(struct buf * bp, struct vnode *, unsigned rw_flag,
void (*cbFunc) (struct buf *), void *cbArg,
int logBytesPerSector, struct proc * b_proc);
-#define Dprintf0(s) if (rf_queueDebug) \
- rf_debug_printf(s,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
-#define Dprintf1(s,a) if (rf_queueDebug) \
- rf_debug_printf(s,a,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
-#define Dprintf2(s,a,b) if (rf_queueDebug) \
- rf_debug_printf(s,a,b,NULL,NULL,NULL,NULL,NULL,NULL)
-#define Dprintf3(s,a,b,c) if (rf_queueDebug) \
- rf_debug_printf(s,a,b,c,NULL,NULL,NULL,NULL,NULL)
-
int raidmarkclean(dev_t dev, struct vnode *b_vp, int);
int raidmarkdirty(dev_t dev, struct vnode *b_vp, int);
@@ -257,6 +234,7 @@ struct raid_softc {
char sc_xname[20]; /* XXX external name */
struct disk sc_dkdev; /* generic disk device info */
struct pool sc_cbufpool; /* component buffer pool */
+ struct buf buf_queue; /* used for the device queue */
};
/* sc_flags */
#define RAIDF_INITED 0x01 /* unit has been initialized */
@@ -271,11 +249,22 @@ static int numraid = 0;
/*
* Allow RAIDOUTSTANDING number of simultaneous IO's to this RAID device.
* Be aware that large numbers can allow the driver to consume a lot of
- * kernel memory, especially on writes...
+ * kernel memory, especially on writes, and in degraded mode reads.
+ *
+ * For example: with a stripe width of 64 blocks (32k) and 5 disks,
+ * a single 64K write will typically require 64K for the old data,
+ * 64K for the old parity, and 64K for the new parity, for a total
+ * of 192K (if the parity buffer is not re-used immediately).
+ * Even it if is used immedately, that's still 128K, which when multiplied
+ * by say 10 requests, is 1280K, *on top* of the 640K of incoming data.
+ *
+ * Now in degraded mode, for example, a 64K read on the above setup may
+ * require data reconstruction, which will require *all* of the 4 remaining
+ * disks to participate -- 4 * 32K/disk == 128K again.
*/
#ifndef RAIDOUTSTANDING
-#define RAIDOUTSTANDING 10
+#define RAIDOUTSTANDING 6
#endif
#define RAIDLABELDEV(dev) \
@@ -295,6 +284,13 @@ int raidlookup __P((char *, struct proc * p, struct vnode **));
static void rf_markalldirty __P((RF_Raid_t *));
+void rf_ReconThread __P((struct rf_recon_req *));
+/* XXX what I want is: */
+/*void rf_ReconThread __P((RF_Raid_t *raidPtr)); */
+void rf_RewriteParityThread __P((RF_Raid_t *raidPtr));
+void rf_CopybackThread __P((RF_Raid_t *raidPtr));
+void rf_ReconstructInPlaceThread __P((struct rf_recon_req *));
+
void
raidattach(num)
int num;
@@ -327,7 +323,6 @@ raidattach(num)
}
rf_sparet_wait_queue = rf_sparet_resp_queue = NULL;
- recon_queue = NULL;
for (i = 0; i < numraid; i++)
raidPtrs[i] = NULL;
@@ -337,8 +332,6 @@ raidattach(num)
else
panic("Serious error booting RAID!!\n");
- rf_kbooted = RFK_BOOT_GOOD;
-
/* put together some datastructures like the CCD device does.. This
* lets us lock the device and what-not when it gets opened. */
@@ -353,10 +346,15 @@ raidattach(num)
bzero(raid_softc, num * sizeof(struct raid_softc));
for (raidID = 0; raidID < num; raidID++) {
+ raid_softc[raidID].buf_queue.b_actf = NULL;
+ raid_softc[raidID].buf_queue.b_actb =
+ &raid_softc[raidID].buf_queue.b_actf;
RF_Calloc(raidPtrs[raidID], 1, sizeof(RF_Raid_t),
(RF_Raid_t *));
if (raidPtrs[raidID] == NULL) {
- printf("raidPtrs[%d] is NULL\n", raidID);
+ printf("WARNING: raidPtrs[%d] is NULL\n", raidID);
+ numraid = raidID;
+ return;
}
}
}
@@ -545,22 +543,16 @@ raidstrategy(bp)
RF_Raid_t *raidPtr;
struct raid_softc *rs = &raid_softc[raidID];
struct disklabel *lp;
+ struct buf *dp;
int wlabel;
-#if 0
- db1_printf(("Strategy: 0x%x 0x%x\n", bp, bp->b_data));
- db1_printf(("Strategy(2): bp->b_bufsize%d\n", (int) bp->b_bufsize));
- db1_printf(("bp->b_count=%d\n", (int) bp->b_bcount));
- db1_printf(("bp->b_resid=%d\n", (int) bp->b_resid));
- db1_printf(("bp->b_blkno=%d\n", (int) bp->b_blkno));
-
- if (bp->b_flags & B_READ)
- db1_printf(("READ\n"));
- else
- db1_printf(("WRITE\n"));
-#endif
- if (rf_kbooted != RFK_BOOT_GOOD)
+ if ((rs->sc_flags & RAIDF_INITED) ==0) {
+ bp->b_error = ENXIO;
+ bp->b_flags = B_ERROR;
+ bp->b_resid = bp->b_bcount;
+ biodone(bp);
return;
+ }
if (raidID >= numraid || !raidPtrs[raidID]) {
bp->b_error = ENODEV;
bp->b_flags |= B_ERROR;
@@ -596,23 +588,21 @@ raidstrategy(bp)
biodone(bp);
return;
}
- s = splbio(); /* XXX Needed? */
- db1_printf(("Beginning strategy...\n"));
+ s = splbio();
bp->b_resid = 0;
- bp->b_error = rf_DoAccessKernel(raidPtrs[raidID], bp,
- NULL, NULL, NULL);
- if (bp->b_error) {
- bp->b_flags |= B_ERROR;
- db1_printf(("bp->b_flags HAS B_ERROR SET!!!: %d\n",
- bp->b_error));
- }
+
+ /* stuff it onto our queue */
+
+ dp = &rs->buf_queue;
+ bp->b_actf = NULL;
+ bp->b_actb = dp->b_actb;
+ *dp->b_actb = bp;
+ dp->b_actb = &bp->b_actf;
+
+ raidstart(raidPtrs[raidID]);
+
splx(s);
-#if 0
- db1_printf(("Strategy exiting: 0x%x 0x%x %d %d\n",
- bp, bp->b_data,
- (int) bp->b_bcount, (int) bp->b_resid));
-#endif
}
/* ARGSUSED */
int
@@ -671,19 +661,11 @@ raidioctl(dev, cmd, data, flag, p)
int error = 0;
int part, pmask;
struct raid_softc *rs;
-#if 0
- int r, c;
-#endif
- /* struct raid_ioctl *ccio = (struct ccd_ioctl *)data; */
-
- /* struct ccdbuf *cbp; */
- /* struct raidbuf *raidbp; */
RF_Config_t *k_cfg, *u_cfg;
u_char *specific_buf;
int retcode = 0;
int row;
int column;
- int s;
struct rf_recon_req *rrcopy, *rr;
RF_ComponentLabel_t *component_label;
RF_ComponentLabel_t ci_label;
@@ -725,13 +707,16 @@ raidioctl(dev, cmd, data, flag, p)
case RAIDFRAME_GET_SIZE:
case RAIDFRAME_FAIL_DISK:
case RAIDFRAME_COPYBACK:
- case RAIDFRAME_CHECKRECON:
+ case RAIDFRAME_CHECK_RECON_STATUS:
case RAIDFRAME_GET_COMPONENT_LABEL:
case RAIDFRAME_SET_COMPONENT_LABEL:
case RAIDFRAME_ADD_HOT_SPARE:
case RAIDFRAME_REMOVE_HOT_SPARE:
case RAIDFRAME_INIT_LABELS:
case RAIDFRAME_REBUILD_IN_PLACE:
+ case RAIDFRAME_CHECK_PARITY:
+ case RAIDFRAME_CHECK_PARITYREWRITE_STATUS:
+ case RAIDFRAME_CHECK_COPYBACK_STATUS:
if ((rs->sc_flags & RAIDF_INITED) == 0)
return (ENXIO);
}
@@ -754,6 +739,7 @@ raidioctl(dev, cmd, data, flag, p)
retcode = copyin((caddr_t) u_cfg, (caddr_t) k_cfg,
sizeof(RF_Config_t));
if (retcode) {
+ RF_Free(k_cfg, sizeof(RF_Config_t));
db3_printf(("rf_ioctl: retcode=%d copyin.1\n",
retcode));
return (retcode);
@@ -763,6 +749,7 @@ raidioctl(dev, cmd, data, flag, p)
if (k_cfg->layoutSpecificSize) {
if (k_cfg->layoutSpecificSize > 10000) {
/* sanity check */
+ RF_Free(k_cfg, sizeof(RF_Config_t));
db3_printf(("rf_ioctl: EINVAL %d\n", retcode));
return (EINVAL);
}
@@ -777,6 +764,8 @@ raidioctl(dev, cmd, data, flag, p)
(caddr_t) specific_buf,
k_cfg->layoutSpecificSize);
if (retcode) {
+ RF_Free(k_cfg, sizeof(RF_Config_t));
+ RF_Free(specific_buf, k_cfg->layoutSpecificSize);
db3_printf(("rf_ioctl: retcode=%d copyin.2\n",
retcode));
return (retcode);
@@ -788,16 +777,6 @@ raidioctl(dev, cmd, data, flag, p)
/* should do some kind of sanity check on the configuration.
* Store the sum of all the bytes in the last byte? */
-#if 0
- db1_printf(("Considering configuring the system.:%d 0x%x\n",
- unit, p));
-#endif
-
- /* We need the pointer to this a little deeper, so stash it
- * here... */
-
- raidPtrs[unit]->proc = p;
-
/* configure the system */
raidPtrs[unit]->raidid = unit;
@@ -807,6 +786,12 @@ raidioctl(dev, cmd, data, flag, p)
/* allow this many simultaneous IO's to this RAID device */
raidPtrs[unit]->openings = RAIDOUTSTANDING;
+ /* XXX should be moved to rf_Configure() */
+
+ raidPtrs[unit]->copyback_in_progress = 0;
+ raidPtrs[unit]->parity_rewrite_in_progress = 0;
+ raidPtrs[unit]->recon_in_progress = 0;
+
if (retcode == 0) {
retcode = raidinit(dev, raidPtrs[unit], unit);
rf_markalldirty( raidPtrs[unit] );
@@ -842,17 +827,9 @@ raidioctl(dev, cmd, data, flag, p)
return (EBUSY);
}
- if (rf_debugKernelAccess) {
- printf("call shutdown\n");
- }
- raidPtrs[unit]->proc = p; /* XXX necessary evil */
-
retcode = rf_Shutdown(raidPtrs[unit]);
- db1_printf(("Done main shutdown\n"));
-
pool_destroy(&rs->sc_cbufpool);
- db1_printf(("Done freeing component buffer freelist\n"));
/* It's no longer initialized... */
rs->sc_flags &= ~RAIDF_INITED;
@@ -883,18 +860,17 @@ raidioctl(dev, cmd, data, flag, p)
sizeof(RF_ComponentLabel_t));
if (retcode) {
+ RF_Free( component_label, sizeof(RF_ComponentLabel_t));
return(retcode);
}
row = component_label->row;
- printf("Row: %d\n",row);
- if (row > raidPtrs[unit]->numRow) {
- row = 0; /* XXX */
- }
column = component_label->column;
- printf("Column: %d\n",column);
- if (column > raidPtrs[unit]->numCol) {
- column = 0; /* XXX */
+
+ if ((row < 0) || (row >= raidPtrs[unit]->numRow) ||
+ (column < 0) || (column >= raidPtrs[unit]->numCol)) {
+ RF_Free( component_label, sizeof(RF_ComponentLabel_t));
+ return(EINVAL);
}
raidread_component_label(
@@ -931,8 +907,8 @@ raidioctl(dev, cmd, data, flag, p)
row = component_label->row;
column = component_label->column;
- if ((row < 0) || (row > raidPtrs[unit]->numRow) ||
- (column < 0) || (column > raidPtrs[unit]->numCol)) {
+ if ((row < 0) || (row >= raidPtrs[unit]->numRow) ||
+ (column < 0) || (column >= raidPtrs[unit]->numCol)) {
return(EINVAL);
}
@@ -986,19 +962,16 @@ raidioctl(dev, cmd, data, flag, p)
return(0);
}
+ if (raidPtrs[unit]->parity_rewrite_in_progress == 1) {
+ /* Re-write is already in progress! */
+ return(EINVAL);
+ }
+
/* borrow the thread of the requesting process */
- raidPtrs[unit]->proc = p; /* Blah... :-p GO */
- retcode = rf_RewriteParity(raidPtrs[unit]);
- /* return I/O Error if the parity rewrite fails */
- if (retcode) {
- retcode = EIO;
- } else {
- /* set the clean bit! If we shutdown correctly,
- the clean bit on each component label will get
- set */
- raidPtrs[unit]->parity_good = RF_RAID_CLEAN;
- }
+ retcode = RF_CREATE_THREAD(raidPtrs[unit]->parity_rewrite_thread,
+ rf_RewriteParityThread,
+ raidPtrs[unit],"raid_parity");
return (retcode);
@@ -1006,7 +979,6 @@ raidioctl(dev, cmd, data, flag, p)
sparePtr = (RF_SingleComponent_t *) data;
memcpy( &hot_spare, sparePtr, sizeof(RF_SingleComponent_t));
printf("Adding spare\n");
- raidPtrs[unit]->proc = p; /* Blah... :-p GO */
retcode = rf_add_hot_spare(raidPtrs[unit], &hot_spare);
return(retcode);
@@ -1014,31 +986,41 @@ raidioctl(dev, cmd, data, flag, p)
return(retcode);
case RAIDFRAME_REBUILD_IN_PLACE:
+
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* Can't do this on a RAID 0!! */
+ return(EINVAL);
+ }
+
+ if (raidPtrs[unit]->recon_in_progress == 1) {
+ /* a reconstruct is already in progress! */
+ return(EINVAL);
+ }
+
componentPtr = (RF_SingleComponent_t *) data;
memcpy( &component, componentPtr,
sizeof(RF_SingleComponent_t));
row = component.row;
column = component.column;
printf("Rebuild: %d %d\n",row, column);
- if ((row < 0) || (row > raidPtrs[unit]->numRow) ||
- (column < 0) || (column > raidPtrs[unit]->numCol)) {
+ if ((row < 0) || (row >= raidPtrs[unit]->numRow) ||
+ (column < 0) || (column >= raidPtrs[unit]->numCol)) {
return(EINVAL);
}
- printf("Attempting a rebuild in place\n");
- s = splbio();
- raidPtrs[unit]->proc = p; /* Blah... :-p GO */
- retcode = rf_ReconstructInPlace(raidPtrs[unit], row, column);
- splx(s);
- return(retcode);
- /* issue a test-unit-ready through raidframe to the indicated
- * device */
-#if 0 /* XXX not supported yet (ever?) */
- case RAIDFRAME_TUR:
- /* debug only */
- retcode = rf_SCSI_DoTUR(0, 0, 0, 0, *(dev_t *) data);
+ RF_Malloc(rrcopy, sizeof(*rrcopy), (struct rf_recon_req *));
+ if (rrcopy == NULL)
+ return(ENOMEM);
+
+ rrcopy->raidPtr = (void *) raidPtrs[unit];
+ rrcopy->row = row;
+ rrcopy->col = column;
+
+ retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread,
+ rf_ReconstructInPlaceThread,
+ rrcopy,"raid_reconip");
return (retcode);
-#endif
+
case RAIDFRAME_GET_INFO:
{
RF_Raid_t *raid = raidPtrs[unit];
@@ -1057,12 +1039,12 @@ raidioctl(dev, cmd, data, flag, p)
cfg->cols = raid->numCol;
cfg->ndevs = raid->numRow * raid->numCol;
if (cfg->ndevs >= RF_MAX_DISKS) {
- cfg->ndevs = 0;
+ RF_Free(cfg, sizeof(RF_DeviceConfig_t));
return (ENOMEM);
}
cfg->nspares = raid->numSpare;
if (cfg->nspares >= RF_MAX_DISKS) {
- cfg->nspares = 0;
+ RF_Free(cfg, sizeof(RF_DeviceConfig_t));
return (ENOMEM);
}
cfg->maxqdepth = raid->maxQueueDepth;
@@ -1083,7 +1065,9 @@ raidioctl(dev, cmd, data, flag, p)
return (retcode);
}
break;
-
+ case RAIDFRAME_CHECK_PARITY:
+ *(int *) data = raidPtrs[unit]->parity_good;
+ return (0);
case RAIDFRAME_RESET_ACCTOTALS:
{
RF_Raid_t *raid = raidPtrs[unit];
@@ -1117,12 +1101,14 @@ raidioctl(dev, cmd, data, flag, p)
*(int *) data = raidPtrs[unit]->totalSectors;
return (0);
-#define RAIDFRAME_RECON 1
- /* XXX The above should probably be set somewhere else!! GO */
-#if RAIDFRAME_RECON > 0
-
/* fail a disk & optionally start reconstruction */
case RAIDFRAME_FAIL_DISK:
+
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* Can't do this on a RAID 0!! */
+ return(EINVAL);
+ }
+
rr = (struct rf_recon_req *) data;
if (rr->row < 0 || rr->row >= raidPtrs[unit]->numRow
@@ -1135,38 +1121,73 @@ raidioctl(dev, cmd, data, flag, p)
/* make a copy of the recon request so that we don't rely on
* the user's buffer */
RF_Malloc(rrcopy, sizeof(*rrcopy), (struct rf_recon_req *));
+ if (rrcopy == NULL)
+ return(ENOMEM);
bcopy(rr, rrcopy, sizeof(*rr));
rrcopy->raidPtr = (void *) raidPtrs[unit];
- LOCK_RECON_Q_MUTEX();
- rrcopy->next = recon_queue;
- recon_queue = rrcopy;
- wakeup(&recon_queue);
- UNLOCK_RECON_Q_MUTEX();
-
+ retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread,
+ rf_ReconThread,
+ rrcopy,"raid_recon");
return (0);
/* invoke a copyback operation after recon on whatever disk
* needs it, if any */
case RAIDFRAME_COPYBACK:
- /* borrow the current thread to get this done */
- raidPtrs[unit]->proc = p; /* ICK.. but needed :-p GO */
- s = splbio();
- rf_CopybackReconstructedData(raidPtrs[unit]);
- splx(s);
- return (0);
+
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* This makes no sense on a RAID 0!! */
+ return(EINVAL);
+ }
+
+ if (raidPtrs[unit]->copyback_in_progress == 1) {
+ /* Copyback is already in progress! */
+ return(EINVAL);
+ }
+
+ retcode = RF_CREATE_THREAD(raidPtrs[unit]->copyback_thread,
+ rf_CopybackThread,
+ raidPtrs[unit],"raid_copyback");
+ return (retcode);
/* return the percentage completion of reconstruction */
- case RAIDFRAME_CHECKRECON:
- row = *(int *) data;
- if (row < 0 || row >= raidPtrs[unit]->numRow)
+ case RAIDFRAME_CHECK_RECON_STATUS:
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* This makes no sense on a RAID 0 */
return (EINVAL);
+ }
+ row = 0; /* XXX we only consider a single row... */
if (raidPtrs[unit]->status[row] != rf_rs_reconstructing)
*(int *) data = 100;
else
*(int *) data = raidPtrs[unit]->reconControl[row]->percentComplete;
return (0);
+ case RAIDFRAME_CHECK_PARITYREWRITE_STATUS:
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* This makes no sense on a RAID 0 */
+ return(EINVAL);
+ }
+ if (raidPtrs[unit]->parity_rewrite_in_progress == 1) {
+ *(int *) data = 100 * raidPtrs[unit]->parity_rewrite_stripes_done / raidPtrs[unit]->Layout.numStripe;
+ } else {
+ *(int *) data = 100;
+ }
+ return (0);
+
+ case RAIDFRAME_CHECK_COPYBACK_STATUS:
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* This makes no sense on a RAID 0 */
+ return(EINVAL);
+ }
+ if (raidPtrs[unit]->copyback_in_progress == 1) {
+ *(int *) data = 100 * raidPtrs[unit]->copyback_stripes_done / raidPtrs[unit]->Layout.numStripe;
+ } else {
+ *(int *) data = 100;
+ }
+ return (0);
+
+
/* the sparetable daemon calls this to wait for the kernel to
* need a spare table. this ioctl does not return until a
* spare table is needed. XXX -- calling mpsleep here in the
@@ -1221,9 +1242,6 @@ raidioctl(dev, cmd, data, flag, p)
return (retcode);
#endif
-
-#endif /* RAIDFRAME_RECON > 0 */
-
default:
break; /* fall through to the os-specific code below */
@@ -1238,21 +1256,17 @@ raidioctl(dev, cmd, data, flag, p)
switch (cmd) {
case DIOCGDINFO:
- db1_printf(("DIOCGDINFO %d %d\n", (int) dev, (int) DISKPART(dev)));
*(struct disklabel *) data = *(rs->sc_dkdev.dk_label);
break;
case DIOCGPART:
- db1_printf(("DIOCGPART: %d %d\n", (int) dev, (int) DISKPART(dev)));
((struct partinfo *) data)->disklab = rs->sc_dkdev.dk_label;
((struct partinfo *) data)->part =
&rs->sc_dkdev.dk_label->d_partitions[DISKPART(dev)];
break;
case DIOCWDINFO:
- db1_printf(("DIOCWDINFO\n"));
case DIOCSDINFO:
- db1_printf(("DIOCSDINFO\n"));
if ((error = raidlock(rs)) != 0)
return (error);
@@ -1275,7 +1289,6 @@ raidioctl(dev, cmd, data, flag, p)
break;
case DIOCWLABEL:
- db1_printf(("DIOCWLABEL\n"));
if (*(int *) data != 0)
rs->sc_flags |= RAIDF_WLABEL;
else
@@ -1283,13 +1296,12 @@ raidioctl(dev, cmd, data, flag, p)
break;
case DIOCGDEFLABEL:
- db1_printf(("DIOCGDEFLABEL\n"));
raidgetdefaultlabel(raidPtrs[unit], rs,
(struct disklabel *) data);
break;
default:
- retcode = ENOTTY; /* XXXX ?? OR EINVAL ? */
+ retcode = ENOTTY;
}
return (retcode);
@@ -1307,8 +1319,6 @@ raidinit(dev, raidPtr, unit)
int unit;
{
int retcode;
- /* int ix; */
- /* struct raidbuf *raidbp; */
struct raid_softc *rs;
retcode = 0;
@@ -1340,51 +1350,14 @@ raidinit(dev, raidPtr, unit)
return (retcode);
}
-/*
- * This kernel thread never exits. It is created once, and persists
- * until the system reboots.
- */
-
-void
-rf_ReconKernelThread()
-{
- struct rf_recon_req *req;
- int s;
-
- /* XXX not sure what spl() level we should be at here... probably
- * splbio() */
- s = splbio();
-
- while (1) {
- /* grab the next reconstruction request from the queue */
- LOCK_RECON_Q_MUTEX();
- while (!recon_queue) {
- UNLOCK_RECON_Q_MUTEX();
- tsleep(&recon_queue, PRIBIO,
- "raidframe recon", 0);
- LOCK_RECON_Q_MUTEX();
- }
- req = recon_queue;
- recon_queue = recon_queue->next;
- UNLOCK_RECON_Q_MUTEX();
-
- /*
- * If flags specifies that we should start recon, this call
- * will not return until reconstruction completes, fails,
- * or is aborted.
- */
- rf_FailDisk((RF_Raid_t *) req->raidPtr, req->row, req->col,
- ((req->flags & RF_FDFLAGS_RECON) ? 1 : 0));
-
- RF_Free(req, sizeof(*req));
- }
-}
/* wake up the daemon & tell it to get us a spare table
* XXX
* the entries in the queues should be tagged with the raidPtr
* so that in the extremely rare case that two recons happen at once,
* we know for which device were requesting a spare table
* XXX
+ *
+ * XXX This code is not currently used. GO
*/
int
rf_GetSpareTableFromDaemon(req)
@@ -1401,11 +1374,6 @@ rf_GetSpareTableFromDaemon(req)
while (!rf_sparet_resp_queue) {
tsleep(&rf_sparet_resp_queue, PRIBIO,
"raidframe getsparetable", 0);
-#if 0
- mpsleep(&rf_sparet_resp_queue, PZERO, "sparet resp", 0,
- (void *) simple_lock_addr(rf_sparet_wait_mutex),
- MS_LOCK_SIMPLE);
-#endif
}
req = rf_sparet_resp_queue;
rf_sparet_resp_queue = req->next;
@@ -1416,19 +1384,18 @@ rf_GetSpareTableFromDaemon(req)
* alloc'd */
return (retcode);
}
+
/* a wrapper around rf_DoAccess that extracts appropriate info from the
* bp & passes it down.
* any calls originating in the kernel must use non-blocking I/O
* do some extra sanity checking to return "appropriate" error values for
* certain conditions (to make some standard utilities work)
+ *
+ * Formerly known as: rf_DoAccessKernel
*/
-int
-rf_DoAccessKernel(raidPtr, bp, flags, cbFunc, cbArg)
+void
+raidstart(raidPtr)
RF_Raid_t *raidPtr;
- struct buf *bp;
- RF_RaidAccessFlags_t flags;
- void (*cbFunc) (struct buf *);
- void *cbArg;
{
RF_SectorCount_t num_blocks, pb, sum;
RF_RaidAddr_t raid_addr;
@@ -1438,31 +1405,52 @@ rf_DoAccessKernel(raidPtr, bp, flags, cbFunc, cbArg)
int unit;
struct raid_softc *rs;
int do_async;
-
- /* XXX The dev_t used here should be for /dev/[r]raid* !!! */
+ struct buf *bp;
+ struct buf *dp;
unit = raidPtr->raidid;
rs = &raid_softc[unit];
+ /* Check to see if we're at the limit... */
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ while (raidPtr->openings > 0) {
+ RF_UNLOCK_MUTEX(raidPtr->mutex);
+
+ /* get the next item, if any, from the queue */
+ dp = &rs->buf_queue;
+ bp = dp->b_actf;
+ if (bp == NULL) {
+ /* nothing more to do */
+ return;
+ }
+
+ /* update structures */
+ dp = bp->b_actf;
+ if (dp != NULL) {
+ dp->b_actb = bp->b_actb;
+ } else {
+ rs->buf_queue.b_actb = bp->b_actb;
+ }
+ *bp->b_actb = dp;
+
/* Ok, for the bp we have here, bp->b_blkno is relative to the
- * partition.. Need to make it absolute to the underlying device.. */
+ * partition.. Need to make it absolute to the underlying
+ * device.. */
blocknum = bp->b_blkno;
if (DISKPART(bp->b_dev) != RAW_PART) {
pp = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)];
blocknum += pp->p_offset;
- db1_printf(("updated: %d %d\n", DISKPART(bp->b_dev),
- pp->p_offset));
- } else {
- db1_printf(("Is raw..\n"));
}
- db1_printf(("Blocks: %d, %d\n", (int) bp->b_blkno, (int) blocknum));
+
+ db1_printf(("Blocks: %d, %d\n", (int) bp->b_blkno,
+ (int) blocknum));
db1_printf(("bp->b_bcount = %d\n", (int) bp->b_bcount));
db1_printf(("bp->b_resid = %d\n", (int) bp->b_resid));
- /* *THIS* is where we adjust what block we're going to... but DO NOT
- * TOUCH bp->b_blkno!!! */
+ /* *THIS* is where we adjust what block we're going to...
+ * but DO NOT TOUCH bp->b_blkno!!! */
raid_addr = blocknum;
num_blocks = bp->b_bcount >> raidPtr->logBytesPerSector;
@@ -1479,7 +1467,8 @@ rf_DoAccessKernel(raidPtr, bp, flags, cbFunc, cbArg)
bp->b_flags |= B_ERROR;
bp->b_resid = bp->b_bcount;
biodone(bp);
- return (bp->b_error);
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ continue;
}
/*
* XXX rf_DoAccess() should do this, not just DoAccessKernel()
@@ -1490,44 +1479,44 @@ rf_DoAccessKernel(raidPtr, bp, flags, cbFunc, cbArg)
bp->b_flags |= B_ERROR;
bp->b_resid = bp->b_bcount;
biodone(bp);
- return (bp->b_error);
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ continue;
+
}
db1_printf(("Calling DoAccess..\n"));
- /* Put a throttle on the number of requests we handle simultanously */
-
- RF_LOCK_MUTEX(raidPtr->mutex);
-
- while(raidPtr->openings <= 0) {
- RF_UNLOCK_MUTEX(raidPtr->mutex);
- (void)tsleep(&raidPtr->openings, PRIBIO, "rfdwait", 0);
RF_LOCK_MUTEX(raidPtr->mutex);
- }
raidPtr->openings--;
-
RF_UNLOCK_MUTEX(raidPtr->mutex);
/*
* Everything is async.
*/
do_async = 1;
+
+ /* don't ever condition on bp->b_flags & B_WRITE.
+ * always condition on B_READ instead */
+
+ /* XXX we're still at splbio() here... do we *really*
+ need to be? */
- /* don't ever condition on bp->b_flags & B_WRITE. always condition on
- * B_READ instead */
+
retcode = rf_DoAccess(raidPtr, (bp->b_flags & B_READ) ?
RF_IO_TYPE_READ : RF_IO_TYPE_WRITE,
do_async, raid_addr, num_blocks,
- bp->b_un.b_addr,
- bp, NULL, NULL, RF_DAG_NONBLOCKING_IO | flags,
- NULL, cbFunc, cbArg);
-#if 0
- db1_printf(("After call to DoAccess: 0x%x 0x%x %d\n", bp,
- bp->b_data, (int) bp->b_resid));
-#endif
+ bp->b_un.b_addr, bp, NULL, NULL,
+ RF_DAG_NONBLOCKING_IO, NULL, NULL, NULL);
- return (retcode);
+
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ }
+ RF_UNLOCK_MUTEX(raidPtr->mutex);
}
+
+
+
+
/* invoke an I/O from kernel mode. Disk queue should be locked upon entry */
int
@@ -1540,7 +1529,10 @@ rf_DispatchKernelIO(queue, req)
struct raidbuf *raidbp = NULL;
struct raid_softc *rs;
int unit;
+ int s;
+ s=0;
+ /* s = splbio();*/ /* want to test this */
/* XXX along with the vnode, we also need the softc associated with
* this device.. */
@@ -1583,10 +1575,10 @@ rf_DispatchKernelIO(queue, req)
raidbp->rf_obp = bp;
raidbp->req = req;
+ LIST_INIT(&raidbp->rf_buf.b_dep);
+
switch (req->type) {
case RF_IO_TYPE_NOP: /* used primarily to unlock a locked queue */
- /* Dprintf2("rf_DispatchKernelIO: NOP to r %d c %d\n",
- * queue->row, queue->col); */
/* XXX need to do something extra here.. */
/* I'm leaving this in, as I've never actually seen it used,
* and I'd like folks to report it... GO */
@@ -1619,8 +1611,6 @@ rf_DispatchKernelIO(queue, req)
/* acc wouldn't have been let in if there were any pending
* reqs at any other priority */
queue->curPriority = req->priority;
- /* Dprintf3("rf_DispatchKernelIO: %c to row %d col %d\n",
- * req->type, queue->row, queue->col); */
db1_printf(("Going for %c to unit %d row %d col %d\n",
req->type, unit, queue->row, queue->col));
@@ -1640,6 +1630,7 @@ rf_DispatchKernelIO(queue, req)
panic("bad req->type in rf_DispatchKernelIO");
}
db1_printf(("Exiting from DispatchKernelIO\n"));
+ /* splx(s); */ /* want to test this */
return (0);
}
/* this is the callback function associated with a I/O invoked from
@@ -1657,31 +1648,19 @@ KernelWakeupFunc(vbp)
int unit;
register int s;
- s = splbio(); /* XXX */
+ s = splbio();
db1_printf(("recovering the request queue:\n"));
req = raidbp->req;
bp = raidbp->rf_obp;
-#if 0
- db1_printf(("bp=0x%x\n", bp));
-#endif
queue = (RF_DiskQueue_t *) req->queue;
if (raidbp->rf_buf.b_flags & B_ERROR) {
-#if 0
- printf("Setting bp->b_flags!!! %d\n", raidbp->rf_buf.b_error);
-#endif
bp->b_flags |= B_ERROR;
bp->b_error = raidbp->rf_buf.b_error ?
raidbp->rf_buf.b_error : EIO;
}
-#if 0
- db1_printf(("raidbp->rf_buf.b_bcount=%d\n", (int) raidbp->rf_buf.b_bcount));
- db1_printf(("raidbp->rf_buf.b_bufsize=%d\n", (int) raidbp->rf_buf.b_bufsize));
- db1_printf(("raidbp->rf_buf.b_resid=%d\n", (int) raidbp->rf_buf.b_resid));
- db1_printf(("raidbp->rf_buf.b_data=0x%x\n", raidbp->rf_buf.b_data));
-#endif
/* XXX methinks this could be wrong... */
#if 1
@@ -1704,7 +1683,7 @@ KernelWakeupFunc(vbp)
/* XXX Ok, let's get aggressive... If B_ERROR is set, let's go
* ballistic, and mark the component as hosed... */
-#if 1
+
if (bp->b_flags & B_ERROR) {
/* Mark the disk as dead */
/* but only mark it once... */
@@ -1722,26 +1701,20 @@ KernelWakeupFunc(vbp)
}
}
-#endif
rs = &raid_softc[unit];
RAIDPUTBUF(rs, raidbp);
if (bp->b_resid == 0) {
- db1_printf(("Disk is no longer busy for this buffer... %d %ld %ld\n",
- unit, bp->b_resid, bp->b_bcount));
/* XXX is this the right place for a disk_unbusy()??!??!?!? */
disk_unbusy(&rs->sc_dkdev, (bp->b_bcount - bp->b_resid));
- } else {
- db1_printf(("b_resid is still %ld\n", bp->b_resid));
}
rf_DiskIOComplete(queue, req, (bp->b_flags & B_ERROR) ? 1 : 0);
(req->CompleteFunc) (req->argument, (bp->b_flags & B_ERROR) ? 1 : 0);
- /* printf("Exiting KernelWakeupFunc\n"); */
- splx(s); /* XXX */
+ splx(s);
}
@@ -1769,15 +1742,9 @@ InitBP(
bp->b_bufsize = bp->b_bcount;
bp->b_error = 0;
bp->b_dev = dev;
- db1_printf(("bp->b_dev is %d\n", dev));
bp->b_un.b_addr = buf;
-#if 0
- db1_printf(("bp->b_data=0x%x\n", bp->b_data));
-#endif
-
bp->b_blkno = startSect;
bp->b_resid = bp->b_bcount; /* XXX is this right!??!?!! */
- db1_printf(("b_bcount is: %d\n", (int) bp->b_bcount));
if (bp->b_bcount == 0) {
panic("bp->b_bcount is zero in InitBP!!\n");
}
@@ -1786,28 +1753,6 @@ InitBP(
bp->b_vp = b_vp;
}
-/* Extras... */
-
-unsigned int
-rpcc()
-{
- /* XXX no clue what this is supposed to do.. my guess is that it's
- * supposed to read the CPU cycle counter... */
- /* db1_printf("this is supposed to do something useful too!??\n"); */
- return (0);
-}
-#if 0
-int
-rf_GetSpareTableFromDaemon(req)
- RF_SparetWait_t *req;
-{
- int retcode = 1;
- printf("This is supposed to do something useful!!\n"); /* XXX */
-
- return (retcode);
-
-}
-#endif
static void
raidgetdefaultlabel(raidPtr, rs, lp)
@@ -2328,3 +2273,90 @@ rf_update_component_labels( raidPtr )
}
/* printf("Component labels updated\n"); */
}
+
+void
+rf_ReconThread(req)
+ struct rf_recon_req *req;
+{
+ int s;
+ RF_Raid_t *raidPtr;
+
+ s = splbio();
+ raidPtr = (RF_Raid_t *) req->raidPtr;
+ raidPtr->recon_in_progress = 1;
+
+ rf_FailDisk((RF_Raid_t *) req->raidPtr, req->row, req->col,
+ ((req->flags & RF_FDFLAGS_RECON) ? 1 : 0));
+
+ /* XXX get rid of this! we don't need it at all.. */
+ RF_Free(req, sizeof(*req));
+
+ raidPtr->recon_in_progress = 0;
+ splx(s);
+
+ /* That's all... */
+ kthread_exit(0); /* does not return */
+}
+
+void
+rf_RewriteParityThread(raidPtr)
+ RF_Raid_t *raidPtr;
+{
+ int retcode;
+ int s;
+
+ raidPtr->parity_rewrite_in_progress = 1;
+ s = splbio();
+ retcode = rf_RewriteParity(raidPtr);
+ splx(s);
+ if (retcode) {
+ printf("raid%d: Error re-writing parity!\n",raidPtr->raidid);
+ } else {
+ /* set the clean bit! If we shutdown correctly,
+ the clean bit on each component label will get
+ set */
+ raidPtr->parity_good = RF_RAID_CLEAN;
+ }
+ raidPtr->parity_rewrite_in_progress = 0;
+
+ /* That's all... */
+ kthread_exit(0); /* does not return */
+}
+
+
+void
+rf_CopybackThread(raidPtr)
+ RF_Raid_t *raidPtr;
+{
+ int s;
+
+ raidPtr->copyback_in_progress = 1;
+ s = splbio();
+ rf_CopybackReconstructedData(raidPtr);
+ splx(s);
+ raidPtr->copyback_in_progress = 0;
+
+ /* That's all... */
+ kthread_exit(0); /* does not return */
+}
+
+
+void
+rf_ReconstructInPlaceThread(req)
+ struct rf_recon_req *req;
+{
+ int retcode;
+ int s;
+ RF_Raid_t *raidPtr;
+
+ s = splbio();
+ raidPtr = req->raidPtr;
+ raidPtr->recon_in_progress = 1;
+ retcode = rf_ReconstructInPlace(raidPtr, req->row, req->col);
+ RF_Free(req, sizeof(*req));
+ raidPtr->recon_in_progress = 0;
+ splx(s);
+
+ /* That's all... */
+ kthread_exit(0); /* does not return */
+}
diff --git a/sys/dev/raidframe/rf_openbsdkintf.c b/sys/dev/raidframe/rf_openbsdkintf.c
index 9799e4325a2..f2ac4fd6810 100644
--- a/sys/dev/raidframe/rf_openbsdkintf.c
+++ b/sys/dev/raidframe/rf_openbsdkintf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_openbsdkintf.c,v 1.7 1999/12/03 22:38:11 art Exp $ */
-
+/* $OpenBSD: rf_openbsdkintf.c,v 1.8 2000/01/07 14:50:21 peter Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.39 2000/01/06 02:06:41 oster Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -150,11 +150,6 @@
int rf_kdebug_level = 0;
-#define RFK_BOOT_NONE 0
-#define RFK_BOOT_GOOD 1
-#define RFK_BOOT_BAD 2
-static int rf_kbooted = RFK_BOOT_NONE;
-
#ifdef RAIDDEBUG
#define db0_printf(a) printf a
#define db_printf(a) do if (rf_kdebug_level > 0) printf a; while(0)
@@ -182,29 +177,12 @@ static RF_SparetWait_t *rf_sparet_wait_queue;
/* responses from installation process */
static RF_SparetWait_t *rf_sparet_resp_queue;
-/* used to communicate reconstruction requests */
-static struct rf_recon_req *recon_queue = NULL;
-
-decl_simple_lock_data(, recon_queue_mutex)
-
-#define LOCK_RECON_Q_MUTEX() simple_lock(&recon_queue_mutex)
-#define UNLOCK_RECON_Q_MUTEX() simple_unlock(&recon_queue_mutex)
-
/* prototypes */
void rf_KernelWakeupFunc __P((struct buf *));
void rf_InitBP __P((struct buf *, struct vnode *, unsigned, dev_t,
RF_SectorNum_t, RF_SectorCount_t, caddr_t, void (*)(struct buf *),
void *, int, struct proc *));
-#define Dprintf0(s) if (rf_queueDebug) \
- rf_debug_printf(s,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
-#define Dprintf1(s,a) if (rf_queueDebug) \
- rf_debug_printf(s,a,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
-#define Dprintf2(s,a,b) if (rf_queueDebug) \
- rf_debug_printf(s,a,b,NULL,NULL,NULL,NULL,NULL,NULL)
-#define Dprintf3(s,a,b,c) if (rf_queueDebug) \
- rf_debug_printf(s,a,b,c,NULL,NULL,NULL,NULL,NULL)
-
int raidmarkclean(dev_t dev, struct vnode *b_vp, int);
int raidmarkdirty(dev_t dev, struct vnode *b_vp, int);
@@ -251,6 +229,7 @@ struct raid_softc {
dev_t sc_dev; /* our device..*/
char sc_xname[20]; /* XXX external name */
struct disk sc_dkdev; /* generic disk device info */
+ struct buf buf_queue; /* used for the device queue */
};
/* sc_flags */
@@ -266,11 +245,22 @@ static int numraid = 0;
/*
* Allow RAIDOUTSTANDING number of simultaneous IO's to this RAID device.
* Be aware that large numbers can allow the driver to consume a lot of
- * kernel memory, especially on writes...
+ * kernel memory, especially on writes, and in degraded mode reads.
+ *
+ * For example: with a stripe width of 64 blocks (32k) and 5 disks,
+ * a single 64K write will typically require 64K for the old data,
+ * 64K for the old parity, and 64K for the new parity, for a total
+ * of 192K (if the parity buffer is not re-used immediately).
+ * Even it if is used immedately, that's still 128K, which when multiplied
+ * by say 10 requests, is 1280K, *on top* of the 640K of incoming data.
+ *
+ * Now in degraded mode, for example, a 64K read on the above setup may
+ * require data reconstruction, which will require *all* of the 4 remaining
+ * disks to participate -- 4 * 32K/disk == 128K again.
*/
#ifndef RAIDOUTSTANDING
-#define RAIDOUTSTANDING 10
+#define RAIDOUTSTANDING 6
#endif
#define RAIDLABELDEV(dev) \
@@ -290,6 +280,13 @@ int raidlookup __P((char *, struct proc *p, struct vnode **));
void rf_markalldirty __P((RF_Raid_t *));
+void rf_ReconThread __P((struct rf_recon_req *));
+/* XXX what I want is: */
+/*void rf_ReconThread __P((RF_Raid_t *raidPtr)); */
+void rf_RewriteParityThread __P((RF_Raid_t *raidPtr));
+void rf_CopybackThread __P((RF_Raid_t *raidPtr));
+void rf_ReconstructInPlaceThread __P((struct rf_recon_req *));
+
void
raidattach(num)
int num;
@@ -320,7 +317,6 @@ raidattach(num)
}
rf_sparet_wait_queue = rf_sparet_resp_queue = NULL;
- recon_queue = NULL;
for (i = 0; i < numraid; i++)
raidPtrs[i] = NULL;
@@ -330,8 +326,6 @@ raidattach(num)
else
panic("Serious error booting RAID!!\n");
- rf_kbooted = RFK_BOOT_GOOD;
-
/*
* Put together some datastructures like the CCD device does..
* This lets us lock the device and what-not when it gets opened.
@@ -347,10 +341,15 @@ raidattach(num)
bzero(raid_softc, num * sizeof (struct raid_softc));
for (raidID = 0; raidID < num; raidID++) {
+ raid_softc[raidID].buf_queue.b_actf = NULL;
+ raid_softc[raidID].buf_queue.b_actb =
+ &raid_softc[raidID].buf_queue.b_actf;
RF_Calloc(raidPtrs[raidID], 1, sizeof (RF_Raid_t),
(RF_Raid_t *));
if (raidPtrs[raidID] == NULL) {
- printf("raidPtrs[%d] is NULL\n", raidID);
+ printf("WARNING: raidPtrs[%d] is NULL\n", raidID);
+ numraid = raidID;
+ return;
}
}
}
@@ -536,21 +535,16 @@ raidstrategy(bp)
RF_Raid_t *raidPtr;
struct raid_softc *rs = &raid_softc[raidID];
struct disklabel *lp;
+ struct buf *dp;
int wlabel;
- db1_printf(("Strategy: 0x%x 0x%x\n", bp, bp->b_data));
- db1_printf(("Strategy(2): bp->b_bufsize %d\n", (int)bp->b_bufsize));
- db1_printf(("bp->b_count=%d\n", (int)bp->b_bcount));
- db1_printf(("bp->b_resid=%d\n", (int)bp->b_resid));
- db1_printf(("bp->b_blkno=%d\n", (int)bp->b_blkno));
-
- if (bp->b_flags & B_READ)
- db1_printf(("READ\n"));
- else
- db1_printf(("WRITE\n"));
-
- if (rf_kbooted != RFK_BOOT_GOOD)
- return;
+ if ((rs->sc_flags & RAIDF_INITED) ==0) {
+ bp->b_error = ENXIO;
+ bp->b_flags = B_ERROR;
+ bp->b_resid = bp->b_bcount;
+ biodone(bp);
+ return;
+ }
if (raidID >= numraid || !raidPtrs[raidID]) {
bp->b_error = ENODEV;
bp->b_flags |= B_ERROR;
@@ -587,21 +581,21 @@ raidstrategy(bp)
return;
}
- /* XXX splbio() needed? */
s = splbio();
- db1_printf(("Beginning strategy...\n"));
-
+
bp->b_resid = 0;
- bp->b_error =
- rf_DoAccessKernel(raidPtrs[raidID], bp, NULL, NULL, NULL);
- if (bp->b_error) {
- bp->b_flags |= B_ERROR;
- db1_printf(
- ("bp->b_flags HAS B_ERROR SET!!!: %d\n", bp->b_error));
- }
+
+ /* stuff it onto our queue */
+
+ dp = &rs->buf_queue;
+ bp->b_actf = NULL;
+ bp->b_actb = dp->b_actb;
+ *dp->b_actb = bp;
+ dp->b_actb = &bp->b_actf;
+
+ raidstart(raidPtrs[raidID]);
+
splx(s);
- db1_printf(("Strategy exiting: 0x%x 0x%x %d %d\n", bp, bp->b_data,
- (int)bp->b_bcount, (int)bp->b_resid));
}
/* ARGSUSED */
@@ -660,19 +654,11 @@ raidioctl(dev, cmd, data, flag, p)
int error = 0;
int part, pmask;
struct raid_softc *rs;
-#if 0
- int r, c;
-#endif
- /* struct raid_ioctl *ccio = (struct ccd_ioctl *)data; */
-
- /* struct ccdbuf *cbp; */
- /* struct raidbuf *raidbp; */
RF_Config_t *k_cfg, *u_cfg;
u_char *specific_buf;
int retcode = 0;
int row;
int column;
- int s;
struct rf_recon_req *rrcopy, *rr;
RF_ComponentLabel_t *component_label;
RF_ComponentLabel_t ci_label;
@@ -713,13 +699,16 @@ raidioctl(dev, cmd, data, flag, p)
case RAIDFRAME_GET_SIZE:
case RAIDFRAME_FAIL_DISK:
case RAIDFRAME_COPYBACK:
- case RAIDFRAME_CHECKRECON:
+ case RAIDFRAME_CHECK_RECON_STATUS:
case RAIDFRAME_GET_COMPONENT_LABEL:
case RAIDFRAME_SET_COMPONENT_LABEL:
case RAIDFRAME_ADD_HOT_SPARE:
case RAIDFRAME_REMOVE_HOT_SPARE:
case RAIDFRAME_INIT_LABELS:
case RAIDFRAME_REBUILD_IN_PLACE:
+ case RAIDFRAME_CHECK_PARITY:
+ case RAIDFRAME_CHECK_PARITYREWRITE_STATUS:
+ case RAIDFRAME_CHECK_COPYBACK_STATUS:
if ((rs->sc_flags & RAIDF_INITED) == 0)
return (ENXIO);
}
@@ -745,6 +734,7 @@ raidioctl(dev, cmd, data, flag, p)
retcode = copyin((caddr_t)u_cfg, (caddr_t)k_cfg,
sizeof (RF_Config_t));
if (retcode) {
+ RF_Free(k_cfg, sizeof(RF_Config_t));
db3_printf(("rf_ioctl: retcode=%d copyin.1\n",
retcode));
return (retcode);
@@ -757,6 +747,7 @@ raidioctl(dev, cmd, data, flag, p)
if (k_cfg->layoutSpecificSize) {
if (k_cfg->layoutSpecificSize > 10000) {
/* sanity check */
+ RF_Free(k_cfg, sizeof(RF_Config_t));
db3_printf(("rf_ioctl: EINVAL %d\n", retcode));
return (EINVAL);
}
@@ -770,6 +761,8 @@ raidioctl(dev, cmd, data, flag, p)
retcode = copyin(k_cfg->layoutSpecific,
(caddr_t)specific_buf, k_cfg->layoutSpecificSize);
if (retcode) {
+ RF_Free(k_cfg, sizeof(RF_Config_t));
+ RF_Free(specific_buf, k_cfg->layoutSpecificSize);
db3_printf(("rf_ioctl: retcode=%d copyin.2\n",
retcode));
return (retcode);
@@ -784,15 +777,6 @@ raidioctl(dev, cmd, data, flag, p)
* Store the sum of all the bytes in the last byte?
*/
- db1_printf(("Considering configuring the system.:%d 0x%x\n",
- unit, p));
-
- /*
- * We need the pointer to this a little deeper,
- * so stash it here...
- */
- raidPtrs[unit]->proc = p;
-
/* configure the system */
raidPtrs[unit]->raidid = unit;
@@ -801,6 +785,12 @@ raidioctl(dev, cmd, data, flag, p)
/* allow this many simultaneous IO's to this RAID device */
raidPtrs[unit]->openings = RAIDOUTSTANDING;
+ /* XXX should be moved to rf_Configure() */
+
+ raidPtrs[unit]->copyback_in_progress = 0;
+ raidPtrs[unit]->parity_rewrite_in_progress = 0;
+ raidPtrs[unit]->recon_in_progress = 0;
+
if (retcode == 0) {
retcode = raidinit(dev, raidPtrs[unit],unit);
rf_markalldirty( raidPtrs[unit] );
@@ -837,15 +827,8 @@ raidioctl(dev, cmd, data, flag, p)
return (EBUSY);
}
- if (rf_debugKernelAccess) {
- printf("call shutdown\n");
- }
- raidPtrs[unit]->proc = p; /* XXX Necessary evil */
-
retcode = rf_Shutdown(raidPtrs[unit]);
- db1_printf(("Done main shutdown\n"));
-
/* It's no longer initialized... */
rs->sc_flags &= ~RAIDF_INITED;
@@ -876,19 +859,17 @@ raidioctl(dev, cmd, data, flag, p)
sizeof(RF_ComponentLabel_t));
if (retcode) {
+ RF_Free( component_label, sizeof(RF_ComponentLabel_t));
return(retcode);
}
row = component_label->row;
- printf("Row: %d\n",row);
- if (row > raidPtrs[unit]->numRow) {
- row = 0; /* XXX */
- }
column = component_label->column;
- printf("Column: %d\n",column);
- if (column > raidPtrs[unit]->numCol) {
- column = 0; /* XXX */
- }
+
+ if ((row < 0) || (row >= raidPtrs[unit]->numRow) ||
+ (column < 0) || (column >= raidPtrs[unit]->numCol)) {
+ return(EINVAL);
+ }
raidread_component_label(
raidPtrs[unit]->Disks[row][column].dev,
@@ -924,8 +905,9 @@ raidioctl(dev, cmd, data, flag, p)
row = component_label->row;
column = component_label->column;
- if ((row < 0) || (row > raidPtrs[unit]->numRow) ||
- (column < 0) || (column > raidPtrs[unit]->numCol)) {
+ if ((row < 0) || (row >= raidPtrs[unit]->numRow) ||
+ (column < 0) || (column >= raidPtrs[unit]->numCol)) {
+ RF_Free( component_label, sizeof(RF_ComponentLabel_t));
return(EINVAL);
}
@@ -978,19 +960,18 @@ raidioctl(dev, cmd, data, flag, p)
return(0);
}
+
+ if (raidPtrs[unit]->parity_rewrite_in_progress == 1) {
+ /* Re-write is already in progress! */
+ return(EINVAL);
+ }
+
/* borrow the thread of the requesting process */
- raidPtrs[unit]->proc = p; /* Blah... :-p GO */
- retcode = rf_RewriteParity(raidPtrs[unit]);
- /* return I/O Error if the parity rewrite fails */
- if (retcode) {
- retcode = EIO;
- } else {
- /* set the clean bit! If we shutdown correctly,
- the clean bit on each component label will get
- set */
- raidPtrs[unit]->parity_good = RF_RAID_CLEAN;
- }
+ retcode = RF_CREATE_THREAD(raidPtrs[unit]->parity_rewrite_thread,
+ rf_RewriteParityThread,
+ raidPtrs[unit],"raid_parity");
+
return (retcode);
@@ -998,7 +979,6 @@ raidioctl(dev, cmd, data, flag, p)
sparePtr = (RF_SingleComponent_t *) data;
memcpy( &hot_spare, sparePtr, sizeof(RF_SingleComponent_t));
printf("Adding spare\n");
- raidPtrs[unit]->proc = p; /* Blah... :-p GO */
retcode = rf_add_hot_spare(raidPtrs[unit], &hot_spare);
return(retcode);
@@ -1006,35 +986,41 @@ raidioctl(dev, cmd, data, flag, p)
return(retcode);
case RAIDFRAME_REBUILD_IN_PLACE:
+
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* Can't do this on a RAID 0!! */
+ return(EINVAL);
+ }
+
+ if (raidPtrs[unit]->recon_in_progress == 1) {
+ /* a reconstruct is already in progress! */
+ return(EINVAL);
+ }
+
componentPtr = (RF_SingleComponent_t *) data;
memcpy( &component, componentPtr,
sizeof(RF_SingleComponent_t));
row = component.row;
column = component.column;
printf("Rebuild: %d %d\n",row, column);
- if ((row < 0) || (row > raidPtrs[unit]->numRow) ||
- (column < 0) || (column > raidPtrs[unit]->numCol)) {
+ if ((row < 0) || (row >= raidPtrs[unit]->numRow) ||
+ (column < 0) || (column >= raidPtrs[unit]->numCol)) {
return(EINVAL);
}
- printf("Attempting a rebuild in place\n");
- s = splbio();
- raidPtrs[unit]->proc = p; /* Blah... :-p GO */
- retcode = rf_ReconstructInPlace(raidPtrs[unit], row, column);
- splx(s);
- return (retcode);
+ RF_Malloc(rrcopy, sizeof(*rrcopy), (struct rf_recon_req *));
+ if (rrcopy == NULL)
+ return(ENOMEM);
-#if 0 /* XXX not supported yet (ever?) */
- case RAIDFRAME_TUR:
- /*
- * Issue a test-unit-ready through raidframe to the
- * indicated device.
- */
+ rrcopy->raidPtr = (void *) raidPtrs[unit];
+ rrcopy->row = row;
+ rrcopy->col = column;
+
+ retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread,
+ rf_ReconstructInPlaceThread,
+ rrcopy,"raid_reconip");
- /* debug only */
- retcode = rf_SCSI_DoTUR(0, 0, 0, 0, *(dev_t *)data);
return (retcode);
-#endif
case RAIDFRAME_GET_INFO:
{
@@ -1054,12 +1040,12 @@ raidioctl(dev, cmd, data, flag, p)
cfg->cols = raid->numCol;
cfg->ndevs = raid->numRow * raid->numCol;
if (cfg->ndevs >= RF_MAX_DISKS) {
- cfg->ndevs = 0;
+ RF_Free(cfg, sizeof(RF_DeviceConfig_t));
return (ENOMEM);
}
cfg->nspares = raid->numSpare;
if (cfg->nspares >= RF_MAX_DISKS) {
- cfg->nspares = 0;
+ RF_Free(cfg, sizeof(RF_DeviceConfig_t));
return (ENOMEM);
}
cfg->maxqdepth = raid->maxQueueDepth;
@@ -1079,8 +1065,10 @@ raidioctl(dev, cmd, data, flag, p)
return (retcode);
}
- break;
-
+ break;
+ case RAIDFRAME_CHECK_PARITY:
+ *(int *) data = raidPtrs[unit]->parity_good;
+ return (0);
case RAIDFRAME_RESET_ACCTOTALS:
{
RF_Raid_t *raid = raidPtrs[unit];
@@ -1114,10 +1102,6 @@ raidioctl(dev, cmd, data, flag, p)
*(int *) data = raidPtrs[unit]->totalSectors;
return (0);
-#define RAIDFRAME_RECON 1
- /* XXX The above should probably be set somewhere else!! GO */
-#if RAIDFRAME_RECON > 0
-
/* fail a disk & optionally start reconstruction */
case RAIDFRAME_FAIL_DISK:
rr = (struct rf_recon_req *)data;
@@ -1134,15 +1118,14 @@ raidioctl(dev, cmd, data, flag, p)
* rely on the user's buffer
*/
RF_Malloc(rrcopy, sizeof(*rrcopy), (struct rf_recon_req *));
+ if (rrcopy == NULL)
+ return(ENOMEM);
bcopy(rr, rrcopy, sizeof(*rr));
rrcopy->raidPtr = (void *)raidPtrs[unit];
- LOCK_RECON_Q_MUTEX();
- rrcopy->next = recon_queue;
- recon_queue = rrcopy;
- wakeup(&recon_queue);
- UNLOCK_RECON_Q_MUTEX();
-
+ retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread,
+ rf_ReconThread,
+ rrcopy,"raid_recon");
return (0);
/*
@@ -1150,25 +1133,49 @@ raidioctl(dev, cmd, data, flag, p)
* disk needs it, if any.
*/
case RAIDFRAME_COPYBACK:
- /* Borrow the current thread to get this done */
- raidPtrs[unit]->proc = p; /* ICK.. but needed :-p GO */
- s = splbio();
- rf_CopybackReconstructedData(raidPtrs[unit]);
- splx(s);
- return (0);
+ if (raidPtrs[unit]->copyback_in_progress == 1) {
+ /* Copyback is already in progress! */
+ return(EINVAL);
+ }
+
+ retcode = RF_CREATE_THREAD(raidPtrs[unit]->copyback_thread,
+ rf_CopybackThread,
+ raidPtrs[unit],"raid_copyback");
+ return (retcode);
/* Return the percentage completion of reconstruction */
- case RAIDFRAME_CHECKRECON:
- row = *(int *)data;
- if (row < 0 || row >= raidPtrs[unit]->numRow)
- return (EINVAL);
+ case RAIDFRAME_CHECK_RECON_STATUS:
+ row = 0; /* XXX we only consider a single row... */
if (raidPtrs[unit]->status[row] != rf_rs_reconstructing)
*(int *)data = 100;
else
*(int *)data =
raidPtrs[unit]->reconControl[row]->percentComplete;
return (0);
-
+ case RAIDFRAME_CHECK_PARITYREWRITE_STATUS:
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* This makes no sense on a RAID 0 */
+ return(EINVAL);
+ }
+ if (raidPtrs[unit]->parity_rewrite_in_progress == 1) {
+ *(int *) data = 100 * raidPtrs[unit]->parity_rewrite_stripes_done / raidPtrs[unit]->Layout.numStripe;
+ } else {
+ *(int *) data = 100;
+ }
+ return (0);
+
+ case RAIDFRAME_CHECK_COPYBACK_STATUS:
+ if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+ /* This makes no sense on a RAID 0 */
+ return(EINVAL);
+ }
+ if (raidPtrs[unit]->copyback_in_progress == 1) {
+ *(int *) data = 100 * raidPtrs[unit]->copyback_stripes_done / raidPtrs[unit]->Layout.numStripe;
+ } else {
+ *(int *) data = 100;
+ }
+ return (0);
+
#if 0
case RAIDFRAME_SPARET_WAIT:
/*
@@ -1234,8 +1241,6 @@ raidioctl(dev, cmd, data, flag, p)
return (retcode);
#endif
-#endif /* RAIDFRAME_RECON > 0 */
-
default:
/* fall through to the os-specific code below */
break;
@@ -1249,23 +1254,17 @@ raidioctl(dev, cmd, data, flag, p)
*/
switch (cmd) {
case DIOCGDINFO:
- db1_printf(
- ("DIOCGDINFO %d %d\n", (int)dev, (int)DISKPART(dev)));
*(struct disklabel *)data = *(rs->sc_dkdev.dk_label);
break;
case DIOCGPART:
- db1_printf(
- ("DIOCGPART: %d %d\n", (int)dev, (int)DISKPART(dev)));
((struct partinfo *)data)->disklab = rs->sc_dkdev.dk_label;
((struct partinfo *)data)->part =
&rs->sc_dkdev.dk_label->d_partitions[DISKPART(dev)];
break;
case DIOCWDINFO:
- db1_printf(("DIOCWDINFO\n"));
case DIOCSDINFO:
- db1_printf(("DIOCSDINFO\n"));
if ((error = raidlock(rs)) != 0)
return (error);
@@ -1289,15 +1288,22 @@ raidioctl(dev, cmd, data, flag, p)
break;
case DIOCWLABEL:
- db1_printf(("DIOCWLABEL\n"));
if (*(int *)data != 0)
rs->sc_flags |= RAIDF_WLABEL;
else
rs->sc_flags &= ~RAIDF_WLABEL;
break;
+#if 0
+ case DIOCGDEFLABEL:
+ raidgetdefaultlabel(raidPtrs[unit], rs,
+ (struct disklabel *) data);
+ break;
+#endif
+
+
default:
- retcode = ENOTTY; /* XXXX ?? OR EINVAL ? */
+ retcode = ENOTTY;
}
return (retcode);
}
@@ -1313,8 +1319,6 @@ raidinit(dev, raidPtr, unit)
int unit;
{
int retcode;
- /* int ix; */
- /* struct raidbuf *raidbp; */
struct raid_softc *rs;
retcode = 0;
@@ -1346,53 +1350,14 @@ raidinit(dev, raidPtr, unit)
}
/*
- * This kernel thread never exits. It is created once, and persists
- * until the system reboots.
- */
-void
-rf_ReconKernelThread()
-{
- struct rf_recon_req *req;
- int s;
-
- /*
- * XXX not sure what spl() level we should be at here...
- * probably splbio()
- */
- s = splbio();
-
- while (1) {
- /* grab the next reconstruction request from the queue */
- LOCK_RECON_Q_MUTEX();
- while (!recon_queue) {
- UNLOCK_RECON_Q_MUTEX();
- tsleep(&recon_queue, PRIBIO,
- "raidframe recon", 0);
- LOCK_RECON_Q_MUTEX();
- }
- req = recon_queue;
- recon_queue = recon_queue->next;
- UNLOCK_RECON_Q_MUTEX();
-
- /*
- * If flags specifies that we should start recon, this call
- * will not return until reconstruction completes, fails, or
- * is aborted.
- */
- rf_FailDisk((RF_Raid_t *)req->raidPtr, req->row, req->col,
- ((req->flags&RF_FDFLAGS_RECON) ? 1 : 0));
-
- RF_Free(req, sizeof *req);
- }
-}
-
-/*
* Wake up the daemon & tell it to get us a spare table
* XXX
* The entries in the queues should be tagged with the raidPtr so that in the
* extremely rare case that two recons happen at once, we know for
* which device were requesting a spare table.
* XXX
+ *
+ * XXX This code is not currently used. GO
*/
int
rf_GetSpareTableFromDaemon(req)
@@ -1409,11 +1374,6 @@ rf_GetSpareTableFromDaemon(req)
while (!rf_sparet_resp_queue) {
tsleep(&rf_sparet_resp_queue, PRIBIO,
"raidframe getsparetable", 0);
-#if 0
- mpsleep(&rf_sparet_resp_queue, PZERO, "sparet resp", 0,
- (void *)simple_lock_addr(rf_sparet_wait_mutex),
- MS_LOCK_SIMPLE);
-#endif
}
req = rf_sparet_resp_queue;
rf_sparet_resp_queue = req->next;
@@ -1431,14 +1391,12 @@ rf_GetSpareTableFromDaemon(req)
* Any calls originating in the kernel must use non-blocking I/O
* do some extra sanity checking to return "appropriate" error values for
* certain conditions (to make some standard utilities work)
+ *
+ * Formerly known as: rf_DoAccessKernel
*/
-int
-rf_DoAccessKernel(raidPtr, bp, flags, cbFunc, cbArg)
+void
+raidstart(raidPtr)
RF_Raid_t *raidPtr;
- struct buf *bp;
- RF_RaidAccessFlags_t flags;
- void (*cbFunc)(struct buf *);
- void *cbArg;
{
RF_SectorCount_t num_blocks, pb, sum;
RF_RaidAddr_t raid_addr;
@@ -1448,95 +1406,114 @@ rf_DoAccessKernel(raidPtr, bp, flags, cbFunc, cbArg)
int unit;
struct raid_softc *rs;
int do_async;
-
- /* XXX The dev_t used here should be for /dev/[r]raid* !!! */
+ struct buf *bp;
+ struct buf *dp;
unit = raidPtr->raidid;
rs = &raid_softc[unit];
- /*
- * Ok, for the bp we have here, bp->b_blkno is relative to the
- * partition.. Need to make it absolute to the underlying device..
- */
- blocknum = bp->b_blkno;
- if (DISKPART(bp->b_dev) != RAW_PART) {
- pp = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)];
- blocknum += pp->p_offset;
- db1_printf(
- ("updated: %d %d\n", DISKPART(bp->b_dev), pp->p_offset));
- } else {
- db1_printf(("Is raw..\n"));
- }
- db1_printf(("Blocks: %d, %d\n", (int)bp->b_blkno, (int)blocknum));
- db1_printf(("bp->b_bcount = %d\n", (int)bp->b_bcount));
- db1_printf(("bp->b_resid = %d\n", (int)bp->b_resid));
-
- /*
- * *THIS* is where we adjust what block we're going to... but
- * DO NOT TOUCH bp->b_blkno!!!
- */
- raid_addr = blocknum;
-
- num_blocks = bp->b_bcount >> raidPtr->logBytesPerSector;
- pb = (bp->b_bcount&raidPtr->sectorMask) ? 1 : 0;
- sum = raid_addr + num_blocks + pb;
- if (1 || rf_debugKernelAccess) {
- db1_printf(("raid_addr=%d sum=%d num_blocks=%d(+%d) (%d)\n",
- (int)raid_addr, (int)sum, (int)num_blocks, (int)pb,
- (int)bp->b_resid));
- }
+ /* Check to see if we're at the limit... */
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ while (raidPtr->openings > 0) {
+ RF_UNLOCK_MUTEX(raidPtr->mutex);
+
+ /* get the next item, if any, from the queue */
+ dp = &rs->buf_queue;
+ bp = dp->b_actf;
+ if (bp == NULL) {
+ /* nothing more to do */
+ return;
+ }
+
+ /* update structures */
+ dp = bp->b_actf;
+ if (dp != NULL) {
+ dp->b_actb = bp->b_actb;
+ } else {
+ rs->buf_queue.b_actb = bp->b_actb;
+ }
+ *bp->b_actb = dp;
+
+ /* Ok, for the bp we have here, bp->b_blkno is relative to the
+ * partition.. Need to make it absolute to the underlying
+ * device.. */
+
+ blocknum = bp->b_blkno;
+ if (DISKPART(bp->b_dev) != RAW_PART) {
+ pp = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)];
+ blocknum += pp->p_offset;
+ }
+
+ db1_printf(("Blocks: %d, %d\n", (int) bp->b_blkno,
+ (int) blocknum));
+
+ db1_printf(("bp->b_bcount = %d\n", (int) bp->b_bcount));
+ db1_printf(("bp->b_resid = %d\n", (int) bp->b_resid));
+
+ /* *THIS* is where we adjust what block we're going to...
+ * but DO NOT TOUCH bp->b_blkno!!! */
+ raid_addr = blocknum;
+
+ num_blocks = bp->b_bcount >> raidPtr->logBytesPerSector;
+ pb = (bp->b_bcount & raidPtr->sectorMask) ? 1 : 0;
+ sum = raid_addr + num_blocks + pb;
+ if (1 || rf_debugKernelAccess) {
+ db1_printf(("raid_addr=%d sum=%d num_blocks=%d(+%d) (%d)\n",
+ (int) raid_addr, (int) sum, (int) num_blocks,
+ (int) pb, (int) bp->b_resid));
+ }
+ if ((sum > raidPtr->totalSectors) || (sum < raid_addr)
+ || (sum < num_blocks) || (sum < pb)) {
+ bp->b_error = ENOSPC;
+ bp->b_flags |= B_ERROR;
+ bp->b_resid = bp->b_bcount;
+ biodone(bp);
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ continue;
+ }
+ /*
+ * XXX rf_DoAccess() should do this, not just DoAccessKernel()
+ */
+
+ if (bp->b_bcount & raidPtr->sectorMask) {
+ bp->b_error = EINVAL;
+ bp->b_flags |= B_ERROR;
+ bp->b_resid = bp->b_bcount;
+ biodone(bp);
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ continue;
+
+ }
+ db1_printf(("Calling DoAccess..\n"));
+
+
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ raidPtr->openings--;
+ RF_UNLOCK_MUTEX(raidPtr->mutex);
- if ((sum > raidPtr->totalSectors) || (sum < raid_addr) ||
- (sum < num_blocks) || (sum < pb)) {
- bp->b_error = ENOSPC;
- bp->b_flags |= B_ERROR;
- bp->b_resid = bp->b_bcount;
- biodone(bp);
- return (bp->b_error);
- }
-
- /*
- * XXX rf_DoAccess() should do this, not just DoAccessKernel()
- */
- if (bp->b_bcount & raidPtr->sectorMask) {
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- bp->b_resid = bp->b_bcount;
- biodone(bp);
- return (bp->b_error);
- }
- db1_printf(("Calling DoAccess..\n"));
+ /*
+ * Everything is async.
+ */
+ do_async = 1;
+
+ /* don't ever condition on bp->b_flags & B_WRITE.
+ * always condition on B_READ instead */
+
+ /* XXX we're still at splbio() here... do we *really*
+ need to be? */
- /* Put a throttle on the number of requests we handle simultanously */
+
+ retcode = rf_DoAccess(raidPtr, (bp->b_flags & B_READ) ?
+ RF_IO_TYPE_READ : RF_IO_TYPE_WRITE,
+ do_async, raid_addr, num_blocks,
+ bp->b_un.b_addr, bp, NULL, NULL,
+ RF_DAG_NONBLOCKING_IO, NULL, NULL, NULL);
- RF_LOCK_MUTEX(raidPtr->mutex);
- while(raidPtr->openings <= 0) {
- RF_UNLOCK_MUTEX(raidPtr->mutex);
- (void)tsleep(&raidPtr->openings, PRIBIO, "rfdwait", 0);
RF_LOCK_MUTEX(raidPtr->mutex);
}
- raidPtr->openings--;
-
RF_UNLOCK_MUTEX(raidPtr->mutex);
-
- /*
- * Everything is async.
- */
- do_async = 1;
-
- /*
- * Don't ever condition on bp->b_flags & B_WRITE.
- * always condition on B_READ instead.
- */
- retcode = rf_DoAccess(raidPtr,
- (bp->b_flags & B_READ) ? RF_IO_TYPE_READ : RF_IO_TYPE_WRITE,
- 0, raid_addr, num_blocks, bp->b_un.b_addr, bp, NULL, NULL,
- RF_DAG_NONBLOCKING_IO|flags, NULL, cbFunc, cbArg);
- db1_printf(("After call to DoAccess: 0x%x 0x%x %d\n", bp, bp->b_data,
- (int)bp->b_resid));
- return (retcode);
}
/* Invoke an I/O from kernel mode. Disk queue should be locked upon entry */
@@ -1551,6 +1528,10 @@ rf_DispatchKernelIO(queue, req)
struct raidbuf *raidbp = NULL;
struct raid_softc *rs;
int unit;
+ int s;
+
+ s=0;
+ /* s = splbio();*/ /* want to test this */
/*
* XXX along with the vnode, we also need the softc associated with
@@ -1600,6 +1581,8 @@ rf_DispatchKernelIO(queue, req)
raidbp->rf_obp = bp;
raidbp->req = req;
+ LIST_INIT(&raidbp->rf_buf.b_dep);
+
switch (req->type) {
case RF_IO_TYPE_NOP:
/* Used primarily to unlock a locked queue. */
@@ -1663,6 +1646,7 @@ rf_DispatchKernelIO(queue, req)
panic("bad req->type in rf_DispatchKernelIO");
}
db1_printf(("Exiting from DispatchKernelIO\n"));
+ /* splx(s); */ /* want to test this */
return (0);
}
@@ -1682,31 +1666,20 @@ rf_KernelWakeupFunc(vbp)
int unit;
int s;
- s = splbio(); /* XXX */
+ s = splbio();
db1_printf(("recovering the request queue:\n"));
req = raidbp->req;
bp = raidbp->rf_obp;
- db1_printf(("bp=0x%x\n", bp));
queue = (RF_DiskQueue_t *)req->queue;
if (raidbp->rf_buf.b_flags & B_ERROR) {
- db1_printf(
- ("Setting bp->b_flags!!! %d\n", raidbp->rf_buf.b_error));
bp->b_flags |= B_ERROR;
bp->b_error =
raidbp->rf_buf.b_error ? raidbp->rf_buf.b_error : EIO;
}
- db1_printf(("raidbp->rf_buf.b_bcount=%d\n",
- (int)raidbp->rf_buf.b_bcount));
- db1_printf(("raidbp->rf_buf.b_bufsize=%d\n",
- (int)raidbp->rf_buf.b_bufsize));
- db1_printf(("raidbp->rf_buf.b_resid=%d\n",
- (int)raidbp->rf_buf.b_resid));
- db1_printf(("raidbp->rf_buf.b_data=0x%x\n", raidbp->rf_buf.b_data));
-
#if 1
/* XXX Methinks this could be wrong... */
bp->b_resid = raidbp->rf_buf.b_resid;
@@ -1728,7 +1701,6 @@ rf_KernelWakeupFunc(vbp)
unit = queue->raidPtr->raidid; /* *Much* simpler :-> */
-#if 1
/*
* XXX Ok, let's get aggressive... If B_ERROR is set, let's go
* ballistic, and mark the component as hosed...
@@ -1751,26 +1723,19 @@ rf_KernelWakeupFunc(vbp)
/* printf("Disk already marked as dead!\n"); */
}
}
-#endif
rs = &raid_softc[unit];
RAIDPUTBUF(raidbp);
if (bp->b_resid==0) {
- db1_printf((
- "Disk is no longer busy for this buffer... %d %ld %ld\n",
- unit, bp->b_resid, bp->b_bcount));
/* XXX is this the right place for a disk_unbusy()??!??!?!? */
disk_unbusy(&rs->sc_dkdev, (bp->b_bcount - bp->b_resid));
- } else {
- db1_printf(("b_resid is still %ld\n", bp->b_resid));
}
rf_DiskIOComplete(queue, req, (bp->b_flags & B_ERROR) ? 1 : 0);
(req->CompleteFunc)(req->argument, (bp->b_flags & B_ERROR) ? 1 : 0);
- /* printf("Exiting rf_KernelWakeupFunc\n"); */
- splx(s); /* XXX */
+ splx(s);
}
/*
@@ -1797,13 +1762,9 @@ rf_InitBP(bp, b_vp, rw_flag, dev, startSect, numSect, buf, cbFunc, cbArg,
bp->b_bufsize = bp->b_bcount;
bp->b_error = 0;
bp->b_dev = dev;
- db1_printf(("bp->b_dev is %d\n", dev));
bp->b_un.b_addr = buf;
- db1_printf(("bp->b_data=0x%x\n", bp->b_data));
-
bp->b_blkno = startSect;
bp->b_resid = bp->b_bcount; /* XXX is this right!??!?!! */
- db1_printf(("b_bcount is: %d\n", (int)bp->b_bcount));
if (bp->b_bcount == 0) {
panic("bp->b_bcount is zero in rf_InitBP!!\n");
}
@@ -1813,29 +1774,6 @@ rf_InitBP(bp, b_vp, rw_flag, dev, startSect, numSect, buf, cbFunc, cbArg,
LIST_INIT(&bp->b_dep);
}
-/* Extras... */
-
-#if 0
-unsigned int
-rpcc()
-{
- /* XXX no clue what this is supposed to do.. my guess is
- that it's supposed to read the CPU cycle counter... */
- /* db1_printf("this is supposed to do something useful too!??\n"); */
- return (0);
-}
-
-int
-rf_GetSpareTableFromDaemon(req)
- RF_SparetWait_t *req;
-{
- int retcode=1;
- printf("This is supposed to do something useful!!\n"); /* XXX */
-
- return (retcode);
-}
-#endif
-
void
raidgetdefaultlabel(raidPtr, rs, lp)
RF_Raid_t *raidPtr;
@@ -1970,7 +1908,9 @@ raidlookup(path, p, vpp)
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p);
if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) {
- db1_printf(("RAIDframe: vn_open returned %d\n", error));
+#ifdef DEBUG
+ printf("RAIDframe: vn_open returned %d\n", error);
+#endif
return (error);
}
vp = nd.ni_vp;
@@ -2355,3 +2295,90 @@ rf_update_component_labels( raidPtr )
}
/* printf("Component labels updated\n"); */
}
+
+void
+rf_ReconThread(req)
+ struct rf_recon_req *req;
+{
+ int s;
+ RF_Raid_t *raidPtr;
+
+ s = splbio();
+ raidPtr = (RF_Raid_t *) req->raidPtr;
+ raidPtr->recon_in_progress = 1;
+
+ rf_FailDisk((RF_Raid_t *) req->raidPtr, req->row, req->col,
+ ((req->flags & RF_FDFLAGS_RECON) ? 1 : 0));
+
+ /* XXX get rid of this! we don't need it at all.. */
+ RF_Free(req, sizeof(*req));
+
+ raidPtr->recon_in_progress = 0;
+ splx(s);
+
+ /* That's all... */
+ kthread_exit(0); /* does not return */
+}
+
+void
+rf_RewriteParityThread(raidPtr)
+ RF_Raid_t *raidPtr;
+{
+ int retcode;
+ int s;
+
+ raidPtr->parity_rewrite_in_progress = 1;
+ s = splbio();
+ retcode = rf_RewriteParity(raidPtr);
+ splx(s);
+ if (retcode) {
+ printf("raid%d: Error re-writing parity!\n",raidPtr->raidid);
+ } else {
+ /* set the clean bit! If we shutdown correctly,
+ the clean bit on each component label will get
+ set */
+ raidPtr->parity_good = RF_RAID_CLEAN;
+ }
+ raidPtr->parity_rewrite_in_progress = 0;
+
+ /* That's all... */
+ kthread_exit(0); /* does not return */
+}
+
+
+void
+rf_CopybackThread(raidPtr)
+ RF_Raid_t *raidPtr;
+{
+ int s;
+
+ raidPtr->copyback_in_progress = 1;
+ s = splbio();
+ rf_CopybackReconstructedData(raidPtr);
+ splx(s);
+ raidPtr->copyback_in_progress = 0;
+
+ /* That's all... */
+ kthread_exit(0); /* does not return */
+}
+
+
+void
+rf_ReconstructInPlaceThread(req)
+ struct rf_recon_req *req;
+{
+ int retcode;
+ int s;
+ RF_Raid_t *raidPtr;
+
+ s = splbio();
+ raidPtr = req->raidPtr;
+ raidPtr->recon_in_progress = 1;
+ retcode = rf_ReconstructInPlace(raidPtr, req->row, req->col);
+ RF_Free(req, sizeof(*req));
+ raidPtr->recon_in_progress = 0;
+ splx(s);
+
+ /* That's all... */
+ kthread_exit(0); /* does not return */
+}
diff --git a/sys/dev/raidframe/rf_optnames.h b/sys/dev/raidframe/rf_optnames.h
index 82ee3434d96..3575f1cd792 100644
--- a/sys/dev/raidframe/rf_optnames.h
+++ b/sys/dev/raidframe/rf_optnames.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_optnames.h,v 1.3 1999/08/04 13:10:55 peter Exp $ */
-/* $NetBSD: rf_optnames.h,v 1.4 1999/02/05 00:06:13 oster Exp $ */
+/* $OpenBSD: rf_optnames.h,v 1.4 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_optnames.h,v 1.6 1999/12/07 02:54:08 oster Exp $ */
/*
* rf_optnames.h
*/
@@ -34,21 +34,14 @@
* Don't protect against multiple inclusion here- we actually want this.
*/
-RF_DBG_OPTION(accSizeKB, 0) /* if nonzero, the fixed access size to run */
RF_DBG_OPTION(accessDebug, 0)
RF_DBG_OPTION(accessTraceBufSize, 0)
-RF_DBG_OPTION(alignAccesses, 0) /* whether accs should be aligned to
- * their size */
-RF_DBG_OPTION(camlayerIOs, 0)
-RF_DBG_OPTION(camlayerDebug, 0) /* debug CAM activity */
RF_DBG_OPTION(cscanDebug, 0) /* debug CSCAN sorting */
RF_DBG_OPTION(dagDebug, 0)
RF_DBG_OPTION(debugPrintUseBuffer, 0)
RF_DBG_OPTION(degDagDebug, 0)
RF_DBG_OPTION(disableAsyncAccs, 0)
RF_DBG_OPTION(diskDebug, 0)
-RF_DBG_OPTION(doDebug, 0)
-RF_DBG_OPTION(dtDebug, 0)
RF_DBG_OPTION(enableAtomicRMW, 0) /* this debug var enables locking of
* the disk arm during small-write
* operations. Setting this variable
@@ -65,11 +58,7 @@ RF_DBG_OPTION(keepAccTotals, 0) /* turn on keep_acc_totals */
RF_DBG_OPTION(lockTableSize, RF_DEFAULT_LOCK_TABLE_SIZE)
RF_DBG_OPTION(mapDebug, 0)
RF_DBG_OPTION(maxNumTraces, -1)
-RF_DBG_OPTION(maxRandomSizeKB, 128) /* if rf_accSizeKB==0, acc sizes are
- * uniform in [ (1/2)..maxRandomSizeKB
- * ] */
-RF_DBG_OPTION(maxTraceRunTimeSec, 0)
-RF_DBG_OPTION(memAmtDebug, 0) /* trace amount of memory allocated */
+
RF_DBG_OPTION(memChunkDebug, 0)
RF_DBG_OPTION(memDebug, 0)
RF_DBG_OPTION(memDebugAddress, 0)
@@ -88,8 +77,6 @@ RF_DBG_OPTION(raidSectorOffset, 0) /* added to all incoming sectors to
* debug alignment problems */
RF_DBG_OPTION(reconDebug, 0)
RF_DBG_OPTION(reconbufferDebug, 0)
-RF_DBG_OPTION(rewriteParityStripes, 0) /* debug flag that causes
- * parity rewrite at startup */
RF_DBG_OPTION(scanDebug, 0) /* debug SCAN sorting */
RF_DBG_OPTION(showXorCallCounts, 0) /* show n-way Xor call counts */
RF_DBG_OPTION(shutdownDebug, 0) /* show shutdown calls */
@@ -98,22 +85,12 @@ RF_DBG_OPTION(sstfDebug, 0) /* turn on debugging info for sstf queueing */
RF_DBG_OPTION(stripeLockDebug, 0)
RF_DBG_OPTION(suppressLocksAndLargeWrites, 0)
RF_DBG_OPTION(suppressTraceDelays, 0)
-RF_DBG_OPTION(testDebug, 0)
RF_DBG_OPTION(useMemChunks, 1)
RF_DBG_OPTION(validateDAGDebug, 0)
RF_DBG_OPTION(validateVisitedDebug, 1) /* XXX turn to zero by
* default? */
RF_DBG_OPTION(verifyParityDebug, 0)
-RF_DBG_OPTION(warnLongIOs, 0)
RF_DBG_OPTION(debugKernelAccess, 0) /* DoAccessKernel debugging */
-#ifndef _KERNEL
-RF_DBG_OPTION(disableParityVerify, 0) /* supress verification of
- * parity */
-RF_DBG_OPTION(interactiveScript, 0) /* set as a debug option for now */
-RF_DBG_OPTION(looptestShowWrites, 0) /* user-level loop test write
- * debugging */
-RF_DBG_OPTION(traceDebug, 0)
-#endif /* !_KERNEL */
#if RF_INCLUDE_PARITYLOGGING > 0
RF_DBG_OPTION(forceParityLogReint, 0)
@@ -126,6 +103,3 @@ RF_DBG_OPTION(totalInCoreLogCapacity, 1024 * 1024) /* target bytes
* logs */
#endif /* RF_INCLUDE_PARITYLOGGING > 0 */
-#if DFSTRACE > 0
-RF_DBG_OPTION(DFSTraceAccesses, 0)
-#endif /* DFSTRACE > 0 */
diff --git a/sys/dev/raidframe/rf_paritylog.c b/sys/dev/raidframe/rf_paritylog.c
index ea5fa86d94a..ce2b3827d56 100644
--- a/sys/dev/raidframe/rf_paritylog.c
+++ b/sys/dev/raidframe/rf_paritylog.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_paritylog.c,v 1.2 1999/02/16 00:03:04 niklas Exp $ */
-/* $NetBSD: rf_paritylog.c,v 1.3 1999/02/05 00:06:13 oster Exp $ */
+/* $OpenBSD: rf_paritylog.c,v 1.3 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_paritylog.c,v 1.4 1999/08/13 03:41:57 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -55,7 +55,6 @@
#include "rf_map.h"
#include "rf_paritylogging.h"
#include "rf_paritylogDiskMgr.h"
-#include "rf_sys.h"
static RF_CommonLogData_t *
AllocParityLogCommonData(RF_Raid_t * raidPtr)
diff --git a/sys/dev/raidframe/rf_paritylogDiskMgr.c b/sys/dev/raidframe/rf_paritylogDiskMgr.c
index 624b1b3609f..6a9bab06551 100644
--- a/sys/dev/raidframe/rf_paritylogDiskMgr.c
+++ b/sys/dev/raidframe/rf_paritylogDiskMgr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_paritylogDiskMgr.c,v 1.2 1999/02/16 00:03:05 niklas Exp $ */
-/* $NetBSD: rf_paritylogDiskMgr.c,v 1.3 1999/02/05 00:06:14 oster Exp $ */
+/* $OpenBSD: rf_paritylogDiskMgr.c,v 1.3 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_paritylogDiskMgr.c,v 1.4 1999/08/13 03:41:57 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -52,7 +52,6 @@
#include "rf_dagutils.h"
#include "rf_map.h"
#include "rf_parityscan.h"
-#include "rf_sys.h"
#include "rf_paritylogDiskMgr.h"
diff --git a/sys/dev/raidframe/rf_paritylogging.c b/sys/dev/raidframe/rf_paritylogging.c
index 4cd95744629..1c9b988d1c7 100644
--- a/sys/dev/raidframe/rf_paritylogging.c
+++ b/sys/dev/raidframe/rf_paritylogging.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_paritylogging.c,v 1.2 1999/02/16 00:03:06 niklas Exp $ */
-/* $NetBSD: rf_paritylogging.c,v 1.3 1999/02/05 00:06:14 oster Exp $ */
+/* $OpenBSD: rf_paritylogging.c,v 1.3 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_paritylogging.c,v 1.4 2000/01/05 02:57:29 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -433,7 +433,7 @@ rf_ConfigureParityLogging(
}
RF_ASSERT(raidPtr->parityLogDiskQueue.threadState == 0);
raidPtr->parityLogDiskQueue.threadState = RF_PLOG_CREATED;
- rc = RF_CREATE_THREAD(raidPtr->pLogDiskThreadHandle, rf_ParityLoggingDiskManager, raidPtr);
+ rc = RF_CREATE_THREAD(raidPtr->pLogDiskThreadHandle, rf_ParityLoggingDiskManager, raidPtr,"rf_log");
if (rc) {
raidPtr->parityLogDiskQueue.threadState = 0;
RF_ERRORMSG3("Unable to create parity logging disk thread file %s line %d rc=%d\n",
diff --git a/sys/dev/raidframe/rf_parityscan.c b/sys/dev/raidframe/rf_parityscan.c
index 60a5bc3b3dc..c139ef39504 100644
--- a/sys/dev/raidframe/rf_parityscan.c
+++ b/sys/dev/raidframe/rf_parityscan.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_parityscan.c,v 1.4 1999/07/30 14:45:33 peter Exp $ */
-/* $NetBSD: rf_parityscan.c,v 1.4 1999/03/14 22:10:46 oster Exp $ */
+/* $OpenBSD: rf_parityscan.c,v 1.5 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_parityscan.c,v 1.8 2000/01/05 02:57:28 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -43,7 +43,6 @@
#include "rf_engine.h"
#include "rf_parityscan.h"
#include "rf_map.h"
-#include "rf_sys.h"
/*****************************************************************************************
*
@@ -64,18 +63,38 @@ rf_RewriteParity(raidPtr)
{
RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
RF_AccessStripeMapHeader_t *asm_h;
+ int ret_val;
int rc;
RF_PhysDiskAddr_t pda;
RF_SectorNum_t i;
+ if (raidPtr->Layout.map->faultsTolerated == 0) {
+ /* There isn't any parity. Call it "okay." */
+ return (RF_PARITY_OKAY);
+ }
+ if (raidPtr->status[0] != rf_rs_optimal) {
+ /*
+ * We're in degraded mode. Don't try to verify parity now!
+ * XXX: this should be a "we don't want to", not a
+ * "we can't" error.
+ */
+ return (RF_PARITY_COULD_NOT_VERIFY);
+ }
+
+ ret_val = 0;
+
pda.startSector = 0;
pda.numSector = raidPtr->Layout.sectorsPerStripeUnit;
+ rc = RF_PARITY_OKAY;
- for (i = 0; i < raidPtr->totalSectors;
+ for (i = 0; i < raidPtr->totalSectors &&
+ rc <= RF_PARITY_CORRECTED;
i += layoutPtr->dataSectorsPerStripe) {
asm_h = rf_MapAccess(raidPtr, i,
layoutPtr->dataSectorsPerStripe,
NULL, RF_DONT_REMAP);
+ raidPtr->parity_rewrite_stripes_done =
+ i / layoutPtr->dataSectorsPerStripe ;
rc = rf_VerifyParity(raidPtr, asm_h->stripeMap, 1, 0);
switch (rc) {
case RF_PARITY_OKAY:
@@ -83,23 +102,23 @@ rf_RewriteParity(raidPtr)
break;
case RF_PARITY_BAD:
printf("Parity bad during correction\n");
- RF_PANIC();
+ ret_val = 1;
break;
case RF_PARITY_COULD_NOT_CORRECT:
printf("Could not correct bad parity\n");
- RF_PANIC();
+ ret_val = 1;
break;
case RF_PARITY_COULD_NOT_VERIFY:
printf("Could not verify parity\n");
- RF_PANIC();
+ ret_val = 1;
break;
default:
printf("Bad rc=%d from VerifyParity in RewriteParity\n", rc);
- RF_PANIC();
+ ret_val = 1;
}
rf_FreeAccessStripeMap(asm_h);
}
- return (0);
+ return (ret_val);
}
/*****************************************************************************************
*
diff --git a/sys/dev/raidframe/rf_pq.c b/sys/dev/raidframe/rf_pq.c
index 0ec2a6e96ce..cdc21edfff6 100644
--- a/sys/dev/raidframe/rf_pq.c
+++ b/sys/dev/raidframe/rf_pq.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_pq.c,v 1.3 1999/08/04 13:10:55 peter Exp $ */
-/* $NetBSD: rf_pq.c,v 1.3 1999/02/05 00:06:14 oster Exp $ */
+/* $OpenBSD: rf_pq.c,v 1.4 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_pq.c,v 1.6 1999/08/15 03:44:46 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -47,7 +47,6 @@
#include "rf_general.h"
#include "rf_map.h"
#include "rf_pq.h"
-#include "rf_sys.h"
RF_RedFuncs_t rf_pFuncs = {rf_RegularONPFunc, "Regular Old-New P", rf_SimpleONPFunc, "Simple Old-New P"};
RF_RedFuncs_t rf_pRecoveryFuncs = {rf_RecoveryPFunc, "Recovery P Func", rf_RecoveryPFunc, "Recovery P Func"};
@@ -118,7 +117,7 @@ rf_PQDagSelect(
switch (ndfail) {
case 0:
/* fault free read */
- *createFunc = rf_CreateFaultFreeReadDAG; /* same as raid 5 */
+ *createFunc = (RF_VoidFuncPtr) rf_CreateFaultFreeReadDAG; /* same as raid 5 */
break;
case 1:
/* lost a single data unit */
@@ -127,22 +126,22 @@ rf_PQDagSelect(
* reconstruct read using "q". */
if (ntfail == 2) { /* also lost redundancy */
if (asmap->failedPDAs[1]->type == RF_PDA_TYPE_PARITY)
- *createFunc = rf_PQ_110_CreateReadDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_110_CreateReadDAG;
else
- *createFunc = rf_PQ_101_CreateReadDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_101_CreateReadDAG;
} else {
/* P and Q are ok. But is there a failure in
* some unaccessed data unit? */
if (rf_NumFailedDataUnitsInStripe(raidPtr, asmap) == 2)
- *createFunc = rf_PQ_200_CreateReadDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_200_CreateReadDAG;
else
- *createFunc = rf_PQ_100_CreateReadDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_100_CreateReadDAG;
}
break;
case 2:
/* lost two data units */
/* *infoFunc = PQOneTwo; */
- *createFunc = rf_PQ_200_CreateReadDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_200_CreateReadDAG;
break;
}
return;
@@ -154,9 +153,9 @@ rf_PQDagSelect(
(((asmap->numStripeUnitsAccessed <= (layoutPtr->numDataCol / 2)) && (layoutPtr->numDataCol != 1)) ||
(asmap->parityInfo->next != NULL) || (asmap->qInfo->next != NULL) || rf_CheckStripeForFailures(raidPtr, asmap))) {
- *createFunc = rf_PQCreateSmallWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQCreateSmallWriteDAG;
} else {
- *createFunc = rf_PQCreateLargeWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQCreateLargeWriteDAG;
}
break;
@@ -168,41 +167,41 @@ rf_PQDagSelect(
* write. */
if (((asmap->numStripeUnitsAccessed <= (layoutPtr->numDataCol / 2)) || (asmap->numStripeUnitsAccessed == 1))
|| rf_NumFailedDataUnitsInStripe(raidPtr, asmap))
- *createFunc = rf_PQ_001_CreateSmallWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_001_CreateSmallWriteDAG;
else
- *createFunc = rf_PQ_001_CreateLargeWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_001_CreateLargeWriteDAG;
} else {/* parity died, small write only updating Q */
if (((asmap->numStripeUnitsAccessed <= (layoutPtr->numDataCol / 2)) || (asmap->numStripeUnitsAccessed == 1))
|| rf_NumFailedDataUnitsInStripe(raidPtr, asmap))
- *createFunc = rf_PQ_010_CreateSmallWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_010_CreateSmallWriteDAG;
else
- *createFunc = rf_PQ_010_CreateLargeWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_010_CreateLargeWriteDAG;
}
} else { /* data missing. Do a P reconstruct write if
* only a single data unit is lost in the
* stripe, otherwise a PQ reconstruct write. */
if (rf_NumFailedDataUnitsInStripe(raidPtr, asmap) == 2)
- *createFunc = rf_PQ_200_CreateWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_200_CreateWriteDAG;
else
- *createFunc = rf_PQ_100_CreateWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_100_CreateWriteDAG;
}
break;
case 2: /* two disk faults */
switch (npfail) {
case 2: /* both p and q dead */
- *createFunc = rf_PQ_011_CreateWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_011_CreateWriteDAG;
break;
case 1: /* either p or q and dead data */
RF_ASSERT(asmap->failedPDAs[0]->type == RF_PDA_TYPE_DATA);
RF_ASSERT((asmap->failedPDAs[1]->type == RF_PDA_TYPE_PARITY) || (asmap->failedPDAs[1]->type == RF_PDA_TYPE_Q));
if (asmap->failedPDAs[1]->type == RF_PDA_TYPE_Q)
- *createFunc = rf_PQ_101_CreateWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_101_CreateWriteDAG;
else
- *createFunc = rf_PQ_110_CreateWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_110_CreateWriteDAG;
break;
case 0: /* double data loss */
- *createFunc = rf_PQ_200_CreateWriteDAG;
+ *createFunc = (RF_VoidFuncPtr) rf_PQ_200_CreateWriteDAG;
break;
}
break;
@@ -216,6 +215,7 @@ rf_PQDagSelect(
/*
Used as a stop gap info function
*/
+#if 0
static void
PQOne(raidPtr, nSucc, nAnte, asmap)
RF_Raid_t *raidPtr;
@@ -236,6 +236,8 @@ PQOneTwo(raidPtr, nSucc, nAnte, asmap)
*nSucc = 1;
*nAnte = 2;
}
+#endif
+
RF_CREATE_DAG_FUNC_DECL(rf_PQCreateLargeWriteDAG)
{
rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2,
@@ -355,6 +357,8 @@ RF_CREATE_DAG_FUNC_DECL(rf_PQCreateSmallWriteDAG)
rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, &rf_qFuncs);
}
+static void RegularQSubr(RF_DagNode_t *node, char *qbuf);
+
static void
RegularQSubr(node, qbuf)
RF_DagNode_t *node;
@@ -397,6 +401,8 @@ RegularQSubr(node, qbuf)
used in degraded writes.
*/
+static void DegrQSubr(RF_DagNode_t *node);
+
static void
DegrQSubr(node)
RF_DagNode_t *node;
@@ -583,7 +589,8 @@ int
rf_RecoveryPQFunc(node)
RF_DagNode_t *node;
{
- RF_PANIC();
+ RF_Raid_t *raidPtr = (RF_Raid_t *) node->params[node->numParams - 1].p;
+ printf("raid%d: Recovery from PQ not implemented.\n",raidPtr->raidid);
return (1);
}
/*
@@ -739,7 +746,10 @@ QDelta(
unsigned long a, d, new;
unsigned long a1, a2;
unsigned int *q = &(rf_qfor[28 - coeff][0]);
- unsigned r = rf_rn[coeff + 1];
+ unsigned int r = rf_rn[coeff + 1];
+
+ r = a1 = a2 = new = d = a = 0; /* XXX for now... */
+ q = NULL; /* XXX for now */
#ifdef _KERNEL
/* PQ in kernel currently not supported because the encoding/decoding
diff --git a/sys/dev/raidframe/rf_pqdeg.c b/sys/dev/raidframe/rf_pqdeg.c
index 82c3e5de08d..f597777a6c8 100644
--- a/sys/dev/raidframe/rf_pqdeg.c
+++ b/sys/dev/raidframe/rf_pqdeg.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_pqdeg.c,v 1.2 1999/02/16 00:03:10 niklas Exp $ */
-/* $NetBSD: rf_pqdeg.c,v 1.3 1999/02/05 00:06:15 oster Exp $ */
+/* $OpenBSD: rf_pqdeg.c,v 1.3 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_pqdeg.c,v 1.4 1999/08/15 02:36:40 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -104,23 +104,29 @@ RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateReadDAG)
both P and Q to reconstruct the data. Note that only
one data unit we are reading may actually be missing.
*/
+RF_CREATE_DAG_FUNC_DECL(rf_CreateDoubleDegradedReadDAG);
RF_CREATE_DAG_FUNC_DECL(rf_CreateDoubleDegradedReadDAG)
{
rf_PQ_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList);
}
+RF_CREATE_DAG_FUNC_DECL(rf_PQ_200_CreateReadDAG);
RF_CREATE_DAG_FUNC_DECL(rf_PQ_200_CreateReadDAG)
{
rf_CreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList);
}
/* Writes, single failure */
+RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateWriteDAG);
RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateWriteDAG)
{
if (asmap->numStripeUnitsAccessed != 1 &&
- asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
+ asmap->failedPDAs[0]->numSector !=
+ raidPtr->Layout.sectorsPerStripeUnit)
RF_PANIC();
- rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
- allocList, 2, (int (*) ()) rf_Degraded_100_PQFunc, RF_FALSE);
+ rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp,
+ flags, allocList, 2,
+ (int (*) (RF_DagNode_t *)) rf_Degraded_100_PQFunc,
+ RF_FALSE);
}
/* Dead P - act like a RAID 5 small write with parity = Q */
RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateSmallWriteDAG)
@@ -130,12 +136,14 @@ RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateSmallWriteDAG)
temp = asmap->parityInfo;
asmap->parityInfo = asmap->qInfo;
asmap->qInfo = temp;
- rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_qFuncs, NULL);
+ rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags,
+ allocList, &rf_qFuncs, NULL);
}
/* Dead Q - act like a RAID 5 small write */
RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateSmallWriteDAG)
{
- rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, NULL);
+ rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags,
+ allocList, &rf_pFuncs, NULL);
}
/* Dead P - act like a RAID 5 large write but for Q */
RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateLargeWriteDAG)
@@ -145,12 +153,14 @@ RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateLargeWriteDAG)
temp = asmap->parityInfo;
asmap->parityInfo = asmap->qInfo;
asmap->qInfo = temp;
- rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularQFunc, RF_FALSE);
+ rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags,
+ allocList, 1, rf_RegularQFunc, RF_FALSE);
}
/* Dead Q - act like a RAID 5 large write */
RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateLargeWriteDAG)
{
- rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_FALSE);
+ rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags,
+ allocList, 1, rf_RegularPFunc, RF_FALSE);
}
@@ -188,7 +198,9 @@ RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateWriteDAG)
asmap->parityInfo = asmap->qInfo;
asmap->qInfo = temp;
rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
- allocList, 1, (int (*) ()) rf_PQ_DegradedWriteQFunc, RF_FALSE);
+ allocList, 1,
+ (int (*) (RF_DagNode_t *)) rf_PQ_DegradedWriteQFunc,
+ RF_FALSE);
/* is the regular Q func the right one to call? */
}
/*
diff --git a/sys/dev/raidframe/rf_pqdegdags.c b/sys/dev/raidframe/rf_pqdegdags.c
index 9dab6207ec6..b66c1ccfe2b 100644
--- a/sys/dev/raidframe/rf_pqdegdags.c
+++ b/sys/dev/raidframe/rf_pqdegdags.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_pqdegdags.c,v 1.3 1999/10/29 08:57:18 todd Exp $ */
-/* $NetBSD: rf_pqdegdags.c,v 1.3 1999/02/05 00:06:15 oster Exp $ */
+/* $OpenBSD: rf_pqdegdags.c,v 1.4 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_pqdegdags.c,v 1.5 1999/08/15 02:36:40 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -40,6 +40,8 @@
#include "rf_types.h"
#include "rf_raid.h"
#include "rf_dag.h"
+#include "rf_dagdegrd.h"
+#include "rf_dagdegwr.h"
#include "rf_dagfuncs.h"
#include "rf_dagutils.h"
#include "rf_etimer.h"
@@ -47,7 +49,6 @@
#include "rf_general.h"
#include "rf_pqdegdags.h"
#include "rf_pq.h"
-#include "rf_sys.h"
static void
applyPDA(RF_Raid_t * raidPtr, RF_PhysDiskAddr_t * pda, RF_PhysDiskAddr_t * ppda,
diff --git a/sys/dev/raidframe/rf_psstatus.c b/sys/dev/raidframe/rf_psstatus.c
index d8874e74146..7383354236e 100644
--- a/sys/dev/raidframe/rf_psstatus.c
+++ b/sys/dev/raidframe/rf_psstatus.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_psstatus.c,v 1.2 1999/02/16 00:03:12 niklas Exp $ */
-/* $NetBSD: rf_psstatus.c,v 1.3 1999/02/05 00:06:15 oster Exp $ */
+/* $OpenBSD: rf_psstatus.c,v 1.3 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_psstatus.c,v 1.4 1999/08/13 03:41:57 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -45,7 +45,6 @@
#include "rf_freelist.h"
#include "rf_psstatus.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
#define Dprintf1(s,a) if (rf_pssDebug) rf_debug_printf(s,(void *)((unsigned long)a),NULL,NULL,NULL,NULL,NULL,NULL,NULL)
#define Dprintf2(s,a,b) if (rf_pssDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),NULL,NULL,NULL,NULL,NULL,NULL)
diff --git a/sys/dev/raidframe/rf_raid.h b/sys/dev/raidframe/rf_raid.h
index dc106a9e767..8efbc6639ee 100644
--- a/sys/dev/raidframe/rf_raid.h
+++ b/sys/dev/raidframe/rf_raid.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_raid.h,v 1.4 1999/08/04 13:10:55 peter Exp $ */
-/* $NetBSD: rf_raid.h,v 1.6 1999/07/08 00:45:24 oster Exp $ */
+/* $OpenBSD: rf_raid.h,v 1.5 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_raid.h,v 1.8 2000/01/05 02:57:29 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -181,14 +181,24 @@ struct RF_Raid_s {
RF_ThroughputStats_t throughputstats;
#endif /* !_KERNEL && !SIMULATE */
RF_CumulativeStats_t userstats;
+ int parity_rewrite_stripes_done;
+ int recon_stripes_done;
+ int copyback_stripes_done;
+
+ int recon_in_progress;
+ int parity_rewrite_in_progress;
+ int copyback_in_progress;
/*
* Engine thread control
*/
- RF_DECLARE_MUTEX(node_queue_mutex)
- RF_DECLARE_COND(node_queue_cond)
+ RF_DECLARE_MUTEX(node_queue_mutex)
+ RF_DECLARE_COND(node_queue_cond)
RF_DagNode_t *node_queue;
+ RF_Thread_t parity_rewrite_thread;
+ RF_Thread_t copyback_thread;
RF_Thread_t engine_thread;
+ RF_Thread_t recon_thread;
RF_ThreadGroup_t engine_tg;
int shutdown_engine;
int dags_in_flight; /* debug */
@@ -226,7 +236,6 @@ struct RF_Raid_s {
int keep_acc_totals;
struct raidcinfo **raid_cinfo; /* array of component info */
- struct proc *proc; /* XXX shouldn't be needed here.. :-p */
int terminate_disk_queues;
diff --git a/sys/dev/raidframe/rf_raid1.c b/sys/dev/raidframe/rf_raid1.c
index 6ad2645a0fa..33f1e7c2962 100644
--- a/sys/dev/raidframe/rf_raid1.c
+++ b/sys/dev/raidframe/rf_raid1.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_raid1.c,v 1.2 1999/02/16 00:03:15 niklas Exp $ */
-/* $NetBSD: rf_raid1.c,v 1.3 1999/02/05 00:06:15 oster Exp $ */
+/* $OpenBSD: rf_raid1.c,v 1.3 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_raid1.c,v 1.4 1999/08/13 03:41:57 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -51,7 +51,6 @@
#include "rf_map.h"
#include "rf_engine.h"
#include "rf_reconbuffer.h"
-#include "rf_sys.h"
typedef struct RF_Raid1ConfigInfo_s {
RF_RowCol_t **stripeIdentifier;
diff --git a/sys/dev/raidframe/rf_raidframe.h b/sys/dev/raidframe/rf_raidframe.h
index 7a78cec080c..bf24693d663 100644
--- a/sys/dev/raidframe/rf_raidframe.h
+++ b/sys/dev/raidframe/rf_raidframe.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_raidframe.h,v 1.3 1999/07/30 14:45:33 peter Exp $ */
-/* $NetBSD: rf_raidframe.h,v 1.5 1999/03/02 03:18:48 oster Exp $ */
+/* $OpenBSD: rf_raidframe.h,v 1.4 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_raidframe.h,v 1.8 2000/01/05 02:57:29 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -44,18 +44,6 @@
#include "rf_disks.h"
#include "rf_raid.h"
-struct rf_test_acc { /* used by RAIDFRAME_TEST_ACC ioctl */
- RF_SectorNum_t startSector; /* raidAddress */
- RF_SectorCount_t numSector; /* number of sectors to xfer */
- char *buf; /* data buffer */
- void *returnBufs[10]; /* for async accs only, completed I/Os
- * returned */
- struct rf_test_acc *next; /* for making lists */
- RF_IoType_t type; /* (see rf_types.h for RF_IO_TYPE_*) */
- struct rf_test_acc *myaddr; /* user-address of this struct */
- void *bp; /* used in-kernel: need not be set by user */
-};
-
typedef RF_uint32 RF_ReconReqFlags_t;
struct rf_recon_req { /* used to tell the kernel to fail a disk */
@@ -108,7 +96,7 @@ typedef struct RF_DeviceConfig_s {
#define RAIDFRAME_FAIL_DISK _IOW ('r', 5, struct rf_recon_req) /* fail a disk &
* optionally start
* recon */
-#define RAIDFRAME_CHECKRECON _IOWR('r', 6, int) /* get reconstruction %
+#define RAIDFRAME_CHECK_RECON_STATUS _IOWR('r', 6, int) /* get reconstruction %
* complete on indicated
* row */
#define RAIDFRAME_REWRITEPARITY _IO ('r', 7) /* rewrite (initialize)
@@ -144,5 +132,7 @@ typedef struct RF_DeviceConfig_s {
#define RAIDFRAME_ADD_HOT_SPARE _IOW ('r', 22, RF_SingleComponent_t)
#define RAIDFRAME_REMOVE_HOT_SPARE _IOW ('r', 23, RF_SingleComponent_t)
#define RAIDFRAME_REBUILD_IN_PLACE _IOW ('r', 24, RF_SingleComponent_t)
-
+#define RAIDFRAME_CHECK_PARITY _IOWR ('r', 25, int)
+#define RAIDFRAME_CHECK_PARITYREWRITE_STATUS _IOWR ('r', 26, int)
+#define RAIDFRAME_CHECK_COPYBACK_STATUS _IOWR ('r', 27, int)
#endif /* !_RF__RF_RAIDFRAME_H_ */
diff --git a/sys/dev/raidframe/rf_reconmap.c b/sys/dev/raidframe/rf_reconmap.c
index 496c8f22d73..1d614c02f0a 100644
--- a/sys/dev/raidframe/rf_reconmap.c
+++ b/sys/dev/raidframe/rf_reconmap.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_reconmap.c,v 1.2 1999/02/16 00:03:21 niklas Exp $ */
-/* $NetBSD: rf_reconmap.c,v 1.4 1999/02/05 00:06:16 oster Exp $ */
+/* $OpenBSD: rf_reconmap.c,v 1.3 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_reconmap.c,v 1.6 1999/08/14 21:44:24 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -38,7 +38,6 @@
#include <sys/time.h>
#include "rf_general.h"
#include "rf_utils.h"
-#include "rf_sys.h"
/* special pointer values indicating that a reconstruction unit
* has been either totally reconstructed or not at all. Both
@@ -141,7 +140,7 @@ rf_ReconMapUpdate(raidPtr, mapPtr, startSector, stopSector)
RF_ReconMapListElem_t *p, *pt;
RF_LOCK_MUTEX(mapPtr->mutex);
- RF_ASSERT(startSector >= 0 && stopSector < mapPtr->sectorsInDisk && stopSector > startSector);
+ RF_ASSERT(startSector >= 0 && stopSector < mapPtr->sectorsInDisk && stopSector >= startSector);
while (startSector <= stopSector) {
i = startSector / mapPtr->sectorsPerReconUnit;
diff --git a/sys/dev/raidframe/rf_reconstruct.c b/sys/dev/raidframe/rf_reconstruct.c
index 7debdac2ade..1880285f1d4 100644
--- a/sys/dev/raidframe/rf_reconstruct.c
+++ b/sys/dev/raidframe/rf_reconstruct.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_reconstruct.c,v 1.5 1999/08/04 13:10:55 peter Exp $ */
-/* $NetBSD: rf_reconstruct.c,v 1.5 1999/03/02 03:18:49 oster Exp $ */
+/* $OpenBSD: rf_reconstruct.c,v 1.6 2000/01/07 14:50:22 peter Exp $ */
+/* $NetBSD: rf_reconstruct.c,v 1.9 2000/01/05 02:57:29 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -64,7 +64,6 @@
#include "rf_utils.h"
#include "rf_cpuutil.h"
#include "rf_shutdown.h"
-#include "rf_sys.h"
#include "rf_kintf.h"
@@ -95,8 +94,10 @@
#define DDprintf7(s,a,b,c,d,e,f,g) if (rf_reconDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),(void *)((unsigned long)c),(void *)((unsigned long)d),(void *)((unsigned long)e),(void *)((unsigned long)f),(void *)((unsigned long)g),NULL)
#define DDprintf8(s,a,b,c,d,e,f,g,h) if (rf_reconDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),(void *)((unsigned long)c),(void *)((unsigned long)d),(void *)((unsigned long)e),(void *)((unsigned long)f),(void *)((unsigned long)g),(void *)((unsigned long)h))
+#if 0
static RF_Thread_t recon_thr_handle;
static int recon_thread_initialized = 0;
+#endif
static RF_FreeList_t *rf_recond_freelist;
#define RF_MAX_FREE_RECOND 4
@@ -212,10 +213,12 @@ rf_ConfigureReconstruction(listp)
rf_ShutdownReconstruction(NULL);
return (rc);
}
+#if 0
if (!recon_thread_initialized) {
- RF_CREATE_THREAD(recon_thr_handle, rf_ReconKernelThread, NULL);
+ RF_CREATE_THREAD(recon_thr_handle, rf_ReconKernelThread, NULL, "raid_recon");
recon_thread_initialized = 1;
}
+#endif
return (0);
}
@@ -256,7 +259,7 @@ rf_FreeReconDesc(reconDesc)
reconDesc->numReconEventWaits, reconDesc->numReconExecDelays);
#endif /* RF_RECON_STATS > 0 */
- printf("RAIDframe: %qu max exec uSec\n", reconDesc->maxReconExecuSecs);
+ printf("RAIDframe: %qu max exec ticks\n", reconDesc->maxReconExecTicks);
#if (RF_RECON_STATS > 0) || defined(_KERNEL)
printf("\n");
@@ -294,14 +297,14 @@ rf_ReconstructFailedDisk(raidPtr, row, col)
raidPtr->reconInProgress++;
RF_UNLOCK_MUTEX(raidPtr->mutex);
rc = rf_ReconstructFailedDiskBasic(raidPtr, row, col);
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ raidPtr->reconInProgress--;
+ RF_UNLOCK_MUTEX(raidPtr->mutex);
} else {
RF_ERRORMSG1("RECON: no way to reconstruct failed disk for arch %c\n",
lp->parityConfig);
rc = EIO;
}
- RF_LOCK_MUTEX(raidPtr->mutex);
- raidPtr->reconInProgress--;
- RF_UNLOCK_MUTEX(raidPtr->mutex);
RF_SIGNAL_COND(raidPtr->waitForReconCond);
wakeup(&raidPtr->waitForReconCond); /* XXX Methinks this will be
* needed at some point... GO */
@@ -361,8 +364,8 @@ rf_ReconstructFailedDiskBasic(raidPtr, row, col)
reconDesc->numReconEventWaits = 0;
#endif /* RF_RECON_STATS > 0 */
reconDesc->reconExecTimerRunning = 0;
- reconDesc->reconExecuSecs = 0;
- reconDesc->maxReconExecuSecs = 0;
+ reconDesc->reconExecTicks = 0;
+ reconDesc->maxReconExecTicks = 0;
rc = rf_ContinueReconstructFailedDisk(reconDesc);
if (!rc) {
@@ -459,6 +462,8 @@ rf_ReconstructInPlace(raidPtr, row, col)
RF_WAIT_COND(raidPtr->waitForReconCond, raidPtr->mutex);
}
+ raidPtr->reconInProgress++;
+
/* first look for a spare drive onto which to reconstruct
the data. spare disk descriptors are stored in row 0.
@@ -473,6 +478,7 @@ rf_ReconstructInPlace(raidPtr, row, col)
if (raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE) {
RF_ERRORMSG2("Unable to reconstruct to disk at row %d col %d: operation not supported for RF_DISTRIBUTE_SPARE\n", row, col);
+ raidPtr->reconInProgress--;
RF_UNLOCK_MUTEX(raidPtr->mutex);
return (EINVAL);
}
@@ -484,7 +490,7 @@ rf_ReconstructInPlace(raidPtr, row, col)
badDisk = &raidPtr->Disks[row][col];
- proc = raidPtr->proc; /* XXX Yes, this is not nice.. */
+ proc = raidPtr->engine_thread;
/* This device may have been opened successfully the
first time. Close it before trying to open it again.. */
@@ -509,8 +515,8 @@ rf_ReconstructInPlace(raidPtr, row, col)
raidPtr->Disks[row][col].devname, retcode);
/* XXX the component isn't responding properly...
- must be
- * still dead :-( */
+ must be still dead :-( */
+ raidPtr->reconInProgress--;
RF_UNLOCK_MUTEX(raidPtr->mutex);
return(retcode);
@@ -521,12 +527,14 @@ rf_ReconstructInPlace(raidPtr, row, col)
if ((retcode = VOP_GETATTR(vp, &va, proc->p_ucred,
proc)) != 0) {
+ raidPtr->reconInProgress--;
RF_UNLOCK_MUTEX(raidPtr->mutex);
return(retcode);
}
retcode = VOP_IOCTL(vp, DIOCGPART, (caddr_t) & dpart,
FREAD, proc->p_ucred, proc);
if (retcode) {
+ raidPtr->reconInProgress--;
RF_UNLOCK_MUTEX(raidPtr->mutex);
return(retcode);
}
@@ -559,8 +567,6 @@ rf_ReconstructInPlace(raidPtr, row, col)
printf(" row %d col %d -> spare at row %d col %d\n",
row, col, row, col);
- raidPtr->reconInProgress++;
-
RF_UNLOCK_MUTEX(raidPtr->mutex);
reconDesc = rf_AllocRaidReconDesc((void *) raidPtr, row, col,
@@ -573,16 +579,20 @@ rf_ReconstructInPlace(raidPtr, row, col)
reconDesc->numReconEventWaits = 0;
#endif /* RF_RECON_STATS > 0 */
reconDesc->reconExecTimerRunning = 0;
- reconDesc->reconExecuSecs = 0;
- reconDesc->maxReconExecuSecs = 0;
+ reconDesc->reconExecTicks = 0;
+ reconDesc->maxReconExecTicks = 0;
rc = rf_ContinueReconstructFailedDisk(reconDesc);
+
+ RF_LOCK_MUTEX(raidPtr->mutex);
+ raidPtr->reconInProgress--;
+ RF_UNLOCK_MUTEX(raidPtr->mutex);
+
} else {
RF_ERRORMSG1("RECON: no way to reconstruct failed disk for arch %c\n",
lp->parityConfig);
rc = EIO;
}
RF_LOCK_MUTEX(raidPtr->mutex);
- raidPtr->reconInProgress--;
if (!rc) {
/* Need to set these here, as at this point it'll be claiming
diff --git a/sys/dev/raidframe/rf_revent.c b/sys/dev/raidframe/rf_revent.c
index e1ad4661ac1..a137a315f7b 100644
--- a/sys/dev/raidframe/rf_revent.c
+++ b/sys/dev/raidframe/rf_revent.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_revent.c,v 1.6 1999/08/03 13:56:38 peter Exp $ */
-/* $NetBSD: rf_revent.c,v 1.4 1999/03/14 21:53:31 oster Exp $ */
+/* $OpenBSD: rf_revent.c,v 1.7 2000/01/07 14:50:23 peter Exp $ */
+/* $NetBSD: rf_revent.c,v 1.5 1999/08/13 03:26:55 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -135,17 +135,17 @@ rf_GetNextReconEvent(reconDesc, row, continueFunc, continueArg)
RF_ETIMER_STOP(reconDesc->recon_exec_timer);
RF_ETIMER_EVAL(reconDesc->recon_exec_timer);
- reconDesc->reconExecuSecs += RF_ETIMER_VAL_US(reconDesc->recon_exec_timer);
- if (reconDesc->reconExecuSecs > reconDesc->maxReconExecuSecs)
- reconDesc->maxReconExecuSecs = reconDesc->reconExecuSecs;
- if (reconDesc->reconExecuSecs >= MAX_RECON_EXEC_USECS) {
+ reconDesc->reconExecTicks += RF_ETIMER_VAL_US(reconDesc->recon_exec_timer);
+ if (reconDesc->reconExecTicks > reconDesc->maxReconExecTicks)
+ reconDesc->maxReconExecTicks = reconDesc->reconExecTicks;
+ if (reconDesc->reconExecTicks >= MAX_RECON_EXEC_USECS) {
/* we've been running too long - sleep */
#if RF_RECON_STATS > 0
reconDesc->numReconExecDelays++;
#endif /* RF_RECON_STATS > 0 */
- status = tsleep(&reconDesc->reconExecuSecs, PRIBIO, "recon delay", RECON_TIMO);
+ status = tsleep(&reconDesc->reconExecTicks, PRIBIO, "recon delay", RECON_TIMO);
RF_ASSERT(status == EWOULDBLOCK);
- reconDesc->reconExecuSecs = 0;
+ reconDesc->reconExecTicks = 0;
}
}
while (!rctrl->eventQueue) {
@@ -153,7 +153,7 @@ rf_GetNextReconEvent(reconDesc, row, continueFunc, continueArg)
reconDesc->numReconEventWaits++;
#endif /* RF_RECON_STATS > 0 */
DO_WAIT(rctrl);
- reconDesc->reconExecuSecs = 0; /* we've just waited */
+ reconDesc->reconExecTicks = 0; /* we've just waited */
}
RF_ETIMER_START(reconDesc->recon_exec_timer);
diff --git a/sys/dev/raidframe/rf_states.c b/sys/dev/raidframe/rf_states.c
index c183945b0d2..1dfc5287e89 100644
--- a/sys/dev/raidframe/rf_states.c
+++ b/sys/dev/raidframe/rf_states.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_states.c,v 1.4 1999/08/04 13:10:55 peter Exp $ */
-/* $NetBSD: rf_states.c,v 1.7 1999/07/08 00:45:24 oster Exp $ */
+/* $OpenBSD: rf_states.c,v 1.5 2000/01/07 14:50:23 peter Exp $ */
+/* $NetBSD: rf_states.c,v 1.10 1999/12/12 20:52:37 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -43,14 +43,7 @@
#include "rf_engine.h"
#include "rf_map.h"
#include "rf_etimer.h"
-
-#if defined(_KERNEL) && (DKUSAGE > 0)
-#include <sys/dkusage.h>
-#include <io/common/iotypes.h>
-#include <io/cam/dec_cam.h>
-#include <io/cam/cam.h>
-#include <io/cam/pdrv.h>
-#endif /* _KERNEL && DKUSAGE > 0 */
+#include "rf_kintf.h"
/* prototypes for some of the available states.
@@ -196,7 +189,6 @@ rf_ContinueDagAccess(RF_DagList_t * dagList)
rf_ContinueRaidAccess(desc);
}
-
int
rf_State_LastState(RF_RaidAccessDesc_t * desc)
{
@@ -205,31 +197,25 @@ rf_State_LastState(RF_RaidAccessDesc_t * desc)
callbackArg.p = desc->callbackArg;
- if (!(desc->flags & RF_DAG_TEST_ACCESS)) { /* don't biodone if this */
-#if DKUSAGE > 0
- RF_DKU_END_IO(((RF_Raid_t *) desc->raidPtr)->raidid, (struct buf *) desc->bp);
-#else
- RF_DKU_END_IO(((RF_Raid_t *) desc->raidPtr)->raidid);
-#endif /* DKUSAGE > 0 */
-
- /*
- * If this is not an async request, wake up the caller
- */
- if (desc->async_flag == 0)
- wakeup(desc->bp);
-
- /*
- * Wakeup any requests waiting to go.
- */
-
- RF_LOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
- ((RF_Raid_t *) desc->raidPtr)->openings++;
- wakeup(&(((RF_Raid_t *) desc->raidPtr)->openings));
- RF_UNLOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
-
- /* printf("Calling biodone on 0x%x\n",desc->bp); */
- biodone(desc->bp); /* access came through ioctl */
- }
+ /*
+ * If this is not an async request, wake up the caller
+ */
+ if (desc->async_flag == 0)
+ wakeup(desc->bp);
+
+ /*
+ * Wakeup any requests waiting to go.
+ */
+
+ RF_LOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
+ ((RF_Raid_t *) desc->raidPtr)->openings++;
+ RF_UNLOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
+
+ /* wake up any pending IO */
+ raidstart(((RF_Raid_t *) desc->raidPtr));
+
+ /* printf("Calling biodone on 0x%x\n",desc->bp); */
+ biodone(desc->bp); /* access came through ioctl */
if (callbackFunc)
callbackFunc(callbackArg);
rf_FreeRaidAccDesc(desc);
diff --git a/sys/dev/raidframe/rf_sys.h b/sys/dev/raidframe/rf_sys.h
deleted file mode 100644
index 290e43c54a8..00000000000
--- a/sys/dev/raidframe/rf_sys.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* $OpenBSD: rf_sys.h,v 1.3 1999/08/04 13:10:55 peter Exp $ */
-/* $NetBSD: rf_sys.h,v 1.3 1999/02/05 00:06:18 oster Exp $ */
-/*
- * rf_sys.h
- *
- * Jim Zelenka, CMU/SCS, 14 June 1996
- */
-/*
- * Copyright (c) 1996 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: 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.
- */
-
-#ifndef _RF__RF_SYS_H_
-#define _RF__RF_SYS_H_
-
-#include "rf_types.h"
-
-#endif /* !_RF__RF_SYS_H_ */
diff --git a/sys/dev/raidframe/rf_threadstuff.c b/sys/dev/raidframe/rf_threadstuff.c
index 55dd660f6e5..cfd1d05ca13 100644
--- a/sys/dev/raidframe/rf_threadstuff.c
+++ b/sys/dev/raidframe/rf_threadstuff.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_threadstuff.c,v 1.2 1999/02/16 00:03:32 niklas Exp $ */
-/* $NetBSD: rf_threadstuff.c,v 1.3 1999/02/05 00:06:18 oster Exp $ */
+/* $OpenBSD: rf_threadstuff.c,v 1.3 2000/01/07 14:50:23 peter Exp $ */
+/* $NetBSD: rf_threadstuff.c,v 1.5 1999/12/07 02:13:28 oster Exp $ */
/*
* rf_threadstuff.c
*/
@@ -37,7 +37,6 @@
static void mutex_destroyer(void *);
static void cond_destroyer(void *);
-void thread_wakeup(void *);
/*
* Shared stuff
@@ -140,13 +139,8 @@ _rf_destroy_threadgroup(g, file, line)
{
int rc1, rc2;
-#if RF_DEBUG_ATOMIC > 0
- rc1 = _rf_mutex_destroy(&g->mutex, file, line);
- rc2 = _rf_cond_destroy(&g->cond, file, line);
-#else /* RF_DEBUG_ATOMIC > 0 */
rc1 = rf_mutex_destroy(&g->mutex);
rc2 = rf_cond_destroy(&g->cond);
-#endif /* RF_DEBUG_ATOMIC > 0 */
if (rc1)
return (rc1);
return (rc2);
@@ -160,16 +154,6 @@ _rf_init_threadgroup(g, file, line)
{
int rc;
-#if RF_DEBUG_ATOMIC > 0
- rc = _rf_mutex_init(&g->mutex, file, line);
- if (rc)
- return (rc);
- rc = _rf_cond_init(&g->cond, file, line);
- if (rc) {
- _rf_mutex_destroy(&g->mutex, file, line);
- return (rc);
- }
-#else /* RF_DEBUG_ATOMIC > 0 */
rc = rf_mutex_init(&g->mutex);
if (rc)
return (rc);
@@ -178,7 +162,6 @@ _rf_init_threadgroup(g, file, line)
rf_mutex_destroy(&g->mutex);
return (rc);
}
-#endif /* RF_DEBUG_ATOMIC > 0 */
g->created = g->running = g->shutdown = 0;
return (0);
}
diff --git a/sys/dev/raidframe/rf_threadstuff.h b/sys/dev/raidframe/rf_threadstuff.h
index 028bef46cc3..1a9ce37adf8 100644
--- a/sys/dev/raidframe/rf_threadstuff.h
+++ b/sys/dev/raidframe/rf_threadstuff.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_threadstuff.h,v 1.3 1999/07/30 14:45:33 peter Exp $ */
-/* $NetBSD: rf_threadstuff.h,v 1.5 1999/07/06 21:51:22 thorpej Exp $ */
+/* $OpenBSD: rf_threadstuff.h,v 1.4 2000/01/07 14:50:23 peter Exp $ */
+/* $NetBSD: rf_threadstuff.h,v 1.6 2000/01/05 02:57:28 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -97,9 +97,9 @@ typedef void *RF_ThreadArg_t;
}
#define RF_SIGNAL_COND(_c_) wakeup(&(_c_))
#define RF_BROADCAST_COND(_c_) wakeup(&(_c_))
-#define RF_CREATE_THREAD(_handle_, _func_, _arg_) \
+#define RF_CREATE_THREAD(_handle_, _func_, _arg_, _name_) \
kthread_create((void (*) __P((void *)))(_func_), (void *)(_arg_), \
- (struct proc **)&(_handle_), "raid")
+ (struct proc **)&(_handle_), _name_)
struct RF_ThreadGroup_s {
int created;
diff --git a/sys/dev/raidframe/rf_types.h b/sys/dev/raidframe/rf_types.h
index 900cea96020..bf98f2c7bd2 100644
--- a/sys/dev/raidframe/rf_types.h
+++ b/sys/dev/raidframe/rf_types.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_types.h,v 1.2 1999/02/16 00:03:32 niklas Exp $ */
-/* $NetBSD: rf_types.h,v 1.4 1999/02/05 00:06:18 oster Exp $ */
+/* $OpenBSD: rf_types.h,v 1.3 2000/01/07 14:50:23 peter Exp $ */
+/* $NetBSD: rf_types.h,v 1.6 1999/09/05 03:05:55 oster Exp $ */
/*
* rf_types.h
*/
@@ -48,12 +48,6 @@
#include <sys/param.h>
#include <sys/lock.h>
-/* XXX not sure about these... */
-/* #define PZERO 0 *//* actually defined in <sys/param.h> */
-#define MS_LOCK_SIMPLE 1
-
-#define TRUE 1 /* XXX why isn't this done somewhere already!! */
-
/*
* First, define system-dependent types and constants.
*
@@ -141,11 +135,6 @@ typedef char RF_IoType_t;
#define RF_IO_IS_R_OR_W(_type_) (((_type_) == RF_IO_TYPE_READ) \
|| ((_type_) == RF_IO_TYPE_WRITE))
-#ifdef SIMULATE
-typedef double RF_TICS_t;
-typedef int RF_Owner_t;
-#endif /* SIMULATE */
-
typedef void (*RF_VoidFuncPtr) (void *,...);
typedef RF_uint32 RF_AccessStripeMapFlags_t;
diff --git a/sys/dev/raidframe/rf_utils.c b/sys/dev/raidframe/rf_utils.c
index 7ebe92e1e4d..959f30caf31 100644
--- a/sys/dev/raidframe/rf_utils.c
+++ b/sys/dev/raidframe/rf_utils.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_utils.c,v 1.2 1999/02/16 00:03:33 niklas Exp $ */
-/* $NetBSD: rf_utils.c,v 1.3 1999/02/05 00:06:18 oster Exp $ */
+/* $OpenBSD: rf_utils.c,v 1.3 2000/01/07 14:50:23 peter Exp $ */
+/* $NetBSD: rf_utils.c,v 1.4 1999/08/13 03:41:58 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -43,7 +43,6 @@
#include "rf_debugMem.h"
#include "rf_alloclist.h"
#include "rf_general.h"
-#include "rf_sys.h"
/* creates & zeros 2-d array with b rows and k columns (MCH) */
RF_RowCol_t **
diff --git a/sys/dev/raidframe/rf_utils.h b/sys/dev/raidframe/rf_utils.h
index 1e5a9d3e872..622e2061b45 100644
--- a/sys/dev/raidframe/rf_utils.h
+++ b/sys/dev/raidframe/rf_utils.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rf_utils.h,v 1.3 1999/08/03 13:56:38 peter Exp $ */
-/* $NetBSD: rf_utils.h,v 1.3 1999/02/05 00:06:18 oster Exp $ */
+/* $OpenBSD: rf_utils.h,v 1.4 2000/01/07 14:50:23 peter Exp $ */
+/* $NetBSD: rf_utils.h,v 1.4 1999/08/13 03:26:55 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -52,7 +52,9 @@ int rf_atoi(char *p);
int rf_htoi(char *p);
#define RF_USEC_PER_SEC 1000000
-#define RF_TIMEVAL_TO_US(_t_) (((_t_).tv_sec) * RF_USEC_PER_SEC + (_t_).tv_usec)
+#define RF_TIMEVAL_TO_US(_t_) (((_t_).tv_sec) \
+ * RF_USEC_PER_SEC + (_t_).tv_usec)
+
#define RF_TIMEVAL_DIFF(_start_,_end_,_diff_) { \
if ((_end_)->tv_usec < (_start_)->tv_usec) { \
(_diff_)->tv_usec = ((_end_)->tv_usec + RF_USEC_PER_SEC) \