diff options
45 files changed, 846 insertions, 1319 deletions
diff --git a/sys/dev/raidframe/rf_archs.h b/sys/dev/raidframe/rf_archs.h index 2cb26be86f0..765b577477f 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.3 2000/01/07 14:50:19 peter Exp $ */ -/* $NetBSD: rf_archs.h,v 1.6 1999/08/26 02:40:27 oster Exp $ */ +/* $OpenBSD: rf_archs.h,v 1.4 2000/01/11 18:02:20 peter Exp $ */ +/* $NetBSD: rf_archs.h,v 1.7 2000/01/08 03:49:37 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -49,11 +49,6 @@ #ifndef _RF__RF_ARCHS_H_ #define _RF__RF_ARCHS_H_ -/* - * Khalil's performance-displaying demo stuff. - * Relies on CMU meter tools. - */ - #define RF_INCLUDE_EVENODD 1 #define RF_INCLUDE_RAID5_RS 1 diff --git a/sys/dev/raidframe/rf_chaindecluster.c b/sys/dev/raidframe/rf_chaindecluster.c index 29a0bbf40d3..6eab8c5f937 100644 --- a/sys/dev/raidframe/rf_chaindecluster.c +++ b/sys/dev/raidframe/rf_chaindecluster.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_chaindecluster.c,v 1.2 1999/02/16 00:02:24 niklas Exp $ */ -/* $NetBSD: rf_chaindecluster.c,v 1.3 1999/02/05 00:06:06 oster Exp $ */ +/* $OpenBSD: rf_chaindecluster.c,v 1.3 2000/01/11 18:02:20 peter Exp $ */ +/* $NetBSD: rf_chaindecluster.c,v 1.4 2000/01/07 03:40:56 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -43,7 +43,6 @@ #include "rf_dagffwr.h" #include "rf_dagdegrd.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_general.h" #include "rf_utils.h" diff --git a/sys/dev/raidframe/rf_copyback.c b/sys/dev/raidframe/rf_copyback.c index 596fa8aa013..f0da14587c3 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.4 2000/01/07 14:50:20 peter Exp $ */ -/* $NetBSD: rf_copyback.c,v 1.10 2000/01/05 02:57:28 oster Exp $ */ +/* $OpenBSD: rf_copyback.c,v 1.5 2000/01/11 18:02:20 peter Exp $ */ +/* $NetBSD: rf_copyback.c,v 1.12 2000/01/09 01:29:28 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -43,7 +43,6 @@ #include <sys/time.h> #include <sys/buf.h> #include "rf_raid.h" -#include "rf_threadid.h" #include "rf_mcpair.h" #include "rf_acctrace.h" #include "rf_etimer.h" @@ -53,6 +52,7 @@ #include "rf_decluster.h" #include "rf_driver.h" #include "rf_shutdown.h" +#include "rf_kintf.h" #define RF_COPYBACK_DATA 0 #define RF_COPYBACK_PARITY 1 @@ -61,9 +61,9 @@ int rf_copyback_in_progress; static int rf_CopybackReadDoneProc(RF_CopybackDesc_t * desc, int status); static int rf_CopybackWriteDoneProc(RF_CopybackDesc_t * desc, int status); -static void -rf_CopybackOne(RF_CopybackDesc_t * desc, int typ, - RF_RaidAddr_t addr, RF_RowCol_t testRow, RF_RowCol_t testCol, +static void rf_CopybackOne(RF_CopybackDesc_t * desc, int typ, + RF_RaidAddr_t addr, RF_RowCol_t testRow, + RF_RowCol_t testCol, RF_SectorNum_t testOffs); static void rf_CopybackComplete(RF_CopybackDesc_t * desc, int status); @@ -84,11 +84,6 @@ rf_ConfigureCopyback(listp) #include <sys/vnode.h> #endif -/* XXX these should be in a .h file somewhere */ -int raidlookup __P((char *, struct proc *, struct vnode **)); -int raidwrite_component_label __P((dev_t, struct vnode *, RF_ComponentLabel_t *)); -int raidread_component_label __P((dev_t, struct vnode *, RF_ComponentLabel_t *)); - /* do a complete copyback */ void rf_CopybackReconstructedData(raidPtr) diff --git a/sys/dev/raidframe/rf_cpuutil.c b/sys/dev/raidframe/rf_cpuutil.c deleted file mode 100644 index 72b301d765e..00000000000 --- a/sys/dev/raidframe/rf_cpuutil.c +++ /dev/null @@ -1,120 +0,0 @@ -/* $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. - * - * Authors: Mark Holland, Jim Zelenka - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ -/* - * rf_cpuutil.c - * - * track cpu utilization - */ - -#include "rf_cpuutil.h" - -#include "rf_types.h" -#include "rf_general.h" -#include "rf_shutdown.h" - - -int -rf_ConfigureCpuMonitor(listp) - RF_ShutdownList_t **listp; -{ -#ifdef AIX - int rc; - - rc = knlist(namelist, 1, sizeof(struct nlist)); - if (rc) { - RF_ERRORMSG("Could not knlist() to config CPU monitor\n"); - return (errno); - } - if (namelist[0].n_value == 0) { - RF_ERRORMSG("Got bogus results from knlist() for CPU monitor\n"); - return (EIO); - } - sysinfo_offset = namelist[0].n_value; - kmem_fd = open("/dev/kmem", O_RDONLY); - if (kmem_fd < 0) { - perror("/dev/kmem"); - return (errno); - } - rc = rf_ShutdownCreate(listp, rf_ShutdownCpuMonitor, NULL); - if (rc) { - RF_ERRORMSG3("Unable to add to shutdown list file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); - rf_ShutdownCpuMonitor(NULL); - return (rc); - } -#endif /* AIX */ - return (0); -} - -void -rf_start_cpu_monitor() -{ -#ifdef AIX - off_t off; - int rc; - - off = lseek(kmem_fd, sysinfo_offset, SEEK_SET); - RF_ASSERT(off == sysinfo_offset); - rc = read(kmem_fd, &sysinfo_start, sizeof(struct sysinfo)); - if (rc != sizeof(struct sysinfo)) { - RF_ERRORMSG2("Starting CPU monitor: rc=%d != %d\n", rc, - sizeof(struct sysinfo)); - } -#endif /* AIX */ -} - -void -rf_stop_cpu_monitor() -{ -#ifdef AIX - off_t off; - int rc; - - off = lseek(kmem_fd, sysinfo_offset, SEEK_SET); - RF_ASSERT(off == sysinfo_offset); - rc = read(kmem_fd, &sysinfo_stop, sizeof(struct sysinfo)); - if (rc != sizeof(struct sysinfo)) { - RF_ERRORMSG2("Stopping CPU monitor: rc=%d != %d\n", rc, - sizeof(struct sysinfo)); - } -#endif /* AIX */ -} - -void -rf_print_cpu_util(s) - char *s; -{ -#ifdef AIX - long idle; - - /* XXX compute a percentage here */ - idle = (long) (sysinfo_stop.cpu[CPU_IDLE] - sysinfo_start.cpu[CPU_IDLE]); - printf("%ld idle ticks during %s.\n", idle, s); -#endif /* AIX */ -} diff --git a/sys/dev/raidframe/rf_cpuutil.h b/sys/dev/raidframe/rf_cpuutil.h deleted file mode 100644 index b1bdac4b8a2..00000000000 --- a/sys/dev/raidframe/rf_cpuutil.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: rf_cpuutil.h,v 1.2 1999/02/16 00:02:27 niklas Exp $ */ -/* $NetBSD: rf_cpuutil.h,v 1.2 1999/02/05 00:06:07 oster Exp $ */ -/* - * rf_cpuutil.h - */ -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Mark Holland, 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. - */ -/* - * : - * Log: rf_cpuutil.h,v - * Revision 1.3 1996/07/18 22:57:14 jimz - * port simulator to AIX - * - * Revision 1.2 1996/05/24 01:59:45 jimz - * another checkpoint in code cleanup for release - * time to sync kernel tree - * - * Revision 1.1 1996/05/18 19:55:29 jimz - * Initial revision - * - */ - -#ifndef _RF__RF_CPUUTIL_H_ -#define _RF__RF_CPUUTIL_H_ - -#include "rf_types.h" - -int rf_ConfigureCpuMonitor(RF_ShutdownList_t ** listp); -void rf_start_cpu_monitor(void); -void rf_stop_cpu_monitor(void); -void rf_print_cpu_util(char *s); - -#endif /* !_RF__RF_CPUUTIL_H_ */ diff --git a/sys/dev/raidframe/rf_dagdegrd.c b/sys/dev/raidframe/rf_dagdegrd.c index eeae59e3a24..306fa952d48 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.3 2000/01/07 14:50:20 peter Exp $ */ -/* $NetBSD: rf_dagdegrd.c,v 1.4 1999/08/13 03:41:53 oster Exp $ */ +/* $OpenBSD: rf_dagdegrd.c,v 1.4 2000/01/11 18:02:20 peter Exp $ */ +/* $NetBSD: rf_dagdegrd.c,v 1.5 2000/01/07 03:40:57 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -38,7 +38,6 @@ #include "rf_dag.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_debugMem.h" #include "rf_memchunk.h" #include "rf_general.h" diff --git a/sys/dev/raidframe/rf_dagdegwr.c b/sys/dev/raidframe/rf_dagdegwr.c index 7e84a1512c2..c5df4e9cac7 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.3 2000/01/07 14:50:20 peter Exp $ */ -/* $NetBSD: rf_dagdegwr.c,v 1.4 1999/08/13 03:41:53 oster Exp $ */ +/* $OpenBSD: rf_dagdegwr.c,v 1.4 2000/01/11 18:02:20 peter Exp $ */ +/* $NetBSD: rf_dagdegwr.c,v 1.5 2000/01/07 03:40:57 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -39,7 +39,6 @@ #include "rf_dag.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_debugMem.h" #include "rf_memchunk.h" #include "rf_general.h" diff --git a/sys/dev/raidframe/rf_dagffrd.c b/sys/dev/raidframe/rf_dagffrd.c index 09df06c22e6..8e6ed1e5af8 100644 --- a/sys/dev/raidframe/rf_dagffrd.c +++ b/sys/dev/raidframe/rf_dagffrd.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_dagffrd.c,v 1.2 1999/02/16 00:02:30 niklas Exp $ */ -/* $NetBSD: rf_dagffrd.c,v 1.3 1999/02/05 00:06:07 oster Exp $ */ +/* $OpenBSD: rf_dagffrd.c,v 1.3 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_dagffrd.c,v 1.4 2000/01/07 03:40:58 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -39,7 +39,6 @@ #include "rf_dag.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_debugMem.h" #include "rf_memchunk.h" #include "rf_general.h" diff --git a/sys/dev/raidframe/rf_dagffwr.c b/sys/dev/raidframe/rf_dagffwr.c index 218639b4951..38e42e43134 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.3 2000/01/07 14:50:20 peter Exp $ */ -/* $NetBSD: rf_dagffwr.c,v 1.4 1999/08/26 02:40:28 oster Exp $ */ +/* $OpenBSD: rf_dagffwr.c,v 1.4 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_dagffwr.c,v 1.5 2000/01/07 03:40:58 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -39,7 +39,6 @@ #include "rf_dag.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_debugMem.h" #include "rf_dagffrd.h" #include "rf_memchunk.h" diff --git a/sys/dev/raidframe/rf_debugMem.c b/sys/dev/raidframe/rf_debugMem.c index 688d9f0a165..731986fee9e 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.3 2000/01/07 14:50:20 peter Exp $ */ -/* $NetBSD: rf_debugMem.c,v 1.6 1999/09/04 21:11:21 oster Exp $ */ +/* $OpenBSD: rf_debugMem.c,v 1.4 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_debugMem.c,v 1.7 2000/01/07 03:40:59 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -40,7 +40,6 @@ #include "rf_types.h" #include "rf_threadstuff.h" -#include "rf_threadid.h" #include "rf_options.h" #include "rf_debugMem.h" #include "rf_general.h" diff --git a/sys/dev/raidframe/rf_desc.h b/sys/dev/raidframe/rf_desc.h index 36f4b029894..84b4cb109a8 100644 --- a/sys/dev/raidframe/rf_desc.h +++ b/sys/dev/raidframe/rf_desc.h @@ -1,5 +1,5 @@ -/* $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 $ */ +/* $OpenBSD: rf_desc.h,v 1.5 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_desc.h,v 1.5 2000/01/09 00:00:18 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -94,8 +94,6 @@ struct RF_RaidAccessDesc_s { void (*callbackFunc) (RF_CBParam_t); /* callback function for this * I/O */ void *callbackArg; /* arg to give to callback func */ - int tid; /* debug only, user-level only: thread id of - * thr that did this access */ RF_AllocListElem_t *cleanupList; /* memory to be freed at the * end of the access */ diff --git a/sys/dev/raidframe/rf_diskqueue.c b/sys/dev/raidframe/rf_diskqueue.c index 973b511b3d5..a4811343f7e 100644 --- a/sys/dev/raidframe/rf_diskqueue.c +++ b/sys/dev/raidframe/rf_diskqueue.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_diskqueue.c,v 1.4 1999/08/04 13:10:54 peter Exp $ */ -/* $NetBSD: rf_diskqueue.c,v 1.7 1999/06/04 01:51:00 oster Exp $ */ +/* $OpenBSD: rf_diskqueue.c,v 1.5 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_diskqueue.c,v 1.8 2000/01/07 03:43:39 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -64,7 +64,6 @@ #include "rf_types.h" #include "rf_threadstuff.h" -#include "rf_threadid.h" #include "rf_raid.h" #include "rf_diskqueue.h" #include "rf_alloclist.h" @@ -354,10 +353,7 @@ rf_DiskIOEnqueue(queue, req, pri) RF_DiskQueueData_t *req; int pri; { - int tid; - RF_ETIMER_START(req->qtime); - rf_get_threadid(tid); RF_ASSERT(req->type == RF_IO_TYPE_NOP || req->numSector); req->priority = pri; diff --git a/sys/dev/raidframe/rf_diskqueue.h b/sys/dev/raidframe/rf_diskqueue.h index 246c799d8a1..09d90dcefac 100644 --- a/sys/dev/raidframe/rf_diskqueue.h +++ b/sys/dev/raidframe/rf_diskqueue.h @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_diskqueue.h,v 1.2 1999/02/16 00:02:40 niklas Exp $ */ -/* $NetBSD: rf_diskqueue.h,v 1.3 1999/02/05 00:06:09 oster Exp $ */ +/* $OpenBSD: rf_diskqueue.h,v 1.3 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_diskqueue.h,v 1.4 2000/01/08 23:02:16 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -72,7 +72,7 @@ struct RF_DiskQueueData_s { * completion of the first I/O * of a Read_Op_Write pair */ void *argument; /* argument to be passed to CompleteFunc */ - void *raidPtr; /* needed for simulation */ + RF_Raid_t *raidPtr; /* needed for simulation */ RF_AccTraceEntry_t *tracerec; /* perf mon only */ RF_Etimer_t qtime; /* perf mon only - time request is in queue */ long entryTime; diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c index 14b00b84fac..a598a218919 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.4 2000/01/07 14:50:21 peter Exp $ */ -/* $NetBSD: rf_disks.c,v 1.13 1999/08/14 03:10:03 oster Exp $ */ +/* $OpenBSD: rf_disks.c,v 1.5 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_disks.c,v 1.14 2000/01/09 01:29:28 oster Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -73,6 +73,7 @@ #include "rf_configure.h" #include "rf_general.h" #include "rf_options.h" +#include "rf_kintf.h" #include <sys/types.h> #include <sys/param.h> @@ -85,9 +86,6 @@ #endif /* XXX these should be in a header file somewhere */ -int raidlookup __P((char *, struct proc * p, struct vnode **)); -int raidwrite_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); -int raidread_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); void rf_UnconfigureVnodes( RF_Raid_t * ); int rf_CheckLabels( RF_Raid_t *, RF_Config_t *); diff --git a/sys/dev/raidframe/rf_diskthreads.h b/sys/dev/raidframe/rf_diskthreads.h deleted file mode 100644 index af446b6b96c..00000000000 --- a/sys/dev/raidframe/rf_diskthreads.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: rf_diskthreads.h,v 1.2 1999/02/16 00:02:40 niklas Exp $ */ -/* $NetBSD: rf_diskthreads.h,v 1.3 1999/02/05 00:06:10 oster Exp $ */ -/* - * rf_diskthreads.h - */ -/* - * 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. - */ - -/* - * rf_diskthreads.h -- types and prototypes for disk thread system - */ - -#ifndef _RF__RF_DISKTHREADS_H_ -#define _RF__RF_DISKTHREADS_H_ - -#include "rf_types.h" - -/* this is the information that a disk thread needs to do its job */ -struct RF_DiskId_s { - RF_DiskQueue_t *queue; - RF_Raid_t *raidPtr; - RF_RaidDisk_t *disk; - int fd; /* file descriptor */ - RF_RowCol_t row, col; /* debug only */ -}; - -int -rf_ConfigureDiskThreads(RF_ShutdownList_t ** listp, RF_Raid_t * raidPtr, - RF_Config_t * cfgPtr); - -int rf_ShutdownDiskThreads(RF_Raid_t * raidPtr); - -#endif /* !_RF__RF_DISKTHREADS_H_ */ diff --git a/sys/dev/raidframe/rf_driver.c b/sys/dev/raidframe/rf_driver.c index d097336676d..95ef423ecf1 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.7 2000/01/08 20:57:12 peter Exp $ */ -/* $NetBSD: rf_driver.c,v 1.20 2000/01/07 03:03:44 oster Exp $ */ +/* $OpenBSD: rf_driver.c,v 1.8 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_driver.c,v 1.27 2000/01/09 03:44:33 oster Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -94,7 +94,6 @@ #include "rf_diskqueue.h" #include "rf_parityscan.h" #include "rf_alloclist.h" -#include "rf_threadid.h" #include "rf_dagutils.h" #include "rf_utils.h" #include "rf_etimer.h" @@ -106,7 +105,6 @@ #include "rf_freelist.h" #include "rf_decluster.h" #include "rf_map.h" -#include "rf_diskthreads.h" #include "rf_revent.h" #include "rf_callback.h" #include "rf_engine.h" @@ -118,7 +116,7 @@ #include "rf_driver.h" #include "rf_options.h" #include "rf_shutdown.h" -#include "rf_cpuutil.h" +#include "rf_kintf.h" #include <sys/buf.h> @@ -144,16 +142,8 @@ static int rf_ConfigureRDFreeList(RF_ShutdownList_t **); void rf_UnconfigureVnodes( RF_Raid_t * ); -/* XXX move these to their own .h file! */ -int raidwrite_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); -int raidread_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); -int raidmarkclean(dev_t dev, struct vnode *b_vp,int); -void rf_update_component_labels( RF_Raid_t *); - RF_DECLARE_MUTEX(rf_printf_mutex) /* debug only: avoids interleaved * printfs by different stripes */ -RF_DECLARE_GLOBAL_THREADID /* declarations for threadid.h */ - #define SIGNAL_QUIESCENT_COND(_raid_) wakeup(&((_raid_)->accesses_suspended)) #define WAIT_FOR_QUIESCENCE(_raid_) \ @@ -166,15 +156,13 @@ RF_DECLARE_GLOBAL_THREADID /* declarations for threadid.h */ biodone(bp); \ } - static int configureCount = 0; /* number of active configurations */ - static int isconfigged = 0; /* is basic raidframe (non per-array) +static int configureCount = 0; /* number of active configurations */ +static int isconfigged = 0; /* is basic raidframe (non per-array) * stuff configged */ RF_DECLARE_STATIC_MUTEX(configureMutex) /* used to lock the configuration * stuff */ - static RF_ShutdownList_t *globalShutdown; /* non array-specific - * stuff */ - - static int rf_ConfigureRDFreeList(RF_ShutdownList_t ** listp); +static RF_ShutdownList_t *globalShutdown; /* non array-specific stuff */ +static int rf_ConfigureRDFreeList(RF_ShutdownList_t ** listp); /* called at system boot time */ int @@ -186,9 +174,6 @@ rf_BootRaidframe() return (EBUSY); raidframe_booted = 1; - rf_setup_threadid(); - rf_assign_threadid(); - rc = rf_mutex_init(&configureMutex); if (rc) { RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, @@ -243,7 +228,6 @@ rf_UnconfigureArray() if (rc) { RF_ERRORMSG1("RAIDFRAME: unable to do global shutdown, rc=%d\n", rc); } - rf_shutdown_threadid(); /* * We must wait until now, because the AllocList module @@ -431,7 +415,6 @@ rf_Configure(raidPtr, cfgPtr) DO_INIT_CONFIGURE(rf_ConfigureReconstruction); DO_INIT_CONFIGURE(rf_ConfigureCopyback); DO_INIT_CONFIGURE(rf_ConfigureDiskQueueSystem); - DO_INIT_CONFIGURE(rf_ConfigureCpuMonitor); isconfigged = 1; } RF_UNLOCK_MUTEX(configureMutex); @@ -644,7 +627,6 @@ rf_AllocRaidAccDesc( desc->numPending = 0; desc->cleanupList = NULL; rf_MakeAllocList(desc->cleanupList); - rf_get_threadid(desc->tid); return (desc); } @@ -690,7 +672,6 @@ async_flag should be RF_TRUE or RF_FALSE bp_in is a buf pointer. void * to facilitate ignoring it outside the kernel */ { - int tid; RF_RaidAccessDesc_t *desc; caddr_t lbufPtr = bufPtr; struct buf *bp = (struct buf *) bp_in; @@ -703,13 +684,12 @@ bp_in is a buf pointer. void * to facilitate ignoring it outside the kernel return (EINVAL); } - rf_get_threadid(tid); if (rf_accessDebug) { printf("logBytes is: %d %d %d\n", raidPtr->raidid, raidPtr->logBytesPerSector, (int) rf_RaidAddressToByte(raidPtr, numBlocks)); - printf("[%d] %s raidAddr %d (stripeid %d-%d) numBlocks %d (%d bytes) buf 0x%lx\n", tid, + printf("raid%d: %s raidAddr %d (stripeid %d-%d) numBlocks %d (%d bytes) buf 0x%lx\n", raidPtr->raidid, (type == RF_IO_TYPE_READ) ? "READ" : "WRITE", (int) raidAddress, (int) rf_RaidAddressToStripeID(&raidPtr->Layout, raidAddress), (int) rf_RaidAddressToStripeID(&raidPtr->Layout, raidAddress + numBlocks - 1), @@ -773,10 +753,7 @@ rf_FailDisk( int fcol, int initRecon) { - int tid; - - rf_get_threadid(tid); - printf("[%d] Failing disk r%d c%d\n", tid, frow, fcol); + printf("raid%d: Failing disk r%d c%d\n", raidPtr->raidid, frow, fcol); RF_LOCK_MUTEX(raidPtr->mutex); raidPtr->numFailures++; raidPtr->Disks[frow][fcol].status = rf_ds_failed; @@ -794,11 +771,9 @@ rf_SignalQuiescenceLock(raidPtr, reconDesc) RF_Raid_t *raidPtr; RF_RaidReconDesc_t *reconDesc; { - int tid; - if (rf_quiesceDebug) { - rf_get_threadid(tid); - printf("[%d] Signalling quiescence lock\n", tid); + printf("raid%d: Signalling quiescence lock\n", + raidPtr->raidid); } raidPtr->access_suspend_release = 1; diff --git a/sys/dev/raidframe/rf_engine.c b/sys/dev/raidframe/rf_engine.c index 3e3235bc940..0ec90d1fecd 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.4 2000/01/07 14:50:21 peter Exp $ */ -/* $NetBSD: rf_engine.c,v 1.6 2000/01/05 02:57:29 oster Exp $ */ +/* $OpenBSD: rf_engine.c,v 1.5 2000/01/11 18:02:21 peter Exp $ */ +/* $NetBSD: rf_engine.c,v 1.9 2000/01/08 22:57:31 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -61,7 +61,6 @@ #include "rf_dag.h" #include "rf_engine.h" -#include "rf_threadid.h" #include "rf_etimer.h" #include "rf_general.h" #include "rf_dagutils.h" @@ -111,11 +110,8 @@ rf_ConfigureEngine( RF_Raid_t * raidPtr, RF_Config_t * cfgPtr) { - int rc, tid = 0; + int rc; - if (rf_engineDebug) { - rf_get_threadid(tid); - } DO_INIT(listp, raidPtr); raidPtr->node_queue = NULL; @@ -129,14 +125,14 @@ rf_ConfigureEngine( * to check return code b/c the kernel panics if it can't create the * thread. */ if (rf_engineDebug) { - printf("[%d] Creating engine thread\n", tid); + printf("raid%d: Creating engine thread\n", raidPtr->raidid); } if (RF_CREATE_THREAD(raidPtr->engine_thread, DAGExecutionThread, raidPtr,"raid")) { RF_ERRORMSG("RAIDFRAME: Unable to create engine thread\n"); return (ENOMEM); } if (rf_engineDebug) { - printf("[%d] Created engine thread\n", tid); + printf("raid%d: Created engine thread\n", raidPtr->raidid); } RF_THREADGROUP_STARTED(&raidPtr->engine_tg); /* XXX something is missing here... */ @@ -148,7 +144,7 @@ rf_ConfigureEngine( #endif /* engine thread is now running and waiting for work */ if (rf_engineDebug) { - printf("[%d] Engine thread running and waiting for events\n", tid); + printf("raid%d: Engine thread running and waiting for events\n", raidPtr->raidid); } rc = rf_ShutdownCreate(listp, rf_ShutdownEngine, raidPtr); if (rc) { @@ -244,14 +240,13 @@ NodeReady(RF_DagNode_t * node) static void FireNode(RF_DagNode_t * node) { - int tid; - switch (node->status) { case rf_fired: /* fire the do function of a node */ if (rf_engineDebug) { - rf_get_threadid(tid); - printf("[%d] Firing node 0x%lx (%s)\n", tid, (unsigned long) node, node->name); + printf("raid%d: Firing node 0x%lx (%s)\n", + node->dagHdr->raidPtr->raidid, + (unsigned long) node, node->name); } if (node->flags & RF_DAGNODE_FLAG_YIELD) { #if (defined(__NetBSD__) || defined(__OpenBSD__)) && defined(_KERNEL) @@ -267,9 +262,10 @@ FireNode(RF_DagNode_t * node) break; case rf_recover: /* fire the undo function of a node */ - if (rf_engineDebug || 1) { - rf_get_threadid(tid); - printf("[%d] Firing (undo) node 0x%lx (%s)\n", tid, (unsigned long) node, node->name); + if (rf_engineDebug) { + printf("raid%d: Firing (undo) node 0x%lx (%s)\n", + node->dagHdr->raidPtr->raidid, + (unsigned long) node, node->name); } if (node->flags & RF_DAGNODE_FLAG_YIELD) #if (defined(__NetBSD__) || defined(__OpenBSD__)) && defined(_KERNEL) @@ -398,7 +394,7 @@ PropagateResults( { RF_DagNode_t *s, *a; RF_Raid_t *raidPtr; - int tid, i, ks; + int i, ks; RF_DagNode_t *finishlist = NULL; /* a list of NIL nodes to be * finished */ RF_DagNode_t *skiplist = NULL; /* list of nodes with failed truedata @@ -407,8 +403,6 @@ PropagateResults( RF_DagNode_t *q = NULL, *qh = NULL, *next; int j, skipNode; - rf_get_threadid(tid); - raidPtr = node->dagHdr->raidPtr; DO_LOCK(raidPtr); @@ -598,7 +592,6 @@ ProcessNode( int context) { RF_Raid_t *raidPtr; - int tid; raidPtr = node->dagHdr->raidPtr; @@ -611,15 +604,13 @@ ProcessNode( node->dagHdr->status = rf_rollForward; /* crossed commit * barrier */ if (rf_engineDebug || 1) { - rf_get_threadid(tid); - printf("[%d] node (%s) returned fail, rolling forward\n", tid, node->name); + printf("raid%d: node (%s) returned fail, rolling forward\n", raidPtr->raidid, node->name); } } else { node->dagHdr->status = rf_rollBackward; /* never reached commit * barrier */ if (rf_engineDebug || 1) { - rf_get_threadid(tid); - printf("[%d] node (%s) returned fail, rolling backward\n", tid, node->name); + printf("raid%d: node (%s) returned fail, rolling backward\n", raidPtr->raidid, node->name); } } break; @@ -681,7 +672,6 @@ rf_DispatchDAG( void *cbArg) { RF_Raid_t *raidPtr; - int tid; raidPtr = dag->raidPtr; if (dag->tracerec) { @@ -692,8 +682,7 @@ rf_DispatchDAG( RF_PANIC(); } if (rf_engineDebug) { - rf_get_threadid(tid); - printf("[%d] Entering DispatchDAG\n", tid); + printf("raid%d: Entering DispatchDAG\n", raidPtr->raidid); } raidPtr->dags_in_flight++; /* debug only: blow off proper * locking */ @@ -720,22 +709,14 @@ DAGExecutionThread(RF_ThreadArg_t arg) { RF_DagNode_t *nd, *local_nq, *term_nq, *fire_nq; RF_Raid_t *raidPtr; - int ks, tid; + int ks; int s; raidPtr = (RF_Raid_t *) arg; - rf_assign_threadid(); if (rf_engineDebug) { - rf_get_threadid(tid); - printf("[%d] Engine thread is running\n", tid); + printf("raid%d: Engine thread is running\n", raidPtr->raidid); } -#if !defined(__NetBSD__) && !defined(__OpenBSD__) - thread = current_thread(); - thread_swappable(thread, RF_FALSE); - thread->priority = thread->sched_pri = BASEPRI_SYSTEM; - s = spl0(); -#endif /* XXX what to put here XXX */ s = splbio(); @@ -811,12 +792,7 @@ DAGExecutionThread(RF_ThreadArg_t arg) DO_UNLOCK(raidPtr); RF_THREADGROUP_DONE(&raidPtr->engine_tg); -#if defined(__NetBSD__) || defined(__OpenBSD__) + splx(s); kthread_exit(0); -#else - splx(s); - thread_terminate(thread); - thread_halt_self(); -#endif } diff --git a/sys/dev/raidframe/rf_evenodd.c b/sys/dev/raidframe/rf_evenodd.c index e37fb0f705b..52118285fc8 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.3 2000/01/07 14:50:21 peter Exp $ */ -/* $NetBSD: rf_evenodd.c,v 1.3 1999/08/13 03:41:56 oster Exp $ */ +/* $OpenBSD: rf_evenodd.c,v 1.4 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_evenodd.c,v 1.4 2000/01/07 03:40:59 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -46,7 +46,6 @@ #include "rf_dagdegwr.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_etimer.h" #include "rf_general.h" #include "rf_evenodd.h" diff --git a/sys/dev/raidframe/rf_evenodd_dagfuncs.c b/sys/dev/raidframe/rf_evenodd_dagfuncs.c index dce6540648c..0ea277c2c9c 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.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 $ */ +/* $OpenBSD: rf_evenodd_dagfuncs.c,v 1.5 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_evenodd_dagfuncs.c,v 1.4 2000/01/07 03:41:00 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -40,7 +40,6 @@ #include "rf_dagdegwr.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_etimer.h" #include "rf_general.h" #include "rf_configure.h" diff --git a/sys/dev/raidframe/rf_fifo.c b/sys/dev/raidframe/rf_fifo.c index 317f3887a27..411f1b65cc8 100644 --- a/sys/dev/raidframe/rf_fifo.c +++ b/sys/dev/raidframe/rf_fifo.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_fifo.c,v 1.3 1999/08/04 13:10:54 peter Exp $ */ -/* $NetBSD: rf_fifo.c,v 1.3 1999/02/05 00:06:11 oster Exp $ */ +/* $OpenBSD: rf_fifo.c,v 1.4 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_fifo.c,v 1.4 2000/01/08 23:45:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -44,8 +44,9 @@ #include "rf_fifo.h" #include "rf_debugMem.h" #include "rf_general.h" -#include "rf_threadid.h" #include "rf_options.h" +#include "rf_raid.h" +#include "rf_types.h" /* just malloc a header, zero it (via calloc), and return it */ /*ARGSUSED*/ @@ -86,9 +87,8 @@ rf_FifoEnqueue(q_in, elem, priority) } else { RF_ASSERT(elem->next == NULL); if (rf_fifoDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] fifo: ENQ lopri\n", tid); + printf("raid%d: fifo: ENQ lopri\n", + elem->raidPtr->raidid); } if (!q->lq_tail) { RF_ASSERT(q->lq_count == 0 && q->lq_head == NULL); @@ -138,9 +138,8 @@ rf_FifoDequeue(q_in) nd->next = NULL; q->lq_count--; if (rf_fifoDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] fifo: DEQ lopri %lx\n", tid, (long) nd); + printf("raid%d: fifo: DEQ lopri %lx\n", + nd->raidPtr->raidid, (long) nd); } } else { RF_ASSERT(q->hq_count == 0 && q->lq_count == 0 && q->hq_tail == NULL && q->lq_tail == NULL); @@ -319,10 +318,5 @@ rf_FifoPromote(q_in, parityStripeID, which_ru) /* sanity check. delete this if you ever put more than one entry in * the low-pri queue */ RF_ASSERT(retval == 0 || retval == 1); - if (rf_fifoDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] fifo: promote %d\n", tid, retval); - } return (retval); } diff --git a/sys/dev/raidframe/rf_interdecluster.c b/sys/dev/raidframe/rf_interdecluster.c index 8a5fb70d939..e2e395f1a0d 100644 --- a/sys/dev/raidframe/rf_interdecluster.c +++ b/sys/dev/raidframe/rf_interdecluster.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_interdecluster.c,v 1.2 1999/02/16 00:02:52 niklas Exp $ */ -/* $NetBSD: rf_interdecluster.c,v 1.3 1999/02/05 00:06:12 oster Exp $ */ +/* $OpenBSD: rf_interdecluster.c,v 1.3 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_interdecluster.c,v 1.4 2000/01/07 03:41:00 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -40,7 +40,6 @@ #include "rf_dag.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_general.h" #include "rf_utils.h" #include "rf_dagffrd.h" diff --git a/sys/dev/raidframe/rf_kintf.h b/sys/dev/raidframe/rf_kintf.h index 19a2d30b6c2..00f3fd8bbd4 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.4 2000/01/07 14:50:21 peter Exp $ */ -/* $NetBSD: rf_kintf.h,v 1.6 2000/01/05 02:57:29 oster Exp $ */ +/* $OpenBSD: rf_kintf.h,v 1.5 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_kintf.h,v 1.7 2000/01/09 01:29:27 oster Exp $ */ /* * rf_kintf.h * @@ -41,4 +41,11 @@ int rf_GetSpareTableFromDaemon(RF_SparetWait_t * req); void raidstart(RF_Raid_t * raidPtr); int rf_DispatchKernelIO(RF_DiskQueue_t * queue, RF_DiskQueueData_t * req); +int raidwrite_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); +int raidread_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); +void rf_update_component_labels( RF_Raid_t *); +int raidlookup __P((char *, struct proc *, struct vnode **)); +int raidmarkclean(dev_t dev, struct vnode *b_vp, int); +int raidmarkdirty(dev_t dev, struct vnode *b_vp, int); + #endif /* _RF__RF_KINTF_H_ */ diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 9a23d1f0c09..2ad2de25273 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.39 2000/01/06 02:06:41 oster Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.46 2000/01/09 03:39:13 oster Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -137,6 +137,7 @@ #include "raid.h" #include "rf_raid.h" #include "rf_raidframe.h" +#include "rf_copyback.h" #include "rf_dag.h" #include "rf_dagflags.h" #include "rf_diskqueue.h" @@ -154,20 +155,9 @@ int rf_kdebug_level = 0; #ifdef DEBUG -#define db0_printf(a) printf a -#define db_printf(a) if (rf_kdebug_level > 0) printf a #define db1_printf(a) if (rf_kdebug_level > 0) printf a -#define db2_printf(a) if (rf_kdebug_level > 1) printf a -#define db3_printf(a) if (rf_kdebug_level > 2) printf a -#define db4_printf(a) if (rf_kdebug_level > 3) printf a -#define db5_printf(a) if (rf_kdebug_level > 4) printf a #else /* DEBUG */ -#define db0_printf(a) printf a #define db1_printf(a) { } -#define db2_printf(a) { } -#define db3_printf(a) { } -#define db4_printf(a) { } -#define db5_printf(a) { } #endif /* DEBUG */ static RF_Raid_t **raidPtrs; /* global raid device descriptors */ @@ -186,17 +176,10 @@ static void InitBP(struct buf * bp, struct vnode *, unsigned rw_flag, RF_SectorCount_t numSect, caddr_t buf, void (*cbFunc) (struct buf *), void *cbArg, int logBytesPerSector, struct proc * b_proc); - -int raidmarkclean(dev_t dev, struct vnode *b_vp, int); -int raidmarkdirty(dev_t dev, struct vnode *b_vp, int); +static int raidinit __P((dev_t, RF_Raid_t *, int)); void raidattach __P((int)); int raidsize __P((dev_t)); - -void rf_DiskIOComplete(RF_DiskQueue_t *, RF_DiskQueueData_t *, int); -void rf_CopybackReconstructedData(RF_Raid_t * raidPtr); -static int raidinit __P((dev_t, RF_Raid_t *, int)); - int raidopen __P((dev_t, int, int, struct proc *)); int raidclose __P((dev_t, int, int, struct proc *)); int raidioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); @@ -205,9 +188,6 @@ int raidread __P((dev_t, struct uio *, int)); void raidstrategy __P((struct buf *)); int raiddump __P((dev_t, daddr_t, caddr_t, size_t)); -int raidwrite_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); -int raidread_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); -void rf_update_component_labels( RF_Raid_t *); /* * Pilfered from ccd.c */ @@ -280,7 +260,6 @@ static void raidmakedisklabel __P((struct raid_softc *)); static int raidlock __P((struct raid_softc *)); static void raidunlock __P((struct raid_softc *)); -int raidlookup __P((char *, struct proc * p, struct vnode **)); static void rf_markalldirty __P((RF_Raid_t *)); @@ -662,6 +641,9 @@ raidioctl(dev, cmd, data, flag, p) int part, pmask; struct raid_softc *rs; RF_Config_t *k_cfg, *u_cfg; + RF_Raid_t *raidPtr; + RF_AccTotals_t *totals; + RF_DeviceConfig_t *d_cfg, **ucfgp; u_char *specific_buf; int retcode = 0; int row; @@ -673,10 +655,12 @@ raidioctl(dev, cmd, data, flag, p) RF_SingleComponent_t *sparePtr,*componentPtr; RF_SingleComponent_t hot_spare; RF_SingleComponent_t component; + int i, j, d; if (unit >= numraid) return (ENXIO); rs = &raid_softc[unit]; + raidPtr = raidPtrs[unit]; db1_printf(("raidioctl: %d %d %d %d\n", (int) dev, (int) DISKPART(dev), (int) unit, (int) cmd)); @@ -723,24 +707,21 @@ raidioctl(dev, cmd, data, flag, p) switch (cmd) { - /* configure the system */ case RAIDFRAME_CONFIGURE: - - db3_printf(("rf_ioctl: RAIDFRAME_CONFIGURE\n")); /* copy-in the configuration information */ /* data points to a pointer to the configuration structure */ + u_cfg = *((RF_Config_t **) data); RF_Malloc(k_cfg, sizeof(RF_Config_t), (RF_Config_t *)); if (k_cfg == NULL) { - db3_printf(("rf_ioctl: ENOMEM for config. Code is %d\n", retcode)); return (ENOMEM); } 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", + db1_printf(("rf_ioctl: retcode=%d copyin.1\n", retcode)); return (retcode); } @@ -750,14 +731,12 @@ raidioctl(dev, cmd, data, flag, p) 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); } RF_Malloc(specific_buf, k_cfg->layoutSpecificSize, (u_char *)); if (specific_buf == NULL) { RF_Free(k_cfg, sizeof(RF_Config_t)); - db3_printf(("rf_ioctl: ENOMEM %d\n", retcode)); return (ENOMEM); } retcode = copyin(k_cfg->layoutSpecific, @@ -765,8 +744,9 @@ raidioctl(dev, cmd, data, flag, p) 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", + RF_Free(specific_buf, + k_cfg->layoutSpecificSize); + db1_printf(("rf_ioctl: retcode=%d copyin.2\n", retcode)); return (retcode); } @@ -779,22 +759,24 @@ raidioctl(dev, cmd, data, flag, p) /* configure the system */ - raidPtrs[unit]->raidid = unit; + raidPtr->raidid = unit; - retcode = rf_Configure(raidPtrs[unit], k_cfg); + retcode = rf_Configure(raidPtr, k_cfg); - /* allow this many simultaneous IO's to this RAID device */ - raidPtrs[unit]->openings = RAIDOUTSTANDING; + if (retcode == 0) { - /* XXX should be moved to rf_Configure() */ + /* allow this many simultaneous IO's to + this RAID device */ + raidPtr->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; + raidPtr->copyback_in_progress = 0; + raidPtr->parity_rewrite_in_progress = 0; + raidPtr->recon_in_progress = 0; - if (retcode == 0) { - retcode = raidinit(dev, raidPtrs[unit], unit); - rf_markalldirty( raidPtrs[unit] ); + retcode = raidinit(dev, raidPtr, unit); + rf_markalldirty( raidPtr ); } /* free the buffers. No return code here. */ if (k_cfg->layoutSpecificSize) { @@ -802,9 +784,6 @@ raidioctl(dev, cmd, data, flag, p) } RF_Free(k_cfg, sizeof(RF_Config_t)); - db3_printf(("rf_ioctl: retcode=%d RAIDFRAME_CONFIGURE\n", - retcode)); - return (retcode); /* shutdown the system */ @@ -827,7 +806,7 @@ raidioctl(dev, cmd, data, flag, p) return (EBUSY); } - retcode = rf_Shutdown(raidPtrs[unit]); + retcode = rf_Shutdown(raidPtr); pool_destroy(&rs->sc_cbufpool); @@ -843,9 +822,7 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_GET_COMPONENT_LABEL: c_label_ptr = (RF_ComponentLabel_t **) data; /* need to read the component label for the disk indicated - by row,column in component_label - XXX need to sanity check these values!!! - */ + by row,column in component_label */ /* For practice, let's get it directly fromdisk, rather than from the in-core copy */ @@ -867,15 +844,15 @@ 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 >= raidPtr->numRow) || + (column < 0) || (column >= raidPtr->numCol)) { RF_Free( component_label, sizeof(RF_ComponentLabel_t)); return(EINVAL); } raidread_component_label( - raidPtrs[unit]->Disks[row][column].dev, - raidPtrs[unit]->raid_cinfo[row][column].ci_vp, + raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, component_label ); retcode = copyout((caddr_t) component_label, @@ -907,16 +884,16 @@ 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 >= raidPtr->numRow) || + (column < 0) || (column >= raidPtr->numCol)) { return(EINVAL); } /* XXX this isn't allowed to do anything for now :-) */ #if 0 raidwrite_component_label( - raidPtrs[unit]->Disks[row][column].dev, - raidPtrs[unit]->raid_cinfo[row][column].ci_vp, + raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, component_label ); #endif return (0); @@ -930,23 +907,23 @@ raidioctl(dev, cmd, data, flag, p) set. */ - raidPtrs[unit]->serial_number = component_label->serial_number; + raidPtr->serial_number = component_label->serial_number; /* current version number */ ci_label.version = RF_COMPONENT_LABEL_VERSION; ci_label.serial_number = component_label->serial_number; - ci_label.mod_counter = raidPtrs[unit]->mod_counter; - ci_label.num_rows = raidPtrs[unit]->numRow; - ci_label.num_columns = raidPtrs[unit]->numCol; + ci_label.mod_counter = raidPtr->mod_counter; + ci_label.num_rows = raidPtr->numRow; + ci_label.num_columns = raidPtr->numCol; ci_label.clean = RF_RAID_DIRTY; /* not clean */ ci_label.status = rf_ds_optimal; /* "It's good!" */ - for(row=0;row<raidPtrs[unit]->numRow;row++) { + for(row=0;row<raidPtr->numRow;row++) { ci_label.row = row; - for(column=0;column<raidPtrs[unit]->numCol;column++) { + for(column=0;column<raidPtr->numCol;column++) { ci_label.column = column; raidwrite_component_label( - raidPtrs[unit]->Disks[row][column].dev, - raidPtrs[unit]->raid_cinfo[row][column].ci_vp, + raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, &ci_label ); } } @@ -956,22 +933,20 @@ raidioctl(dev, cmd, data, flag, p) /* initialize all parity */ case RAIDFRAME_REWRITEPARITY: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->Layout.map->faultsTolerated == 0) { /* Parity for RAID 0 is trivially correct */ - raidPtrs[unit]->parity_good = RF_RAID_CLEAN; + raidPtr->parity_good = RF_RAID_CLEAN; return(0); } - if (raidPtrs[unit]->parity_rewrite_in_progress == 1) { + if (raidPtr->parity_rewrite_in_progress == 1) { /* Re-write is already in progress! */ return(EINVAL); } - /* borrow the thread of the requesting process */ - - retcode = RF_CREATE_THREAD(raidPtrs[unit]->parity_rewrite_thread, + retcode = RF_CREATE_THREAD(raidPtr->parity_rewrite_thread, rf_RewriteParityThread, - raidPtrs[unit],"raid_parity"); + raidPtr,"raid_parity"); return (retcode); @@ -979,7 +954,7 @@ raidioctl(dev, cmd, data, flag, p) sparePtr = (RF_SingleComponent_t *) data; memcpy( &hot_spare, sparePtr, sizeof(RF_SingleComponent_t)); printf("Adding spare\n"); - retcode = rf_add_hot_spare(raidPtrs[unit], &hot_spare); + retcode = rf_add_hot_spare(raidPtr, &hot_spare); return(retcode); case RAIDFRAME_REMOVE_HOT_SPARE: @@ -987,12 +962,12 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_REBUILD_IN_PLACE: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->Layout.map->faultsTolerated == 0) { /* Can't do this on a RAID 0!! */ return(EINVAL); } - if (raidPtrs[unit]->recon_in_progress == 1) { + if (raidPtr->recon_in_progress == 1) { /* a reconstruct is already in progress! */ return(EINVAL); } @@ -1003,8 +978,8 @@ raidioctl(dev, cmd, data, flag, p) 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 >= raidPtr->numRow) || + (column < 0) || (column >= raidPtr->numCol)) { return(EINVAL); } @@ -1012,107 +987,86 @@ raidioctl(dev, cmd, data, flag, p) if (rrcopy == NULL) return(ENOMEM); - rrcopy->raidPtr = (void *) raidPtrs[unit]; + rrcopy->raidPtr = (void *) raidPtr; rrcopy->row = row; rrcopy->col = column; - retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread, + retcode = RF_CREATE_THREAD(raidPtr->recon_thread, rf_ReconstructInPlaceThread, rrcopy,"raid_reconip"); return (retcode); case RAIDFRAME_GET_INFO: - { - RF_Raid_t *raid = raidPtrs[unit]; - RF_DeviceConfig_t *cfg, **ucfgp; - int i, j, d; - - if (!raid->valid) - return (ENODEV); - ucfgp = (RF_DeviceConfig_t **) data; - RF_Malloc(cfg, sizeof(RF_DeviceConfig_t), - (RF_DeviceConfig_t *)); - if (cfg == NULL) - return (ENOMEM); - bzero((char *) cfg, sizeof(RF_DeviceConfig_t)); - cfg->rows = raid->numRow; - cfg->cols = raid->numCol; - cfg->ndevs = raid->numRow * raid->numCol; - if (cfg->ndevs >= RF_MAX_DISKS) { - RF_Free(cfg, sizeof(RF_DeviceConfig_t)); - return (ENOMEM); - } - cfg->nspares = raid->numSpare; - if (cfg->nspares >= RF_MAX_DISKS) { - RF_Free(cfg, sizeof(RF_DeviceConfig_t)); - return (ENOMEM); - } - cfg->maxqdepth = raid->maxQueueDepth; - d = 0; - for (i = 0; i < cfg->rows; i++) { - for (j = 0; j < cfg->cols; j++) { - cfg->devs[d] = raid->Disks[i][j]; - d++; - } - } - for (j = cfg->cols, i = 0; i < cfg->nspares; i++, j++) { - cfg->spares[i] = raid->Disks[0][j]; + if (!raidPtr->valid) + return (ENODEV); + ucfgp = (RF_DeviceConfig_t **) data; + RF_Malloc(d_cfg, sizeof(RF_DeviceConfig_t), + (RF_DeviceConfig_t *)); + if (d_cfg == NULL) + return (ENOMEM); + bzero((char *) d_cfg, sizeof(RF_DeviceConfig_t)); + d_cfg->rows = raidPtr->numRow; + d_cfg->cols = raidPtr->numCol; + d_cfg->ndevs = raidPtr->numRow * raidPtr->numCol; + if (d_cfg->ndevs >= RF_MAX_DISKS) { + RF_Free(d_cfg, sizeof(RF_DeviceConfig_t)); + return (ENOMEM); + } + d_cfg->nspares = raidPtr->numSpare; + if (d_cfg->nspares >= RF_MAX_DISKS) { + RF_Free(d_cfg, sizeof(RF_DeviceConfig_t)); + return (ENOMEM); + } + d_cfg->maxqdepth = raidPtr->maxQueueDepth; + d = 0; + for (i = 0; i < d_cfg->rows; i++) { + for (j = 0; j < d_cfg->cols; j++) { + d_cfg->devs[d] = raidPtr->Disks[i][j]; + d++; } - retcode = copyout((caddr_t) cfg, (caddr_t) * ucfgp, - sizeof(RF_DeviceConfig_t)); - RF_Free(cfg, sizeof(RF_DeviceConfig_t)); - - return (retcode); } - break; + for (j = d_cfg->cols, i = 0; i < d_cfg->nspares; i++, j++) { + d_cfg->spares[i] = raidPtr->Disks[0][j]; + } + retcode = copyout((caddr_t) d_cfg, (caddr_t) * ucfgp, + sizeof(RF_DeviceConfig_t)); + RF_Free(d_cfg, sizeof(RF_DeviceConfig_t)); + + return (retcode); + case RAIDFRAME_CHECK_PARITY: - *(int *) data = raidPtrs[unit]->parity_good; + *(int *) data = raidPtr->parity_good; return (0); - case RAIDFRAME_RESET_ACCTOTALS: - { - RF_Raid_t *raid = raidPtrs[unit]; - bzero(&raid->acc_totals, sizeof(raid->acc_totals)); - return (0); - } - break; + case RAIDFRAME_RESET_ACCTOTALS: + bzero(&raidPtr->acc_totals, sizeof(raidPtr->acc_totals)); + return (0); case RAIDFRAME_GET_ACCTOTALS: - { - RF_AccTotals_t *totals = (RF_AccTotals_t *) data; - RF_Raid_t *raid = raidPtrs[unit]; - - *totals = raid->acc_totals; - return (0); - } - break; + totals = (RF_AccTotals_t *) data; + *totals = raidPtr->acc_totals; + return (0); case RAIDFRAME_KEEP_ACCTOTALS: - { - RF_Raid_t *raid = raidPtrs[unit]; - int *keep = (int *) data; - - raid->keep_acc_totals = *keep; - return (0); - } - break; + raidPtr->keep_acc_totals = *(int *)data; + return (0); case RAIDFRAME_GET_SIZE: - *(int *) data = raidPtrs[unit]->totalSectors; + *(int *) data = raidPtr->totalSectors; return (0); /* fail a disk & optionally start reconstruction */ case RAIDFRAME_FAIL_DISK: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->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 - || rr->col < 0 || rr->col >= raidPtrs[unit]->numCol) + if (rr->row < 0 || rr->row >= raidPtr->numRow + || rr->col < 0 || rr->col >= raidPtr->numCol) return (EINVAL); printf("raid%d: Failing the disk: row: %d col: %d\n", @@ -1124,9 +1078,9 @@ raidioctl(dev, cmd, data, flag, p) if (rrcopy == NULL) return(ENOMEM); bcopy(rr, rrcopy, sizeof(*rr)); - rrcopy->raidPtr = (void *) raidPtrs[unit]; + rrcopy->raidPtr = (void *) raidPtr; - retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread, + retcode = RF_CREATE_THREAD(raidPtr->recon_thread, rf_ReconThread, rrcopy,"raid_recon"); return (0); @@ -1135,53 +1089,53 @@ raidioctl(dev, cmd, data, flag, p) * needs it, if any */ case RAIDFRAME_COPYBACK: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->Layout.map->faultsTolerated == 0) { /* This makes no sense on a RAID 0!! */ return(EINVAL); } - if (raidPtrs[unit]->copyback_in_progress == 1) { + if (raidPtr->copyback_in_progress == 1) { /* Copyback is already in progress! */ return(EINVAL); } - retcode = RF_CREATE_THREAD(raidPtrs[unit]->copyback_thread, + retcode = RF_CREATE_THREAD(raidPtr->copyback_thread, rf_CopybackThread, - raidPtrs[unit],"raid_copyback"); + raidPtr,"raid_copyback"); return (retcode); /* return the percentage completion of reconstruction */ case RAIDFRAME_CHECK_RECON_STATUS: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->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) + if (raidPtr->status[row] != rf_rs_reconstructing) *(int *) data = 100; else - *(int *) data = raidPtrs[unit]->reconControl[row]->percentComplete; + *(int *) data = raidPtr->reconControl[row]->percentComplete; return (0); case RAIDFRAME_CHECK_PARITYREWRITE_STATUS: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->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; + if (raidPtr->parity_rewrite_in_progress == 1) { + *(int *) data = 100 * raidPtr->parity_rewrite_stripes_done / raidPtr->Layout.numStripe; } else { *(int *) data = 100; } return (0); case RAIDFRAME_CHECK_COPYBACK_STATUS: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->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; + if (raidPtr->copyback_in_progress == 1) { + *(int *) data = 100 * raidPtr->copyback_stripes_done / raidPtr->Layout.numStripe; } else { *(int *) data = 100; } @@ -1194,7 +1148,7 @@ raidioctl(dev, cmd, data, flag, p) * ioctl code is almost certainly wrong and evil. -- XXX XXX * -- I should either compute the spare table in the kernel, * or have a different -- XXX XXX -- interface (a different - * character device) for delivering the table -- XXX */ + * character device) for delivering the table -- XXX */ #if 0 case RAIDFRAME_SPARET_WAIT: RF_LOCK_MUTEX(rf_sparet_wait_mutex); @@ -1204,12 +1158,12 @@ raidioctl(dev, cmd, data, flag, p) rf_sparet_wait_queue = rf_sparet_wait_queue->next; RF_UNLOCK_MUTEX(rf_sparet_wait_mutex); - *((RF_SparetWait_t *) data) = *waitreq; /* structure assignment */ + /* structure assignment */ + *((RF_SparetWait_t *) data) = *waitreq; RF_Free(waitreq, sizeof(*waitreq)); return (0); - /* wakes up a process waiting on SPARET_WAIT and puts an error * code in it that will cause the dameon to exit */ case RAIDFRAME_ABORT_SPARET_WAIT: @@ -1227,7 +1181,7 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_SEND_SPARET: /* install the spare table */ - retcode = rf_SetSpareTable(raidPtrs[unit], *(void **) data); + retcode = rf_SetSpareTable(raidPtr, *(void **) data); /* respond to the requestor. the return status of the spare * table installation is passed in the "fcol" field */ @@ -1247,7 +1201,7 @@ raidioctl(dev, cmd, data, flag, p) } - if (!raidPtrs[unit]->valid) + if (!raidPtr->valid) return (EINVAL); /* @@ -1296,7 +1250,7 @@ raidioctl(dev, cmd, data, flag, p) break; case DIOCGDEFLABEL: - raidgetdefaultlabel(raidPtrs[unit], rs, + raidgetdefaultlabel(raidPtr, rs, (struct disklabel *) data); break; @@ -1766,9 +1720,10 @@ raidgetdefaultlabel(raidPtr, rs, lp) /* fabricate a label... */ lp->d_secperunit = raidPtr->totalSectors; lp->d_secsize = raidPtr->bytesPerSector; - lp->d_nsectors = 1024 * (1024 / raidPtr->bytesPerSector); + lp->d_nsectors = raidPtr->Layout.dataSectorsPerStripe; lp->d_ntracks = 1; - lp->d_ncylinders = raidPtr->totalSectors / lp->d_nsectors; + lp->d_ncylinders = raidPtr->totalSectors / + (lp->d_nsectors * lp->d_ntracks); lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; strncpy(lp->d_typename, "raid", sizeof(lp->d_typename)); diff --git a/sys/dev/raidframe/rf_openbsdkintf.c b/sys/dev/raidframe/rf_openbsdkintf.c index f2ac4fd6810..8ad4dc3364c 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.8 2000/01/07 14:50:21 peter Exp $ */ -/* $NetBSD: rf_netbsdkintf.c,v 1.39 2000/01/06 02:06:41 oster Exp $ */ +/* $OpenBSD: rf_openbsdkintf.c,v 1.9 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.46 2000/01/09 03:39:13 oster Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -134,6 +134,7 @@ #include "raid.h" #include "rf_raid.h" #include "rf_raidframe.h" +#include "rf_copyback.h" #include "rf_dag.h" #include "rf_dagflags.h" #include "rf_diskqueue.h" @@ -151,20 +152,9 @@ int rf_kdebug_level = 0; #ifdef RAIDDEBUG -#define db0_printf(a) printf a -#define db_printf(a) do if (rf_kdebug_level > 0) printf a; while(0) #define db1_printf(a) do if (rf_kdebug_level > 0) printf a; while(0) -#define db2_printf(a) do if (rf_kdebug_level > 1) printf a; while(0) -#define db3_printf(a) do if (rf_kdebug_level > 2) printf a; while(0) -#define db4_printf(a) do if (rf_kdebug_level > 3) printf a; while(0) -#define db5_printf(a) do if (rf_kdebug_level > 4) printf a; while(0) #else /* RAIDDEBUG */ -#define db0_printf(a) printf a #define db1_printf(a) (void)0 -#define db2_printf(a) (void)0 -#define db3_printf(a) (void)0 -#define db4_printf(a) (void)0 -#define db5_printf(a) (void)0 #endif /* RAIDDEBUG */ static RF_Raid_t **raidPtrs; /* global raid device descriptors */ @@ -182,17 +172,10 @@ 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 *)); - -int raidmarkclean(dev_t dev, struct vnode *b_vp, int); -int raidmarkdirty(dev_t dev, struct vnode *b_vp, int); +static int raidinit __P((dev_t, RF_Raid_t *, int)); void raidattach __P((int)); int raidsize __P((dev_t)); - -void rf_DiskIOComplete(RF_DiskQueue_t *, RF_DiskQueueData_t *, int); -void rf_CopybackReconstructedData(RF_Raid_t *raidPtr); -int raidinit __P((dev_t,RF_Raid_t *,int)); - int raidopen __P((dev_t, int, int, struct proc *)); int raidclose __P((dev_t, int, int, struct proc *)); int raidioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); @@ -201,10 +184,6 @@ int raidread __P((dev_t, struct uio *, int)); void raidstrategy __P((struct buf *)); int raiddump __P((dev_t, daddr_t, caddr_t, size_t)); -int raidwrite_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); -int raidread_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); -void rf_update_component_labels( RF_Raid_t *); - /* * Pilfered from ccd.c */ @@ -276,7 +255,6 @@ void raidmakedisklabel __P((struct raid_softc *)); int raidlock __P((struct raid_softc *)); void raidunlock __P((struct raid_softc *)); -int raidlookup __P((char *, struct proc *p, struct vnode **)); void rf_markalldirty __P((RF_Raid_t *)); @@ -655,6 +633,9 @@ raidioctl(dev, cmd, data, flag, p) int part, pmask; struct raid_softc *rs; RF_Config_t *k_cfg, *u_cfg; + RF_Raid_t *raidPtr; + RF_AccTotals_t *totals; + RF_DeviceConfig_t *d_cfg, **ucfgp; u_char *specific_buf; int retcode = 0; int row; @@ -666,10 +647,12 @@ raidioctl(dev, cmd, data, flag, p) RF_SingleComponent_t *sparePtr,*componentPtr; RF_SingleComponent_t hot_spare; RF_SingleComponent_t component; + int i, j, d; if (unit >= numraid) return (ENXIO); rs = &raid_softc[unit]; + raidPtr = raidPtrs[unit]; db1_printf(("raidioctl: %d %d %d %d\n", (int)dev, (int)DISKPART(dev), (int)unit, (int)cmd)); @@ -714,11 +697,8 @@ raidioctl(dev, cmd, data, flag, p) } switch (cmd) { - case RAIDFRAME_CONFIGURE: /* Configure the system */ - - db3_printf(("rf_ioctl: RAIDFRAME_CONFIGURE\n")); - + case RAIDFRAME_CONFIGURE: /* * Copy-in the configuration information * data points to a pointer to the configuration structure. @@ -726,17 +706,12 @@ raidioctl(dev, cmd, data, flag, p) u_cfg = *((RF_Config_t **)data); RF_Malloc(k_cfg, sizeof (RF_Config_t), (RF_Config_t *)); if (k_cfg == NULL) { - db3_printf(( - "rf_ioctl: ENOMEM for config. Code is %d\n", - retcode)); return (ENOMEM); } 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); } @@ -748,23 +723,20 @@ raidioctl(dev, cmd, data, flag, p) 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); } RF_Malloc(specific_buf, k_cfg->layoutSpecificSize, (u_char *)); if (specific_buf == NULL) { RF_Free(k_cfg, sizeof (RF_Config_t)); - db3_printf(("rf_ioctl: ENOMEM %d\n", retcode)); return (ENOMEM); } 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)); + RF_Free(specific_buf, + k_cfg->layoutSpecificSize); return (retcode); } } else @@ -778,22 +750,24 @@ raidioctl(dev, cmd, data, flag, p) */ /* configure the system */ - raidPtrs[unit]->raidid = unit; + raidPtr->raidid = unit; - retcode = rf_Configure(raidPtrs[unit], k_cfg); + retcode = rf_Configure(raidPtr, k_cfg); + + if (retcode == 0) { - /* allow this many simultaneous IO's to this RAID device */ - raidPtrs[unit]->openings = RAIDOUTSTANDING; + /* allow this many simultaneous IO's to + this RAID device */ + raidPtr->openings = RAIDOUTSTANDING; - /* XXX should be moved to rf_Configure() */ + /* 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; + raidPtr->copyback_in_progress = 0; + raidPtr->parity_rewrite_in_progress = 0; + raidPtr->recon_in_progress = 0; - if (retcode == 0) { - retcode = raidinit(dev, raidPtrs[unit],unit); - rf_markalldirty( raidPtrs[unit] ); + retcode = raidinit(dev, raidPtr, unit); + rf_markalldirty( raidPtr ); } /* Free the buffers. No return code here. */ @@ -802,9 +776,6 @@ raidioctl(dev, cmd, data, flag, p) } RF_Free(k_cfg, sizeof (RF_Config_t)); - db3_printf(("rf_ioctl: retcode=%d RAIDFRAME_CONFIGURE\n", - retcode)); - return (retcode); case RAIDFRAME_SHUTDOWN: @@ -827,7 +798,7 @@ raidioctl(dev, cmd, data, flag, p) return (EBUSY); } - retcode = rf_Shutdown(raidPtrs[unit]); + retcode = rf_Shutdown(raidPtr); /* It's no longer initialized... */ rs->sc_flags &= ~RAIDF_INITED; @@ -842,9 +813,7 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_GET_COMPONENT_LABEL: c_label_ptr = (RF_ComponentLabel_t **) data; /* need to read the component label for the disk indicated - by row,column in component_label - XXX need to sanity check these values!!! - */ + by row,column in component_label */ /* For practice, let's get it directly fromdisk, rather than from the in-core copy */ @@ -866,14 +835,14 @@ 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 >= raidPtr->numRow) || + (column < 0) || (column >= raidPtr->numCol)) { return(EINVAL); } raidread_component_label( - raidPtrs[unit]->Disks[row][column].dev, - raidPtrs[unit]->raid_cinfo[row][column].ci_vp, + raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, component_label ); retcode = copyout((caddr_t) component_label, @@ -905,8 +874,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 >= raidPtr->numRow) || + (column < 0) || (column >= raidPtr->numCol)) { RF_Free( component_label, sizeof(RF_ComponentLabel_t)); return(EINVAL); } @@ -914,8 +883,8 @@ raidioctl(dev, cmd, data, flag, p) /* XXX this isn't allowed to do anything for now :-) */ #if 0 raidwrite_component_label( - raidPtrs[unit]->Disks[row][column].dev, - raidPtrs[unit]->raid_cinfo[row][column].ci_vp, + raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, component_label ); #endif return (0); @@ -929,23 +898,23 @@ raidioctl(dev, cmd, data, flag, p) set. */ - raidPtrs[unit]->serial_number = component_label->serial_number; + raidPtr->serial_number = component_label->serial_number; /* current version number */ ci_label.version = RF_COMPONENT_LABEL_VERSION; ci_label.serial_number = component_label->serial_number; - ci_label.mod_counter = raidPtrs[unit]->mod_counter; - ci_label.num_rows = raidPtrs[unit]->numRow; - ci_label.num_columns = raidPtrs[unit]->numCol; + ci_label.mod_counter = raidPtr->mod_counter; + ci_label.num_rows = raidPtr->numRow; + ci_label.num_columns = raidPtr->numCol; ci_label.clean = RF_RAID_DIRTY; /* not clean */ ci_label.status = rf_ds_optimal; /* "It's good!" */ - for(row=0;row<raidPtrs[unit]->numRow;row++) { + for(row=0;row<raidPtr->numRow;row++) { ci_label.row = row; - for(column=0;column<raidPtrs[unit]->numCol;column++) { + for(column=0;column<raidPtr->numCol;column++) { ci_label.column = column; raidwrite_component_label( - raidPtrs[unit]->Disks[row][column].dev, - raidPtrs[unit]->raid_cinfo[row][column].ci_vp, + raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, &ci_label ); } } @@ -954,23 +923,21 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_REWRITEPARITY: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->Layout.map->faultsTolerated == 0) { /* Parity for RAID 0 is trivially correct */ - raidPtrs[unit]->parity_good = RF_RAID_CLEAN; + raidPtr->parity_good = RF_RAID_CLEAN; return(0); } - if (raidPtrs[unit]->parity_rewrite_in_progress == 1) { + if (raidPtr->parity_rewrite_in_progress == 1) { /* Re-write is already in progress! */ return(EINVAL); } - /* borrow the thread of the requesting process */ - - retcode = RF_CREATE_THREAD(raidPtrs[unit]->parity_rewrite_thread, + retcode = RF_CREATE_THREAD(raidPtr->parity_rewrite_thread, rf_RewriteParityThread, - raidPtrs[unit],"raid_parity"); + raidPtr,"raid_parity"); return (retcode); @@ -979,7 +946,7 @@ raidioctl(dev, cmd, data, flag, p) sparePtr = (RF_SingleComponent_t *) data; memcpy( &hot_spare, sparePtr, sizeof(RF_SingleComponent_t)); printf("Adding spare\n"); - retcode = rf_add_hot_spare(raidPtrs[unit], &hot_spare); + retcode = rf_add_hot_spare(raidPtr, &hot_spare); return(retcode); case RAIDFRAME_REMOVE_HOT_SPARE: @@ -987,12 +954,12 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_REBUILD_IN_PLACE: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->Layout.map->faultsTolerated == 0) { /* Can't do this on a RAID 0!! */ return(EINVAL); } - if (raidPtrs[unit]->recon_in_progress == 1) { + if (raidPtr->recon_in_progress == 1) { /* a reconstruct is already in progress! */ return(EINVAL); } @@ -1003,8 +970,8 @@ raidioctl(dev, cmd, data, flag, p) 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 >= raidPtr->numRow) || + (column < 0) || (column >= raidPtr->numCol)) { return(EINVAL); } @@ -1012,102 +979,80 @@ raidioctl(dev, cmd, data, flag, p) if (rrcopy == NULL) return(ENOMEM); - rrcopy->raidPtr = (void *) raidPtrs[unit]; + rrcopy->raidPtr = (void *) raidPtr; rrcopy->row = row; rrcopy->col = column; - retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread, + retcode = RF_CREATE_THREAD(raidPtr->recon_thread, rf_ReconstructInPlaceThread, rrcopy,"raid_reconip"); return (retcode); case RAIDFRAME_GET_INFO: - { - RF_Raid_t *raid = raidPtrs[unit]; - RF_DeviceConfig_t *cfg, **ucfgp; - int i, j, d; - - if (!raid->valid) - return (ENODEV); - ucfgp = (RF_DeviceConfig_t **)data; - RF_Malloc(cfg, sizeof (RF_DeviceConfig_t), - (RF_DeviceConfig_t *)); - if (cfg == NULL) - return (ENOMEM); - bzero((char *)cfg, sizeof(RF_DeviceConfig_t)); - cfg->rows = raid->numRow; - cfg->cols = raid->numCol; - cfg->ndevs = raid->numRow * raid->numCol; - if (cfg->ndevs >= RF_MAX_DISKS) { - RF_Free(cfg, sizeof(RF_DeviceConfig_t)); - return (ENOMEM); - } - cfg->nspares = raid->numSpare; - if (cfg->nspares >= RF_MAX_DISKS) { - RF_Free(cfg, sizeof(RF_DeviceConfig_t)); - return (ENOMEM); - } - cfg->maxqdepth = raid->maxQueueDepth; - d = 0; - for(i = 0; i < cfg->rows; i++) { - for(j = 0; j < cfg->cols; j++) { - cfg->devs[d] = raid->Disks[i][j]; - d++; - } - } - for(j = cfg->cols, i = 0; i < cfg->nspares; i++, j++) { - cfg->spares[i] = raid->Disks[0][j]; + if (!raidPtr->valid) + return (ENODEV); + ucfgp = (RF_DeviceConfig_t **) data; + RF_Malloc(d_cfg, sizeof(RF_DeviceConfig_t), + (RF_DeviceConfig_t *)); + if (d_cfg == NULL) + return (ENOMEM); + bzero((char *) d_cfg, sizeof(RF_DeviceConfig_t)); + d_cfg->rows = raidPtr->numRow; + d_cfg->cols = raidPtr->numCol; + d_cfg->ndevs = raidPtr->numRow * raidPtr->numCol; + if (d_cfg->ndevs >= RF_MAX_DISKS) { + RF_Free(d_cfg, sizeof(RF_DeviceConfig_t)); + return (ENOMEM); + } + d_cfg->nspares = raidPtr->numSpare; + if (d_cfg->nspares >= RF_MAX_DISKS) { + RF_Free(d_cfg, sizeof(RF_DeviceConfig_t)); + return (ENOMEM); + } + d_cfg->maxqdepth = raidPtr->maxQueueDepth; + d = 0; + for (i = 0; i < d_cfg->rows; i++) { + for (j = 0; j < d_cfg->cols; j++) { + d_cfg->devs[d] = raidPtr->Disks[i][j]; + d++; } - retcode = copyout((caddr_t)cfg, (caddr_t)*ucfgp, - sizeof (RF_DeviceConfig_t)); - RF_Free(cfg, sizeof (RF_DeviceConfig_t)); - - return (retcode); } - break; + for (j = d_cfg->cols, i = 0; i < d_cfg->nspares; i++, j++) { + d_cfg->spares[i] = raidPtr->Disks[0][j]; + } + retcode = copyout((caddr_t) d_cfg, (caddr_t) * ucfgp, + sizeof(RF_DeviceConfig_t)); + RF_Free(d_cfg, sizeof(RF_DeviceConfig_t)); + + return (retcode); + case RAIDFRAME_CHECK_PARITY: - *(int *) data = raidPtrs[unit]->parity_good; + *(int *) data = raidPtr->parity_good; return (0); case RAIDFRAME_RESET_ACCTOTALS: - { - RF_Raid_t *raid = raidPtrs[unit]; - - bzero(&raid->acc_totals, sizeof(raid->acc_totals)); - return (0); - } - break; - - case RAIDFRAME_GET_ACCTOTALS: - { - RF_AccTotals_t *totals = (RF_AccTotals_t *)data; - RF_Raid_t *raid = raidPtrs[unit]; - - *totals = raid->acc_totals; - return (0); - } - break; - + bzero(&raidPtr->acc_totals, sizeof(raidPtr->acc_totals)); + return (0); + + case RAIDFRAME_GET_ACCTOTALS: + totals = (RF_AccTotals_t *) data; + *totals = raidPtr->acc_totals; + return (0); + case RAIDFRAME_KEEP_ACCTOTALS: - { - RF_Raid_t *raid = raidPtrs[unit]; - int *keep = (int *)data; - - raid->keep_acc_totals = *keep; - return (0); - } - break; - + raidPtr->keep_acc_totals = *(int *)data; + return (0); + case RAIDFRAME_GET_SIZE: - *(int *) data = raidPtrs[unit]->totalSectors; + *(int *) data = raidPtr->totalSectors; return (0); /* fail a disk & optionally start reconstruction */ case RAIDFRAME_FAIL_DISK: rr = (struct rf_recon_req *)data; - if (rr->row < 0 || rr->row >= raidPtrs[unit]->numRow || - rr->col < 0 || rr->col >= raidPtrs[unit]->numCol) + if (rr->row < 0 || rr->row >= raidPtr->numRow || + rr->col < 0 || rr->col >= raidPtr->numCol) return (EINVAL); printf("raid%d: Failing the disk: row: %d col: %d\n", @@ -1121,9 +1066,9 @@ raidioctl(dev, cmd, data, flag, p) if (rrcopy == NULL) return(ENOMEM); bcopy(rr, rrcopy, sizeof(*rr)); - rrcopy->raidPtr = (void *)raidPtrs[unit]; + rrcopy->raidPtr = (void *)raidPtr; - retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread, + retcode = RF_CREATE_THREAD(raidPtr->recon_thread, rf_ReconThread, rrcopy,"raid_recon"); return (0); @@ -1133,44 +1078,53 @@ raidioctl(dev, cmd, data, flag, p) * disk needs it, if any. */ case RAIDFRAME_COPYBACK: - if (raidPtrs[unit]->copyback_in_progress == 1) { + if (raidPtr->Layout.map->faultsTolerated == 0) { + /* This makes no sense on a RAID 0!! */ + return(EINVAL); + } + + if (raidPtr->copyback_in_progress == 1) { /* Copyback is already in progress! */ return(EINVAL); } - retcode = RF_CREATE_THREAD(raidPtrs[unit]->copyback_thread, + retcode = RF_CREATE_THREAD(raidPtr->copyback_thread, rf_CopybackThread, - raidPtrs[unit],"raid_copyback"); + raidPtr,"raid_copyback"); return (retcode); /* Return the percentage completion of reconstruction */ case RAIDFRAME_CHECK_RECON_STATUS: + if (raidPtr->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) + if (raidPtr->status[row] != rf_rs_reconstructing) *(int *)data = 100; else *(int *)data = - raidPtrs[unit]->reconControl[row]->percentComplete; + raidPtr->reconControl[row]->percentComplete; return (0); case RAIDFRAME_CHECK_PARITYREWRITE_STATUS: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->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; + if (raidPtr->parity_rewrite_in_progress == 1) { + *(int *) data = 100 * raidPtr->parity_rewrite_stripes_done / raidPtr->Layout.numStripe; } else { *(int *) data = 100; } return (0); case RAIDFRAME_CHECK_COPYBACK_STATUS: - if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) { + if (raidPtr->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; + if (raidPtr->copyback_in_progress == 1) { + *(int *) data = 100 * raidPtr->copyback_stripes_done / raidPtr->Layout.numStripe; } else { *(int *) data = 100; } @@ -1225,7 +1179,7 @@ raidioctl(dev, cmd, data, flag, p) */ /* Install the spare table */ - retcode = rf_SetSpareTable(raidPtrs[unit],*(void **)data); + retcode = rf_SetSpareTable(raidPtr,*(void **)data); /* * Respond to the requestor. the return status of the @@ -1246,7 +1200,7 @@ raidioctl(dev, cmd, data, flag, p) break; } - if (!raidPtrs[unit]->valid) + if (!raidPtr->valid) return (EINVAL); /* @@ -1296,7 +1250,7 @@ raidioctl(dev, cmd, data, flag, p) #if 0 case DIOCGDEFLABEL: - raidgetdefaultlabel(raidPtrs[unit], rs, + raidgetdefaultlabel(raidPtr, rs, (struct disklabel *) data); break; #endif @@ -1786,9 +1740,10 @@ raidgetdefaultlabel(raidPtr, rs, lp) /* fabricate a label... */ lp->d_secperunit = raidPtr->totalSectors; lp->d_secsize = raidPtr->bytesPerSector; - lp->d_nsectors = 1024 * (1024 / raidPtr->bytesPerSector); + lp->d_nsectors = raidPtr->Layout.dataSectorsPerStripe; lp->d_ntracks = 1; - lp->d_ncylinders = raidPtr->totalSectors / lp->d_nsectors; + lp->d_ncylinders = raidPtr->totalSectors / + (lp->d_nsectors * lp->d_ntracks); lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; strncpy(lp->d_typename, "raid", sizeof(lp->d_typename)); diff --git a/sys/dev/raidframe/rf_paritylog.c b/sys/dev/raidframe/rf_paritylog.c index ce2b3827d56..657bb6db9fa 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.3 2000/01/07 14:50:22 peter Exp $ */ -/* $NetBSD: rf_paritylog.c,v 1.4 1999/08/13 03:41:57 oster Exp $ */ +/* $OpenBSD: rf_paritylog.c,v 1.4 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_paritylog.c,v 1.5 2000/01/07 03:41:01 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -51,7 +51,6 @@ #include "rf_etimer.h" #include "rf_paritylog.h" #include "rf_general.h" -#include "rf_threadid.h" #include "rf_map.h" #include "rf_paritylogging.h" #include "rf_paritylogDiskMgr.h" diff --git a/sys/dev/raidframe/rf_paritylogDiskMgr.c b/sys/dev/raidframe/rf_paritylogDiskMgr.c index 6a9bab06551..41c3417c175 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.3 2000/01/07 14:50:22 peter Exp $ */ -/* $NetBSD: rf_paritylogDiskMgr.c,v 1.4 1999/08/13 03:41:57 oster Exp $ */ +/* $OpenBSD: rf_paritylogDiskMgr.c,v 1.4 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_paritylogDiskMgr.c,v 1.7 2000/01/08 01:18:36 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -45,7 +45,6 @@ #include "rf_diskqueue.h" #include "rf_paritylog.h" #include "rf_general.h" -#include "rf_threadid.h" #include "rf_etimer.h" #include "rf_paritylogging.h" #include "rf_engine.h" @@ -555,8 +554,6 @@ rf_ParityLoggingDiskManager(RF_Raid_t * raidPtr) RF_ParityLog_t *reintQueue, *flushQueue; int workNeeded, done = RF_FALSE; - rf_assign_threadid(); /* don't remove this line */ - /* Main program for parity logging disk thread. This routine waits * for work to appear in either the flush or reintegration queues and * is responsible for flushing core logs to the log disk as well as @@ -644,14 +641,11 @@ rf_ParityLoggingDiskManager(RF_Raid_t * raidPtr) raidPtr->parityLogDiskQueue.threadState |= RF_PLOG_SHUTDOWN; RF_UNLOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex); RF_SIGNAL_COND(raidPtr->parityLogDiskQueue.cond); -#if (defined(__NetBSD__) || defined(__OpenBSD__)) && defined(_KERNEL) + /* * In the Net- & OpenBSD kernel, the thread must exit; returning would * cause the proc trampoline to attempt to return to userspace. */ kthread_exit(0); /* does not return */ -#else - return (0); -#endif } #endif /* RF_INCLUDE_PARITYLOGGING > 0 */ diff --git a/sys/dev/raidframe/rf_paritylogging.c b/sys/dev/raidframe/rf_paritylogging.c index 1c9b988d1c7..65877664637 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.3 2000/01/07 14:50:22 peter Exp $ */ -/* $NetBSD: rf_paritylogging.c,v 1.4 2000/01/05 02:57:29 oster Exp $ */ +/* $OpenBSD: rf_paritylogging.c,v 1.4 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_paritylogging.c,v 1.8 2000/01/09 04:35:13 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -45,7 +45,6 @@ #include "rf_dagffwr.h" #include "rf_dagdegrd.h" #include "rf_dagdegwr.h" -#include "rf_threadid.h" #include "rf_paritylog.h" #include "rf_paritylogDiskMgr.h" #include "rf_paritylogging.h" @@ -82,6 +81,9 @@ rf_ConfigureParityLogging( RF_ParityLog_t *l = NULL, *next; caddr_t lHeapPtr; + if (rf_numParityRegions <= 0) + return(EINVAL); + /* * We create multiple entries on the shutdown list here, since * this configuration routine is fairly complicated in and of @@ -92,7 +94,9 @@ rf_ConfigureParityLogging( raidPtr->numSectorsPerLog = RF_DEFAULT_NUM_SECTORS_PER_LOG; /* create a parity logging configuration structure */ - RF_MallocAndAdd(info, sizeof(RF_ParityLoggingConfigInfo_t), (RF_ParityLoggingConfigInfo_t *), raidPtr->cleanupList); + RF_MallocAndAdd(info, sizeof(RF_ParityLoggingConfigInfo_t), + (RF_ParityLoggingConfigInfo_t *), + raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; @@ -101,14 +105,17 @@ rf_ConfigureParityLogging( /* the stripe identifier must identify the disks in each stripe, IN * THE ORDER THAT THEY APPEAR IN THE STRIPE. */ - info->stripeIdentifier = rf_make_2d_array((raidPtr->numCol), (raidPtr->numCol), raidPtr->cleanupList); + info->stripeIdentifier = rf_make_2d_array((raidPtr->numCol), + (raidPtr->numCol), + raidPtr->cleanupList); if (info->stripeIdentifier == NULL) return (ENOMEM); startdisk = 0; for (i = 0; i < (raidPtr->numCol); i++) { for (j = 0; j < (raidPtr->numCol); j++) { - info->stripeIdentifier[i][j] = (startdisk + j) % (raidPtr->numCol - 1); + info->stripeIdentifier[i][j] = (startdisk + j) % + (raidPtr->numCol - 1); } if ((--startdisk) < 0) startdisk = raidPtr->numCol - 1 - 1; @@ -116,30 +123,40 @@ rf_ConfigureParityLogging( /* fill in the remaining layout parameters */ layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk; - layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector; + layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << + raidPtr->logBytesPerSector; layoutPtr->numParityCol = 1; layoutPtr->numParityLogCol = 1; - layoutPtr->numDataCol = raidPtr->numCol - layoutPtr->numParityCol - layoutPtr->numParityLogCol; - layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit; + layoutPtr->numDataCol = raidPtr->numCol - layoutPtr->numParityCol - + layoutPtr->numParityLogCol; + layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * + layoutPtr->sectorsPerStripeUnit; layoutPtr->dataStripeUnitsPerDisk = layoutPtr->stripeUnitsPerDisk; - raidPtr->sectorsPerDisk = layoutPtr->stripeUnitsPerDisk * layoutPtr->sectorsPerStripeUnit; + raidPtr->sectorsPerDisk = layoutPtr->stripeUnitsPerDisk * + layoutPtr->sectorsPerStripeUnit; - raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit; + raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * + layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit; /* configure parity log parameters * - * parameter comment/constraints ---------------- - * ------------------- numParityRegions all regions (except - * possibly last) of equal size totalInCoreLogCapacity amount of - * memory in bytes available for in-core logs (default 1 MB) # - * numSectorsPerLog capacity of an in-core log in sectors (1 - * disk track) numParityLogs total number of in-core logs, - * should be at least numParityRegions regionLogCapacity size of - * a region log (except possibly last one) in sectors totalLogCapacity - * total amount of log space in sectors + * parameter comment/constraints + * ------------------------------------------- + * numParityRegions* all regions (except possibly last) + * of equal size + * totalInCoreLogCapacity* amount of memory in bytes available + * for in-core logs (default 1 MB) + * numSectorsPerLog# capacity of an in-core log in sectors + * (1 * disk track) + * numParityLogs total number of in-core logs, + * should be at least numParityRegions + * regionLogCapacity size of a region log (except possibly + * last one) in sectors + * totalLogCapacity total amount of log space in sectors * - * denotes a user settable parameter. # logs are fixed to be the size of - * a disk track, value #defined in rf_paritylog.h + * where '*' denotes a user settable parameter. + * Note that logs are fixed to be the size of a disk track, + * value #defined in rf_paritylog.h * */ @@ -154,37 +171,51 @@ rf_ConfigureParityLogging( fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog; if (fragmentation > 0) for (i = 1; i < (raidPtr->numSectorsPerLog / 2); i++) { - if (((totalLogCapacity / (rf_numParityRegions + i)) % raidPtr->numSectorsPerLog) < fragmentation) { + if (((totalLogCapacity / (rf_numParityRegions + i)) % + raidPtr->numSectorsPerLog) < fragmentation) { rf_numParityRegions++; - raidPtr->regionLogCapacity = totalLogCapacity / rf_numParityRegions; - fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog; + raidPtr->regionLogCapacity = totalLogCapacity / + rf_numParityRegions; + fragmentation = raidPtr->regionLogCapacity % + raidPtr->numSectorsPerLog; } - if (((totalLogCapacity / (rf_numParityRegions - i)) % raidPtr->numSectorsPerLog) < fragmentation) { + if (((totalLogCapacity / (rf_numParityRegions - i)) % + raidPtr->numSectorsPerLog) < fragmentation) { rf_numParityRegions--; - raidPtr->regionLogCapacity = totalLogCapacity / rf_numParityRegions; - fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog; + raidPtr->regionLogCapacity = totalLogCapacity / + rf_numParityRegions; + fragmentation = raidPtr->regionLogCapacity % + raidPtr->numSectorsPerLog; } } /* ensure integral number of regions per log */ - raidPtr->regionLogCapacity = (raidPtr->regionLogCapacity / raidPtr->numSectorsPerLog) * raidPtr->numSectorsPerLog; + raidPtr->regionLogCapacity = (raidPtr->regionLogCapacity / + raidPtr->numSectorsPerLog) * + raidPtr->numSectorsPerLog; - raidPtr->numParityLogs = rf_totalInCoreLogCapacity / (raidPtr->bytesPerSector * raidPtr->numSectorsPerLog); + raidPtr->numParityLogs = rf_totalInCoreLogCapacity / + (raidPtr->bytesPerSector * raidPtr->numSectorsPerLog); /* to avoid deadlock, must ensure that enough logs exist for each * region to have one simultaneously */ if (raidPtr->numParityLogs < rf_numParityRegions) raidPtr->numParityLogs = rf_numParityRegions; /* create region information structs */ - RF_Malloc(raidPtr->regionInfo, (rf_numParityRegions * sizeof(RF_RegionInfo_t)), (RF_RegionInfo_t *)); + RF_Malloc(raidPtr->regionInfo, + (rf_numParityRegions * sizeof(RF_RegionInfo_t)), + (RF_RegionInfo_t *)); if (raidPtr->regionInfo == NULL) return (ENOMEM); /* last region may not be full capacity */ lastRegionCapacity = raidPtr->regionLogCapacity; - while ((rf_numParityRegions - 1) * raidPtr->regionLogCapacity + lastRegionCapacity > totalLogCapacity) - lastRegionCapacity = lastRegionCapacity - raidPtr->numSectorsPerLog; + while ((rf_numParityRegions - 1) * raidPtr->regionLogCapacity + + lastRegionCapacity > totalLogCapacity) + lastRegionCapacity = lastRegionCapacity - + raidPtr->numSectorsPerLog; - raidPtr->regionParityRange = raidPtr->sectorsPerDisk / rf_numParityRegions; + raidPtr->regionParityRange = raidPtr->sectorsPerDisk / + rf_numParityRegions; maxRegionParityRange = raidPtr->regionParityRange; /* i can't remember why this line is in the code -wvcii 6/30/95 */ @@ -192,30 +223,43 @@ rf_ConfigureParityLogging( regionParityRange++; */ /* build pool of unused parity logs */ - RF_Malloc(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector, (caddr_t)); + RF_Malloc(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * + raidPtr->numSectorsPerLog * raidPtr->bytesPerSector, + (caddr_t)); if (raidPtr->parityLogBufferHeap == NULL) return (ENOMEM); lHeapPtr = raidPtr->parityLogBufferHeap; rc = rf_mutex_init(&raidPtr->parityLogPool.mutex); if (rc) { - RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); - RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector); + RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); + RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * + raidPtr->numSectorsPerLog * raidPtr->bytesPerSector); return (ENOMEM); } for (i = 0; i < raidPtr->numParityLogs; i++) { if (i == 0) { - RF_Calloc(raidPtr->parityLogPool.parityLogs, 1, sizeof(RF_ParityLog_t), (RF_ParityLog_t *)); + RF_Calloc(raidPtr->parityLogPool.parityLogs, 1, + sizeof(RF_ParityLog_t), (RF_ParityLog_t *)); if (raidPtr->parityLogPool.parityLogs == NULL) { - RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector); + RF_Free(raidPtr->parityLogBufferHeap, + raidPtr->numParityLogs * + raidPtr->numSectorsPerLog * + raidPtr->bytesPerSector); return (ENOMEM); } l = raidPtr->parityLogPool.parityLogs; } else { - RF_Calloc(l->next, 1, sizeof(RF_ParityLog_t), (RF_ParityLog_t *)); + RF_Calloc(l->next, 1, sizeof(RF_ParityLog_t), + (RF_ParityLog_t *)); if (l->next == NULL) { - RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector); - for (l = raidPtr->parityLogPool.parityLogs; l; l = next) { + RF_Free(raidPtr->parityLogBufferHeap, + raidPtr->numParityLogs * + raidPtr->numSectorsPerLog * + raidPtr->bytesPerSector); + for (l = raidPtr->parityLogPool.parityLogs; + l; + l = next) { next = l->next; if (l->records) RF_Free(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t))); @@ -226,14 +270,24 @@ rf_ConfigureParityLogging( l = l->next; } l->bufPtr = lHeapPtr; - lHeapPtr += raidPtr->numSectorsPerLog * raidPtr->bytesPerSector; - RF_Malloc(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t)), (RF_ParityLogRecord_t *)); + lHeapPtr += raidPtr->numSectorsPerLog * + raidPtr->bytesPerSector; + RF_Malloc(l->records, (raidPtr->numSectorsPerLog * + sizeof(RF_ParityLogRecord_t)), + (RF_ParityLogRecord_t *)); if (l->records == NULL) { - RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector); - for (l = raidPtr->parityLogPool.parityLogs; l; l = next) { + RF_Free(raidPtr->parityLogBufferHeap, + raidPtr->numParityLogs * + raidPtr->numSectorsPerLog * + raidPtr->bytesPerSector); + for (l = raidPtr->parityLogPool.parityLogs; + l; + l = next) { next = l->next; if (l->records) - RF_Free(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t))); + RF_Free(l->records, + (raidPtr->numSectorsPerLog * + sizeof(RF_ParityLogRecord_t))); RF_Free(l, sizeof(RF_ParityLog_t)); } return (ENOMEM); @@ -249,46 +303,60 @@ rf_ConfigureParityLogging( /* build pool of region buffers */ rc = rf_mutex_init(&raidPtr->regionBufferPool.mutex); if (rc) { - RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); + RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); return (ENOMEM); } rc = rf_cond_init(&raidPtr->regionBufferPool.cond); if (rc) { - RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); + RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); rf_mutex_destroy(&raidPtr->regionBufferPool.mutex); return (ENOMEM); } - raidPtr->regionBufferPool.bufferSize = raidPtr->regionLogCapacity * raidPtr->bytesPerSector; - printf("regionBufferPool.bufferSize %d\n", raidPtr->regionBufferPool.bufferSize); - raidPtr->regionBufferPool.totalBuffers = 1; /* for now, only one - * region at a time may - * be reintegrated */ - raidPtr->regionBufferPool.availableBuffers = raidPtr->regionBufferPool.totalBuffers; + raidPtr->regionBufferPool.bufferSize = raidPtr->regionLogCapacity * + raidPtr->bytesPerSector; + printf("regionBufferPool.bufferSize %d\n", + raidPtr->regionBufferPool.bufferSize); + + /* for now, only one region at a time may be reintegrated */ + raidPtr->regionBufferPool.totalBuffers = 1; + + raidPtr->regionBufferPool.availableBuffers = + raidPtr->regionBufferPool.totalBuffers; raidPtr->regionBufferPool.availBuffersIndex = 0; raidPtr->regionBufferPool.emptyBuffersIndex = 0; - RF_Malloc(raidPtr->regionBufferPool.buffers, raidPtr->regionBufferPool.totalBuffers * sizeof(caddr_t), (caddr_t *)); + RF_Malloc(raidPtr->regionBufferPool.buffers, + raidPtr->regionBufferPool.totalBuffers * sizeof(caddr_t), + (caddr_t *)); if (raidPtr->regionBufferPool.buffers == NULL) { rf_mutex_destroy(&raidPtr->regionBufferPool.mutex); rf_cond_destroy(&raidPtr->regionBufferPool.cond); return (ENOMEM); } for (i = 0; i < raidPtr->regionBufferPool.totalBuffers; i++) { - RF_Malloc(raidPtr->regionBufferPool.buffers[i], raidPtr->regionBufferPool.bufferSize * sizeof(char), (caddr_t)); - if (raidPtr->regionBufferPool.buffers == NULL) { + RF_Malloc(raidPtr->regionBufferPool.buffers[i], + raidPtr->regionBufferPool.bufferSize * sizeof(char), + (caddr_t)); + if (raidPtr->regionBufferPool.buffers[i] == NULL) { rf_mutex_destroy(&raidPtr->regionBufferPool.mutex); rf_cond_destroy(&raidPtr->regionBufferPool.cond); for (j = 0; j < i; j++) { - RF_Free(raidPtr->regionBufferPool.buffers[i], raidPtr->regionBufferPool.bufferSize * sizeof(char)); + RF_Free(raidPtr->regionBufferPool.buffers[i], + raidPtr->regionBufferPool.bufferSize * + sizeof(char)); } - RF_Free(raidPtr->regionBufferPool.buffers, raidPtr->regionBufferPool.totalBuffers * sizeof(caddr_t)); + RF_Free(raidPtr->regionBufferPool.buffers, + raidPtr->regionBufferPool.totalBuffers * + sizeof(caddr_t)); return (ENOMEM); } printf("raidPtr->regionBufferPool.buffers[%d] = %lx\n", i, (long) raidPtr->regionBufferPool.buffers[i]); } - rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingRegionBufferPool, raidPtr); + rc = rf_ShutdownCreate(listp, + rf_ShutdownParityLoggingRegionBufferPool, + raidPtr); if (rc) { RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__, __LINE__, rc); @@ -299,46 +367,60 @@ rf_ConfigureParityLogging( parityBufferCapacity = maxRegionParityRange; rc = rf_mutex_init(&raidPtr->parityBufferPool.mutex); if (rc) { - RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); + RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); return (rc); } rc = rf_cond_init(&raidPtr->parityBufferPool.cond); if (rc) { - RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); + RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); rf_mutex_destroy(&raidPtr->parityBufferPool.mutex); return (ENOMEM); } - raidPtr->parityBufferPool.bufferSize = parityBufferCapacity * raidPtr->bytesPerSector; - printf("parityBufferPool.bufferSize %d\n", raidPtr->parityBufferPool.bufferSize); - raidPtr->parityBufferPool.totalBuffers = 1; /* for now, only one - * region at a time may - * be reintegrated */ - raidPtr->parityBufferPool.availableBuffers = raidPtr->parityBufferPool.totalBuffers; + raidPtr->parityBufferPool.bufferSize = parityBufferCapacity * + raidPtr->bytesPerSector; + printf("parityBufferPool.bufferSize %d\n", + raidPtr->parityBufferPool.bufferSize); + + /* for now, only one region at a time may be reintegrated */ + raidPtr->parityBufferPool.totalBuffers = 1; + + raidPtr->parityBufferPool.availableBuffers = + raidPtr->parityBufferPool.totalBuffers; raidPtr->parityBufferPool.availBuffersIndex = 0; raidPtr->parityBufferPool.emptyBuffersIndex = 0; - RF_Malloc(raidPtr->parityBufferPool.buffers, raidPtr->parityBufferPool.totalBuffers * sizeof(caddr_t), (caddr_t *)); + RF_Malloc(raidPtr->parityBufferPool.buffers, + raidPtr->parityBufferPool.totalBuffers * sizeof(caddr_t), + (caddr_t *)); if (raidPtr->parityBufferPool.buffers == NULL) { rf_mutex_destroy(&raidPtr->parityBufferPool.mutex); rf_cond_destroy(&raidPtr->parityBufferPool.cond); return (ENOMEM); } for (i = 0; i < raidPtr->parityBufferPool.totalBuffers; i++) { - RF_Malloc(raidPtr->parityBufferPool.buffers[i], raidPtr->parityBufferPool.bufferSize * sizeof(char), (caddr_t)); + RF_Malloc(raidPtr->parityBufferPool.buffers[i], + raidPtr->parityBufferPool.bufferSize * sizeof(char), + (caddr_t)); if (raidPtr->parityBufferPool.buffers == NULL) { rf_mutex_destroy(&raidPtr->parityBufferPool.mutex); rf_cond_destroy(&raidPtr->parityBufferPool.cond); for (j = 0; j < i; j++) { - RF_Free(raidPtr->parityBufferPool.buffers[i], raidPtr->regionBufferPool.bufferSize * sizeof(char)); + RF_Free(raidPtr->parityBufferPool.buffers[i], + raidPtr->regionBufferPool.bufferSize * + sizeof(char)); } - RF_Free(raidPtr->parityBufferPool.buffers, raidPtr->regionBufferPool.totalBuffers * sizeof(caddr_t)); + RF_Free(raidPtr->parityBufferPool.buffers, + raidPtr->regionBufferPool.totalBuffers * + sizeof(caddr_t)); return (ENOMEM); } printf("parityBufferPool.buffers[%d] = %lx\n", i, (long) raidPtr->parityBufferPool.buffers[i]); } - rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingParityBufferPool, raidPtr); + rc = rf_ShutdownCreate(listp, + rf_ShutdownParityLoggingParityBufferPool, + raidPtr); if (rc) { RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__, __LINE__, rc); @@ -346,16 +428,17 @@ rf_ConfigureParityLogging( return (rc); } /* initialize parityLogDiskQueue */ - rc = rf_create_managed_mutex(listp, &raidPtr->parityLogDiskQueue.mutex); + rc = rf_create_managed_mutex(listp, + &raidPtr->parityLogDiskQueue.mutex); if (rc) { - RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); + RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); return (rc); } rc = rf_create_managed_cond(listp, &raidPtr->parityLogDiskQueue.cond); if (rc) { - RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); + RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); return (rc); } raidPtr->parityLogDiskQueue.flushQueue = NULL; @@ -371,7 +454,9 @@ rf_ConfigureParityLogging( raidPtr->parityLogDiskQueue.freeDataList = NULL; raidPtr->parityLogDiskQueue.freeCommonList = NULL; - rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingDiskQueue, raidPtr); + rc = rf_ShutdownCreate(listp, + rf_ShutdownParityLoggingDiskQueue, + raidPtr); if (rc) { RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__, __LINE__, rc); @@ -384,7 +469,9 @@ rf_ConfigureParityLogging( __LINE__, rc); for (j = 0; j < i; j++) FreeRegionInfo(raidPtr, j); - RF_Free(raidPtr->regionInfo, (rf_numParityRegions * sizeof(RF_RegionInfo_t))); + RF_Free(raidPtr->regionInfo, + (rf_numParityRegions * + sizeof(RF_RegionInfo_t))); return (ENOMEM); } rc = rf_mutex_init(&raidPtr->regionInfo[i].reintMutex); @@ -394,37 +481,59 @@ rf_ConfigureParityLogging( rf_mutex_destroy(&raidPtr->regionInfo[i].mutex); for (j = 0; j < i; j++) FreeRegionInfo(raidPtr, j); - RF_Free(raidPtr->regionInfo, (rf_numParityRegions * sizeof(RF_RegionInfo_t))); + RF_Free(raidPtr->regionInfo, + (rf_numParityRegions * + sizeof(RF_RegionInfo_t))); return (ENOMEM); } raidPtr->regionInfo[i].reintInProgress = RF_FALSE; - raidPtr->regionInfo[i].regionStartAddr = raidPtr->regionLogCapacity * i; - raidPtr->regionInfo[i].parityStartAddr = raidPtr->regionParityRange * i; + raidPtr->regionInfo[i].regionStartAddr = + raidPtr->regionLogCapacity * i; + raidPtr->regionInfo[i].parityStartAddr = + raidPtr->regionParityRange * i; if (i < rf_numParityRegions - 1) { - raidPtr->regionInfo[i].capacity = raidPtr->regionLogCapacity; - raidPtr->regionInfo[i].numSectorsParity = raidPtr->regionParityRange; + raidPtr->regionInfo[i].capacity = + raidPtr->regionLogCapacity; + raidPtr->regionInfo[i].numSectorsParity = + raidPtr->regionParityRange; } else { - raidPtr->regionInfo[i].capacity = lastRegionCapacity; - raidPtr->regionInfo[i].numSectorsParity = raidPtr->sectorsPerDisk - raidPtr->regionParityRange * i; - if (raidPtr->regionInfo[i].numSectorsParity > maxRegionParityRange) - maxRegionParityRange = raidPtr->regionInfo[i].numSectorsParity; + raidPtr->regionInfo[i].capacity = + lastRegionCapacity; + raidPtr->regionInfo[i].numSectorsParity = + raidPtr->sectorsPerDisk - + raidPtr->regionParityRange * i; + if (raidPtr->regionInfo[i].numSectorsParity > + maxRegionParityRange) + maxRegionParityRange = + raidPtr->regionInfo[i].numSectorsParity; } raidPtr->regionInfo[i].diskCount = 0; - RF_ASSERT(raidPtr->regionInfo[i].capacity + raidPtr->regionInfo[i].regionStartAddr <= totalLogCapacity); - RF_ASSERT(raidPtr->regionInfo[i].parityStartAddr + raidPtr->regionInfo[i].numSectorsParity <= raidPtr->sectorsPerDisk); - RF_Malloc(raidPtr->regionInfo[i].diskMap, (raidPtr->regionInfo[i].capacity * sizeof(RF_DiskMap_t)), (RF_DiskMap_t *)); + RF_ASSERT(raidPtr->regionInfo[i].capacity + + raidPtr->regionInfo[i].regionStartAddr <= + totalLogCapacity); + RF_ASSERT(raidPtr->regionInfo[i].parityStartAddr + + raidPtr->regionInfo[i].numSectorsParity <= + raidPtr->sectorsPerDisk); + RF_Malloc(raidPtr->regionInfo[i].diskMap, + (raidPtr->regionInfo[i].capacity * + sizeof(RF_DiskMap_t)), + (RF_DiskMap_t *)); if (raidPtr->regionInfo[i].diskMap == NULL) { rf_mutex_destroy(&raidPtr->regionInfo[i].mutex); rf_mutex_destroy(&raidPtr->regionInfo[i].reintMutex); for (j = 0; j < i; j++) FreeRegionInfo(raidPtr, j); - RF_Free(raidPtr->regionInfo, (rf_numParityRegions * sizeof(RF_RegionInfo_t))); + RF_Free(raidPtr->regionInfo, + (rf_numParityRegions * + sizeof(RF_RegionInfo_t))); return (ENOMEM); } raidPtr->regionInfo[i].loggingEnabled = RF_FALSE; raidPtr->regionInfo[i].coreLog = NULL; } - rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingRegionInfo, raidPtr); + rc = rf_ShutdownCreate(listp, + rf_ShutdownParityLoggingRegionInfo, + raidPtr); if (rc) { RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__, __LINE__, rc); @@ -433,7 +542,8 @@ rf_ConfigureParityLogging( } RF_ASSERT(raidPtr->parityLogDiskQueue.threadState == 0); raidPtr->parityLogDiskQueue.threadState = RF_PLOG_CREATED; - rc = RF_CREATE_THREAD(raidPtr->pLogDiskThreadHandle, rf_ParityLoggingDiskManager, raidPtr,"rf_log"); + 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", @@ -443,7 +553,8 @@ rf_ConfigureParityLogging( /* wait for thread to start */ RF_LOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex); while (!(raidPtr->parityLogDiskQueue.threadState & RF_PLOG_RUNNING)) { - RF_WAIT_COND(raidPtr->parityLogDiskQueue.cond, raidPtr->parityLogDiskQueue.mutex); + RF_WAIT_COND(raidPtr->parityLogDiskQueue.cond, + raidPtr->parityLogDiskQueue.mutex); } RF_UNLOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex); @@ -474,9 +585,12 @@ FreeRegionInfo( RF_RegionId_t regionID) { RF_LOCK_MUTEX(raidPtr->regionInfo[regionID].mutex); - RF_Free(raidPtr->regionInfo[regionID].diskMap, (raidPtr->regionInfo[regionID].capacity * sizeof(RF_DiskMap_t))); + RF_Free(raidPtr->regionInfo[regionID].diskMap, + (raidPtr->regionInfo[regionID].capacity * + sizeof(RF_DiskMap_t))); if (!rf_forceParityLogReint && raidPtr->regionInfo[regionID].coreLog) { - rf_ReleaseParityLogs(raidPtr, raidPtr->regionInfo[regionID].coreLog); + rf_ReleaseParityLogs(raidPtr, + raidPtr->regionInfo[regionID].coreLog); raidPtr->regionInfo[regionID].coreLog = NULL; } else { RF_ASSERT(raidPtr->regionInfo[regionID].coreLog == NULL); @@ -500,7 +614,8 @@ FreeParityLogQueue( while (l1) { l2 = l1; l1 = l2->next; - RF_Free(l2->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t))); + RF_Free(l2->records, (raidPtr->numSectorsPerLog * + sizeof(RF_ParityLogRecord_t))); RF_Free(l2, sizeof(RF_ParityLog_t)); } RF_UNLOCK_MUTEX(queue->mutex); @@ -533,14 +648,14 @@ rf_ShutdownParityLoggingRegionInfo(RF_ThreadArg_t arg) raidPtr = (RF_Raid_t *) arg; if (rf_parityLogDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] ShutdownParityLoggingRegionInfo\n", tid); + printf("raid%d: ShutdownParityLoggingRegionInfo\n", + raidPtr->raidid); } /* free region information structs */ for (i = 0; i < rf_numParityRegions; i++) FreeRegionInfo(raidPtr, i); - RF_Free(raidPtr->regionInfo, (rf_numParityRegions * sizeof(raidPtr->regionInfo))); + RF_Free(raidPtr->regionInfo, (rf_numParityRegions * + sizeof(raidPtr->regionInfo))); raidPtr->regionInfo = NULL; } @@ -551,13 +666,12 @@ rf_ShutdownParityLoggingPool(RF_ThreadArg_t arg) raidPtr = (RF_Raid_t *) arg; if (rf_parityLogDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] ShutdownParityLoggingPool\n", tid); + printf("raid%d: ShutdownParityLoggingPool\n", raidPtr->raidid); } /* free contents of parityLogPool */ FreeParityLogQueue(raidPtr, &raidPtr->parityLogPool); - RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector); + RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * + raidPtr->numSectorsPerLog * raidPtr->bytesPerSector); } static void @@ -567,9 +681,8 @@ rf_ShutdownParityLoggingRegionBufferPool(RF_ThreadArg_t arg) raidPtr = (RF_Raid_t *) arg; if (rf_parityLogDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] ShutdownParityLoggingRegionBufferPool\n", tid); + printf("raid%d: ShutdownParityLoggingRegionBufferPool\n", + raidPtr->raidid); } FreeRegionBufferQueue(&raidPtr->regionBufferPool); } @@ -581,9 +694,8 @@ rf_ShutdownParityLoggingParityBufferPool(RF_ThreadArg_t arg) raidPtr = (RF_Raid_t *) arg; if (rf_parityLogDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] ShutdownParityLoggingParityBufferPool\n", tid); + printf("raid%d: ShutdownParityLoggingParityBufferPool\n", + raidPtr->raidid); } FreeRegionBufferQueue(&raidPtr->parityBufferPool); } @@ -597,9 +709,8 @@ rf_ShutdownParityLoggingDiskQueue(RF_ThreadArg_t arg) raidPtr = (RF_Raid_t *) arg; if (rf_parityLogDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] ShutdownParityLoggingDiskQueue\n", tid); + printf("raid%d: ShutdownParityLoggingDiskQueue\n", + raidPtr->raidid); } /* free disk manager stuff */ RF_ASSERT(raidPtr->parityLogDiskQueue.bufHead == NULL); @@ -608,13 +719,15 @@ rf_ShutdownParityLoggingDiskQueue(RF_ThreadArg_t arg) RF_ASSERT(raidPtr->parityLogDiskQueue.reintTail == NULL); while (raidPtr->parityLogDiskQueue.freeDataList) { d = raidPtr->parityLogDiskQueue.freeDataList; - raidPtr->parityLogDiskQueue.freeDataList = raidPtr->parityLogDiskQueue.freeDataList->next; + raidPtr->parityLogDiskQueue.freeDataList = + raidPtr->parityLogDiskQueue.freeDataList->next; RF_Free(d, sizeof(RF_ParityLogData_t)); } while (raidPtr->parityLogDiskQueue.freeCommonList) { c = raidPtr->parityLogDiskQueue.freeCommonList; rf_mutex_destroy(&c->mutex); - raidPtr->parityLogDiskQueue.freeCommonList = raidPtr->parityLogDiskQueue.freeCommonList->next; + raidPtr->parityLogDiskQueue.freeCommonList = + raidPtr->parityLogDiskQueue.freeCommonList->next; RF_Free(c, sizeof(RF_CommonLogData_t)); } } @@ -626,9 +739,7 @@ rf_ShutdownParityLogging(RF_ThreadArg_t arg) raidPtr = (RF_Raid_t *) arg; if (rf_parityLogDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] ShutdownParityLogging\n", tid); + printf("raid%d: ShutdownParityLogging\n", raidPtr->raidid); } /* shutdown disk thread */ /* This has the desirable side-effect of forcing all regions to be @@ -645,13 +756,12 @@ rf_ShutdownParityLogging(RF_ThreadArg_t arg) */ RF_LOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex); while (!(raidPtr->parityLogDiskQueue.threadState & RF_PLOG_SHUTDOWN)) { - RF_WAIT_COND(raidPtr->parityLogDiskQueue.cond, raidPtr->parityLogDiskQueue.mutex); + RF_WAIT_COND(raidPtr->parityLogDiskQueue.cond, + raidPtr->parityLogDiskQueue.mutex); } RF_UNLOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex); if (rf_parityLogDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] ShutdownParityLogging done (thread completed)\n", tid); + printf("raid%d: ShutdownParityLogging done (thread completed)\n", raidPtr->raidid); } } @@ -681,7 +791,8 @@ rf_MapRegionIDParityLogging( regionID--; } RF_ASSERT(address >= raidPtr->regionInfo[regionID].parityStartAddr); - RF_ASSERT(address < raidPtr->regionInfo[regionID].parityStartAddr + raidPtr->regionInfo[regionID].numSectorsParity); + RF_ASSERT(address < raidPtr->regionInfo[regionID].parityStartAddr + + raidPtr->regionInfo[regionID].numSectorsParity); RF_ASSERT(regionID < rf_numParityRegions); return (regionID); } @@ -697,12 +808,14 @@ rf_MapSectorParityLogging( RF_SectorNum_t * diskSector, int remap) { - RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit; + RF_StripeNum_t SUID = raidSector / + raidPtr->Layout.sectorsPerStripeUnit; *row = 0; /* *col = (SUID % (raidPtr->numCol - * raidPtr->Layout.numParityLogCol)); */ *col = SUID % raidPtr->Layout.numDataCol; - *diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit + + *diskSector = (SUID / (raidPtr->Layout.numDataCol)) * + raidPtr->Layout.sectorsPerStripeUnit + (raidSector % raidPtr->Layout.sectorsPerStripeUnit); } @@ -717,14 +830,16 @@ rf_MapParityParityLogging( RF_SectorNum_t * diskSector, int remap) { - RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit; + RF_StripeNum_t SUID = raidSector / + raidPtr->Layout.sectorsPerStripeUnit; *row = 0; /* *col = * raidPtr->Layout.numDataCol-(SUID/raidPtr->Layout.numDataCol)%(raidPt * r->numCol - raidPtr->Layout.numParityLogCol); */ *col = raidPtr->Layout.numDataCol; - *diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit + + *diskSector = (SUID / (raidPtr->Layout.numDataCol)) * + raidPtr->Layout.sectorsPerStripeUnit + (raidSector % raidPtr->Layout.sectorsPerStripeUnit); } @@ -745,7 +860,8 @@ rf_MapLogParityLogging( } -/* given a regionID, determine the physical disk address of the logged parity for that region */ +/* given a regionID, determine the physical disk address of the logged + parity for that region */ void rf_MapRegionParity( RF_Raid_t * raidPtr, @@ -762,7 +878,8 @@ rf_MapRegionParity( } -/* given a logical RAID address, determine the participating disks in the stripe */ +/* given a logical RAID address, determine the participating disks in + the stripe */ void rf_IdentifyStripeParityLogging( RF_Raid_t * raidPtr, @@ -770,8 +887,10 @@ rf_IdentifyStripeParityLogging( RF_RowCol_t ** diskids, RF_RowCol_t * outRow) { - RF_StripeNum_t stripeID = rf_RaidAddressToStripeID(&raidPtr->Layout, addr); - RF_ParityLoggingConfigInfo_t *info = (RF_ParityLoggingConfigInfo_t *) raidPtr->Layout.layoutSpecificInfo; + RF_StripeNum_t stripeID = rf_RaidAddressToStripeID(&raidPtr->Layout, + addr); + RF_ParityLoggingConfigInfo_t *info = (RF_ParityLoggingConfigInfo_t *) + raidPtr->Layout.layoutSpecificInfo; *outRow = 0; *diskids = info->stripeIdentifier[stripeID % raidPtr->numCol]; } @@ -805,7 +924,6 @@ rf_ParityLoggingDagSelect( RF_RowCol_t frow, fcol; RF_RowStatus_t rstat; int prior_recon; - int tid; RF_ASSERT(RF_IO_IS_R_OR_W(type)); @@ -830,8 +948,9 @@ rf_ParityLoggingDagSelect( if (prior_recon) { RF_RowCol_t or = failedPDA->row, oc = failedPDA->col; RF_SectorNum_t oo = failedPDA->startSector; - if (layoutPtr->map->flags & RF_DISTRIBUTE_SPARE) { /* redirect to dist - * spare space */ + if (layoutPtr->map->flags & + RF_DISTRIBUTE_SPARE) { + /* redirect to dist spare space */ if (failedPDA == asmp->parityInfo) { @@ -862,8 +981,8 @@ rf_ParityLoggingDagSelect( } - } else { /* redirect to dedicated spare - * space */ + } else { + /* redirect to dedicated spare space */ failedPDA->row = raidPtr->Disks[frow][fcol].spareRow; failedPDA->col = raidPtr->Disks[frow][fcol].spareCol; @@ -876,8 +995,7 @@ rf_ParityLoggingDagSelect( failedPDA->next->row = failedPDA->row; failedPDA->next->col = failedPDA->col; } else - if (failedPDA == asmp->parityInfo->next) { /* paranoid: should - * never occur */ + if (failedPDA == asmp->parityInfo->next) { /* paranoid: should never occur */ asmp->parityInfo->row = failedPDA->row; asmp->parityInfo->col = failedPDA->col; } @@ -887,9 +1005,8 @@ rf_ParityLoggingDagSelect( RF_ASSERT(failedPDA->col != -1); if (rf_dagDebug || rf_mapDebug) { - rf_get_threadid(tid); - printf("[%d] Redirected type '%c' r %d c %d o %ld -> r %d c %d o %ld\n", - tid, type, or, oc, (long) oo, failedPDA->row, failedPDA->col, (long) failedPDA->startSector); + printf("raid%d: Redirected type '%c' r %d c %d o %ld -> r %d c %d o %ld\n", + raidPtr->raidid, type, or, oc, (long) oo, failedPDA->row, failedPDA->col, (long) failedPDA->startSector); } asmp->numDataFailed = asmp->numParityFailed = 0; } @@ -913,8 +1030,11 @@ rf_ParityLoggingDagSelect( * when G is 3 or 4, numDataCol/2 is 1, and I want * single-stripe-unit updates to use just one disk. */ if ((asmp->numDataFailed + asmp->numParityFailed) == 0) { - if (((asmp->numStripeUnitsAccessed <= (layoutPtr->numDataCol / 2)) && (layoutPtr->numDataCol != 1)) || - (asmp->parityInfo->next != NULL) || rf_CheckStripeForFailures(raidPtr, asmp)) { + if (((asmp->numStripeUnitsAccessed <= + (layoutPtr->numDataCol / 2)) && + (layoutPtr->numDataCol != 1)) || + (asmp->parityInfo->next != NULL) || + rf_CheckStripeForFailures(raidPtr, asmp)) { *createFunc = (RF_VoidFuncPtr) rf_CreateParityLoggingSmallWriteDAG; } else *createFunc = (RF_VoidFuncPtr) rf_CreateParityLoggingLargeWriteDAG; diff --git a/sys/dev/raidframe/rf_parityloggingdags.c b/sys/dev/raidframe/rf_parityloggingdags.c index 921a80e03f3..cd7cd3c6be6 100644 --- a/sys/dev/raidframe/rf_parityloggingdags.c +++ b/sys/dev/raidframe/rf_parityloggingdags.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_parityloggingdags.c,v 1.2 1999/02/16 00:03:08 niklas Exp $ */ -/* $NetBSD: rf_parityloggingdags.c,v 1.3 1999/02/05 00:06:14 oster Exp $ */ +/* $OpenBSD: rf_parityloggingdags.c,v 1.3 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_parityloggingdags.c,v 1.4 2000/01/07 03:41:04 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -40,7 +40,6 @@ #include "rf_dag.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_debugMem.h" #include "rf_paritylog.h" #include "rf_memchunk.h" diff --git a/sys/dev/raidframe/rf_pq.c b/sys/dev/raidframe/rf_pq.c index cdc21edfff6..06a04287e16 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.4 2000/01/07 14:50:22 peter Exp $ */ -/* $NetBSD: rf_pq.c,v 1.6 1999/08/15 03:44:46 oster Exp $ */ +/* $OpenBSD: rf_pq.c,v 1.5 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_pq.c,v 1.7 2000/01/07 03:41:02 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -41,7 +41,6 @@ #include "rf_dagdegwr.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_etimer.h" #include "rf_pqdeg.h" #include "rf_general.h" diff --git a/sys/dev/raidframe/rf_pqdeg.c b/sys/dev/raidframe/rf_pqdeg.c index f597777a6c8..6cfbebc4430 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.3 2000/01/07 14:50:22 peter Exp $ */ -/* $NetBSD: rf_pqdeg.c,v 1.4 1999/08/15 02:36:40 oster Exp $ */ +/* $OpenBSD: rf_pqdeg.c,v 1.4 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_pqdeg.c,v 1.5 2000/01/07 03:41:04 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -40,7 +40,6 @@ #include "rf_dagffwr.h" #include "rf_dagdegrd.h" #include "rf_dagdegwr.h" -#include "rf_threadid.h" #include "rf_etimer.h" #include "rf_pqdeg.h" #include "rf_general.h" diff --git a/sys/dev/raidframe/rf_psstatus.c b/sys/dev/raidframe/rf_psstatus.c index 7383354236e..c602e152fd8 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.3 2000/01/07 14:50:22 peter Exp $ */ -/* $NetBSD: rf_psstatus.c,v 1.4 1999/08/13 03:41:57 oster Exp $ */ +/* $OpenBSD: rf_psstatus.c,v 1.4 2000/01/11 18:02:22 peter Exp $ */ +/* $NetBSD: rf_psstatus.c,v 1.5 2000/01/08 22:57:31 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -39,7 +39,6 @@ #include "rf_types.h" #include "rf_raid.h" -#include "rf_threadid.h" #include "rf_general.h" #include "rf_debugprint.h" #include "rf_freelist.h" @@ -210,11 +209,10 @@ rf_LookupRUStatus( * specifying */ } if (p && (flags & RF_PSS_RECON_BLOCKED)) { - int tid; - rf_get_threadid(tid); p->blockCount++;/* if we're asking to block recon, bump the * count */ - Dprintf3("[%d] Blocked recon on psid %ld. count now %d\n", tid, psID, p->blockCount); + Dprintf3("raid%d: Blocked recon on psid %ld. count now %d\n", + raidPtr->raidid, psID, p->blockCount); } return (p); } diff --git a/sys/dev/raidframe/rf_raid0.c b/sys/dev/raidframe/rf_raid0.c index c26ae1509cf..be28e945deb 100644 --- a/sys/dev/raidframe/rf_raid0.c +++ b/sys/dev/raidframe/rf_raid0.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_raid0.c,v 1.2 1999/02/16 00:03:13 niklas Exp $ */ -/* $NetBSD: rf_raid0.c,v 1.3 1999/02/05 00:06:15 oster Exp $ */ +/* $OpenBSD: rf_raid0.c,v 1.3 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_raid0.c,v 1.4 2000/01/07 03:41:02 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -41,7 +41,6 @@ #include "rf_dagffwr.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_general.h" #include "rf_configure.h" #include "rf_parityscan.h" diff --git a/sys/dev/raidframe/rf_raid1.c b/sys/dev/raidframe/rf_raid1.c index 33f1e7c2962..aad180d4e33 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.3 2000/01/07 14:50:22 peter Exp $ */ -/* $NetBSD: rf_raid1.c,v 1.4 1999/08/13 03:41:57 oster Exp $ */ +/* $OpenBSD: rf_raid1.c,v 1.4 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_raid1.c,v 1.5 2000/01/08 22:57:30 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -41,7 +41,6 @@ #include "rf_dagdegrd.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_diskqueue.h" #include "rf_general.h" #include "rf_utils.h" @@ -196,7 +195,7 @@ rf_RAID1DagSelect( { RF_RowCol_t frow, fcol, or, oc; RF_PhysDiskAddr_t *failedPDA; - int prior_recon, tid; + int prior_recon; RF_RowStatus_t rstat; RF_SectorNum_t oo; @@ -252,9 +251,10 @@ rf_RAID1DagSelect( } } if (rf_dagDebug || rf_mapDebug) { - rf_get_threadid(tid); - printf("[%d] Redirected type '%c' r %d c %d o %ld -> r %d c %d o %ld\n", - tid, type, or, oc, (long) oo, failedPDA->row, failedPDA->col, + printf("raid%d: Redirected type '%c' r %d c %d o %ld -> r %d c %d o %ld\n", + raidPtr->raidid, type, or, oc, + (long) oo, failedPDA->row, + failedPDA->col, (long) failedPDA->startSector); } asmap->numDataFailed = asmap->numParityFailed = 0; @@ -278,7 +278,7 @@ rf_VerifyParityRAID1( int correct_it, RF_RaidAccessFlags_t flags) { - int nbytes, bcount, stripeWidth, ret, i, j, tid = 0, nbad, *bbufs; + int nbytes, bcount, stripeWidth, ret, i, j, nbad, *bbufs; RF_DagNode_t *blockNode, *unblockNode, *wrBlock; RF_DagHeader_t *rd_dag_h, *wr_dag_h; RF_AccessStripeMapHeader_t *asm_h; @@ -294,9 +294,6 @@ rf_VerifyParityRAID1( RF_StripeNum_t psID; RF_MCPair_t *mcpair; - if (rf_verifyParityDebug) { - rf_get_threadid(tid); - } layoutPtr = &raidPtr->Layout; startAddr = rf_RaidAddressOfPrevStripeBoundary(layoutPtr, raidAddr); nsector = parityPDA->numSector; @@ -322,8 +319,9 @@ rf_VerifyParityRAID1( if (buf == NULL) goto done; if (rf_verifyParityDebug) { - printf("[%d] RAID1 parity verify: buf=%lx bcount=%d (%lx - %lx)\n", - tid, (long) buf, bcount, (long) buf, (long) buf + bcount); + printf("raid%d: RAID1 parity verify: buf=%lx bcount=%d (%lx - %lx)\n", + raidPtr->raidid, (long) buf, bcount, (long) buf, + (long) buf + bcount); } /* * Generate a DAG which will read the entire stripe- then we can @@ -395,7 +393,8 @@ rf_VerifyParityRAID1( rd_dag_h->tracerec = &tracerec; if (rf_verifyParityDebug > 1) { - printf("[%d] RAID1 parity verify read dag:\n", tid); + printf("raid%d: RAID1 parity verify read dag:\n", + raidPtr->raidid); rf_PrintDAGList(rd_dag_h); } RF_LOCK_MUTEX(mcpair->mutex); @@ -433,8 +432,9 @@ rf_VerifyParityRAID1( */ for (i = 0; i < layoutPtr->numDataCol; i++) { if (rf_verifyParityDebug) { - printf("[%d] RAID1 parity verify %d bytes: i=%d buf1=%lx buf2=%lx buf=%lx\n", - tid, nbytes, i, (long) buf1, (long) buf2, (long) buf); + printf("raid%d: RAID1 parity verify %d bytes: i=%d buf1=%lx buf2=%lx buf=%lx\n", + raidPtr->raidid, nbytes, i, (long) buf1, + (long) buf2, (long) buf); } ret = bcmp(buf1, buf2, nbytes); if (ret) { @@ -450,7 +450,7 @@ rf_VerifyParityRAID1( buf2[1] & 0xff, buf2[2] & 0xff, buf2[3] & 0xff, buf2[4] & 0xff); } if (rf_verifyParityDebug) { - printf("[%d] RAID1: found bad parity, i=%d\n", tid, i); + printf("raid%d: RAID1: found bad parity, i=%d\n", raidPtr->raidid, i); } /* * Parity is bad. Keep track of which columns were bad. @@ -467,7 +467,7 @@ rf_VerifyParityRAID1( if ((ret != RF_PARITY_OKAY) && correct_it) { ret = RF_PARITY_COULD_NOT_CORRECT; if (rf_verifyParityDebug) { - printf("[%d] RAID1 parity verify: parity not correct\n", tid); + printf("raid%d: RAID1 parity verify: parity not correct\n", raidPtr->raidid); } if (bbufs == NULL) goto done; @@ -532,7 +532,8 @@ done: rf_FreeMCPair(mcpair); rf_FreeAllocList(allocList); if (rf_verifyParityDebug) { - printf("[%d] RAID1 parity verify, returning %d\n", tid, ret); + printf("raid%d: RAID1 parity verify, returning %d\n", + raidPtr->raidid, ret); } return (ret); } @@ -548,7 +549,7 @@ rf_SubmitReconBufferRAID1(rbuf, keep_it, use_committed) RF_ReconParityStripeStatus_t *pssPtr; RF_ReconCtrl_t *reconCtrlPtr; RF_RaidLayout_t *layoutPtr; - int tid = 0, retcode, created; + int retcode, created; RF_CallbackDesc_t *cb, *p; RF_ReconBuffer_t *t; RF_Raid_t *raidPtr; @@ -565,9 +566,9 @@ rf_SubmitReconBufferRAID1(rbuf, keep_it, use_committed) RF_ASSERT(rbuf->col != reconCtrlPtr->fcol); if (rf_reconbufferDebug) { - rf_get_threadid(tid); - printf("[%d] RAID1 reconbuffer submission r%d c%d psid %ld ru%d (failed offset %ld)\n", - tid, rbuf->row, rbuf->col, (long) rbuf->parityStripeID, rbuf->which_ru, + printf("raid%d: RAID1 reconbuffer submission r%d c%d psid %ld ru%d (failed offset %ld)\n", + raidPtr->raidid, rbuf->row, rbuf->col, + (long) rbuf->parityStripeID, rbuf->which_ru, (long) rbuf->failedDiskSectorOffset); } if (rf_reconDebug) { @@ -595,13 +596,14 @@ rf_SubmitReconBufferRAID1(rbuf, keep_it, use_committed) t = NULL; if (keep_it) { if (rf_reconbufferDebug) { - printf("[%d] RAID1 rbuf submission: keeping rbuf\n", tid); + printf("raid%d: RAID1 rbuf submission: keeping rbuf\n", + raidPtr->raidid); } t = rbuf; } else { if (use_committed) { if (rf_reconbufferDebug) { - printf("[%d] RAID1 rbuf submission: using committed rbuf\n", tid); + printf("raid%d: RAID1 rbuf submission: using committed rbuf\n", raidPtr->raidid); } t = reconCtrlPtr->committedRbufs; RF_ASSERT(t); @@ -610,7 +612,7 @@ rf_SubmitReconBufferRAID1(rbuf, keep_it, use_committed) } else if (reconCtrlPtr->floatingRbufs) { if (rf_reconbufferDebug) { - printf("[%d] RAID1 rbuf submission: using floating rbuf\n", tid); + printf("raid%d: RAID1 rbuf submission: using floating rbuf\n", raidPtr->raidid); } t = reconCtrlPtr->floatingRbufs; reconCtrlPtr->floatingRbufs = t->next; @@ -619,7 +621,7 @@ rf_SubmitReconBufferRAID1(rbuf, keep_it, use_committed) } if (t == NULL) { if (rf_reconbufferDebug) { - printf("[%d] RAID1 rbuf submission: waiting for rbuf\n", tid); + printf("raid%d: RAID1 rbuf submission: waiting for rbuf\n", raidPtr->raidid); } RF_ASSERT((keep_it == 0) && (use_committed == 0)); raidPtr->procsInBufWait++; @@ -679,7 +681,8 @@ out: RF_UNLOCK_PSS_MUTEX(raidPtr, rbuf->row, rbuf->parityStripeID); RF_UNLOCK_MUTEX(reconCtrlPtr->rb_mutex); if (rf_reconbufferDebug) { - printf("[%d] RAID1 rbuf submission: returning %d\n", tid, retcode); + printf("raid%d: RAID1 rbuf submission: returning %d\n", + raidPtr->raidid, retcode); } return (retcode); } diff --git a/sys/dev/raidframe/rf_raid4.c b/sys/dev/raidframe/rf_raid4.c index 5c8c963d73c..c0c4af22e4c 100644 --- a/sys/dev/raidframe/rf_raid4.c +++ b/sys/dev/raidframe/rf_raid4.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_raid4.c,v 1.2 1999/02/16 00:03:16 niklas Exp $ */ -/* $NetBSD: rf_raid4.c,v 1.3 1999/02/05 00:06:16 oster Exp $ */ +/* $OpenBSD: rf_raid4.c,v 1.3 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_raid4.c,v 1.4 2000/01/07 03:41:02 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -41,7 +41,6 @@ #include "rf_dagffwr.h" #include "rf_dagdegrd.h" #include "rf_dagdegwr.h" -#include "rf_threadid.h" #include "rf_raid4.h" #include "rf_general.h" diff --git a/sys/dev/raidframe/rf_raid5.c b/sys/dev/raidframe/rf_raid5.c index 8e00cfc271f..48f7fda379d 100644 --- a/sys/dev/raidframe/rf_raid5.c +++ b/sys/dev/raidframe/rf_raid5.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_raid5.c,v 1.2 1999/02/16 00:03:17 niklas Exp $ */ -/* $NetBSD: rf_raid5.c,v 1.3 1999/02/05 00:06:16 oster Exp $ */ +/* $OpenBSD: rf_raid5.c,v 1.3 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_raid5.c,v 1.4 2000/01/08 22:57:30 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -42,7 +42,6 @@ #include "rf_dagdegrd.h" #include "rf_dagdegwr.h" #include "rf_dagutils.h" -#include "rf_threadid.h" #include "rf_general.h" #include "rf_map.h" #include "rf_utils.h" @@ -190,7 +189,6 @@ rf_RaidFiveDagSelect( RF_RowCol_t frow, fcol; RF_RowStatus_t rstat; int prior_recon; - int tid; RF_ASSERT(RF_IO_IS_R_OR_W(type)); @@ -273,9 +271,10 @@ rf_RaidFiveDagSelect( RF_ASSERT(failedPDA->col != -1); if (rf_dagDebug || rf_mapDebug) { - rf_get_threadid(tid); - printf("[%d] Redirected type '%c' r %d c %d o %ld -> r %d c %d o %ld\n", - tid, type, or, oc, (long) oo, failedPDA->row, failedPDA->col, + printf("raid%d: Redirected type '%c' r %d c %d o %ld -> r %d c %d o %ld\n", + raidPtr->raidid, type, or, oc, + (long) oo, failedPDA->row, + failedPDA->col, (long) failedPDA->startSector); } asmap->numDataFailed = asmap->numParityFailed = 0; diff --git a/sys/dev/raidframe/rf_raid5_rotatedspare.c b/sys/dev/raidframe/rf_raid5_rotatedspare.c index 5995d61ea15..ad7defb05ca 100644 --- a/sys/dev/raidframe/rf_raid5_rotatedspare.c +++ b/sys/dev/raidframe/rf_raid5_rotatedspare.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_raid5_rotatedspare.c,v 1.2 1999/02/16 00:03:18 niklas Exp $ */ -/* $NetBSD: rf_raid5_rotatedspare.c,v 1.3 1999/02/05 00:06:16 oster Exp $ */ +/* $OpenBSD: rf_raid5_rotatedspare.c,v 1.3 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_raid5_rotatedspare.c,v 1.4 2000/01/07 03:41:03 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -38,7 +38,6 @@ #include "rf_dag.h" #include "rf_dagutils.h" #include "rf_dagfuncs.h" -#include "rf_threadid.h" #include "rf_general.h" #include "rf_utils.h" #include "rf_raid5_rotatedspare.h" diff --git a/sys/dev/raidframe/rf_reconstruct.c b/sys/dev/raidframe/rf_reconstruct.c index 08cfe417d0b..e731bcc42a3 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.7 2000/01/11 14:51:37 peter Exp $ */ -/* $NetBSD: rf_reconstruct.c,v 1.9 2000/01/05 02:57:29 oster Exp $ */ +/* $OpenBSD: rf_reconstruct.c,v 1.8 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_reconstruct.c,v 1.14 2000/01/09 03:14:33 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -52,7 +52,6 @@ #include "rf_reconutil.h" #include "rf_revent.h" #include "rf_reconbuffer.h" -#include "rf_threadid.h" #include "rf_acctrace.h" #include "rf_etimer.h" #include "rf_dag.h" @@ -62,7 +61,6 @@ #include "rf_debugprint.h" #include "rf_driver.h" #include "rf_utils.h" -#include "rf_cpuutil.h" #include "rf_shutdown.h" #include "rf_kintf.h" @@ -77,21 +75,9 @@ #define Dprintf5(s,a,b,c,d,e) 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),NULL,NULL,NULL) #define Dprintf6(s,a,b,c,d,e,f) 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),NULL,NULL) #define Dprintf7(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 Dprintf8(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)) #define DDprintf1(s,a) if (rf_reconDebug) rf_debug_printf(s,(void *)((unsigned long)a),NULL,NULL,NULL,NULL,NULL,NULL,NULL) #define DDprintf2(s,a,b) if (rf_reconDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),NULL,NULL,NULL,NULL,NULL,NULL) -#define DDprintf3(s,a,b,c) if (rf_reconDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),(void *)((unsigned long)c),NULL,NULL,NULL,NULL,NULL) -#define DDprintf4(s,a,b,c,d) if (rf_reconDebug) rf_debug_printf(s,(void *)((unsigned long)a),(void *)((unsigned long)b),(void *)((unsigned long)c),(void *)((unsigned long)d),NULL,NULL,NULL,NULL) -#define DDprintf5(s,a,b,c,d,e) 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),NULL,NULL,NULL) -#define DDprintf6(s,a,b,c,d,e,f) 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),NULL,NULL) -#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 @@ -118,11 +104,6 @@ int rf_IssueNextWriteRequest __P((RF_Raid_t *, RF_RowCol_t)); int rf_CheckForcedOrBlockedReconstruction __P((RF_Raid_t *, RF_ReconParityStripeStatus_t *, RF_PerDiskReconCtrl_t *, RF_RowCol_t, RF_RowCol_t, RF_StripeNum_t, RF_ReconUnitNum_t)); void rf_SignalReconDone __P((RF_Raid_t *)); -/* XXX these should be in a .h file somewhere */ -int raidlookup __P((char *, struct proc *, struct vnode **)); -int raidwrite_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); -int raidread_component_label(dev_t, struct vnode *, RF_ComponentLabel_t *); - struct RF_ReconDoneProc_s { void (*proc) (RF_Raid_t *, void *); void *arg; @@ -167,7 +148,7 @@ rf_RegisterReconDoneProc( *handlep = p; return (0); } -/***************************************************************************************** +/************************************************************************** * * sets up the parameters that will be used by the reconstruction process * currently there are none, except for those that the layout-specific @@ -175,7 +156,7 @@ rf_RegisterReconDoneProc( * * in the kernel, we fire off the recon thread. * - ****************************************************************************************/ + **************************************************************************/ void rf_ShutdownReconstruction(ignored) void *ignored; @@ -207,12 +188,6 @@ rf_ConfigureReconstruction(listp) rf_ShutdownReconstruction(NULL); return (rc); } -#if 0 - if (!recon_thread_initialized) { - RF_CREATE_THREAD(recon_thr_handle, rf_ReconKernelThread, NULL, "raid_recon"); - recon_thread_initialized = 1; - } -#endif return (0); } @@ -675,7 +650,7 @@ rf_ContinueReconstructFailedDisk(reconDesc) /* now start up the actual reconstruction: issue a read for * each surviving disk */ - rf_start_cpu_monitor(); + reconDesc->numDisksDone = 0; for (i = 0; i < raidPtr->numCol; i++) { if (i != col) { @@ -740,8 +715,6 @@ rf_ContinueReconstructFailedDisk(reconDesc) reconDesc->state = 5; case 5: - rf_stop_cpu_monitor(); - /* Success: mark the dead disk as reconstructed. We quiesce * the array here to assure no nasty interactions with pending * user accesses when we free up the psstatus structure as @@ -784,7 +757,7 @@ rf_ContinueReconstructFailedDisk(reconDesc) (int) raidPtr->reconControl[row]->starttime.tv_sec, (int) raidPtr->reconControl[row]->starttime.tv_usec, (int) etime.tv_sec, (int) etime.tv_usec); - rf_print_cpu_util("reconstruction"); + #if RF_RECON_STATS > 0 printf("Total head-sep stall count was %d\n", (int) reconDesc->hsStallCount); @@ -798,10 +771,11 @@ rf_ContinueReconstructFailedDisk(reconDesc) rf_SignalReconDone(raidPtr); return (0); } -/***************************************************************************************** +/***************************************************************************** * do the right thing upon each reconstruction event. - * returns nonzero if and only if there is nothing left unread on the indicated disk - ****************************************************************************************/ + * returns nonzero if and only if there is nothing left unread on the + * indicated disk + *****************************************************************************/ int rf_ProcessReconEvent(raidPtr, frow, event) RF_Raid_t *raidPtr; @@ -912,23 +886,27 @@ rf_ProcessReconEvent(raidPtr, frow, event) return (retcode); } -/***************************************************************************************** +/***************************************************************************** + * + * find the next thing that's needed on the indicated disk, and issue + * a read request for it. We assume that the reconstruction buffer + * associated with this process is free to receive the data. If + * reconstruction is blocked on the indicated RU, we issue a + * blockage-release request instead of a physical disk read request. + * If the current disk gets too far ahead of the others, we issue a + * head-separation wait request and return. * - * find the next thing that's needed on the indicated disk, and issue a read - * request for it. We assume that the reconstruction buffer associated with this - * process is free to receive the data. If reconstruction is blocked on the - * indicated RU, we issue a blockage-release request instead of a physical disk - * read request. If the current disk gets too far ahead of the others, we issue - * a head-separation wait request and return. + * ctrl->{ru_count, curPSID, diskOffset} and + * rbuf->failedDiskSectorOffset are maintained to point the the unit + * we're currently accessing. Note that this deviates from the + * standard C idiom of having counters point to the next thing to be + * accessed. This allows us to easily retry when we're blocked by + * head separation or reconstruction-blockage events. * - * ctrl->{ru_count, curPSID, diskOffset} and rbuf->failedDiskSectorOffset are - * maintained to point the the unit we're currently accessing. Note that this deviates - * from the standard C idiom of having counters point to the next thing to be - * accessed. This allows us to easily retry when we're blocked by head separation - * or reconstruction-blockage events. + * returns nonzero if and only if there is nothing left unread on the + * indicated disk * - * returns nonzero if and only if there is nothing left unread on the indicated disk - ****************************************************************************************/ + *****************************************************************************/ int rf_IssueNextReadRequest(raidPtr, row, col) RF_Raid_t *raidPtr; @@ -997,11 +975,16 @@ rf_IssueNextReadRequest(raidPtr, row, col) retcode = rf_TryToRead(raidPtr, row, col); return (retcode); } -/* tries to issue the next read on the indicated disk. We may be blocked by (a) the heads being too - * far apart, or (b) recon on the indicated RU being blocked due to a write by a user thread. - * In this case, we issue a head-sep or blockage wait request, which will cause this same routine - * to be invoked again later when the blockage has cleared. + +/* + * tries to issue the next read on the indicated disk. We may be + * blocked by (a) the heads being too far apart, or (b) recon on the + * indicated RU being blocked due to a write by a user thread. In + * this case, we issue a head-sep or blockage wait request, which will + * cause this same routine to be invoked again later when the blockage + * has cleared. */ + int rf_TryToRead(raidPtr, row, col) RF_Raid_t *raidPtr; @@ -1075,26 +1058,30 @@ out: } -/* given a parity stripe ID, we want to find out whether both the current disk and the - * failed disk exist in that parity stripe. If not, we want to skip this whole PS. - * If so, we want to find the disk offset of the start of the PS on both the current - * disk and the failed disk. +/* + * given a parity stripe ID, we want to find out whether both the + * current disk and the failed disk exist in that parity stripe. If + * not, we want to skip this whole PS. If so, we want to find the + * disk offset of the start of the PS on both the current disk and the + * failed disk. * - * this works by getting a list of disks comprising the indicated parity stripe, and - * searching the list for the current and failed disks. Once we've decided they both - * exist in the parity stripe, we need to decide whether each is data or parity, - * so that we'll know which mapping function to call to get the corresponding disk + * this works by getting a list of disks comprising the indicated + * parity stripe, and searching the list for the current and failed + * disks. Once we've decided they both exist in the parity stripe, we + * need to decide whether each is data or parity, so that we'll know + * which mapping function to call to get the corresponding disk * offsets. * - * this is kind of unpleasant, but doing it this way allows the reconstruction code - * to use parity stripe IDs rather than physical disks address to march through the - * failed disk, which greatly simplifies a lot of code, as well as eliminating the - * need for a reverse-mapping function. I also think it will execute faster, since - * the calls to the mapping module are kept to a minimum. + * this is kind of unpleasant, but doing it this way allows the + * reconstruction code to use parity stripe IDs rather than physical + * disks address to march through the failed disk, which greatly + * simplifies a lot of code, as well as eliminating the need for a + * reverse-mapping function. I also think it will execute faster, + * since the calls to the mapping module are kept to a minimum. * - * ASSUMES THAT THE STRIPE IDENTIFIER IDENTIFIES THE DISKS COMPRISING THE STRIPE - * IN THE CORRECT ORDER - */ + * ASSUMES THAT THE STRIPE IDENTIFIER IDENTIFIES THE DISKS COMPRISING + * THE STRIPE IN THE CORRECT ORDER */ + int rf_ComputePSDiskOffsets( RF_Raid_t * raidPtr, /* raid descriptor */ @@ -1250,11 +1237,14 @@ rf_IssueNextWriteRequest(raidPtr, row) return (0); } -/* this gets called upon the completion of a reconstruction read operation - * the arg is a pointer to the per-disk reconstruction control structure - * for the process that just finished a read. + +/* + * this gets called upon the completion of a reconstruction read + * operation the arg is a pointer to the per-disk reconstruction + * control structure for the process that just finished a read. * - * called at interrupt context in the kernel, so don't do anything illegal here. + * called at interrupt context in the kernel, so don't do anything + * illegal here. */ int rf_ReconReadDoneProc(arg, status) @@ -1303,7 +1293,10 @@ rf_ReconWriteDoneProc(arg, status) } -/* computes a new minimum head sep, and wakes up anyone who needs to be woken as a result */ +/* + * computes a new minimum head sep, and wakes up anyone who needs to + * be woken as a result + */ void rf_CheckForNewMinHeadSep(raidPtr, row, hsCtr) RF_Raid_t *raidPtr; @@ -1343,16 +1336,18 @@ rf_CheckForNewMinHeadSep(raidPtr, row, hsCtr) } RF_UNLOCK_MUTEX(reconCtrlPtr->rb_mutex); } -/* checks to see that the maximum head separation will not be violated - * if we initiate a reconstruction I/O on the indicated disk. Limiting the - * maximum head separation between two disks eliminates the nasty buffer-stall - * conditions that occur when one disk races ahead of the others and consumes - * all of the floating recon buffers. This code is complex and unpleasant - * but it's necessary to avoid some very nasty, albeit fairly rare, - * reconstruction behavior. + +/* + * checks to see that the maximum head separation will not be violated + * if we initiate a reconstruction I/O on the indicated disk. + * Limiting the maximum head separation between two disks eliminates + * the nasty buffer-stall conditions that occur when one disk races + * ahead of the others and consumes all of the floating recon buffers. + * This code is complex and unpleasant but it's necessary to avoid + * some very nasty, albeit fairly rare, reconstruction behavior. * - * returns non-zero if and only if we have to stop working on the indicated disk - * due to a head-separation delay. + * returns non-zero if and only if we have to stop working on the + * indicated disk due to a head-separation delay. */ int rf_CheckHeadSeparation( @@ -1365,7 +1360,7 @@ rf_CheckHeadSeparation( { RF_ReconCtrl_t *reconCtrlPtr = raidPtr->reconControl[row]; RF_CallbackDesc_t *cb, *p, *pt; - int retval = 0, tid; + int retval = 0; /* if we're too far ahead of the slowest disk, stop working on this * disk until the slower ones catch up. We do this by scheduling a @@ -1375,12 +1370,13 @@ rf_CheckHeadSeparation( * separation before we'll wake up. * */ - rf_get_threadid(tid); RF_LOCK_MUTEX(reconCtrlPtr->rb_mutex); if ((raidPtr->headSepLimit >= 0) && ((ctrl->headSepCounter - reconCtrlPtr->minHeadSepCounter) > raidPtr->headSepLimit)) { - Dprintf6("[%d] RECON: head sep stall: row %d col %d hsCtr %ld minHSCtr %ld limit %ld\n", - tid, row, col, ctrl->headSepCounter, reconCtrlPtr->minHeadSepCounter, raidPtr->headSepLimit); + Dprintf6("raid%d: RECON: head sep stall: row %d col %d hsCtr %ld minHSCtr %ld limit %ld\n", + raidPtr->raidid, row, col, ctrl->headSepCounter, + reconCtrlPtr->minHeadSepCounter, + raidPtr->headSepLimit); cb = rf_AllocCallbackDesc(); /* the minHeadSepCounter value we have to get to before we'll * wake up. build in 20% hysteresis. */ @@ -1412,10 +1408,10 @@ rf_CheckHeadSeparation( return (retval); } -/* checks to see if reconstruction has been either forced or blocked by a user operation. - * if forced, we skip this RU entirely. - * else if blocked, put ourselves on the wait list. - * else return 0. +/* + * checks to see if reconstruction has been either forced or blocked + * by a user operation. if forced, we skip this RU entirely. else if + * blocked, put ourselves on the wait list. else return 0. * * ASSUMES THE PSS MUTEX IS LOCKED UPON ENTRY */ @@ -1452,11 +1448,13 @@ rf_CheckForcedOrBlockedReconstruction( return (retcode); } -/* if reconstruction is currently ongoing for the indicated stripeID, reconstruction - * is forced to completion and we return non-zero to indicate that the caller must - * wait. If not, then reconstruction is blocked on the indicated stripe and the - * routine returns zero. If and only if we return non-zero, we'll cause the cbFunc - * to get invoked with the cbArg when the reconstruction has completed. +/* + * if reconstruction is currently ongoing for the indicated stripeID, + * reconstruction is forced to completion and we return non-zero to + * indicate that the caller must wait. If not, then reconstruction is + * blocked on the indicated stripe and the routine returns zero. If + * and only if we return non-zero, we'll cause the cbFunc to get + * invoked with the cbArg when the reconstruction has completed. */ int rf_ForceOrBlockRecon(raidPtr, asmap, cbFunc, cbArg) @@ -1477,7 +1475,6 @@ rf_ForceOrBlockRecon(raidPtr, asmap, cbFunc, cbArg) * offset */ RF_RowCol_t *diskids; RF_RowCol_t stripe; - int tid; RF_ReconUnitNum_t which_ru; /* RU within parity stripe */ RF_RowCol_t fcol, diskno, i; RF_ReconBuffer_t *new_rbuf; /* ptr to newly allocated rbufs */ @@ -1485,7 +1482,6 @@ rf_ForceOrBlockRecon(raidPtr, asmap, cbFunc, cbArg) RF_CallbackDesc_t *cb; int created = 0, nPromoted; - rf_get_threadid(tid); psid = rf_MapStripeIDToParityStripeID(&raidPtr->Layout, stripeID, &which_ru); RF_LOCK_PSS_MUTEX(raidPtr, row, psid); @@ -1525,7 +1521,7 @@ rf_ForceOrBlockRecon(raidPtr, asmap, cbFunc, cbArg) if (pssPtr->issued[diskno]) { nPromoted = rf_DiskIOPromote(&raidPtr->Queues[row][diskno], psid, which_ru); if (rf_reconDebug && nPromoted) - printf("[%d] promoted read from row %d col %d\n", tid, row, diskno); + printf("raid%d: promoted read from row %d col %d\n", raidPtr->raidid, row, diskno); } else { new_rbuf = rf_MakeReconBuffer(raidPtr, row, diskno, RF_RBUF_TYPE_FORCED); /* create new buf */ rf_ComputePSDiskOffsets(raidPtr, psid, row, diskno, &offset, &fd_offset, @@ -1547,13 +1543,14 @@ rf_ForceOrBlockRecon(raidPtr, asmap, cbFunc, cbArg) new_rbuf->arg = req; rf_DiskIOEnqueue(&raidPtr->Queues[row][diskno], req, RF_IO_NORMAL_PRIORITY); /* enqueue the I/O */ - Dprintf3("[%d] Issued new read req on row %d col %d\n", tid, row, diskno); + Dprintf3("raid%d: Issued new read req on row %d col %d\n", raidPtr->raidid, row, diskno); } } /* if the write is sitting in the disk queue, elevate its * priority */ if (rf_DiskIOPromote(&raidPtr->Queues[row][fcol], psid, which_ru)) - printf("[%d] promoted write to row %d col %d\n", tid, row, fcol); + printf("raid%d: promoted write to row %d col %d\n", + raidPtr->raidid, row, fcol); } /* install a callback descriptor to be invoked when recon completes on * this parity stripe. */ @@ -1564,7 +1561,8 @@ rf_ForceOrBlockRecon(raidPtr, asmap, cbFunc, cbArg) cb->callbackArg.p = (void *) cbArg; cb->next = pssPtr->procWaitList; pssPtr->procWaitList = cb; - DDprintf2("[%d] Waiting for forced recon on psid %ld\n", tid, psid); + DDprintf2("raid%d: Waiting for forced recon on psid %ld\n", + raidPtr->raidid, psid); RF_UNLOCK_PSS_MUTEX(raidPtr, row, psid); return (1); @@ -1599,10 +1597,9 @@ rf_UnblockRecon(raidPtr, asmap) RF_ReconParityStripeStatus_t *pssPtr; RF_ReconUnitNum_t which_ru; RF_StripeNum_t psid; - int tid, created = 0; + int created = 0; RF_CallbackDesc_t *cb; - rf_get_threadid(tid); psid = rf_MapStripeIDToParityStripeID(&raidPtr->Layout, stripeID, &which_ru); RF_LOCK_PSS_MUTEX(raidPtr, row, psid); pssPtr = rf_LookupRUStatus(raidPtr, raidPtr->reconControl[row]->pssTable, psid, which_ru, RF_PSS_NONE, &created); @@ -1619,7 +1616,8 @@ rf_UnblockRecon(raidPtr, asmap) goto out; } pssPtr->blockCount--; - Dprintf3("[%d] unblocking recon on psid %ld: blockcount is %d\n", tid, psid, pssPtr->blockCount); + Dprintf3("raid%d: unblocking recon on psid %ld: blockcount is %d\n", + raidPtr->raidid, psid, pssPtr->blockCount); if (pssPtr->blockCount == 0) { /* if recon blockage has been released */ /* unblock recon before calling CauseReconEvent in case @@ -1628,18 +1626,17 @@ rf_UnblockRecon(raidPtr, asmap) pssPtr->flags &= ~RF_PSS_RECON_BLOCKED; - while (pssPtr->blockWaitList) { /* spin through the block-wait - * list and release all the - * waiters */ + while (pssPtr->blockWaitList) { + /* spin through the block-wait list and + release all the waiters */ cb = pssPtr->blockWaitList; pssPtr->blockWaitList = cb->next; cb->next = NULL; rf_CauseReconEvent(raidPtr, cb->row, cb->col, NULL, RF_REVENT_BLOCKCLEAR); rf_FreeCallbackDesc(cb); } - if (!(pssPtr->flags & RF_PSS_UNDER_RECON)) { /* if no recon was - * requested while recon - * was blocked */ + if (!(pssPtr->flags & RF_PSS_UNDER_RECON)) { + /* if no recon was requested while recon was blocked */ rf_PSStatusDelete(raidPtr, raidPtr->reconControl[row]->pssTable, pssPtr); } } diff --git a/sys/dev/raidframe/rf_reconstub.c b/sys/dev/raidframe/rf_reconstub.c deleted file mode 100644 index d6a84a98d20..00000000000 --- a/sys/dev/raidframe/rf_reconstub.c +++ /dev/null @@ -1,103 +0,0 @@ -/* $OpenBSD: rf_reconstub.c,v 1.2 1999/02/16 00:03:23 niklas Exp $ */ -/* $NetBSD: rf_reconstub.c,v 1.3 1999/02/05 00:06:17 oster Exp $ */ -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Mark Holland - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/************************************************************************** - * - * rf_reconstub.c -- stub routines used when you don't want reconstruction - * in some particular instantiation of the raidframe - * - * this file also contains stubs for some reconstruction-related - * routines that we don't want compiled into the kernel. - * - * The OSF/1 kernel configuration includes an option "raidframe_recon". If - * enabled, most of this file is ifdef'd out. - * - **************************************************************************/ - -#include <sys/errno.h> - -#if RAIDFRAME_RECON == 0 - -int rf_ConfigureReconstruction() { - return (0); -} -int rf_ConfigureReconEvent() { - return (0); -} -int rf_ConfigurePSStatus() { - return (0); -} -int rf_ConfigureNWayXor() { - return (0); -} -int rf_ConfigureCopyback() { - return (0); -} -int rf_ShutdownCopyback() { - return (0); -} -int rf_ShutdownReconstruction() { - return (0); -} -int rf_ShutdownReconEvent() { - return (0); -} -int rf_ShutdownPSStatus() { - return (0); -} -int rf_ShutdownNWayXor() { - return (0); -} - -int rf_ForceOrBlockRecon() { - return (0); -} -int rf_UnblockRecon() { - return (0); -} -int rf_ReconstructFailedDisk() { - return (ENOTTY); -} -int rf_CheckRUReconstructed() { - return (0); -} - -void -rf_start_cpu_monitor() -{ -} -void -rf_stop_cpu_monitor() -{ -} -void -rf_print_cpu_util() -{ -} -#endif /* RAIDFRAME_RECON == 0 */ diff --git a/sys/dev/raidframe/rf_shutdown.c b/sys/dev/raidframe/rf_shutdown.c index 5091cbb7b02..9e776b90958 100644 --- a/sys/dev/raidframe/rf_shutdown.c +++ b/sys/dev/raidframe/rf_shutdown.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_shutdown.c,v 1.2 1999/02/16 00:03:26 niklas Exp $ */ -/* $NetBSD: rf_shutdown.c,v 1.4 1999/02/05 00:06:17 oster Exp $ */ +/* $OpenBSD: rf_shutdown.c,v 1.3 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_shutdown.c,v 1.5 2000/01/08 22:57:31 oster Exp $ */ /* * rf_shutdown.c */ @@ -39,7 +39,6 @@ #include "rf_shutdown.h" #include "rf_debugMem.h" #include "rf_freelist.h" -#include "rf_threadid.h" static void rf_FreeShutdownEnt(RF_ShutdownList_t * ent) @@ -86,16 +85,12 @@ rf_ShutdownList(RF_ShutdownList_t ** list) line = r->line; if (rf_shutdownDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] call shutdown, created %s:%d\n", tid, file, line); + printf("call shutdown, created %s:%d\n", file, line); } r->cleanup(r->arg); if (rf_shutdownDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] completed shutdown, created %s:%d\n", tid, file, line); + printf("completed shutdown, created %s:%d\n", file, line); } rf_FreeShutdownEnt(r); } diff --git a/sys/dev/raidframe/rf_sstf.c b/sys/dev/raidframe/rf_sstf.c index 107190ce46b..e603b98b859 100644 --- a/sys/dev/raidframe/rf_sstf.c +++ b/sys/dev/raidframe/rf_sstf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_sstf.c,v 1.2 1999/02/16 00:03:27 niklas Exp $ */ -/* $NetBSD: rf_sstf.c,v 1.3 1999/02/05 00:06:17 oster Exp $ */ +/* $OpenBSD: rf_sstf.c,v 1.3 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_sstf.c,v 1.4 2000/01/08 23:45:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -40,8 +40,9 @@ #include "rf_sstf.h" #include "rf_debugMem.h" #include "rf_general.h" -#include "rf_threadid.h" #include "rf_options.h" +#include "rf_raid.h" +#include "rf_types.h" #define DIR_LEFT 1 #define DIR_RIGHT 2 @@ -295,11 +296,11 @@ rf_SstfEnqueue(qptr, req, priority) if (priority == RF_IO_LOW_PRIORITY) { if (rf_sstfDebug || rf_scanDebug || rf_cscanDebug) { RF_DiskQueue_t *dq; - int tid; - rf_get_threadid(tid); dq = (RF_DiskQueue_t *) req->queue; - printf("[%d] ENQ lopri %d,%d queues are %d,%d,%d\n", - tid, dq->row, dq->col, sstfq->left.qlen, sstfq->right.qlen, + printf("raid%d: ENQ lopri %d,%d queues are %d,%d,%d\n", + req->raidPtr->raidid, + dq->row, dq->col, + sstfq->left.qlen, sstfq->right.qlen, sstfq->lopri.qlen); } do_sstf_ord_q(&sstfq->lopri.queue, &sstfq->lopri.qtail, req); @@ -323,9 +324,7 @@ do_dequeue(queue, req) RF_DiskQueueData_t *req2; if (rf_sstfDebug || rf_scanDebug || rf_cscanDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] do_dequeue\n", tid); + printf("raid%d: do_dequeue\n", req->raidPtr->raidid); } if (req == queue->queue) { DO_HEAD_DEQ(req2, queue); @@ -356,13 +355,11 @@ rf_SstfDequeue(qptr) if (rf_sstfDebug) { RF_DiskQueue_t *dq; - int tid; - rf_get_threadid(tid); dq = (RF_DiskQueue_t *) req->queue; RF_ASSERT(QSUM(sstfq) == dq->queueLength); - printf("[%d] sstf: Dequeue %d,%d queues are %d,%d,%d\n", tid, - dq->row, dq->col, sstfq->left.qlen, sstfq->right.qlen, - sstfq->lopri.qlen); + printf("raid%d: sstf: Dequeue %d,%d queues are %d,%d,%d\n", + req->raidPtr->raidid, dq->row, dq->col, + sstfq->left.qlen, sstfq->right.qlen, sstfq->lopri.qlen); } if (sstfq->left.queue == NULL) { RF_ASSERT(sstfq->left.qlen == 0); @@ -373,16 +370,14 @@ rf_SstfDequeue(qptr) return (NULL); } if (rf_sstfDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] sstf: check for close lopri", tid); + printf("raid%d: sstf: check for close lopri", + req->raidPtr->raidid); } req = closest_to_arm(&sstfq->lopri, sstfq->last_sector, &sstfq->dir, sstfq->allow_reverse); if (rf_sstfDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] sstf: closest_to_arm said %lx", tid, (long) req); + printf("raid%d: sstf: closest_to_arm said %lx", + req->raidPtr->raidid, (long) req); } if (req == NULL) return (NULL); @@ -419,13 +414,11 @@ rf_ScanDequeue(qptr) if (rf_scanDebug) { RF_DiskQueue_t *dq; - int tid; - rf_get_threadid(tid); dq = (RF_DiskQueue_t *) req->queue; RF_ASSERT(QSUM(scanq) == dq->queueLength); - printf("[%d] scan: Dequeue %d,%d queues are %d,%d,%d\n", tid, - dq->row, dq->col, scanq->left.qlen, scanq->right.qlen, - scanq->lopri.qlen); + printf("raid%d: scan: Dequeue %d,%d queues are %d,%d,%d\n", + req->raidPtr->raidid, dq->row, dq->col, + scanq->left.qlen, scanq->right.qlen, scanq->lopri.qlen); } if (scanq->left.queue == NULL) { RF_ASSERT(scanq->left.qlen == 0); @@ -476,12 +469,11 @@ rf_CscanDequeue(qptr) RF_ASSERT(cscanq->dir == DIR_RIGHT); if (rf_cscanDebug) { RF_DiskQueue_t *dq; - int tid; - rf_get_threadid(tid); dq = (RF_DiskQueue_t *) req->queue; RF_ASSERT(QSUM(cscanq) == dq->queueLength); - printf("[%d] scan: Dequeue %d,%d queues are %d,%d,%d\n", tid, - dq->row, dq->col, cscanq->left.qlen, cscanq->right.qlen, + printf("raid%d: scan: Dequeue %d,%d queues are %d,%d,%d\n", + req->raidPtr->raidid, dq->row, dq->col, + cscanq->left.qlen, cscanq->right.qlen, cscanq->lopri.qlen); } if (cscanq->right.queue) { @@ -643,10 +635,9 @@ rf_SstfPromote(qptr, parityStripeID, which_ru) n = 0; if (rf_sstfDebug || rf_scanDebug || rf_cscanDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] promote %ld %d queues are %d,%d,%d\n", - tid, (long) parityStripeID, (int) which_ru, + printf("raid%d: promote %ld %d queues are %d,%d,%d\n", + r->raidPtr->raidid, (long) parityStripeID, + (int) which_ru, sstfq->left.qlen, sstfq->right.qlen, sstfq->lopri.qlen); @@ -654,9 +645,8 @@ rf_SstfPromote(qptr, parityStripeID, which_ru) for (r = sstfq->lopri.queue; r; r = next) { next = r->next; if (rf_sstfDebug || rf_scanDebug || rf_cscanDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] check promote %lx\n", tid, (long) r); + printf("raid%d: check promote %lx\n", + r->raidPtr->raidid, (long) r); } if ((r->parityStripeID == parityStripeID) && (r->which_ru == which_ru)) { @@ -666,10 +656,9 @@ rf_SstfPromote(qptr, parityStripeID, which_ru) } } if (rf_sstfDebug || rf_scanDebug || rf_cscanDebug) { - int tid; - rf_get_threadid(tid); - printf("[%d] promoted %d matching I/Os queues are %d,%d,%d\n", - tid, n, sstfq->left.qlen, sstfq->right.qlen, sstfq->lopri.qlen); + printf("raid%d: promoted %d matching I/Os queues are %d,%d,%d\n", + r->raidPtr->raidid, n, sstfq->left.qlen, + sstfq->right.qlen, sstfq->lopri.qlen); } return (n); } diff --git a/sys/dev/raidframe/rf_states.c b/sys/dev/raidframe/rf_states.c index 1dfc5287e89..994902e8067 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.5 2000/01/07 14:50:23 peter Exp $ */ -/* $NetBSD: rf_states.c,v 1.10 1999/12/12 20:52:37 oster Exp $ */ +/* $OpenBSD: rf_states.c,v 1.6 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_states.c,v 1.13 2000/01/09 00:00:18 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -35,7 +35,6 @@ #include "rf_dag.h" #include "rf_desc.h" #include "rf_aselect.h" -#include "rf_threadid.h" #include "rf_general.h" #include "rf_states.h" #include "rf_dagutils.h" @@ -91,6 +90,7 @@ rf_ContinueRaidAccess(RF_RaidAccessDesc_t * desc) int suspended = RF_FALSE; int current_state_index = desc->state; RF_AccessState_t current_state = desc->states[current_state_index]; + int unit = desc->raidPtr->raidid; do { @@ -136,11 +136,9 @@ rf_ContinueRaidAccess(RF_RaidAccessDesc_t * desc) * renter this function or loop back up, desc should be valid. */ if (rf_printStatesDebug) { - int tid; - rf_get_threadid(tid); - - printf("[%d] State: %-24s StateIndex: %3i desc: 0x%ld %s\n", - tid, StateName(current_state), current_state_index, (long) desc, + printf("raid%d: State: %-24s StateIndex: %3i desc: 0x%ld %s\n", + unit, StateName(current_state), + current_state_index, (long) desc, suspended ? "callback scheduled" : "looping"); } } while (!suspended && current_state != rf_LastState); @@ -179,10 +177,12 @@ rf_ContinueDagAccess(RF_DagList_t * dagList) * free all dags and start over */ desc->status = 1; /* bad status */ { - printf("[%d] DAG failure: %c addr 0x%lx (%ld) nblk 0x%x (%d) buf 0x%lx\n", - desc->tid, desc->type, (long) desc->raidAddress, + printf("raid%d: DAG failure: %c addr 0x%lx (%ld) nblk 0x%x (%d) buf 0x%lx\n", + desc->raidPtr->raidid, desc->type, + (long) desc->raidAddress, (long) desc->raidAddress, (int) desc->numBlocks, - (int) desc->numBlocks, (unsigned long) (desc->bufPtr)); + (int) desc->numBlocks, + (unsigned long) (desc->bufPtr)); } } dagList->numDagsDone++; @@ -373,14 +373,16 @@ rf_State_Lock(RF_RaidAccessDesc_t * desc) } } else { if (rf_pssDebug) { - printf("[%d] skipping force/block because already done, psid %ld\n", - desc->tid, (long) asm_p->stripeID); + printf("raid%d: skipping force/block because already done, psid %ld\n", + desc->raidPtr->raidid, + (long) asm_p->stripeID); } } } else { if (rf_pssDebug) { - printf("[%d] skipping force/block because not write or not under recon, psid %ld\n", - desc->tid, (long) asm_p->stripeID); + printf("raid%d: skipping force/block because not write or not under recon, psid %ld\n", + desc->raidPtr->raidid, + (long) asm_p->stripeID); } } } @@ -575,12 +577,10 @@ rf_State_Cleanup(RF_RaidAccessDesc_t * desc) RF_AccessStripeMap_t *asm_p; RF_DagHeader_t *dag_h; RF_Etimer_t timer; - int tid, i; + int i; desc->state++; - rf_get_threadid(tid); - timer = tracerec->timer; RF_ETIMER_STOP(timer); RF_ETIMER_EVAL(timer); @@ -619,7 +619,8 @@ rf_State_Cleanup(RF_RaidAccessDesc_t * desc) asm_p->parityInfo && !(desc->flags & RF_DAG_SUPPRESS_LOCKS)) { RF_ASSERT_VALID_LOCKREQ(&asm_p->lockReqDesc); - rf_ReleaseStripeLock(raidPtr->lockTable, asm_p->stripeID, + rf_ReleaseStripeLock(raidPtr->lockTable, + asm_p->stripeID, &asm_p->lockReqDesc); } if (asm_p->flags & RF_ASM_FLAGS_RECON_BLOCKED) { diff --git a/sys/dev/raidframe/rf_stripelocks.c b/sys/dev/raidframe/rf_stripelocks.c index e3d35b1caa9..34eff4c4b47 100644 --- a/sys/dev/raidframe/rf_stripelocks.c +++ b/sys/dev/raidframe/rf_stripelocks.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_stripelocks.c,v 1.3 2000/01/08 20:57:13 peter Exp $ */ -/* $NetBSD: rf_stripelocks.c,v 1.4 2000/01/07 03:04:41 oster Exp $ */ +/* $OpenBSD: rf_stripelocks.c,v 1.4 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_stripelocks.c,v 1.5 2000/01/08 23:45:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -61,7 +61,6 @@ #include "rf_raid.h" #include "rf_stripelocks.h" #include "rf_alloclist.h" -#include "rf_threadid.h" #include "rf_general.h" #include "rf_freelist.h" #include "rf_debugprint.h" @@ -237,7 +236,6 @@ rf_AcquireStripeLock( RF_ASSERT(RF_IO_IS_R_OR_W(lockReqDesc->type)); if (rf_stripeLockDebug) { - rf_get_threadid(tid); if (stripeID == -1) Dprintf1("[%d] Lock acquisition supressed (stripeID == -1)\n", tid); else { @@ -347,7 +345,6 @@ rf_ReleaseStripeLock( RF_ASSERT(RF_IO_IS_R_OR_W(type)); if (rf_stripeLockDebug) { - rf_get_threadid(tid); if (stripeID == -1) Dprintf1("[%d] Lock release supressed (stripeID == -1)\n", tid); else { @@ -574,7 +571,6 @@ AddToWaitersQueue( int tid; if (rf_stripeLockDebug) { - rf_get_threadid(tid); Dprintf3("[%d] Waiting on lock for stripe %ld table 0x%lx\n", tid, lockDesc->stripeID, (unsigned long) lockTable); FLUSH; } diff --git a/sys/dev/raidframe/rf_threadid.h b/sys/dev/raidframe/rf_threadid.h deleted file mode 100644 index f9ca8bb7599..00000000000 --- a/sys/dev/raidframe/rf_threadid.h +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: rf_threadid.h,v 1.3 1999/08/04 13:10:55 peter Exp $ */ -/* $NetBSD: rf_threadid.h,v 1.3 1999/02/05 00:06:18 oster Exp $ */ -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Daniel Stodolsky, Mark Holland - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/* rf_threadid.h - * - * simple macros to register and lookup integer identifiers for threads. - * must include pthread.h before including this - * - * This is one of two places where the pthreads package is used explicitly. - * The other is in threadstuff.h - * - * none of this is used in the kernel, so it all gets compiled out if _KERNEL is defined - */ - -#ifndef _RF__RF_THREADID_H_ -#define _RF__RF_THREADID_H_ - -/* - * Kernel - */ - -#define RF_DECLARE_GLOBAL_THREADID -#define rf_setup_threadid() -#define rf_shutdown_threadid() -#define rf_assign_threadid() - -#define rf_get_threadid(_id_) _id_ = 0; - -#endif /* !_RF__RF_THREADID_H_ */ diff --git a/sys/dev/raidframe/rf_threadstuff.h b/sys/dev/raidframe/rf_threadstuff.h index 1a9ce37adf8..033999efa6c 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.4 2000/01/07 14:50:23 peter Exp $ */ -/* $NetBSD: rf_threadstuff.h,v 1.6 2000/01/05 02:57:28 oster Exp $ */ +/* $OpenBSD: rf_threadstuff.h,v 1.5 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_threadstuff.h,v 1.7 2000/01/09 01:34:29 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -182,6 +182,6 @@ int _rf_create_managed_cond(RF_ShutdownList_t ** listp, int *, char *file, int line); -int rf_cond_init(int *c); /* XXX need to write?? */ -int rf_cond_destroy(int *c);/* XXX need to write?? */ +int rf_cond_init(int *c); +int rf_cond_destroy(int *c); #endif /* !_RF__RF_THREADSTUFF_H_ */ diff --git a/sys/dev/raidframe/rf_utils.c b/sys/dev/raidframe/rf_utils.c index 959f30caf31..2b5a99cbebf 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.3 2000/01/07 14:50:23 peter Exp $ */ -/* $NetBSD: rf_utils.c,v 1.4 1999/08/13 03:41:58 oster Exp $ */ +/* $OpenBSD: rf_utils.c,v 1.4 2000/01/11 18:02:23 peter Exp $ */ +/* $NetBSD: rf_utils.c,v 1.5 2000/01/07 03:41:03 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -38,7 +38,6 @@ #include <sys/time.h> -#include "rf_threadid.h" #include "rf_utils.h" #include "rf_debugMem.h" #include "rf_alloclist.h" |