convert the iodone_lock to a mutex, and use a condvar for signalling. this only handles the smallest use of old simple_lock/tsleep/wakeup APIs inside raidframe, and it points out that cv(9)'s have only one wait channel per cv, whereas each tsleep() caller can specify a different wait channel. this change removes the difference between normal raidio and waiting for IO during shutdown. i've tested this one 3 systems, ran atf, and had mlelstv and rmind review the change.diff -r1.122 -r1.123 src/sys/dev/raidframe/rf_driver.c
(mrg)
--- src/sys/dev/raidframe/rf_driver.c 2009/11/17 18:54:26 1.122
+++ src/sys/dev/raidframe/rf_driver.c 2011/04/23 06:29:05 1.123
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rf_driver.c,v 1.122 2009/11/17 18:54:26 jld Exp $ */ | 1 | /* $NetBSD: rf_driver.c,v 1.123 2011/04/23 06:29:05 mrg Exp $ */ | |
2 | /*- | 2 | /*- | |
3 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | 3 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * This code is derived from software contributed to The NetBSD Foundation | 6 | * This code is derived from software contributed to The NetBSD Foundation | |
7 | * by Greg Oster | 7 | * by Greg Oster | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -56,27 +56,27 @@ | @@ -56,27 +56,27 @@ | |||
56 | * rights to redistribute these changes. | 56 | * rights to redistribute these changes. | |
57 | */ | 57 | */ | |
58 | 58 | |||
59 | /****************************************************************************** | 59 | /****************************************************************************** | |
60 | * | 60 | * | |
61 | * rf_driver.c -- main setup, teardown, and access routines for the RAID driver | 61 | * rf_driver.c -- main setup, teardown, and access routines for the RAID driver | |
62 | * | 62 | * | |
63 | * all routines are prefixed with rf_ (raidframe), to avoid conficts. | 63 | * all routines are prefixed with rf_ (raidframe), to avoid conficts. | |
64 | * | 64 | * | |
65 | ******************************************************************************/ | 65 | ******************************************************************************/ | |
66 | 66 | |||
67 | 67 | |||
68 | #include <sys/cdefs.h> | 68 | #include <sys/cdefs.h> | |
69 | __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.122 2009/11/17 18:54:26 jld Exp $"); | 69 | __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.123 2011/04/23 06:29:05 mrg Exp $"); | |
70 | 70 | |||
71 | #ifdef _KERNEL_OPT | 71 | #ifdef _KERNEL_OPT | |
72 | #include "opt_raid_diagnostic.h" | 72 | #include "opt_raid_diagnostic.h" | |
73 | #endif | 73 | #endif | |
74 | 74 | |||
75 | #include <sys/param.h> | 75 | #include <sys/param.h> | |
76 | #include <sys/systm.h> | 76 | #include <sys/systm.h> | |
77 | #include <sys/ioctl.h> | 77 | #include <sys/ioctl.h> | |
78 | #include <sys/fcntl.h> | 78 | #include <sys/fcntl.h> | |
79 | #include <sys/vnode.h> | 79 | #include <sys/vnode.h> | |
80 | 80 | |||
81 | 81 | |||
82 | #include "rf_archs.h" | 82 | #include "rf_archs.h" | |
@@ -230,26 +230,29 @@ rf_Shutdown(RF_Raid_t *raidPtr) | @@ -230,26 +230,29 @@ rf_Shutdown(RF_Raid_t *raidPtr) | |||
230 | raidPtr->raidid); | 230 | raidPtr->raidid); | |
231 | tsleep(&raidPtr->parity_rewrite_in_progress, PRIBIO, | 231 | tsleep(&raidPtr->parity_rewrite_in_progress, PRIBIO, | |
232 | "rfprwshutdown", 0); | 232 | "rfprwshutdown", 0); | |
233 | } | 233 | } | |
234 | 234 | |||
235 | /* Wait for any reconstruction to stop... */ | 235 | /* Wait for any reconstruction to stop... */ | |
236 | while (raidPtr->reconInProgress) { | 236 | while (raidPtr->reconInProgress) { | |
237 | printf("raid%d: Waiting for reconstruction to stop...\n", | 237 | printf("raid%d: Waiting for reconstruction to stop...\n", | |
238 | raidPtr->raidid); | 238 | raidPtr->raidid); | |
239 | tsleep(&raidPtr->waitForReconCond, PRIBIO, | 239 | tsleep(&raidPtr->waitForReconCond, PRIBIO, | |
240 | "rfreshutdown",0); | 240 | "rfreshutdown",0); | |
241 | } | 241 | } | |
242 | 242 | |||
243 | mutex_destroy(&raidPtr->iodone_lock); | |||
244 | cv_destroy(&raidPtr->iodone_cv); | |||
245 | ||||
243 | raidPtr->valid = 0; | 246 | raidPtr->valid = 0; | |
244 | 247 | |||
245 | if (raidPtr->parity_map != NULL) | 248 | if (raidPtr->parity_map != NULL) | |
246 | rf_paritymap_detach(raidPtr); | 249 | rf_paritymap_detach(raidPtr); | |
247 | 250 | |||
248 | rf_update_component_labels(raidPtr, RF_FINAL_COMPONENT_UPDATE); | 251 | rf_update_component_labels(raidPtr, RF_FINAL_COMPONENT_UPDATE); | |
249 | 252 | |||
250 | rf_UnconfigureVnodes(raidPtr); | 253 | rf_UnconfigureVnodes(raidPtr); | |
251 | 254 | |||
252 | rf_FreeEmergBuffers(raidPtr); | 255 | rf_FreeEmergBuffers(raidPtr); | |
253 | 256 | |||
254 | rf_ShutdownList(&raidPtr->shutdownList); | 257 | rf_ShutdownList(&raidPtr->shutdownList); | |
255 | 258 | |||
@@ -341,27 +344,28 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Conf | @@ -341,27 +344,28 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Conf | |||
341 | return (ENOMEM); | 344 | return (ENOMEM); | |
342 | } | 345 | } | |
343 | rf_ShutdownCreate(&raidPtr->shutdownList, | 346 | rf_ShutdownCreate(&raidPtr->shutdownList, | |
344 | (void (*) (void *)) rf_FreeAllocList, | 347 | (void (*) (void *)) rf_FreeAllocList, | |
345 | raidPtr->cleanupList); | 348 | raidPtr->cleanupList); | |
346 | 349 | |||
347 | raidPtr->numCol = cfgPtr->numCol; | 350 | raidPtr->numCol = cfgPtr->numCol; | |
348 | raidPtr->numSpare = cfgPtr->numSpare; | 351 | raidPtr->numSpare = cfgPtr->numSpare; | |
349 | 352 | |||
350 | raidPtr->status = rf_rs_optimal; | 353 | raidPtr->status = rf_rs_optimal; | |
351 | raidPtr->reconControl = NULL; | 354 | raidPtr->reconControl = NULL; | |
352 | 355 | |||
353 | TAILQ_INIT(&(raidPtr->iodone)); | 356 | TAILQ_INIT(&(raidPtr->iodone)); | |
354 | simple_lock_init(&(raidPtr->iodone_lock)); | 357 | mutex_init(&raidPtr->iodone_lock, MUTEX_DEFAULT, IPL_VM); | |
358 | cv_init(&raidPtr->iodone_cv, "raidiow"); | |||
355 | 359 | |||
356 | DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine); | 360 | DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine); | |
357 | DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks); | 361 | DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks); | |
358 | 362 | |||
359 | raidPtr->outstandingCond = 0; | 363 | raidPtr->outstandingCond = 0; | |
360 | 364 | |||
361 | raidPtr->nAccOutstanding = 0; | 365 | raidPtr->nAccOutstanding = 0; | |
362 | raidPtr->waitShutdown = 0; | 366 | raidPtr->waitShutdown = 0; | |
363 | 367 | |||
364 | DO_RAID_MUTEX(&raidPtr->access_suspend_mutex); | 368 | DO_RAID_MUTEX(&raidPtr->access_suspend_mutex); | |
365 | 369 | |||
366 | raidPtr->waitForReconCond = 0; | 370 | raidPtr->waitForReconCond = 0; | |
367 | 371 |
--- src/sys/dev/raidframe/rf_engine.c 2010/09/13 08:43:06 1.41
+++ src/sys/dev/raidframe/rf_engine.c 2011/04/23 06:29:05 1.42
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rf_engine.c,v 1.41 2010/09/13 08:43:06 drochner Exp $ */ | 1 | /* $NetBSD: rf_engine.c,v 1.42 2011/04/23 06:29:05 mrg Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 1995 Carnegie-Mellon University. | 3 | * Copyright (c) 1995 Carnegie-Mellon University. | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Author: William V. Courtright II, Mark Holland, Rachad Youssef | 6 | * Author: William V. Courtright II, Mark Holland, Rachad Youssef | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify and distribute this software and | 8 | * Permission to use, copy, modify and distribute this software and | |
9 | * its documentation is hereby granted, provided that both the copyright | 9 | * its documentation is hereby granted, provided that both the copyright | |
10 | * notice and this permission notice appear in all copies of the | 10 | * notice and this permission notice appear in all copies of the | |
11 | * software, derivative works or modified versions, and any portions | 11 | * software, derivative works or modified versions, and any portions | |
12 | * thereof, and that both notices appear in supporting documentation. | 12 | * thereof, and that both notices appear in supporting documentation. | |
13 | * | 13 | * | |
14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | 14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
@@ -45,27 +45,27 @@ | @@ -45,27 +45,27 @@ | |||
45 | * Terminator nodes are never fired, but rather cause the callback * | 45 | * Terminator nodes are never fired, but rather cause the callback * | |
46 | * associated with the DAG to be invoked. * | 46 | * associated with the DAG to be invoked. * | |
47 | * * | 47 | * * | |
48 | * If a node fails, the dag either rolls forward to the completion or * | 48 | * If a node fails, the dag either rolls forward to the completion or * | |
49 | * rolls back, undoing previously-completed nodes and fails atomically. * | 49 | * rolls back, undoing previously-completed nodes and fails atomically. * | |
50 | * The direction of recovery is determined by the location of the failed * | 50 | * The direction of recovery is determined by the location of the failed * | |
51 | * node in the graph. If the failure occurred before the commit node in * | 51 | * node in the graph. If the failure occurred before the commit node in * | |
52 | * the graph, backward recovery is used. Otherwise, forward recovery is * | 52 | * the graph, backward recovery is used. Otherwise, forward recovery is * | |
53 | * used. * | 53 | * used. * | |
54 | * * | 54 | * * | |
55 | ****************************************************************************/ | 55 | ****************************************************************************/ | |
56 | 56 | |||
57 | #include <sys/cdefs.h> | 57 | #include <sys/cdefs.h> | |
58 | __KERNEL_RCSID(0, "$NetBSD: rf_engine.c,v 1.41 2010/09/13 08:43:06 drochner Exp $"); | 58 | __KERNEL_RCSID(0, "$NetBSD: rf_engine.c,v 1.42 2011/04/23 06:29:05 mrg Exp $"); | |
59 | 59 | |||
60 | #include <sys/errno.h> | 60 | #include <sys/errno.h> | |
61 | 61 | |||
62 | #include "rf_threadstuff.h" | 62 | #include "rf_threadstuff.h" | |
63 | #include "rf_dag.h" | 63 | #include "rf_dag.h" | |
64 | #include "rf_engine.h" | 64 | #include "rf_engine.h" | |
65 | #include "rf_etimer.h" | 65 | #include "rf_etimer.h" | |
66 | #include "rf_general.h" | 66 | #include "rf_general.h" | |
67 | #include "rf_dagutils.h" | 67 | #include "rf_dagutils.h" | |
68 | #include "rf_shutdown.h" | 68 | #include "rf_shutdown.h" | |
69 | #include "rf_raid.h" | 69 | #include "rf_raid.h" | |
70 | #include "rf_kintf.h" | 70 | #include "rf_kintf.h" | |
71 | #include "rf_paritymap.h" | 71 | #include "rf_paritymap.h" | |
@@ -93,37 +93,36 @@ do { \ | @@ -93,37 +93,36 @@ do { \ | |||
93 | 93 | |||
94 | #define DO_SIGNAL(_r_) \ | 94 | #define DO_SIGNAL(_r_) \ | |
95 | RF_BROADCAST_COND((_r_)->node_queue) /* XXX RF_SIGNAL_COND? */ | 95 | RF_BROADCAST_COND((_r_)->node_queue) /* XXX RF_SIGNAL_COND? */ | |
96 | 96 | |||
97 | static void | 97 | static void | |
98 | rf_ShutdownEngine(void *arg) | 98 | rf_ShutdownEngine(void *arg) | |
99 | { | 99 | { | |
100 | RF_Raid_t *raidPtr; | 100 | RF_Raid_t *raidPtr; | |
101 | int ks; | 101 | int ks; | |
102 | 102 | |||
103 | raidPtr = (RF_Raid_t *) arg; | 103 | raidPtr = (RF_Raid_t *) arg; | |
104 | 104 | |||
105 | /* Tell the rf_RaidIOThread to shutdown */ | 105 | /* Tell the rf_RaidIOThread to shutdown */ | |
106 | simple_lock(&(raidPtr->iodone_lock)); | 106 | mutex_enter(&raidPtr->iodone_lock); | |
107 | 107 | |||
108 | raidPtr->shutdown_raidio = 1; | 108 | raidPtr->shutdown_raidio = 1; | |
109 | wakeup(&(raidPtr->iodone)); | 109 | cv_signal(&raidPtr->iodone_cv); | |
110 | 110 | |||
111 | /* ...and wait for it to tell us it has finished */ | 111 | /* ...and wait for it to tell us it has finished */ | |
112 | while (raidPtr->shutdown_raidio) | 112 | while (raidPtr->shutdown_raidio) | |
113 | ltsleep(&(raidPtr->shutdown_raidio), PRIBIO, "raidshutdown", 0, | 113 | cv_wait(&raidPtr->iodone_cv, &raidPtr->iodone_lock); | |
114 | &(raidPtr->iodone_lock)); | |||
115 | 114 | |||
116 | simple_unlock(&(raidPtr->iodone_lock)); | 115 | mutex_exit(&raidPtr->iodone_lock); | |
117 | 116 | |||
118 | /* Now shut down the DAG execution engine. */ | 117 | /* Now shut down the DAG execution engine. */ | |
119 | DO_LOCK(raidPtr); | 118 | DO_LOCK(raidPtr); | |
120 | raidPtr->shutdown_engine = 1; | 119 | raidPtr->shutdown_engine = 1; | |
121 | DO_SIGNAL(raidPtr); | 120 | DO_SIGNAL(raidPtr); | |
122 | DO_UNLOCK(raidPtr); | 121 | DO_UNLOCK(raidPtr); | |
123 | 122 | |||
124 | } | 123 | } | |
125 | 124 | |||
126 | int | 125 | int | |
127 | rf_ConfigureEngine(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr, | 126 | rf_ConfigureEngine(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr, | |
128 | RF_Config_t *cfgPtr) | 127 | RF_Config_t *cfgPtr) | |
129 | { | 128 | { | |
@@ -838,55 +837,54 @@ DAGExecutionThread(RF_ThreadArg_t arg) | @@ -838,55 +837,54 @@ DAGExecutionThread(RF_ThreadArg_t arg) | |||
838 | * request, and by calling any required CompleteFunc for the request. | 837 | * request, and by calling any required CompleteFunc for the request. | |
839 | */ | 838 | */ | |
840 | 839 | |||
841 | static void | 840 | static void | |
842 | rf_RaidIOThread(RF_ThreadArg_t arg) | 841 | rf_RaidIOThread(RF_ThreadArg_t arg) | |
843 | { | 842 | { | |
844 | RF_Raid_t *raidPtr; | 843 | RF_Raid_t *raidPtr; | |
845 | RF_DiskQueueData_t *req; | 844 | RF_DiskQueueData_t *req; | |
846 | int s; | 845 | int s; | |
847 | 846 | |||
848 | raidPtr = (RF_Raid_t *) arg; | 847 | raidPtr = (RF_Raid_t *) arg; | |
849 | 848 | |||
850 | s = splbio(); | 849 | s = splbio(); | |
851 | simple_lock(&(raidPtr->iodone_lock)); | 850 | mutex_enter(&raidPtr->iodone_lock); | |
852 | 851 | |||
853 | while (!raidPtr->shutdown_raidio) { | 852 | while (!raidPtr->shutdown_raidio) { | |
854 | /* if there is nothing to do, then snooze. */ | 853 | /* if there is nothing to do, then snooze. */ | |
855 | if (TAILQ_EMPTY(&(raidPtr->iodone)) && | 854 | if (TAILQ_EMPTY(&(raidPtr->iodone)) && | |
856 | rf_buf_queue_check(raidPtr->raidid)) { | 855 | rf_buf_queue_check(raidPtr->raidid)) { | |
857 | ltsleep(&(raidPtr->iodone), PRIBIO, "raidiow", 0, | 856 | cv_wait(&raidPtr->iodone_cv, &raidPtr->iodone_lock); | |
858 | &(raidPtr->iodone_lock)); | |||
859 | } | 857 | } | |
860 | 858 | |||
861 | /* Check for deferred parity-map-related work. */ | 859 | /* Check for deferred parity-map-related work. */ | |
862 | if (raidPtr->parity_map != NULL) { | 860 | if (raidPtr->parity_map != NULL) { | |
863 | simple_unlock(&(raidPtr->iodone_lock)); | 861 | mutex_exit(&raidPtr->iodone_lock); | |
864 | rf_paritymap_checkwork(raidPtr->parity_map); | 862 | rf_paritymap_checkwork(raidPtr->parity_map); | |
865 | simple_lock(&(raidPtr->iodone_lock)); | 863 | mutex_enter(&raidPtr->iodone_lock); | |
866 | } | 864 | } | |
867 | 865 | |||
868 | /* See what I/Os, if any, have arrived */ | 866 | /* See what I/Os, if any, have arrived */ | |
869 | while ((req = TAILQ_FIRST(&(raidPtr->iodone))) != NULL) { | 867 | while ((req = TAILQ_FIRST(&(raidPtr->iodone))) != NULL) { | |
870 | TAILQ_REMOVE(&(raidPtr->iodone), req, iodone_entries); | 868 | TAILQ_REMOVE(&(raidPtr->iodone), req, iodone_entries); | |
871 | simple_unlock(&(raidPtr->iodone_lock)); | 869 | mutex_exit(&raidPtr->iodone_lock); | |
872 | rf_DiskIOComplete(req->queue, req, req->error); | 870 | rf_DiskIOComplete(req->queue, req, req->error); | |
873 | (req->CompleteFunc) (req->argument, req->error); | 871 | (req->CompleteFunc) (req->argument, req->error); | |
874 | simple_lock(&(raidPtr->iodone_lock)); | 872 | mutex_enter(&raidPtr->iodone_lock); | |
875 | } | 873 | } | |
876 | 874 | |||
877 | /* process any pending outgoing IO */ | 875 | /* process any pending outgoing IO */ | |
878 | simple_unlock(&(raidPtr->iodone_lock)); | 876 | mutex_exit(&raidPtr->iodone_lock); | |
879 | raidstart(raidPtr); | 877 | raidstart(raidPtr); | |
880 | simple_lock(&(raidPtr->iodone_lock)); | 878 | mutex_enter(&raidPtr->iodone_lock); | |
881 | 879 | |||
882 | } | 880 | } | |
883 | 881 | |||
884 | /* Let rf_ShutdownEngine know that we're done... */ | 882 | /* Let rf_ShutdownEngine know that we're done... */ | |
885 | raidPtr->shutdown_raidio = 0; | 883 | raidPtr->shutdown_raidio = 0; | |
886 | wakeup(&(raidPtr->shutdown_raidio)); | 884 | cv_signal(&raidPtr->iodone_cv); | |
887 | 885 | |||
888 | simple_unlock(&(raidPtr->iodone_lock)); | 886 | mutex_exit(&raidPtr->iodone_lock); | |
889 | splx(s); | 887 | splx(s); | |
890 | 888 | |||
891 | kthread_exit(0); | 889 | kthread_exit(0); | |
892 | } | 890 | } |
--- src/sys/dev/raidframe/rf_netbsdkintf.c 2011/03/18 23:53:26 1.284
+++ src/sys/dev/raidframe/rf_netbsdkintf.c 2011/04/23 06:29:05 1.285
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rf_netbsdkintf.c,v 1.284 2011/03/18 23:53:26 mrg Exp $ */ | 1 | /* $NetBSD: rf_netbsdkintf.c,v 1.285 2011/04/23 06:29:05 mrg Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Greg Oster; Jason R. Thorpe. | 8 | * by Greg Oster; Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -91,27 +91,27 @@ | @@ -91,27 +91,27 @@ | |||
91 | * Pittsburgh PA 15213-3890 | 91 | * Pittsburgh PA 15213-3890 | |
92 | * | 92 | * | |
93 | * any improvements or extensions that they make and grant Carnegie the | 93 | * any improvements or extensions that they make and grant Carnegie the | |
94 | * rights to redistribute these changes. | 94 | * rights to redistribute these changes. | |
95 | */ | 95 | */ | |
96 | 96 | |||
97 | /*********************************************************** | 97 | /*********************************************************** | |
98 | * | 98 | * | |
99 | * rf_kintf.c -- the kernel interface routines for RAIDframe | 99 | * rf_kintf.c -- the kernel interface routines for RAIDframe | |
100 | * | 100 | * | |
101 | ***********************************************************/ | 101 | ***********************************************************/ | |
102 | 102 | |||
103 | #include <sys/cdefs.h> | 103 | #include <sys/cdefs.h> | |
104 | __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.284 2011/03/18 23:53:26 mrg Exp $"); | 104 | __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.285 2011/04/23 06:29:05 mrg Exp $"); | |
105 | 105 | |||
106 | #ifdef _KERNEL_OPT | 106 | #ifdef _KERNEL_OPT | |
107 | #include "opt_compat_netbsd.h" | 107 | #include "opt_compat_netbsd.h" | |
108 | #include "opt_raid_autoconfig.h" | 108 | #include "opt_raid_autoconfig.h" | |
109 | #include "raid.h" | 109 | #include "raid.h" | |
110 | #endif | 110 | #endif | |
111 | 111 | |||
112 | #include <sys/param.h> | 112 | #include <sys/param.h> | |
113 | #include <sys/errno.h> | 113 | #include <sys/errno.h> | |
114 | #include <sys/pool.h> | 114 | #include <sys/pool.h> | |
115 | #include <sys/proc.h> | 115 | #include <sys/proc.h> | |
116 | #include <sys/queue.h> | 116 | #include <sys/queue.h> | |
117 | #include <sys/disk.h> | 117 | #include <sys/disk.h> | |
@@ -819,28 +819,26 @@ raidclose(dev_t dev, int flags, int fmt, | @@ -819,28 +819,26 @@ raidclose(dev_t dev, int flags, int fmt, | |||
819 | /* If the kernel is shutting down, it will detach | 819 | /* If the kernel is shutting down, it will detach | |
820 | * this RAID set soon enough. | 820 | * this RAID set soon enough. | |
821 | */ | 821 | */ | |
822 | } | 822 | } | |
823 | 823 | |||
824 | raidunlock(rs); | 824 | raidunlock(rs); | |
825 | return (0); | 825 | return (0); | |
826 | 826 | |||
827 | } | 827 | } | |
828 | 828 | |||
829 | void | 829 | void | |
830 | raidstrategy(struct buf *bp) | 830 | raidstrategy(struct buf *bp) | |
831 | { | 831 | { | |
832 | int s; | |||
833 | ||||
834 | unsigned int raidID = raidunit(bp->b_dev); | 832 | unsigned int raidID = raidunit(bp->b_dev); | |
835 | RF_Raid_t *raidPtr; | 833 | RF_Raid_t *raidPtr; | |
836 | struct raid_softc *rs = &raid_softc[raidID]; | 834 | struct raid_softc *rs = &raid_softc[raidID]; | |
837 | int wlabel; | 835 | int wlabel; | |
838 | 836 | |||
839 | if ((rs->sc_flags & RAIDF_INITED) ==0) { | 837 | if ((rs->sc_flags & RAIDF_INITED) ==0) { | |
840 | bp->b_error = ENXIO; | 838 | bp->b_error = ENXIO; | |
841 | goto done; | 839 | goto done; | |
842 | } | 840 | } | |
843 | if (raidID >= numraid || !raidPtrs[raidID]) { | 841 | if (raidID >= numraid || !raidPtrs[raidID]) { | |
844 | bp->b_error = ENODEV; | 842 | bp->b_error = ENODEV; | |
845 | goto done; | 843 | goto done; | |
846 | } | 844 | } | |
@@ -870,37 +868,38 @@ raidstrategy(struct buf *bp) | @@ -870,37 +868,38 @@ raidstrategy(struct buf *bp) | |||
870 | size = raidPtr->totalSectors >> | 868 | size = raidPtr->totalSectors >> | |
871 | (DEV_BSHIFT - raidPtr->logBytesPerSector); | 869 | (DEV_BSHIFT - raidPtr->logBytesPerSector); | |
872 | } | 870 | } | |
873 | if (bounds_check_with_mediasize(bp, DEV_BSIZE, size) <= 0) { | 871 | if (bounds_check_with_mediasize(bp, DEV_BSIZE, size) <= 0) { | |
874 | goto done; | 872 | goto done; | |
875 | } | 873 | } | |
876 | } else { | 874 | } else { | |
877 | if (bounds_check_with_label(&rs->sc_dkdev, bp, wlabel) <= 0) { | 875 | if (bounds_check_with_label(&rs->sc_dkdev, bp, wlabel) <= 0) { | |
878 | db1_printf(("Bounds check failed!!:%d %d\n", | 876 | db1_printf(("Bounds check failed!!:%d %d\n", | |
879 | (int) bp->b_blkno, (int) wlabel)); | 877 | (int) bp->b_blkno, (int) wlabel)); | |
880 | goto done; | 878 | goto done; | |
881 | } | 879 | } | |
882 | } | 880 | } | |
883 | s = splbio(); | 881 | ||
882 | mutex_enter(&raidPtr->iodone_lock); | |||
884 | 883 | |||
885 | bp->b_resid = 0; | 884 | bp->b_resid = 0; | |
886 | 885 | |||
887 | /* stuff it onto our queue */ | 886 | /* stuff it onto our queue */ | |
888 | bufq_put(rs->buf_queue, bp); | 887 | bufq_put(rs->buf_queue, bp); | |
889 | 888 | |||
890 | /* scheduled the IO to happen at the next convenient time */ | 889 | /* scheduled the IO to happen at the next convenient time */ | |
891 | wakeup(&(raidPtrs[raidID]->iodone)); | 890 | cv_signal(&raidPtr->iodone_cv); | |
891 | mutex_exit(&raidPtr->iodone_lock); | |||
892 | 892 | |||
893 | splx(s); | |||
894 | return; | 893 | return; | |
895 | 894 | |||
896 | done: | 895 | done: | |
897 | bp->b_resid = bp->b_bcount; | 896 | bp->b_resid = bp->b_bcount; | |
898 | biodone(bp); | 897 | biodone(bp); | |
899 | } | 898 | } | |
900 | /* ARGSUSED */ | 899 | /* ARGSUSED */ | |
901 | int | 900 | int | |
902 | raidread(dev_t dev, struct uio *uio, int flags) | 901 | raidread(dev_t dev, struct uio *uio, int flags) | |
903 | { | 902 | { | |
904 | int unit = raidunit(dev); | 903 | int unit = raidunit(dev); | |
905 | struct raid_softc *rs; | 904 | struct raid_softc *rs; | |
906 | 905 | |||
@@ -2150,34 +2149,35 @@ rf_DispatchKernelIO(RF_DiskQueue_t *queu | @@ -2150,34 +2149,35 @@ rf_DispatchKernelIO(RF_DiskQueue_t *queu | |||
2150 | } | 2149 | } | |
2151 | db1_printf(("Exiting from DispatchKernelIO\n")); | 2150 | db1_printf(("Exiting from DispatchKernelIO\n")); | |
2152 | 2151 | |||
2153 | return (0); | 2152 | return (0); | |
2154 | } | 2153 | } | |
2155 | /* this is the callback function associated with a I/O invoked from | 2154 | /* this is the callback function associated with a I/O invoked from | |
2156 | kernel code. | 2155 | kernel code. | |
2157 | */ | 2156 | */ | |
2158 | static void | 2157 | static void | |
2159 | KernelWakeupFunc(struct buf *bp) | 2158 | KernelWakeupFunc(struct buf *bp) | |
2160 | { | 2159 | { | |
2161 | RF_DiskQueueData_t *req = NULL; | 2160 | RF_DiskQueueData_t *req = NULL; | |
2162 | RF_DiskQueue_t *queue; | 2161 | RF_DiskQueue_t *queue; | |
2163 | int s; | |||
2164 | 2162 | |||
2165 | s = splbio(); | |||
2166 | db1_printf(("recovering the request queue:\n")); | 2163 | db1_printf(("recovering the request queue:\n")); | |
2164 | ||||
2167 | req = bp->b_private; | 2165 | req = bp->b_private; | |
2168 | 2166 | |||
2169 | queue = (RF_DiskQueue_t *) req->queue; | 2167 | queue = (RF_DiskQueue_t *) req->queue; | |
2170 | 2168 | |||
2169 | mutex_enter(&queue->raidPtr->iodone_lock); | |||
2170 | ||||
2171 | #if RF_ACC_TRACE > 0 | 2171 | #if RF_ACC_TRACE > 0 | |
2172 | if (req->tracerec) { | 2172 | if (req->tracerec) { | |
2173 | RF_ETIMER_STOP(req->tracerec->timer); | 2173 | RF_ETIMER_STOP(req->tracerec->timer); | |
2174 | RF_ETIMER_EVAL(req->tracerec->timer); | 2174 | RF_ETIMER_EVAL(req->tracerec->timer); | |
2175 | RF_LOCK_MUTEX(rf_tracing_mutex); | 2175 | RF_LOCK_MUTEX(rf_tracing_mutex); | |
2176 | req->tracerec->diskwait_us += RF_ETIMER_VAL_US(req->tracerec->timer); | 2176 | req->tracerec->diskwait_us += RF_ETIMER_VAL_US(req->tracerec->timer); | |
2177 | req->tracerec->phys_io_us += RF_ETIMER_VAL_US(req->tracerec->timer); | 2177 | req->tracerec->phys_io_us += RF_ETIMER_VAL_US(req->tracerec->timer); | |
2178 | req->tracerec->num_phys_ios++; | 2178 | req->tracerec->num_phys_ios++; | |
2179 | RF_UNLOCK_MUTEX(rf_tracing_mutex); | 2179 | RF_UNLOCK_MUTEX(rf_tracing_mutex); | |
2180 | } | 2180 | } | |
2181 | #endif | 2181 | #endif | |
2182 | 2182 | |||
2183 | /* XXX Ok, let's get aggressive... If b_error is set, let's go | 2183 | /* XXX Ok, let's get aggressive... If b_error is set, let's go | |
@@ -2199,44 +2199,38 @@ KernelWakeupFunc(struct buf *bp) | @@ -2199,44 +2199,38 @@ KernelWakeupFunc(struct buf *bp) | |||
2199 | queue->raidPtr->Disks[queue->col].devname); | 2199 | queue->raidPtr->Disks[queue->col].devname); | |
2200 | queue->raidPtr->Disks[queue->col].status = | 2200 | queue->raidPtr->Disks[queue->col].status = | |
2201 | rf_ds_failed; | 2201 | rf_ds_failed; | |
2202 | queue->raidPtr->status = rf_rs_degraded; | 2202 | queue->raidPtr->status = rf_rs_degraded; | |
2203 | queue->raidPtr->numFailures++; | 2203 | queue->raidPtr->numFailures++; | |
2204 | queue->raidPtr->numNewFailures++; | 2204 | queue->raidPtr->numNewFailures++; | |
2205 | } else { /* Disk is already dead... */ | 2205 | } else { /* Disk is already dead... */ | |
2206 | /* printf("Disk already marked as dead!\n"); */ | 2206 | /* printf("Disk already marked as dead!\n"); */ | |
2207 | } | 2207 | } | |
2208 | 2208 | |||
2209 | } | 2209 | } | |
2210 | 2210 | |||
2211 | /* Fill in the error value */ | 2211 | /* Fill in the error value */ | |
2212 | ||||
2213 | req->error = bp->b_error; | 2212 | req->error = bp->b_error; | |
2214 | 2213 | |||
2215 | simple_lock(&queue->raidPtr->iodone_lock); | |||
2216 | ||||
2217 | /* Drop this one on the "finished" queue... */ | 2214 | /* Drop this one on the "finished" queue... */ | |
2218 | TAILQ_INSERT_TAIL(&(queue->raidPtr->iodone), req, iodone_entries); | 2215 | TAILQ_INSERT_TAIL(&(queue->raidPtr->iodone), req, iodone_entries); | |
2219 | 2216 | |||
2220 | /* Let the raidio thread know there is work to be done. */ | 2217 | /* Let the raidio thread know there is work to be done. */ | |
2221 | wakeup(&(queue->raidPtr->iodone)); | 2218 | cv_signal(&queue->raidPtr->iodone_cv); | |
2222 | 2219 | |||
2223 | simple_unlock(&queue->raidPtr->iodone_lock); | 2220 | mutex_exit(&queue->raidPtr->iodone_lock); | |
2224 | ||||
2225 | splx(s); | |||
2226 | } | 2221 | } | |
2227 | 2222 | |||
2228 | 2223 | |||
2229 | ||||
2230 | /* | 2224 | /* | |
2231 | * initialize a buf structure for doing an I/O in the kernel. | 2225 | * initialize a buf structure for doing an I/O in the kernel. | |
2232 | */ | 2226 | */ | |
2233 | static void | 2227 | static void | |
2234 | InitBP(struct buf *bp, struct vnode *b_vp, unsigned rw_flag, dev_t dev, | 2228 | InitBP(struct buf *bp, struct vnode *b_vp, unsigned rw_flag, dev_t dev, | |
2235 | RF_SectorNum_t startSect, RF_SectorCount_t numSect, void *bf, | 2229 | RF_SectorNum_t startSect, RF_SectorCount_t numSect, void *bf, | |
2236 | void (*cbFunc) (struct buf *), void *cbArg, int logBytesPerSector, | 2230 | void (*cbFunc) (struct buf *), void *cbArg, int logBytesPerSector, | |
2237 | struct proc *b_proc) | 2231 | struct proc *b_proc) | |
2238 | { | 2232 | { | |
2239 | /* bp->b_flags = B_PHYS | rw_flag; */ | 2233 | /* bp->b_flags = B_PHYS | rw_flag; */ | |
2240 | bp->b_flags = rw_flag; /* XXX need B_PHYS here too??? */ | 2234 | bp->b_flags = rw_flag; /* XXX need B_PHYS here too??? */ | |
2241 | bp->b_oflags = 0; | 2235 | bp->b_oflags = 0; | |
2242 | bp->b_cflags = 0; | 2236 | bp->b_cflags = 0; |
--- src/sys/dev/raidframe/rf_paritymap.c 2011/03/01 22:51:14 1.6
+++ src/sys/dev/raidframe/rf_paritymap.c 2011/04/23 06:29:05 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rf_paritymap.c,v 1.6 2011/03/01 22:51:14 riz Exp $ */ | 1 | /* $NetBSD: rf_paritymap.c,v 1.7 2011/04/23 06:29:05 mrg Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2009 Jed Davis. | 4 | * Copyright (c) 2009 Jed Davis. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.6 2011/03/01 22:51:14 riz Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.7 2011/04/23 06:29:05 mrg Exp $"); | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/callout.h> | 33 | #include <sys/callout.h> | |
34 | #include <sys/kmem.h> | 34 | #include <sys/kmem.h> | |
35 | #include <sys/mutex.h> | 35 | #include <sys/mutex.h> | |
36 | #include <sys/rwlock.h> | 36 | #include <sys/rwlock.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/types.h> | 38 | #include <sys/types.h> | |
39 | 39 | |||
40 | #include <dev/raidframe/rf_paritymap.h> | 40 | #include <dev/raidframe/rf_paritymap.h> | |
41 | #include <dev/raidframe/rf_stripelocks.h> | 41 | #include <dev/raidframe/rf_stripelocks.h> | |
42 | #include <dev/raidframe/rf_layout.h> | 42 | #include <dev/raidframe/rf_layout.h> | |
43 | #include <dev/raidframe/rf_raid.h> | 43 | #include <dev/raidframe/rf_raid.h> | |
@@ -249,27 +249,30 @@ rf_paritymap_forceclean(struct rf_parity | @@ -249,27 +249,30 @@ rf_paritymap_forceclean(struct rf_parity | |||
249 | /* | 249 | /* | |
250 | * The cooldown callout routine just defers its work to a thread; it can't do | 250 | * The cooldown callout routine just defers its work to a thread; it can't do | |
251 | * the parity map write itself as it would block, and although mutex-induced | 251 | * the parity map write itself as it would block, and although mutex-induced | |
252 | * blocking is permitted it seems wise to avoid tying up the softint. | 252 | * blocking is permitted it seems wise to avoid tying up the softint. | |
253 | */ | 253 | */ | |
254 | static void | 254 | static void | |
255 | rf_paritymap_tick(void *arg) | 255 | rf_paritymap_tick(void *arg) | |
256 | { | 256 | { | |
257 | struct rf_paritymap *pm = arg; | 257 | struct rf_paritymap *pm = arg; | |
258 | 258 | |||
259 | mutex_enter(&pm->lk_flags); | 259 | mutex_enter(&pm->lk_flags); | |
260 | pm->flags |= TICKED; | 260 | pm->flags |= TICKED; | |
261 | mutex_exit(&pm->lk_flags); | 261 | mutex_exit(&pm->lk_flags); | |
262 | wakeup(&(pm->raid->iodone)); /* XXX */ | 262 | ||
263 | mutex_enter(&pm->raid->iodone_lock); | |||
264 | cv_signal(&pm->raid->iodone_cv); /* XXX */ | |||
265 | mutex_exit(&pm->raid->iodone_lock); | |||
263 | } | 266 | } | |
264 | 267 | |||
265 | /* | 268 | /* | |
266 | * This is where the parity cooling work (and rearming the callout if needed) | 269 | * This is where the parity cooling work (and rearming the callout if needed) | |
267 | * is done; the raidio thread calls it when woken up, as by the above. | 270 | * is done; the raidio thread calls it when woken up, as by the above. | |
268 | */ | 271 | */ | |
269 | void | 272 | void | |
270 | rf_paritymap_checkwork(struct rf_paritymap *pm) | 273 | rf_paritymap_checkwork(struct rf_paritymap *pm) | |
271 | { | 274 | { | |
272 | int i, zerop, progressp; | 275 | int i, zerop, progressp; | |
273 | 276 | |||
274 | mutex_enter(&pm->lk_flags); | 277 | mutex_enter(&pm->lk_flags); | |
275 | if (pm->flags & TICKED) { | 278 | if (pm->flags & TICKED) { | |
@@ -572,30 +575,30 @@ rf_paritymap_merge(struct rf_paritymap_o | @@ -572,30 +575,30 @@ rf_paritymap_merge(struct rf_paritymap_o | |||
572 | } | 575 | } | |
573 | 576 | |||
574 | /* | 577 | /* | |
575 | * Detach a parity map from its RAID. This is not meant to be applied except | 578 | * Detach a parity map from its RAID. This is not meant to be applied except | |
576 | * when unconfiguring the RAID after all I/O has been resolved, as otherwise | 579 | * when unconfiguring the RAID after all I/O has been resolved, as otherwise | |
577 | * an out-of-date parity map could be treated as current. | 580 | * an out-of-date parity map could be treated as current. | |
578 | */ | 581 | */ | |
579 | void | 582 | void | |
580 | rf_paritymap_detach(RF_Raid_t *raidPtr) | 583 | rf_paritymap_detach(RF_Raid_t *raidPtr) | |
581 | { | 584 | { | |
582 | if (raidPtr->parity_map == NULL) | 585 | if (raidPtr->parity_map == NULL) | |
583 | return; | 586 | return; | |
584 | 587 | |||
585 | simple_lock(&(raidPtr->iodone_lock)); | 588 | mutex_enter(&raidPtr->iodone_lock); | |
586 | struct rf_paritymap *pm = raidPtr->parity_map; | 589 | struct rf_paritymap *pm = raidPtr->parity_map; | |
587 | raidPtr->parity_map = NULL; | 590 | raidPtr->parity_map = NULL; | |
588 | simple_unlock(&(raidPtr->iodone_lock)); | 591 | mutex_exit(&raidPtr->iodone_lock); | |
589 | /* XXXjld is that enough locking? Or too much? */ | 592 | /* XXXjld is that enough locking? Or too much? */ | |
590 | rf_paritymap_destroy(pm, 0); | 593 | rf_paritymap_destroy(pm, 0); | |
591 | kmem_free(pm, sizeof(*pm)); | 594 | kmem_free(pm, sizeof(*pm)); | |
592 | } | 595 | } | |
593 | 596 | |||
594 | /* | 597 | /* | |
595 | * Is this RAID set ineligible for parity-map use due to not actually | 598 | * Is this RAID set ineligible for parity-map use due to not actually | |
596 | * having any parity? (If so, rf_paritymap_attach is a no-op, but | 599 | * having any parity? (If so, rf_paritymap_attach is a no-op, but | |
597 | * rf_paritymap_{get,set}_disable will still pointlessly act on the | 600 | * rf_paritymap_{get,set}_disable will still pointlessly act on the | |
598 | * component labels.) | 601 | * component labels.) | |
599 | */ | 602 | */ | |
600 | int | 603 | int | |
601 | rf_paritymap_ineligible(RF_Raid_t *raidPtr) | 604 | rf_paritymap_ineligible(RF_Raid_t *raidPtr) |
--- src/sys/dev/raidframe/rf_raid.h 2009/11/17 18:54:26 1.38
+++ src/sys/dev/raidframe/rf_raid.h 2011/04/23 06:29:05 1.39
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rf_raid.h,v 1.38 2009/11/17 18:54:26 jld Exp $ */ | 1 | /* $NetBSD: rf_raid.h,v 1.39 2011/04/23 06:29:05 mrg Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 1995 Carnegie-Mellon University. | 3 | * Copyright (c) 1995 Carnegie-Mellon University. | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Author: Mark Holland | 6 | * Author: Mark Holland | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify and distribute this software and | 8 | * Permission to use, copy, modify and distribute this software and | |
9 | * its documentation is hereby granted, provided that both the copyright | 9 | * its documentation is hereby granted, provided that both the copyright | |
10 | * notice and this permission notice appear in all copies of the | 10 | * notice and this permission notice appear in all copies of the | |
11 | * software, derivative works or modified versions, and any portions | 11 | * software, derivative works or modified versions, and any portions | |
12 | * thereof, and that both notices appear in supporting documentation. | 12 | * thereof, and that both notices appear in supporting documentation. | |
13 | * | 13 | * | |
14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | 14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
@@ -151,28 +151,29 @@ struct RF_Raid_s { | @@ -151,28 +151,29 @@ struct RF_Raid_s { | |||
151 | int last_unit; /* last unit number (e.g. 0 for /dev/raid0) | 151 | int last_unit; /* last unit number (e.g. 0 for /dev/raid0) | |
152 | of this component. Used for autoconfigure | 152 | of this component. Used for autoconfigure | |
153 | only. */ | 153 | only. */ | |
154 | int config_order; /* 0 .. n. The order in which the component | 154 | int config_order; /* 0 .. n. The order in which the component | |
155 | should be auto-configured. E.g. 0 is will | 155 | should be auto-configured. E.g. 0 is will | |
156 | done first, (and would become raid0). | 156 | done first, (and would become raid0). | |
157 | This may be in conflict with last_unit!!?! */ | 157 | This may be in conflict with last_unit!!?! */ | |
158 | /* Not currently used. */ | 158 | /* Not currently used. */ | |
159 | 159 | |||
160 | /* queue to gather up requests from KernelWakeupFunc() and let | 160 | /* queue to gather up requests from KernelWakeupFunc() and let | |
161 | a kernel thread deal with calling rf_DiskIOComplete and any | 161 | a kernel thread deal with calling rf_DiskIOComplete and any | |
162 | callback functions. */ | 162 | callback functions. */ | |
163 | TAILQ_HEAD(iodone_q,RF_DiskQueueData_s) iodone; | 163 | TAILQ_HEAD(iodone_q,RF_DiskQueueData_s) iodone; | |
164 | /* and a lock to protect it */ | 164 | /* and a lock/cv to protect it */ | |
165 | struct simplelock iodone_lock; | 165 | kmutex_t iodone_lock; | |
166 | kcondvar_t iodone_cv; | |||
166 | 167 | |||
167 | 168 | |||
168 | RF_VoidPointerListElem_t *iobuf; /* I/O buffer free list */ | 169 | RF_VoidPointerListElem_t *iobuf; /* I/O buffer free list */ | |
169 | int iobuf_count; /* count of I/O buffers on the freelist */ | 170 | int iobuf_count; /* count of I/O buffers on the freelist */ | |
170 | int numEmergencyBuffers; /* number of these buffers to pre-allocate */ | 171 | int numEmergencyBuffers; /* number of these buffers to pre-allocate */ | |
171 | 172 | |||
172 | RF_VoidPointerListElem_t *stripebuf; /* Full-stripe buffer free list */ | 173 | RF_VoidPointerListElem_t *stripebuf; /* Full-stripe buffer free list */ | |
173 | int stripebuf_count; /* count of full-stripe buffers on the freelist */ | 174 | int stripebuf_count; /* count of full-stripe buffers on the freelist */ | |
174 | int numEmergencyStripeBuffers; /* number of these buffers to pre-allocate */ | 175 | int numEmergencyStripeBuffers; /* number of these buffers to pre-allocate */ | |
175 | 176 | |||
176 | /* | 177 | /* | |
177 | * Cleanup stuff | 178 | * Cleanup stuff | |
178 | */ | 179 | */ |
--- src/sys/dev/raidframe/rf_states.c 2009/11/17 18:54:26 1.44
+++ src/sys/dev/raidframe/rf_states.c 2011/04/23 06:29:05 1.45
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rf_states.c,v 1.44 2009/11/17 18:54:26 jld Exp $ */ | 1 | /* $NetBSD: rf_states.c,v 1.45 2011/04/23 06:29:05 mrg Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 1995 Carnegie-Mellon University. | 3 | * Copyright (c) 1995 Carnegie-Mellon University. | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Author: Mark Holland, William V. Courtright II, Robby Findler | 6 | * Author: Mark Holland, William V. Courtright II, Robby Findler | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify and distribute this software and | 8 | * Permission to use, copy, modify and distribute this software and | |
9 | * its documentation is hereby granted, provided that both the copyright | 9 | * its documentation is hereby granted, provided that both the copyright | |
10 | * notice and this permission notice appear in all copies of the | 10 | * notice and this permission notice appear in all copies of the | |
11 | * software, derivative works or modified versions, and any portions | 11 | * software, derivative works or modified versions, and any portions | |
12 | * thereof, and that both notices appear in supporting documentation. | 12 | * thereof, and that both notices appear in supporting documentation. | |
13 | * | 13 | * | |
14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | 14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * | 17 | * | |
18 | * Carnegie Mellon requests users of this software to return to | 18 | * Carnegie Mellon requests users of this software to return to | |
19 | * | 19 | * | |
20 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | 20 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
21 | * School of Computer Science | 21 | * School of Computer Science | |
22 | * Carnegie Mellon University | 22 | * Carnegie Mellon University | |
23 | * Pittsburgh PA 15213-3890 | 23 | * Pittsburgh PA 15213-3890 | |
24 | * | 24 | * | |
25 | * any improvements or extensions that they make and grant Carnegie the | 25 | * any improvements or extensions that they make and grant Carnegie the | |
26 | * rights to redistribute these changes. | 26 | * rights to redistribute these changes. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: rf_states.c,v 1.44 2009/11/17 18:54:26 jld Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: rf_states.c,v 1.45 2011/04/23 06:29:05 mrg Exp $"); | |
31 | 31 | |||
32 | #include <sys/errno.h> | 32 | #include <sys/errno.h> | |
33 | 33 | |||
34 | #include "rf_archs.h" | 34 | #include "rf_archs.h" | |
35 | #include "rf_threadstuff.h" | 35 | #include "rf_threadstuff.h" | |
36 | #include "rf_raid.h" | 36 | #include "rf_raid.h" | |
37 | #include "rf_dag.h" | 37 | #include "rf_dag.h" | |
38 | #include "rf_desc.h" | 38 | #include "rf_desc.h" | |
39 | #include "rf_aselect.h" | 39 | #include "rf_aselect.h" | |
40 | #include "rf_general.h" | 40 | #include "rf_general.h" | |
41 | #include "rf_states.h" | 41 | #include "rf_states.h" | |
42 | #include "rf_dagutils.h" | 42 | #include "rf_dagutils.h" | |
43 | #include "rf_driver.h" | 43 | #include "rf_driver.h" | |
@@ -226,27 +226,29 @@ rf_State_LastState(RF_RaidAccessDesc_t * | @@ -226,27 +226,29 @@ rf_State_LastState(RF_RaidAccessDesc_t * | |||
226 | * That's all the IO for this one... unbusy the 'disk'. | 226 | * That's all the IO for this one... unbusy the 'disk'. | |
227 | */ | 227 | */ | |
228 | 228 | |||
229 | rf_disk_unbusy(desc); | 229 | rf_disk_unbusy(desc); | |
230 | 230 | |||
231 | /* | 231 | /* | |
232 | * Wakeup any requests waiting to go. | 232 | * Wakeup any requests waiting to go. | |
233 | */ | 233 | */ | |
234 | 234 | |||
235 | RF_LOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex); | 235 | RF_LOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex); | |
236 | ((RF_Raid_t *) desc->raidPtr)->openings++; | 236 | ((RF_Raid_t *) desc->raidPtr)->openings++; | |
237 | RF_UNLOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex); | 237 | RF_UNLOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex); | |
238 | 238 | |||
239 | wakeup(&(desc->raidPtr->iodone)); | 239 | mutex_enter(&desc->raidPtr->iodone_lock); | |
240 | cv_signal(&desc->raidPtr->iodone_cv); | |||
241 | mutex_exit(&desc->raidPtr->iodone_lock); | |||
240 | 242 | |||
241 | /* | 243 | /* | |
242 | * The parity_map hook has to go here, because the iodone | 244 | * The parity_map hook has to go here, because the iodone | |
243 | * callback goes straight into the kintf layer. | 245 | * callback goes straight into the kintf layer. | |
244 | */ | 246 | */ | |
245 | if (desc->raidPtr->parity_map != NULL && | 247 | if (desc->raidPtr->parity_map != NULL && | |
246 | desc->type == RF_IO_TYPE_WRITE) | 248 | desc->type == RF_IO_TYPE_WRITE) | |
247 | rf_paritymap_end(desc->raidPtr->parity_map, | 249 | rf_paritymap_end(desc->raidPtr->parity_map, | |
248 | desc->raidAddress, desc->numBlocks); | 250 | desc->raidAddress, desc->numBlocks); | |
249 | 251 | |||
250 | /* printf("Calling biodone on 0x%x\n",desc->bp); */ | 252 | /* printf("Calling biodone on 0x%x\n",desc->bp); */ | |
251 | biodone(desc->bp); /* access came through ioctl */ | 253 | biodone(desc->bp); /* access came through ioctl */ | |
252 | 254 |