At (closer to) 80-columns, this may actually be readable code.
This commit is contained in:
parent
636b65bec8
commit
2c4bbb1b26
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: rf_paritylogging.c,v 1.7 2000/01/09 03:28:11 oster Exp $ */
|
/* $NetBSD: rf_paritylogging.c,v 1.8 2000/01/09 04:35:13 oster Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995 Carnegie-Mellon University.
|
* Copyright (c) 1995 Carnegie-Mellon University.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
@ -93,7 +93,9 @@ rf_ConfigureParityLogging(
|
||||||
raidPtr->numSectorsPerLog = RF_DEFAULT_NUM_SECTORS_PER_LOG;
|
raidPtr->numSectorsPerLog = RF_DEFAULT_NUM_SECTORS_PER_LOG;
|
||||||
|
|
||||||
/* create a parity logging configuration structure */
|
/* 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)
|
if (info == NULL)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
layoutPtr->layoutSpecificInfo = (void *) info;
|
layoutPtr->layoutSpecificInfo = (void *) info;
|
||||||
|
@ -102,14 +104,17 @@ rf_ConfigureParityLogging(
|
||||||
|
|
||||||
/* the stripe identifier must identify the disks in each stripe, IN
|
/* the stripe identifier must identify the disks in each stripe, IN
|
||||||
* THE ORDER THAT THEY APPEAR IN THE STRIPE. */
|
* 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)
|
if (info->stripeIdentifier == NULL)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
|
|
||||||
startdisk = 0;
|
startdisk = 0;
|
||||||
for (i = 0; i < (raidPtr->numCol); i++) {
|
for (i = 0; i < (raidPtr->numCol); i++) {
|
||||||
for (j = 0; j < (raidPtr->numCol); j++) {
|
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)
|
if ((--startdisk) < 0)
|
||||||
startdisk = raidPtr->numCol - 1 - 1;
|
startdisk = raidPtr->numCol - 1 - 1;
|
||||||
|
@ -117,15 +122,20 @@ rf_ConfigureParityLogging(
|
||||||
|
|
||||||
/* fill in the remaining layout parameters */
|
/* fill in the remaining layout parameters */
|
||||||
layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
|
layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
|
||||||
layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector;
|
layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit <<
|
||||||
|
raidPtr->logBytesPerSector;
|
||||||
layoutPtr->numParityCol = 1;
|
layoutPtr->numParityCol = 1;
|
||||||
layoutPtr->numParityLogCol = 1;
|
layoutPtr->numParityLogCol = 1;
|
||||||
layoutPtr->numDataCol = raidPtr->numCol - layoutPtr->numParityCol - layoutPtr->numParityLogCol;
|
layoutPtr->numDataCol = raidPtr->numCol - layoutPtr->numParityCol -
|
||||||
layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
|
layoutPtr->numParityLogCol;
|
||||||
|
layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol *
|
||||||
|
layoutPtr->sectorsPerStripeUnit;
|
||||||
layoutPtr->dataStripeUnitsPerDisk = layoutPtr->stripeUnitsPerDisk;
|
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
|
/* configure parity log parameters
|
||||||
*
|
*
|
||||||
|
@ -160,37 +170,51 @@ rf_ConfigureParityLogging(
|
||||||
fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog;
|
fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog;
|
||||||
if (fragmentation > 0)
|
if (fragmentation > 0)
|
||||||
for (i = 1; i < (raidPtr->numSectorsPerLog / 2); i++) {
|
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++;
|
rf_numParityRegions++;
|
||||||
raidPtr->regionLogCapacity = totalLogCapacity / rf_numParityRegions;
|
raidPtr->regionLogCapacity = totalLogCapacity /
|
||||||
fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog;
|
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--;
|
rf_numParityRegions--;
|
||||||
raidPtr->regionLogCapacity = totalLogCapacity / rf_numParityRegions;
|
raidPtr->regionLogCapacity = totalLogCapacity /
|
||||||
fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog;
|
rf_numParityRegions;
|
||||||
|
fragmentation = raidPtr->regionLogCapacity %
|
||||||
|
raidPtr->numSectorsPerLog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* ensure integral number of regions per log */
|
/* 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
|
/* to avoid deadlock, must ensure that enough logs exist for each
|
||||||
* region to have one simultaneously */
|
* region to have one simultaneously */
|
||||||
if (raidPtr->numParityLogs < rf_numParityRegions)
|
if (raidPtr->numParityLogs < rf_numParityRegions)
|
||||||
raidPtr->numParityLogs = rf_numParityRegions;
|
raidPtr->numParityLogs = rf_numParityRegions;
|
||||||
|
|
||||||
/* create region information structs */
|
/* 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)
|
if (raidPtr->regionInfo == NULL)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
|
|
||||||
/* last region may not be full capacity */
|
/* last region may not be full capacity */
|
||||||
lastRegionCapacity = raidPtr->regionLogCapacity;
|
lastRegionCapacity = raidPtr->regionLogCapacity;
|
||||||
while ((rf_numParityRegions - 1) * raidPtr->regionLogCapacity + lastRegionCapacity > totalLogCapacity)
|
while ((rf_numParityRegions - 1) * raidPtr->regionLogCapacity +
|
||||||
lastRegionCapacity = lastRegionCapacity - raidPtr->numSectorsPerLog;
|
lastRegionCapacity > totalLogCapacity)
|
||||||
|
lastRegionCapacity = lastRegionCapacity -
|
||||||
|
raidPtr->numSectorsPerLog;
|
||||||
|
|
||||||
raidPtr->regionParityRange = raidPtr->sectorsPerDisk / rf_numParityRegions;
|
raidPtr->regionParityRange = raidPtr->sectorsPerDisk /
|
||||||
|
rf_numParityRegions;
|
||||||
maxRegionParityRange = raidPtr->regionParityRange;
|
maxRegionParityRange = raidPtr->regionParityRange;
|
||||||
|
|
||||||
/* i can't remember why this line is in the code -wvcii 6/30/95 */
|
/* i can't remember why this line is in the code -wvcii 6/30/95 */
|
||||||
|
@ -198,30 +222,43 @@ rf_ConfigureParityLogging(
|
||||||
regionParityRange++; */
|
regionParityRange++; */
|
||||||
|
|
||||||
/* build pool of unused parity logs */
|
/* 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)
|
if (raidPtr->parityLogBufferHeap == NULL)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
lHeapPtr = raidPtr->parityLogBufferHeap;
|
lHeapPtr = raidPtr->parityLogBufferHeap;
|
||||||
rc = rf_mutex_init(&raidPtr->parityLogPool.mutex);
|
rc = rf_mutex_init(&raidPtr->parityLogPool.mutex);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n",
|
||||||
__LINE__, rc);
|
__FILE__, __LINE__, rc);
|
||||||
RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
|
RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs *
|
||||||
|
raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
for (i = 0; i < raidPtr->numParityLogs; i++) {
|
for (i = 0; i < raidPtr->numParityLogs; i++) {
|
||||||
if (i == 0) {
|
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) {
|
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);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
l = raidPtr->parityLogPool.parityLogs;
|
l = raidPtr->parityLogPool.parityLogs;
|
||||||
} else {
|
} 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) {
|
if (l->next == NULL) {
|
||||||
RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
|
RF_Free(raidPtr->parityLogBufferHeap,
|
||||||
for (l = raidPtr->parityLogPool.parityLogs; l; l = next) {
|
raidPtr->numParityLogs *
|
||||||
|
raidPtr->numSectorsPerLog *
|
||||||
|
raidPtr->bytesPerSector);
|
||||||
|
for (l = raidPtr->parityLogPool.parityLogs;
|
||||||
|
l;
|
||||||
|
l = next) {
|
||||||
next = l->next;
|
next = l->next;
|
||||||
if (l->records)
|
if (l->records)
|
||||||
RF_Free(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t)));
|
RF_Free(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t)));
|
||||||
|
@ -232,14 +269,24 @@ rf_ConfigureParityLogging(
|
||||||
l = l->next;
|
l = l->next;
|
||||||
}
|
}
|
||||||
l->bufPtr = lHeapPtr;
|
l->bufPtr = lHeapPtr;
|
||||||
lHeapPtr += raidPtr->numSectorsPerLog * raidPtr->bytesPerSector;
|
lHeapPtr += raidPtr->numSectorsPerLog *
|
||||||
RF_Malloc(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t)), (RF_ParityLogRecord_t *));
|
raidPtr->bytesPerSector;
|
||||||
|
RF_Malloc(l->records, (raidPtr->numSectorsPerLog *
|
||||||
|
sizeof(RF_ParityLogRecord_t)),
|
||||||
|
(RF_ParityLogRecord_t *));
|
||||||
if (l->records == NULL) {
|
if (l->records == NULL) {
|
||||||
RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
|
RF_Free(raidPtr->parityLogBufferHeap,
|
||||||
for (l = raidPtr->parityLogPool.parityLogs; l; l = next) {
|
raidPtr->numParityLogs *
|
||||||
|
raidPtr->numSectorsPerLog *
|
||||||
|
raidPtr->bytesPerSector);
|
||||||
|
for (l = raidPtr->parityLogPool.parityLogs;
|
||||||
|
l;
|
||||||
|
l = next) {
|
||||||
next = l->next;
|
next = l->next;
|
||||||
if (l->records)
|
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));
|
RF_Free(l, sizeof(RF_ParityLog_t));
|
||||||
}
|
}
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
|
@ -255,46 +302,60 @@ rf_ConfigureParityLogging(
|
||||||
/* build pool of region buffers */
|
/* build pool of region buffers */
|
||||||
rc = rf_mutex_init(&raidPtr->regionBufferPool.mutex);
|
rc = rf_mutex_init(&raidPtr->regionBufferPool.mutex);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n",
|
||||||
__LINE__, rc);
|
__FILE__, __LINE__, rc);
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
rc = rf_cond_init(&raidPtr->regionBufferPool.cond);
|
rc = rf_cond_init(&raidPtr->regionBufferPool.cond);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n",
|
||||||
__LINE__, rc);
|
__FILE__, __LINE__, rc);
|
||||||
rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
|
rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
raidPtr->regionBufferPool.bufferSize = raidPtr->regionLogCapacity * raidPtr->bytesPerSector;
|
raidPtr->regionBufferPool.bufferSize = raidPtr->regionLogCapacity *
|
||||||
printf("regionBufferPool.bufferSize %d\n", raidPtr->regionBufferPool.bufferSize);
|
raidPtr->bytesPerSector;
|
||||||
raidPtr->regionBufferPool.totalBuffers = 1; /* for now, only one
|
printf("regionBufferPool.bufferSize %d\n",
|
||||||
* region at a time may
|
raidPtr->regionBufferPool.bufferSize);
|
||||||
* be reintegrated */
|
|
||||||
raidPtr->regionBufferPool.availableBuffers = raidPtr->regionBufferPool.totalBuffers;
|
/* 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.availBuffersIndex = 0;
|
||||||
raidPtr->regionBufferPool.emptyBuffersIndex = 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) {
|
if (raidPtr->regionBufferPool.buffers == NULL) {
|
||||||
rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
|
rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
|
||||||
rf_cond_destroy(&raidPtr->regionBufferPool.cond);
|
rf_cond_destroy(&raidPtr->regionBufferPool.cond);
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
for (i = 0; i < raidPtr->regionBufferPool.totalBuffers; i++) {
|
for (i = 0; i < raidPtr->regionBufferPool.totalBuffers; i++) {
|
||||||
RF_Malloc(raidPtr->regionBufferPool.buffers[i], raidPtr->regionBufferPool.bufferSize * sizeof(char), (caddr_t));
|
RF_Malloc(raidPtr->regionBufferPool.buffers[i],
|
||||||
|
raidPtr->regionBufferPool.bufferSize * sizeof(char),
|
||||||
|
(caddr_t));
|
||||||
if (raidPtr->regionBufferPool.buffers[i] == NULL) {
|
if (raidPtr->regionBufferPool.buffers[i] == NULL) {
|
||||||
rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
|
rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
|
||||||
rf_cond_destroy(&raidPtr->regionBufferPool.cond);
|
rf_cond_destroy(&raidPtr->regionBufferPool.cond);
|
||||||
for (j = 0; j < i; j++) {
|
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);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
printf("raidPtr->regionBufferPool.buffers[%d] = %lx\n", i,
|
printf("raidPtr->regionBufferPool.buffers[%d] = %lx\n", i,
|
||||||
(long) raidPtr->regionBufferPool.buffers[i]);
|
(long) raidPtr->regionBufferPool.buffers[i]);
|
||||||
}
|
}
|
||||||
rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingRegionBufferPool, raidPtr);
|
rc = rf_ShutdownCreate(listp,
|
||||||
|
rf_ShutdownParityLoggingRegionBufferPool,
|
||||||
|
raidPtr);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
|
||||||
__LINE__, rc);
|
__LINE__, rc);
|
||||||
|
@ -305,46 +366,60 @@ rf_ConfigureParityLogging(
|
||||||
parityBufferCapacity = maxRegionParityRange;
|
parityBufferCapacity = maxRegionParityRange;
|
||||||
rc = rf_mutex_init(&raidPtr->parityBufferPool.mutex);
|
rc = rf_mutex_init(&raidPtr->parityBufferPool.mutex);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n",
|
||||||
__LINE__, rc);
|
__FILE__, __LINE__, rc);
|
||||||
return (rc);
|
return (rc);
|
||||||
}
|
}
|
||||||
rc = rf_cond_init(&raidPtr->parityBufferPool.cond);
|
rc = rf_cond_init(&raidPtr->parityBufferPool.cond);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n",
|
||||||
__LINE__, rc);
|
__FILE__, __LINE__, rc);
|
||||||
rf_mutex_destroy(&raidPtr->parityBufferPool.mutex);
|
rf_mutex_destroy(&raidPtr->parityBufferPool.mutex);
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
raidPtr->parityBufferPool.bufferSize = parityBufferCapacity * raidPtr->bytesPerSector;
|
raidPtr->parityBufferPool.bufferSize = parityBufferCapacity *
|
||||||
printf("parityBufferPool.bufferSize %d\n", raidPtr->parityBufferPool.bufferSize);
|
raidPtr->bytesPerSector;
|
||||||
raidPtr->parityBufferPool.totalBuffers = 1; /* for now, only one
|
printf("parityBufferPool.bufferSize %d\n",
|
||||||
* region at a time may
|
raidPtr->parityBufferPool.bufferSize);
|
||||||
* be reintegrated */
|
|
||||||
raidPtr->parityBufferPool.availableBuffers = raidPtr->parityBufferPool.totalBuffers;
|
/* 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.availBuffersIndex = 0;
|
||||||
raidPtr->parityBufferPool.emptyBuffersIndex = 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) {
|
if (raidPtr->parityBufferPool.buffers == NULL) {
|
||||||
rf_mutex_destroy(&raidPtr->parityBufferPool.mutex);
|
rf_mutex_destroy(&raidPtr->parityBufferPool.mutex);
|
||||||
rf_cond_destroy(&raidPtr->parityBufferPool.cond);
|
rf_cond_destroy(&raidPtr->parityBufferPool.cond);
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
for (i = 0; i < raidPtr->parityBufferPool.totalBuffers; i++) {
|
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) {
|
if (raidPtr->parityBufferPool.buffers == NULL) {
|
||||||
rf_mutex_destroy(&raidPtr->parityBufferPool.mutex);
|
rf_mutex_destroy(&raidPtr->parityBufferPool.mutex);
|
||||||
rf_cond_destroy(&raidPtr->parityBufferPool.cond);
|
rf_cond_destroy(&raidPtr->parityBufferPool.cond);
|
||||||
for (j = 0; j < i; j++) {
|
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);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
printf("parityBufferPool.buffers[%d] = %lx\n", i,
|
printf("parityBufferPool.buffers[%d] = %lx\n", i,
|
||||||
(long) raidPtr->parityBufferPool.buffers[i]);
|
(long) raidPtr->parityBufferPool.buffers[i]);
|
||||||
}
|
}
|
||||||
rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingParityBufferPool, raidPtr);
|
rc = rf_ShutdownCreate(listp,
|
||||||
|
rf_ShutdownParityLoggingParityBufferPool,
|
||||||
|
raidPtr);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
|
||||||
__LINE__, rc);
|
__LINE__, rc);
|
||||||
|
@ -352,16 +427,17 @@ rf_ConfigureParityLogging(
|
||||||
return (rc);
|
return (rc);
|
||||||
}
|
}
|
||||||
/* initialize parityLogDiskQueue */
|
/* initialize parityLogDiskQueue */
|
||||||
rc = rf_create_managed_mutex(listp, &raidPtr->parityLogDiskQueue.mutex);
|
rc = rf_create_managed_mutex(listp,
|
||||||
|
&raidPtr->parityLogDiskQueue.mutex);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n",
|
||||||
__LINE__, rc);
|
__FILE__, __LINE__, rc);
|
||||||
return (rc);
|
return (rc);
|
||||||
}
|
}
|
||||||
rc = rf_create_managed_cond(listp, &raidPtr->parityLogDiskQueue.cond);
|
rc = rf_create_managed_cond(listp, &raidPtr->parityLogDiskQueue.cond);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n",
|
||||||
__LINE__, rc);
|
__FILE__, __LINE__, rc);
|
||||||
return (rc);
|
return (rc);
|
||||||
}
|
}
|
||||||
raidPtr->parityLogDiskQueue.flushQueue = NULL;
|
raidPtr->parityLogDiskQueue.flushQueue = NULL;
|
||||||
|
@ -377,7 +453,9 @@ rf_ConfigureParityLogging(
|
||||||
raidPtr->parityLogDiskQueue.freeDataList = NULL;
|
raidPtr->parityLogDiskQueue.freeDataList = NULL;
|
||||||
raidPtr->parityLogDiskQueue.freeCommonList = NULL;
|
raidPtr->parityLogDiskQueue.freeCommonList = NULL;
|
||||||
|
|
||||||
rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingDiskQueue, raidPtr);
|
rc = rf_ShutdownCreate(listp,
|
||||||
|
rf_ShutdownParityLoggingDiskQueue,
|
||||||
|
raidPtr);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
|
||||||
__LINE__, rc);
|
__LINE__, rc);
|
||||||
|
@ -390,7 +468,9 @@ rf_ConfigureParityLogging(
|
||||||
__LINE__, rc);
|
__LINE__, rc);
|
||||||
for (j = 0; j < i; j++)
|
for (j = 0; j < i; j++)
|
||||||
FreeRegionInfo(raidPtr, 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);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
rc = rf_mutex_init(&raidPtr->regionInfo[i].reintMutex);
|
rc = rf_mutex_init(&raidPtr->regionInfo[i].reintMutex);
|
||||||
|
@ -400,37 +480,59 @@ rf_ConfigureParityLogging(
|
||||||
rf_mutex_destroy(&raidPtr->regionInfo[i].mutex);
|
rf_mutex_destroy(&raidPtr->regionInfo[i].mutex);
|
||||||
for (j = 0; j < i; j++)
|
for (j = 0; j < i; j++)
|
||||||
FreeRegionInfo(raidPtr, 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);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
raidPtr->regionInfo[i].reintInProgress = RF_FALSE;
|
raidPtr->regionInfo[i].reintInProgress = RF_FALSE;
|
||||||
raidPtr->regionInfo[i].regionStartAddr = raidPtr->regionLogCapacity * i;
|
raidPtr->regionInfo[i].regionStartAddr =
|
||||||
raidPtr->regionInfo[i].parityStartAddr = raidPtr->regionParityRange * i;
|
raidPtr->regionLogCapacity * i;
|
||||||
|
raidPtr->regionInfo[i].parityStartAddr =
|
||||||
|
raidPtr->regionParityRange * i;
|
||||||
if (i < rf_numParityRegions - 1) {
|
if (i < rf_numParityRegions - 1) {
|
||||||
raidPtr->regionInfo[i].capacity = raidPtr->regionLogCapacity;
|
raidPtr->regionInfo[i].capacity =
|
||||||
raidPtr->regionInfo[i].numSectorsParity = raidPtr->regionParityRange;
|
raidPtr->regionLogCapacity;
|
||||||
|
raidPtr->regionInfo[i].numSectorsParity =
|
||||||
|
raidPtr->regionParityRange;
|
||||||
} else {
|
} else {
|
||||||
raidPtr->regionInfo[i].capacity = lastRegionCapacity;
|
raidPtr->regionInfo[i].capacity =
|
||||||
raidPtr->regionInfo[i].numSectorsParity = raidPtr->sectorsPerDisk - raidPtr->regionParityRange * i;
|
lastRegionCapacity;
|
||||||
if (raidPtr->regionInfo[i].numSectorsParity > maxRegionParityRange)
|
raidPtr->regionInfo[i].numSectorsParity =
|
||||||
maxRegionParityRange = 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;
|
raidPtr->regionInfo[i].diskCount = 0;
|
||||||
RF_ASSERT(raidPtr->regionInfo[i].capacity + raidPtr->regionInfo[i].regionStartAddr <= totalLogCapacity);
|
RF_ASSERT(raidPtr->regionInfo[i].capacity +
|
||||||
RF_ASSERT(raidPtr->regionInfo[i].parityStartAddr + raidPtr->regionInfo[i].numSectorsParity <= raidPtr->sectorsPerDisk);
|
raidPtr->regionInfo[i].regionStartAddr <=
|
||||||
RF_Malloc(raidPtr->regionInfo[i].diskMap, (raidPtr->regionInfo[i].capacity * sizeof(RF_DiskMap_t)), (RF_DiskMap_t *));
|
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) {
|
if (raidPtr->regionInfo[i].diskMap == NULL) {
|
||||||
rf_mutex_destroy(&raidPtr->regionInfo[i].mutex);
|
rf_mutex_destroy(&raidPtr->regionInfo[i].mutex);
|
||||||
rf_mutex_destroy(&raidPtr->regionInfo[i].reintMutex);
|
rf_mutex_destroy(&raidPtr->regionInfo[i].reintMutex);
|
||||||
for (j = 0; j < i; j++)
|
for (j = 0; j < i; j++)
|
||||||
FreeRegionInfo(raidPtr, 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);
|
return (ENOMEM);
|
||||||
}
|
}
|
||||||
raidPtr->regionInfo[i].loggingEnabled = RF_FALSE;
|
raidPtr->regionInfo[i].loggingEnabled = RF_FALSE;
|
||||||
raidPtr->regionInfo[i].coreLog = NULL;
|
raidPtr->regionInfo[i].coreLog = NULL;
|
||||||
}
|
}
|
||||||
rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingRegionInfo, raidPtr);
|
rc = rf_ShutdownCreate(listp,
|
||||||
|
rf_ShutdownParityLoggingRegionInfo,
|
||||||
|
raidPtr);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
|
RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
|
||||||
__LINE__, rc);
|
__LINE__, rc);
|
||||||
|
@ -439,7 +541,8 @@ rf_ConfigureParityLogging(
|
||||||
}
|
}
|
||||||
RF_ASSERT(raidPtr->parityLogDiskQueue.threadState == 0);
|
RF_ASSERT(raidPtr->parityLogDiskQueue.threadState == 0);
|
||||||
raidPtr->parityLogDiskQueue.threadState = RF_PLOG_CREATED;
|
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) {
|
if (rc) {
|
||||||
raidPtr->parityLogDiskQueue.threadState = 0;
|
raidPtr->parityLogDiskQueue.threadState = 0;
|
||||||
RF_ERRORMSG3("Unable to create parity logging disk thread file %s line %d rc=%d\n",
|
RF_ERRORMSG3("Unable to create parity logging disk thread file %s line %d rc=%d\n",
|
||||||
|
@ -449,7 +552,8 @@ rf_ConfigureParityLogging(
|
||||||
/* wait for thread to start */
|
/* wait for thread to start */
|
||||||
RF_LOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex);
|
RF_LOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex);
|
||||||
while (!(raidPtr->parityLogDiskQueue.threadState & RF_PLOG_RUNNING)) {
|
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);
|
RF_UNLOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex);
|
||||||
|
|
||||||
|
@ -480,9 +584,12 @@ FreeRegionInfo(
|
||||||
RF_RegionId_t regionID)
|
RF_RegionId_t regionID)
|
||||||
{
|
{
|
||||||
RF_LOCK_MUTEX(raidPtr->regionInfo[regionID].mutex);
|
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) {
|
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;
|
raidPtr->regionInfo[regionID].coreLog = NULL;
|
||||||
} else {
|
} else {
|
||||||
RF_ASSERT(raidPtr->regionInfo[regionID].coreLog == NULL);
|
RF_ASSERT(raidPtr->regionInfo[regionID].coreLog == NULL);
|
||||||
|
@ -506,7 +613,8 @@ FreeParityLogQueue(
|
||||||
while (l1) {
|
while (l1) {
|
||||||
l2 = l1;
|
l2 = l1;
|
||||||
l1 = l2->next;
|
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_Free(l2, sizeof(RF_ParityLog_t));
|
||||||
}
|
}
|
||||||
RF_UNLOCK_MUTEX(queue->mutex);
|
RF_UNLOCK_MUTEX(queue->mutex);
|
||||||
|
@ -545,7 +653,8 @@ rf_ShutdownParityLoggingRegionInfo(RF_ThreadArg_t arg)
|
||||||
/* free region information structs */
|
/* free region information structs */
|
||||||
for (i = 0; i < rf_numParityRegions; i++)
|
for (i = 0; i < rf_numParityRegions; i++)
|
||||||
FreeRegionInfo(raidPtr, 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;
|
raidPtr->regionInfo = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +669,8 @@ rf_ShutdownParityLoggingPool(RF_ThreadArg_t arg)
|
||||||
}
|
}
|
||||||
/* free contents of parityLogPool */
|
/* free contents of parityLogPool */
|
||||||
FreeParityLogQueue(raidPtr, &raidPtr->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
|
static void
|
||||||
|
@ -608,13 +718,15 @@ rf_ShutdownParityLoggingDiskQueue(RF_ThreadArg_t arg)
|
||||||
RF_ASSERT(raidPtr->parityLogDiskQueue.reintTail == NULL);
|
RF_ASSERT(raidPtr->parityLogDiskQueue.reintTail == NULL);
|
||||||
while (raidPtr->parityLogDiskQueue.freeDataList) {
|
while (raidPtr->parityLogDiskQueue.freeDataList) {
|
||||||
d = 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));
|
RF_Free(d, sizeof(RF_ParityLogData_t));
|
||||||
}
|
}
|
||||||
while (raidPtr->parityLogDiskQueue.freeCommonList) {
|
while (raidPtr->parityLogDiskQueue.freeCommonList) {
|
||||||
c = raidPtr->parityLogDiskQueue.freeCommonList;
|
c = raidPtr->parityLogDiskQueue.freeCommonList;
|
||||||
rf_mutex_destroy(&c->mutex);
|
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));
|
RF_Free(c, sizeof(RF_CommonLogData_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,7 +755,8 @@ rf_ShutdownParityLogging(RF_ThreadArg_t arg)
|
||||||
*/
|
*/
|
||||||
RF_LOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex);
|
RF_LOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex);
|
||||||
while (!(raidPtr->parityLogDiskQueue.threadState & RF_PLOG_SHUTDOWN)) {
|
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);
|
RF_UNLOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex);
|
||||||
if (rf_parityLogDebug) {
|
if (rf_parityLogDebug) {
|
||||||
|
@ -677,7 +790,8 @@ rf_MapRegionIDParityLogging(
|
||||||
regionID--;
|
regionID--;
|
||||||
}
|
}
|
||||||
RF_ASSERT(address >= raidPtr->regionInfo[regionID].parityStartAddr);
|
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);
|
RF_ASSERT(regionID < rf_numParityRegions);
|
||||||
return (regionID);
|
return (regionID);
|
||||||
}
|
}
|
||||||
|
@ -693,13 +807,15 @@ rf_MapSectorParityLogging(
|
||||||
RF_SectorNum_t * diskSector,
|
RF_SectorNum_t * diskSector,
|
||||||
int remap)
|
int remap)
|
||||||
{
|
{
|
||||||
RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
|
RF_StripeNum_t SUID = raidSector /
|
||||||
|
raidPtr->Layout.sectorsPerStripeUnit;
|
||||||
*row = 0;
|
*row = 0;
|
||||||
/* *col = (SUID % (raidPtr->numCol -
|
/* *col = (SUID % (raidPtr->numCol -
|
||||||
* raidPtr->Layout.numParityLogCol)); */
|
* raidPtr->Layout.numParityLogCol)); */
|
||||||
*col = SUID % raidPtr->Layout.numDataCol;
|
*col = SUID % raidPtr->Layout.numDataCol;
|
||||||
*diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
|
*diskSector = (SUID / (raidPtr->Layout.numDataCol)) *
|
||||||
(raidSector % raidPtr->Layout.sectorsPerStripeUnit);
|
raidPtr->Layout.sectorsPerStripeUnit +
|
||||||
|
(raidSector % raidPtr->Layout.sectorsPerStripeUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -713,15 +829,17 @@ rf_MapParityParityLogging(
|
||||||
RF_SectorNum_t * diskSector,
|
RF_SectorNum_t * diskSector,
|
||||||
int remap)
|
int remap)
|
||||||
{
|
{
|
||||||
RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
|
RF_StripeNum_t SUID = raidSector /
|
||||||
|
raidPtr->Layout.sectorsPerStripeUnit;
|
||||||
|
|
||||||
*row = 0;
|
*row = 0;
|
||||||
/* *col =
|
/* *col =
|
||||||
* raidPtr->Layout.numDataCol-(SUID/raidPtr->Layout.numDataCol)%(raidPt
|
* raidPtr->Layout.numDataCol-(SUID/raidPtr->Layout.numDataCol)%(raidPt
|
||||||
* r->numCol - raidPtr->Layout.numParityLogCol); */
|
* r->numCol - raidPtr->Layout.numParityLogCol); */
|
||||||
*col = raidPtr->Layout.numDataCol;
|
*col = raidPtr->Layout.numDataCol;
|
||||||
*diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
|
*diskSector = (SUID / (raidPtr->Layout.numDataCol)) *
|
||||||
(raidSector % raidPtr->Layout.sectorsPerStripeUnit);
|
raidPtr->Layout.sectorsPerStripeUnit +
|
||||||
|
(raidSector % raidPtr->Layout.sectorsPerStripeUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -741,7 +859,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
|
void
|
||||||
rf_MapRegionParity(
|
rf_MapRegionParity(
|
||||||
RF_Raid_t * raidPtr,
|
RF_Raid_t * raidPtr,
|
||||||
|
@ -758,7 +877,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
|
void
|
||||||
rf_IdentifyStripeParityLogging(
|
rf_IdentifyStripeParityLogging(
|
||||||
RF_Raid_t * raidPtr,
|
RF_Raid_t * raidPtr,
|
||||||
|
@ -766,8 +886,10 @@ rf_IdentifyStripeParityLogging(
|
||||||
RF_RowCol_t ** diskids,
|
RF_RowCol_t ** diskids,
|
||||||
RF_RowCol_t * outRow)
|
RF_RowCol_t * outRow)
|
||||||
{
|
{
|
||||||
RF_StripeNum_t stripeID = rf_RaidAddressToStripeID(&raidPtr->Layout, addr);
|
RF_StripeNum_t stripeID = rf_RaidAddressToStripeID(&raidPtr->Layout,
|
||||||
RF_ParityLoggingConfigInfo_t *info = (RF_ParityLoggingConfigInfo_t *) raidPtr->Layout.layoutSpecificInfo;
|
addr);
|
||||||
|
RF_ParityLoggingConfigInfo_t *info = (RF_ParityLoggingConfigInfo_t *)
|
||||||
|
raidPtr->Layout.layoutSpecificInfo;
|
||||||
*outRow = 0;
|
*outRow = 0;
|
||||||
*diskids = info->stripeIdentifier[stripeID % raidPtr->numCol];
|
*diskids = info->stripeIdentifier[stripeID % raidPtr->numCol];
|
||||||
}
|
}
|
||||||
|
@ -825,8 +947,9 @@ rf_ParityLoggingDagSelect(
|
||||||
if (prior_recon) {
|
if (prior_recon) {
|
||||||
RF_RowCol_t or = failedPDA->row, oc = failedPDA->col;
|
RF_RowCol_t or = failedPDA->row, oc = failedPDA->col;
|
||||||
RF_SectorNum_t oo = failedPDA->startSector;
|
RF_SectorNum_t oo = failedPDA->startSector;
|
||||||
if (layoutPtr->map->flags & RF_DISTRIBUTE_SPARE) { /* redirect to dist
|
if (layoutPtr->map->flags &
|
||||||
* spare space */
|
RF_DISTRIBUTE_SPARE) {
|
||||||
|
/* redirect to dist spare space */
|
||||||
|
|
||||||
if (failedPDA == asmp->parityInfo) {
|
if (failedPDA == asmp->parityInfo) {
|
||||||
|
|
||||||
|
@ -857,8 +980,8 @@ rf_ParityLoggingDagSelect(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { /* redirect to dedicated spare
|
} else {
|
||||||
* space */
|
/* redirect to dedicated spare space */
|
||||||
|
|
||||||
failedPDA->row = raidPtr->Disks[frow][fcol].spareRow;
|
failedPDA->row = raidPtr->Disks[frow][fcol].spareRow;
|
||||||
failedPDA->col = raidPtr->Disks[frow][fcol].spareCol;
|
failedPDA->col = raidPtr->Disks[frow][fcol].spareCol;
|
||||||
|
@ -871,8 +994,7 @@ rf_ParityLoggingDagSelect(
|
||||||
failedPDA->next->row = failedPDA->row;
|
failedPDA->next->row = failedPDA->row;
|
||||||
failedPDA->next->col = failedPDA->col;
|
failedPDA->next->col = failedPDA->col;
|
||||||
} else
|
} else
|
||||||
if (failedPDA == asmp->parityInfo->next) { /* paranoid: should
|
if (failedPDA == asmp->parityInfo->next) { /* paranoid: should never occur */
|
||||||
* never occur */
|
|
||||||
asmp->parityInfo->row = failedPDA->row;
|
asmp->parityInfo->row = failedPDA->row;
|
||||||
asmp->parityInfo->col = failedPDA->col;
|
asmp->parityInfo->col = failedPDA->col;
|
||||||
}
|
}
|
||||||
|
@ -907,8 +1029,11 @@ rf_ParityLoggingDagSelect(
|
||||||
* when G is 3 or 4, numDataCol/2 is 1, and I want
|
* when G is 3 or 4, numDataCol/2 is 1, and I want
|
||||||
* single-stripe-unit updates to use just one disk. */
|
* single-stripe-unit updates to use just one disk. */
|
||||||
if ((asmp->numDataFailed + asmp->numParityFailed) == 0) {
|
if ((asmp->numDataFailed + asmp->numParityFailed) == 0) {
|
||||||
if (((asmp->numStripeUnitsAccessed <= (layoutPtr->numDataCol / 2)) && (layoutPtr->numDataCol != 1)) ||
|
if (((asmp->numStripeUnitsAccessed <=
|
||||||
(asmp->parityInfo->next != NULL) || rf_CheckStripeForFailures(raidPtr, asmp)) {
|
(layoutPtr->numDataCol / 2)) &&
|
||||||
|
(layoutPtr->numDataCol != 1)) ||
|
||||||
|
(asmp->parityInfo->next != NULL) ||
|
||||||
|
rf_CheckStripeForFailures(raidPtr, asmp)) {
|
||||||
*createFunc = (RF_VoidFuncPtr) rf_CreateParityLoggingSmallWriteDAG;
|
*createFunc = (RF_VoidFuncPtr) rf_CreateParityLoggingSmallWriteDAG;
|
||||||
} else
|
} else
|
||||||
*createFunc = (RF_VoidFuncPtr) rf_CreateParityLoggingLargeWriteDAG;
|
*createFunc = (RF_VoidFuncPtr) rf_CreateParityLoggingLargeWriteDAG;
|
||||||
|
|
Loading…
Reference in New Issue