Commit Graph

104 Commits

Author SHA1 Message Date
oster 4880044636 Remove a (redundant) check that was already performed in raidstart(). 2004-06-29 17:09:01 +00:00
oster 6df1f117b1 Address a number of issues:
1) Introduce functions to allocate and free the emergency IO buffers.

2) Make sure we free any allocated emergency buffers in the event that
we bail out during configuration, or when we unconfigure an array.

3) if we run out of memory trying to allocate a given type of buffer,
don't continue to try to allocate more of those buffers.
(Partially addresses PR#25787)
2004-06-27 03:15:18 +00:00
drochner e7bdadd856 fix const'ificication, gcc-3.4 will notice it 2004-06-02 22:58:28 +00:00
itojun aca4c091d3 sprintf -> snprintf 2004-04-22 00:17:10 +00:00
oster 4a82b086a3 Allocating emergency buffer space is all fine and well, but one should really
remember to return the memory when unconfiguring the array.  Same thing goes
for the pool elements used to build the list!
2004-04-10 05:52:33 +00:00
oster 85611189b6 These changes complete the effective removal of malloc() from all
write paths within RAIDframe.  They also resolve the "panics with
RAID 5 sets with more than 3 components" issue which was present
(briefly) in the commits which were previously supposed to address
the malloc() issue.

With this new code the 5-component RAID 5 set panics are now gone.

It is also now also possible to swap to RAID 5.

The changes made are:

1) Introduce rf_AllocStripeBuffer() and rf_FreeStripeBuffer() to
allocate/free one stripe's worth of space.  rf_AllocStripeBuffer() is
used in rf_MapUnaccessedPortionOfStripe() where it is not sufficient to
allocate memory using just rf_AllocBuffer().  rf_FreeStripeBuffer() is
called from rf_FreeRaidAccDesc(), well after the DAG is finished.

2) Add a set of emergency "stripe buffers" to struct RF_Raid_s.
Arrange for their initialization in rf_Configure().  In low-memory
situations these buffers will be returned by rf_AllocStripeBuffer()
and re-populated by rf_FreeStripeBuffer().

3) Move	RF_VoidPointerListElem_t *iobufs from the dagHeader into
into struct RF_RaidAccessDesc_s.  This is more consistent with the
original code, and will not result in items being freed "too early".

4) Add a RF_RaidAccessDesc_t *desc to RF_DagHeader_s so that we have a
way to find desc->iobufs.

5) Arrange for desc in the DagHeader to be initialized in InitHdrNode().

6) Don't cleanup iobufs in rf_FreeDAG() -- the freeing is now delayed
until rf_FreeRaidAccDesc() (which is how the original code handled the
allocList, and for which there seem to be some subtle, undocumented
assumptions).

7) Rename rf_AllocBuffer2() to be rf_AllocBuffer() and remove the
former rf_AllocBuffer().  Fix all callers of rf_AllocBuffer().
(This was how it was *supposed* to be after the last time these
changes were made, before they were backed out).

8) Remove RF_IOBufHeader and all references to it.

9) Remove desc->cleanupList and all references to it.

Fixes PR#20191
2004-04-09 23:10:16 +00:00
oster 78d093eaf5 Yesterday's fix to rf_disks.c (rev 1.51) was necessary, but not
sufficient to clobber this nasty little bug.  The behaviour observed
was a panic when doing a 'raidctl -f' on a component when DAGs were
in flight for the given RAID set.  Unfortunatly, the faulty behaviour
was very intermittent, and it was difficult to not only reliably
reproduce the bug (nor determine when it was fixed!) but also to even
figure out what might be the cause of the problem.

The real issue was that ci_vp for the failed component was being
set to NULL in rf_FailDisk(), but with DAGs still in flight, some
of them were still expecting to use ci_vp to determine where to
read to/write from!

The fix is to call rf_SuspendNewRequestsAndWait() from rf_FailDisk()
to make sure the RAID set is quiet and all IOs have completed before
mucking with ci_vp and other data structures.  rf_ResumeNewRequests()
is then used to continue on as usual.
2004-03-21 21:08:08 +00:00
oster 0ff2145648 For each RAID set, pre-allocate a number of "emergency buffers" to be
used in the event that we can't malloc a buffer of the appropriate
size in the traditional way.  rf_AllocIOBuffer() and rf_FreeIOBuffer()
deal with allocating/freeing these structures.  These buffers are
stored in a list on the 'iobuf' list.  iobuf_count keeps track of how
many buffers are available, and numEmergencyBuffers is the effective
"high-water" mark for the freelist.  The buffers allocated by
rf_AllocIOBuffer() are stripe-unit sized, which is the maximum
size requested by any of the callers.

Add an iobufs entry to RF_DagHeader_s.  Use it for keeping track of
buffers that get allocated from the free-list.

Add a "generic list" pool (VoidPointerListElement Pool) for elements
used to maintain a list of allocated memory.  [It is somewhat less
than ideal to add another little pool to handle this...]

Teach rf_AllocBuffer() to use the new rf_AllocIOBuffer().  Modify
other Mallocs to use rf_AllocIOBuffer(), and to update dag_h->iobufs as
appropriate.

Update rf_FreeDAG() to handle cleanup of dag_h->iobufs.

While here, add some missing pool_destroy() calls for a number of pools.

With these changes, it should (in theory) be possible to swap on
RAID 5 sets again.  That said, I've not had any success there yet --
but the last issue I saw at least wasn't in RAIDframe. :-}

[There is room for this code to become a bit more consise, but I
wanted to do a checkpoint here with something known to work :) ]
2004-03-20 04:22:05 +00:00
oster 8e82e43e0e This desc->mutex is only ever initialized -- never used. *toss* 2004-03-13 02:31:12 +00:00
oster ae179d21e5 paramDAG and paramASM are only ever set, but never used. *toss* 2004-03-13 02:20:40 +00:00
oster 8150ff6fbd - don't use rf_PrintUserStats() for recon statistics.
rf_PrintUserStats() was mean for the simulator, and doesn't provide
any real info in kernel-space, especially for reconstructs.
Reconstructing actually renders the stats even more useless, since it
resets them all to zero before the reconstruct starts!

 - since rf_PrintUserStats() is no longer used, nuke it along with the
routines that feed it.  Nothing was using this code, and if we ever
need it again, we know where to find it.
2004-03-13 02:00:15 +00:00
oster 82c3abf8e3 Use RF_DEBUG_QUIESCE to #if-out some printfs that really only should
be seen when debugging.
2004-03-09 02:41:21 +00:00
oster 71371823e7 rf_ShutdownList() isn't returning anything useful, and doesn't need to
return anything.  Cleanup.

Cleanup function prototypes in rf_shutdown.h

Use #if RF_DEBUG_SHUTDOWN to #if-out more code.
2004-03-09 02:15:33 +00:00
oster c25748c684 Rename rf_rad_pool_lock to rf_rad_lock. The latter is far more
accurate.
2004-03-07 23:17:44 +00:00
oster f95359dd19 - Introduce rf_pools which contains all of the various global pools used
by RAIDframe.  Convert all other RAIDframe global pools to use pools
defined within this new structure.
- Introduce rf_pool_init(), used for initializing a single pool in
RAIDframe.  Teach each of the configuration routines to use
rf_pool_init().
- Cleanup a few pool-related comments.
- Cleanup revent initialization and #defines.
- Add a missing pool_destroy() for the reconbuffer pool.

(Saves another 1K off of an i386 GENERIC kernel, and makes
stuff a lot more readable)
2004-03-07 22:15:19 +00:00
oster 834d494bb2 - Introduce rf_pools which contains all of the various global pools used
by RAIDframe.  Convert all other RAIDframe global pools to use pools
defined within this new structure.
- Introduce rf_pool_init(), used for initializing a single pool in
RAIDframe.  Teach each of the configuration routines to use
rf_pool_init().
- Cleanup a few pool-related comments.
- Cleanup revent initialization and #defines.
- Add a missing pool_destroy() for the reconbuffer pool.

(Saves another 1K off of an i386 GENERIC kernel, and makes
stuff a lot more readable)
2004-03-07 21:57:44 +00:00
oster a0413593bc - remove the RF_*_INC's, as necessary. They are not needed any more.
- introduce RF_MIN_*'s, as necessary.  These will indicate the
low-water mark for pools as well as the pool_prime() value.
- add pool_setlowat() for the critical pools.
- pool_prime() and pool_setlowat() the raidframe_cbufpool.
- re-order some pool_prime()'s and pool_sethiwat()'s for clarity.
2004-03-05 02:53:55 +00:00
oster c7eaad6a14 Use RF_ACC_TRACE to #if out more chunks of code related only
to access tracing.  (not turned on yet)
2004-03-01 23:30:57 +00:00
oster 5a02af5b21 Adjust _rf_ShutdownCreate() so that it is willing to wait for more
memory.  Since we only now ever "return(0)", just return (void)
instead.

Cleanup all uses of rf_ShutdownCreate() to not worry about
it ever failing.  Shaves another 600 bytes off of an i386 GENERIC kernel.
2004-02-29 04:03:50 +00:00
oster 24099528e9 Use a dynamically allocated linked list of dagLists instead of using a
dynamically allocated variable-sized array (dagArray).  Convert code
to use the new linked list stuff instead of the array stuff (the ratio
of one dagList per stripe still applies).  The big advantage is in
being able to more efficiently allocate the dagLists on-the-fly, and
not have to know the size(s) of the array beforehand.
2004-02-27 02:55:17 +00:00
oster 1a5bc3eb34 Add missing simple_lock_init(). Noted by skrueger-at-europe-dot-com. 2004-01-15 20:27:27 +00:00
oster 7ab3e4e2e3 Add 2 missing RF_LOCK_MUTEX()es. Problem pointed out by
skrueger-at-europe-dot-com.  (It turns out that the mutex used to
serve two different purposes, not just one, and for its current use,
it's actually miss-named.  Will fix that some other time.)
2004-01-14 15:10:55 +00:00
oster 181f2eebee remove terminate_disk_queues from RF_Raid_s. The hist_diskreq[]
stuff is only used for the CHAINDECLUSTERING, so hide it with an #if.
2004-01-05 01:19:07 +00:00
oster d3aa064253 Nuke a bunch of unused variables:
- node_queue_cond
 - quiescent_cond
 - eq_cond
 - desc->cond
 - desc->head
 - diskqueue->numWaiting

Nuke rf_print_unable_to_init_cond().
Nuke rf_TerminateDiskQueues prototype from rf_diskqueue.h.
2004-01-01 19:27:35 +00:00
oster 01635d963b Make function declarations consistent a) with each other and b) with
KNF.   Clean up comments.
2003-12-30 19:28:26 +00:00
oster ee0afdc3dc rf_lkmgr_mutex_init() is only called from one spot, and it really
can't fail.  Simplify life in rf_BootRaidframe(), and then nuke
rf_lkmgr_mutex_init().  Cleanup rf_threadstuff.h a bit more too.
rf_threadstuff.c is about to Go Away.
2003-12-29 06:30:42 +00:00
oster 8b09b35f45 Let's see... raidPtr->recon_done_procs is never set to anything
(other than NULL when raidPtr is initialized).  That means
SignalReconDone() never does anything useful.  Bye-bye!

Say good-bye to recon_done_procs and recon_done_procs_mutex (and its
initializer) as well.
2003-12-29 05:58:34 +00:00
oster 6a080d56e0 IO_BUF_ERR really doesn't need to be a macro. Replace the macro. 2003-12-29 05:52:58 +00:00
oster fc5966383f _rf_create_managed_cond() is now left doing nothing. Convert callers.
Mash DO_RAID_COND in rf_driver.c out of existance.

- Nuke (already #if 0'ed) _rf_create_managed_lkmgr_mutex() while we're
busy here.

simplify DO_INIT in rf_engine.c
2003-12-29 05:48:13 +00:00
oster c629932636 _rf_create_managed_mutex() is doing just a simple:
rf_mutex_init(m)

now.  The rest of the fluff is no longer needed.
It also cannot fail, so error checking on rf_create_managed_mutex()
is just wasting space.

Nuke the #define's associated with rf_create_managed_mutex().
Convert rf_create_managed_mutex(listp,m) to just rf_mutex_init(m).
Remove wasteful "error checking" and simplify all instances where this
is called.  (another 0.3K saved in the binary, but the real savings
is in code readability!)
2003-12-29 05:22:16 +00:00
oster c0a4bb0ea1 init_rad() and clean_rad() really do..... very little.. and only serve
to make things look far more complicated than they really are.  It was
also impossible for any of the mutex/cond initializations in
init_rad() to actually fail, making the "error detection code"
unneeded.  Collapse the little work done by init_rad into
rf_AllocRaidAccDesc(), and nuke init_rad() and clean_rad().  Save
another 0.25K in GENERIC.

[To be accurate/complete, init_rad() and clean_rad() *ARE* used in the
simulator version of RAIDframe.  But we're so far removed from that
now that there is no point pretending otherwise.]
2003-12-29 04:00:17 +00:00
oster ee19b085aa - first kick at a major reworking of RAIDframe's memory allocation code:
- all freelists converted to pools
  - initialization of structure members in certain cases where
	code was relying on specific allocation and usage properties
	to keep structures in a "known state" (that doesn't work with
	pools!).
  - make most pool_get() be "PR_WAITOK" until they can be analyzed
	further, and/or have proper error handling added.
  - all RF_Mallocs zero the space returned, so there is no difference
	between RF_Calloc and RF_Malloc.  In fact, all the RF_Calloc()'s
	do is tend to do is get things horribly confused.
	Make RF_Malloc() the "general memory allocator", with
	RF_MallocAndAdd() the "general memory allocator with
	allocation list".
  - some of these RF_Malloc's et al. are destined to disappear.
  - remove rf_rdp_freelist entirely (it's not used anywhere!)
  - remove: #include "rf_freelist.h"
  - to the files that were relying on the above, add: #include "rf_general.h"
  - add: #include "rf_debugMem.h" to rf_shutdown.h to make it happy
	about the loss of: #include "rf_freelist.h".

This shrinks an i386 GENERIC kernel by approx 5K.  RAIDframe now
weighs in at about 162K on i386.
2003-12-29 03:33:47 +00:00
oster 10f077a0fb [Having received a definite lack of strenuous objection, a small amount
of strenuous agreement, and some general agreement, this commit is
going ahead because it's now starting to block some other changes I
wish to make.]

Remove most of the support for the concept of "rows" from RAIDframe.
While the "row" interface has been exported to the world, RAIDframe
internals have really only supported a single row, even though they
have feigned support of multiple rows.

Nothing changes in configuration land -- config files still need to
specify a single row, etc.  All auto-config structures remain fully
forward/backwards compatible.

The only visible difference to the average user should be a
reduction in the size of a GENERIC kernel (i386) by 4.5K.  For those
of us trolling through RAIDframe kernel code, a lot of the driver
configuration code has become a LOT easier to read.
2003-12-29 02:38:17 +00:00
martin d505b18964 Make sure to include opt_foo.h if a defflag option FOO is used. 2003-06-23 11:00:59 +00:00
oster 6ac4a184c4 For reconstructs, move checks for failed components to before the
kernel threads are created.
2002-11-19 01:45:28 +00:00
oster 0cfd5a5b13 Cleanup more printfs. 2002-11-16 16:59:58 +00:00
oster f03dc09c94 Don't allow failing more than one component of a set, or
failing a component that has been spared, or "double-failing"
an already failed component.  XXX This isn't the right place to fix
this, but better here than no-where (and I'm hoping to move it sometime
soon).
2002-11-14 03:04:20 +00:00
oster 1ac4be5d3e Nuke a printf() from rf_FailDisk(). 2002-11-09 19:50:03 +00:00
oster 08933e5968 Better protect hot-spare adding, and make it LOCKDEBUG friendly. 2002-10-22 03:15:28 +00:00
oster 2eecfbf479 Improve and/or re-arrange a number of locks. While much of the locking is
still a mess, and there are a number of unresolved issues here, this
gets us closer to being happier in LOCKDEBUG land.
2002-10-18 02:46:36 +00:00
oster 8bdc70d040 As part of the effort to get RAIDframe playing nicely with LOCKDEBUG,
rework how completed requests are handled.  In particular, instead of
doing all sorts of work and locking in interrupt context, completed
requests are now queued.  A new kernel thread (rf_RaidIOThread) now
handles calling rf_DiskIOComplete() and (req->CompleteFunc)() for each
completed request.  There is still work to be done to make RAIDframe
LOCKDEBUG friendly, but this change is a huge step forward.

Reviewed by (and many thanks to): thorpej
2002-10-04 20:05:14 +00:00
oster eb144de792 The 'reconDesc' argument to rf_SignalQuiescenceLock() is a holdover from
simulation code. *poof*  Thanks to Simon B.
2002-09-23 04:14:20 +00:00
oster a16692eff6 rf_UnbootRaidframe isn't used. rf_print_assert_panic_message is
only needed if RAID_DIAGNOSTIC is defined.  Thanks Krister!
2002-09-21 01:00:43 +00:00
oster 8fd475e54a RF_DEBUG_ACCESS and RF_DEBUG_QUIESCE make things a little smaller. 2002-09-17 03:54:42 +00:00
oster e8ffb40a0e Those of us who might be interested in debugging internal memory usage
of RAIDframe can use RF_DEBUG_MEM.  I suspsect the rest of the world would
rather use that 14K of kernel memory for something else.
2002-09-16 23:40:57 +00:00
oster b51d271e17 Nuke 'numPending' from the RF_RaidAccessDesc_s structure, and minor cleanup. 2002-09-15 19:25:07 +00:00
oster a2b9142871 Everyone and their dog was using RF_ERRORMSG3 to print out the same
sort of error message, over and over again, in different files.
Rather than having the same text repeated in multiple .o files,
create a couple of little functions to do the printing, and save a
bundle of space.  Also improves readability of code.
2002-09-14 17:53:57 +00:00
oster cdb79dd4ae Nuke unneeded #include "rf_debugprint.h" 2002-09-11 02:22:49 +00:00
oster 23f63d631e On a 'raidctl -f' or 'raidctl -F', close the failed component.
Thanks to Grant and Matt (phone) for poking me about this.
2002-09-09 01:54:53 +00:00
oster 2a80a0fbe1 make 'configureMutex' be a lockmgr lock instead of a simple lock.
The result is MUCH fewer complaints with kernels compiled with LOCKDEBUG.
2002-08-08 02:55:36 +00:00