2002-10-06 22:49:12 +04:00
|
|
|
/* $NetBSD: rf_reconmap.c,v 1.15 2002/10/06 18:49:12 oster Exp $ */
|
1998-11-13 07:20:26 +03:00
|
|
|
/*
|
|
|
|
* 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_reconmap.c
|
|
|
|
*
|
|
|
|
* code to maintain a map of what sectors have/have not been reconstructed
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2001-11-13 10:11:12 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-10-06 22:49:12 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.15 2002/10/06 18:49:12 oster Exp $");
|
2001-11-13 10:11:12 +03:00
|
|
|
|
1998-11-13 07:20:26 +03:00
|
|
|
#include "rf_raid.h"
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "rf_general.h"
|
|
|
|
#include "rf_utils.h"
|
|
|
|
|
|
|
|
/* special pointer values indicating that a reconstruction unit
|
|
|
|
* has been either totally reconstructed or not at all. Both
|
|
|
|
* are illegal pointer values, so you have to be careful not to
|
|
|
|
* dereference through them. RU_NOTHING must be zero, since
|
2001-07-18 10:45:33 +04:00
|
|
|
* MakeReconMap uses memset to initialize the structure. These are used
|
1998-11-13 07:20:26 +03:00
|
|
|
* only at the head of the list.
|
|
|
|
*/
|
|
|
|
#define RU_ALL ((RF_ReconMapListElem_t *) -1)
|
|
|
|
#define RU_NOTHING ((RF_ReconMapListElem_t *) 0)
|
|
|
|
|
2002-10-06 22:49:12 +04:00
|
|
|
/* For most reconstructs we need at most 3 RF_ReconMapListElem_t's.
|
|
|
|
* Bounding the number we need is quite difficult, as it depends on how
|
|
|
|
* badly the sectors to be reconstructed get divided up. In the current
|
|
|
|
* code, the reconstructed sectors appeared aligned on stripe boundaries,
|
|
|
|
* and are always presented in stripe width units, so we're probably
|
|
|
|
* allocating quite a bit more than we'll ever need.
|
|
|
|
*/
|
|
|
|
#define RF_NUM_RECON_POOL_ELEM 100
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
static void
|
|
|
|
compact_stat_entry(RF_Raid_t * raidPtr, RF_ReconMap_t * mapPtr,
|
|
|
|
int i);
|
2002-10-06 22:49:12 +04:00
|
|
|
static void crunch_list(RF_ReconMap_t *mapPtr,
|
|
|
|
RF_ReconMapListElem_t * listPtr);
|
1999-02-05 03:06:06 +03:00
|
|
|
static RF_ReconMapListElem_t *
|
2002-10-06 22:49:12 +04:00
|
|
|
MakeReconMapListElem(RF_ReconMap_t *mapPtr, RF_SectorNum_t startSector,
|
|
|
|
RF_SectorNum_t stopSector, RF_ReconMapListElem_t * next);
|
1999-02-05 03:06:06 +03:00
|
|
|
static void
|
2002-10-06 22:49:12 +04:00
|
|
|
FreeReconMapListElem(RF_ReconMap_t *mapPtr, RF_ReconMapListElem_t * p);
|
2002-09-17 07:11:41 +04:00
|
|
|
#if 0
|
1999-02-05 03:06:06 +03:00
|
|
|
static void PrintList(RF_ReconMapListElem_t * listPtr);
|
2002-09-17 07:11:41 +04:00
|
|
|
#endif
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2002-10-05 03:49:35 +04:00
|
|
|
/*---------------------------------------------------------------------------
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
1999-02-05 03:06:06 +03:00
|
|
|
* Creates and initializes new Reconstruction map
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2002-10-05 03:49:35 +04:00
|
|
|
*-------------------------------------------------------------------------*/
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconMap_t *
|
|
|
|
rf_MakeReconMap(raidPtr, ru_sectors, disk_sectors, spareUnitsPerDisk)
|
|
|
|
RF_Raid_t *raidPtr;
|
|
|
|
RF_SectorCount_t ru_sectors; /* size of reconstruction unit in
|
|
|
|
* sectors */
|
|
|
|
RF_SectorCount_t disk_sectors; /* size of disk in sectors */
|
|
|
|
RF_ReconUnitCount_t spareUnitsPerDisk; /* zero unless distributed
|
|
|
|
* sparing */
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
|
|
|
|
RF_ReconUnitCount_t num_rus = layoutPtr->stripeUnitsPerDisk / layoutPtr->SUsPerRU;
|
|
|
|
RF_ReconMap_t *p;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RF_Malloc(p, sizeof(RF_ReconMap_t), (RF_ReconMap_t *));
|
|
|
|
p->sectorsPerReconUnit = ru_sectors;
|
|
|
|
p->sectorsInDisk = disk_sectors;
|
|
|
|
|
|
|
|
p->totalRUs = num_rus;
|
|
|
|
p->spareRUs = spareUnitsPerDisk;
|
|
|
|
p->unitsLeft = num_rus - spareUnitsPerDisk;
|
|
|
|
|
|
|
|
RF_Malloc(p->status, num_rus * sizeof(RF_ReconMapListElem_t *), (RF_ReconMapListElem_t **));
|
|
|
|
RF_ASSERT(p->status != (RF_ReconMapListElem_t **) NULL);
|
|
|
|
|
2001-07-18 10:45:33 +04:00
|
|
|
(void) memset((char *) p->status, 0,
|
|
|
|
num_rus * sizeof(RF_ReconMapListElem_t *));
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2002-10-06 22:49:12 +04:00
|
|
|
|
|
|
|
pool_init(&p->elem_pool, sizeof(RF_ReconMapListElem_t), 0,
|
|
|
|
0, RF_NUM_RECON_POOL_ELEM, "raidreconpl", NULL);
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
rc = rf_mutex_init(&p->mutex);
|
|
|
|
if (rc) {
|
2002-09-14 21:53:57 +04:00
|
|
|
rf_print_unable_to_init_mutex(__FILE__, __LINE__, rc);
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_Free(p->status, num_rus * sizeof(RF_ReconMapListElem_t *));
|
|
|
|
RF_Free(p, sizeof(RF_ReconMap_t));
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
return (p);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-05 03:49:35 +04:00
|
|
|
/*---------------------------------------------------------------------------
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2002-10-05 03:49:35 +04:00
|
|
|
* marks a new set of sectors as reconstructed. All the possible
|
|
|
|
* mergings get complicated. To simplify matters, the approach I take
|
|
|
|
* is to just dump something into the list, and then clean it up
|
|
|
|
* (i.e. merge elements and eliminate redundant ones) in a second pass
|
|
|
|
* over the list (compact_stat_entry()). Not 100% efficient, since a
|
|
|
|
* structure can be allocated and then immediately freed, but it keeps
|
|
|
|
* this code from becoming (more of) a nightmare of special cases.
|
|
|
|
* The only thing that compact_stat_entry() assumes is that the list
|
|
|
|
* is sorted by startSector, and so this is the only condition I
|
|
|
|
* maintain here. (MCH)
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2002-10-06 22:49:12 +04:00
|
|
|
* This code now uses a pool instead of the previous malloc/free
|
|
|
|
* stuff.
|
2002-10-05 03:49:35 +04:00
|
|
|
*-------------------------------------------------------------------------*/
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
void
|
|
|
|
rf_ReconMapUpdate(raidPtr, mapPtr, startSector, stopSector)
|
|
|
|
RF_Raid_t *raidPtr;
|
|
|
|
RF_ReconMap_t *mapPtr;
|
|
|
|
RF_SectorNum_t startSector;
|
|
|
|
RF_SectorNum_t stopSector;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_SectorCount_t sectorsPerReconUnit = mapPtr->sectorsPerReconUnit;
|
|
|
|
RF_SectorNum_t i, first_in_RU, last_in_RU;
|
|
|
|
RF_ReconMapListElem_t *p, *pt;
|
|
|
|
|
|
|
|
RF_LOCK_MUTEX(mapPtr->mutex);
|
2002-10-05 03:49:35 +04:00
|
|
|
RF_ASSERT(startSector >= 0 && stopSector < mapPtr->sectorsInDisk &&
|
|
|
|
stopSector >= startSector);
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
while (startSector <= stopSector) {
|
|
|
|
i = startSector / mapPtr->sectorsPerReconUnit;
|
|
|
|
first_in_RU = i * sectorsPerReconUnit;
|
|
|
|
last_in_RU = first_in_RU + sectorsPerReconUnit - 1;
|
|
|
|
p = mapPtr->status[i];
|
|
|
|
if (p != RU_ALL) {
|
2002-10-05 03:49:35 +04:00
|
|
|
if (p == RU_NOTHING || p->startSector > startSector) {
|
|
|
|
/* insert at front of list */
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2002-10-06 22:49:12 +04:00
|
|
|
mapPtr->status[i] = MakeReconMapListElem(mapPtr,startSector, RF_MIN(stopSector, last_in_RU), (p == RU_NOTHING) ? NULL : p);
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
} else {/* general case */
|
|
|
|
do { /* search for place to insert */
|
|
|
|
pt = p;
|
|
|
|
p = p->next;
|
|
|
|
} while (p && (p->startSector < startSector));
|
2002-10-06 22:49:12 +04:00
|
|
|
pt->next = MakeReconMapListElem(mapPtr,startSector, RF_MIN(stopSector, last_in_RU), p);
|
2002-10-06 02:45:46 +04:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
compact_stat_entry(raidPtr, mapPtr, i);
|
|
|
|
}
|
|
|
|
startSector = RF_MIN(stopSector, last_in_RU) + 1;
|
|
|
|
}
|
|
|
|
RF_UNLOCK_MUTEX(mapPtr->mutex);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-05 03:49:35 +04:00
|
|
|
/*---------------------------------------------------------------------------
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
|
|
|
* performs whatever list compactions can be done, and frees any space
|
|
|
|
* that is no longer necessary. Assumes only that the list is sorted
|
2002-10-05 03:49:35 +04:00
|
|
|
* by startSector. crunch_list() compacts a single list as much as
|
|
|
|
* possible, and the second block of code deletes the entire list if
|
|
|
|
* possible. crunch_list() is also called from
|
|
|
|
* MakeReconMapAccessList().
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
|
|
|
* When a recon unit is detected to be fully reconstructed, we set the
|
|
|
|
* corresponding bit in the parity stripe map so that the head follow
|
2002-10-05 03:49:35 +04:00
|
|
|
* code will not select this parity stripe again. This is redundant
|
|
|
|
* (but harmless) when compact_stat_entry is called from the
|
|
|
|
* reconstruction code, but necessary when called from the user-write
|
|
|
|
* code.
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2002-10-05 03:49:35 +04:00
|
|
|
*-------------------------------------------------------------------------*/
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
static void
|
|
|
|
compact_stat_entry(raidPtr, mapPtr, i)
|
|
|
|
RF_Raid_t *raidPtr;
|
|
|
|
RF_ReconMap_t *mapPtr;
|
|
|
|
int i;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_SectorCount_t sectorsPerReconUnit = mapPtr->sectorsPerReconUnit;
|
|
|
|
RF_ReconMapListElem_t *p = mapPtr->status[i];
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2002-10-06 22:49:12 +04:00
|
|
|
crunch_list(mapPtr, p);
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if ((p->startSector == i * sectorsPerReconUnit) &&
|
2002-10-05 03:49:35 +04:00
|
|
|
(p->stopSector == i * sectorsPerReconUnit +
|
|
|
|
sectorsPerReconUnit - 1)) {
|
1999-02-05 03:06:06 +03:00
|
|
|
mapPtr->status[i] = RU_ALL;
|
|
|
|
mapPtr->unitsLeft--;
|
2002-10-06 22:49:12 +04:00
|
|
|
FreeReconMapListElem(mapPtr, p);
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
static void
|
2002-10-06 22:49:12 +04:00
|
|
|
crunch_list(mapPtr, listPtr)
|
|
|
|
RF_ReconMap_t *mapPtr;
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconMapListElem_t *listPtr;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconMapListElem_t *pt, *p = listPtr;
|
|
|
|
|
|
|
|
if (!p)
|
|
|
|
return;
|
|
|
|
pt = p;
|
|
|
|
p = p->next;
|
|
|
|
while (p) {
|
|
|
|
if (pt->stopSector >= p->startSector - 1) {
|
|
|
|
pt->stopSector = RF_MAX(pt->stopSector, p->stopSector);
|
|
|
|
pt->next = p->next;
|
2002-10-06 22:49:12 +04:00
|
|
|
FreeReconMapListElem(mapPtr, p);
|
1999-02-05 03:06:06 +03:00
|
|
|
p = pt->next;
|
|
|
|
} else {
|
|
|
|
pt = p;
|
|
|
|
p = p->next;
|
|
|
|
}
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-10-05 03:49:35 +04:00
|
|
|
/*---------------------------------------------------------------------------
|
1999-02-05 03:06:06 +03:00
|
|
|
*
|
1998-11-13 07:20:26 +03:00
|
|
|
* Allocate and fill a new list element
|
|
|
|
*
|
2002-10-05 03:49:35 +04:00
|
|
|
*-------------------------------------------------------------------------*/
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
static RF_ReconMapListElem_t *
|
|
|
|
MakeReconMapListElem(
|
2002-10-06 22:49:12 +04:00
|
|
|
RF_ReconMap_t *mapPtr,
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_SectorNum_t startSector,
|
|
|
|
RF_SectorNum_t stopSector,
|
|
|
|
RF_ReconMapListElem_t * next)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconMapListElem_t *p;
|
|
|
|
|
2002-10-06 22:49:12 +04:00
|
|
|
p = pool_get(&mapPtr->elem_pool, PR_NOWAIT);
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if (p == NULL)
|
|
|
|
return (NULL);
|
2002-10-06 22:49:12 +04:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
p->startSector = startSector;
|
|
|
|
p->stopSector = stopSector;
|
|
|
|
p->next = next;
|
|
|
|
return (p);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-10-05 03:49:35 +04:00
|
|
|
/*---------------------------------------------------------------------------
|
1999-02-05 03:06:06 +03:00
|
|
|
*
|
1998-11-13 07:20:26 +03:00
|
|
|
* Free a list element
|
|
|
|
*
|
2002-10-05 03:49:35 +04:00
|
|
|
*-------------------------------------------------------------------------*/
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
static void
|
2002-10-06 22:49:12 +04:00
|
|
|
FreeReconMapListElem(mapPtr, p)
|
|
|
|
RF_ReconMap_t *mapPtr;
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconMapListElem_t *p;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
2002-10-06 22:49:12 +04:00
|
|
|
pool_put(&mapPtr->elem_pool, p);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-10-05 03:49:35 +04:00
|
|
|
/*---------------------------------------------------------------------------
|
1999-02-05 03:06:06 +03:00
|
|
|
*
|
2002-10-05 03:49:35 +04:00
|
|
|
* Free an entire status structure. Inefficient, but can be called at
|
|
|
|
* any time.
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2002-10-05 03:49:35 +04:00
|
|
|
*-------------------------------------------------------------------------*/
|
1999-02-05 03:06:06 +03:00
|
|
|
void
|
|
|
|
rf_FreeReconMap(mapPtr)
|
|
|
|
RF_ReconMap_t *mapPtr;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconMapListElem_t *p, *q;
|
|
|
|
RF_ReconUnitCount_t numRUs;
|
|
|
|
RF_ReconUnitNum_t i;
|
|
|
|
|
|
|
|
numRUs = mapPtr->sectorsInDisk / mapPtr->sectorsPerReconUnit;
|
|
|
|
if (mapPtr->sectorsInDisk % mapPtr->sectorsPerReconUnit)
|
|
|
|
numRUs++;
|
|
|
|
|
|
|
|
for (i = 0; i < numRUs; i++) {
|
|
|
|
p = mapPtr->status[i];
|
|
|
|
while (p != RU_NOTHING && p != RU_ALL) {
|
|
|
|
q = p;
|
|
|
|
p = p->next;
|
|
|
|
RF_Free(q, sizeof(*q));
|
|
|
|
}
|
|
|
|
}
|
2002-10-06 22:49:12 +04:00
|
|
|
pool_destroy(&mapPtr->elem_pool);
|
1999-02-05 03:06:06 +03:00
|
|
|
rf_mutex_destroy(&mapPtr->mutex);
|
2002-10-05 03:49:35 +04:00
|
|
|
RF_Free(mapPtr->status, mapPtr->totalRUs *
|
|
|
|
sizeof(RF_ReconMapListElem_t *));
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_Free(mapPtr, sizeof(RF_ReconMap_t));
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-10-05 03:49:35 +04:00
|
|
|
/*---------------------------------------------------------------------------
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
|
|
|
* returns nonzero if the indicated RU has been reconstructed already
|
|
|
|
*
|
2002-10-05 03:49:35 +04:00
|
|
|
*-------------------------------------------------------------------------*/
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
int
|
|
|
|
rf_CheckRUReconstructed(mapPtr, startSector)
|
|
|
|
RF_ReconMap_t *mapPtr;
|
|
|
|
RF_SectorNum_t startSector;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconMapListElem_t *l; /* used for searching */
|
|
|
|
RF_ReconUnitNum_t i;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
i = startSector / mapPtr->sectorsPerReconUnit;
|
|
|
|
l = mapPtr->status[i];
|
|
|
|
return ((l == RU_ALL) ? 1 : 0);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconUnitCount_t
|
|
|
|
rf_UnitsLeftToReconstruct(mapPtr)
|
|
|
|
RF_ReconMap_t *mapPtr;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ASSERT(mapPtr != NULL);
|
|
|
|
return (mapPtr->unitsLeft);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
2002-09-17 07:11:41 +04:00
|
|
|
#if 0
|
1999-02-05 03:06:06 +03:00
|
|
|
static void
|
|
|
|
PrintList(listPtr)
|
|
|
|
RF_ReconMapListElem_t *listPtr;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
while (listPtr) {
|
2002-10-05 03:49:35 +04:00
|
|
|
printf("%d,%d -> ", (int) listPtr->startSector,
|
|
|
|
(int) listPtr->stopSector);
|
1999-02-05 03:06:06 +03:00
|
|
|
listPtr = listPtr->next;
|
|
|
|
}
|
|
|
|
printf("\n");
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
rf_PrintReconMap(raidPtr, mapPtr, frow, fcol)
|
|
|
|
RF_Raid_t *raidPtr;
|
|
|
|
RF_ReconMap_t *mapPtr;
|
|
|
|
RF_RowCol_t frow;
|
|
|
|
RF_RowCol_t fcol;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ReconUnitCount_t numRUs;
|
|
|
|
RF_ReconMapListElem_t *p;
|
|
|
|
RF_ReconUnitNum_t i;
|
|
|
|
|
|
|
|
numRUs = mapPtr->totalRUs;
|
|
|
|
if (mapPtr->sectorsInDisk % mapPtr->sectorsPerReconUnit)
|
|
|
|
numRUs++;
|
|
|
|
|
|
|
|
for (i = 0; i < numRUs; i++) {
|
|
|
|
p = mapPtr->status[i];
|
|
|
|
if (p == RU_ALL)/* printf("[%d] ALL\n",i) */
|
|
|
|
;
|
|
|
|
else
|
|
|
|
if (p == RU_NOTHING) {
|
|
|
|
printf("%d: Unreconstructed\n", i);
|
|
|
|
} else {
|
|
|
|
printf("%d: ", i);
|
|
|
|
PrintList(p);
|
|
|
|
}
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-09-17 07:11:41 +04:00
|
|
|
#endif
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2002-09-17 07:30:33 +04:00
|
|
|
#if RF_DEBUG_RECON
|
1999-02-05 03:06:06 +03:00
|
|
|
void
|
|
|
|
rf_PrintReconSchedule(mapPtr, starttime)
|
|
|
|
RF_ReconMap_t *mapPtr;
|
|
|
|
struct timeval *starttime;
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
static int old_pctg = -1;
|
|
|
|
struct timeval tv, diff;
|
|
|
|
int new_pctg;
|
|
|
|
|
2002-10-05 03:49:35 +04:00
|
|
|
new_pctg = 100 - (rf_UnitsLeftToReconstruct(mapPtr) *
|
|
|
|
100 / mapPtr->totalRUs);
|
1999-02-05 03:06:06 +03:00
|
|
|
if (new_pctg != old_pctg) {
|
|
|
|
RF_GETTIME(tv);
|
|
|
|
RF_TIMEVAL_DIFF(starttime, &tv, &diff);
|
2002-10-05 03:49:35 +04:00
|
|
|
printf("%d %d.%06d\n", (int) new_pctg, (int) diff.tv_sec,
|
|
|
|
(int) diff.tv_usec);
|
1999-02-05 03:06:06 +03:00
|
|
|
old_pctg = new_pctg;
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-09-17 07:30:33 +04:00
|
|
|
#endif
|
|
|
|
|