Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/raidframe At (closer to) 80-columns, this may actual...



details:   https://anonhg.NetBSD.org/src/rev/4cdcb836c207
branches:  trunk
changeset: 480311:4cdcb836c207
user:      oster <oster%NetBSD.org@localhost>
date:      Sun Jan 09 04:35:13 2000 +0000

description:
At (closer to) 80-columns, this may actually be readable code.

diffstat:

 sys/dev/raidframe/rf_paritylogging.c |  355 +++++++++++++++++++++++-----------
 1 files changed, 240 insertions(+), 115 deletions(-)

diffs (truncated from 707 to 300 lines):

diff -r f53b1fbe940b -r 4cdcb836c207 sys/dev/raidframe/rf_paritylogging.c
--- a/sys/dev/raidframe/rf_paritylogging.c      Sun Jan 09 03:55:28 2000 +0000
+++ b/sys/dev/raidframe/rf_paritylogging.c      Sun Jan 09 04:35:13 2000 +0000
@@ -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.
  * All rights reserved.
@@ -93,7 +93,9 @@
        raidPtr->numSectorsPerLog = RF_DEFAULT_NUM_SECTORS_PER_LOG;
 
        /* create a parity logging configuration structure */
-       RF_MallocAndAdd(info, sizeof(RF_ParityLoggingConfigInfo_t), (RF_ParityLoggingConfigInfo_t *), raidPtr->cleanupList);
+       RF_MallocAndAdd(info, sizeof(RF_ParityLoggingConfigInfo_t), 
+                       (RF_ParityLoggingConfigInfo_t *), 
+                       raidPtr->cleanupList);
        if (info == NULL)
                return (ENOMEM);
        layoutPtr->layoutSpecificInfo = (void *) info;
@@ -102,14 +104,17 @@
 
        /* the stripe identifier must identify the disks in each stripe, IN
         * THE ORDER THAT THEY APPEAR IN THE STRIPE. */
-       info->stripeIdentifier = rf_make_2d_array((raidPtr->numCol), (raidPtr->numCol), raidPtr->cleanupList);
+       info->stripeIdentifier = rf_make_2d_array((raidPtr->numCol), 
+                                                 (raidPtr->numCol), 
+                                                 raidPtr->cleanupList);
        if (info->stripeIdentifier == NULL)
                return (ENOMEM);
 
        startdisk = 0;
        for (i = 0; i < (raidPtr->numCol); i++) {
                for (j = 0; j < (raidPtr->numCol); j++) {
-                       info->stripeIdentifier[i][j] = (startdisk + j) % (raidPtr->numCol - 1);
+                       info->stripeIdentifier[i][j] = (startdisk + j) % 
+                               (raidPtr->numCol - 1);
                }
                if ((--startdisk) < 0)
                        startdisk = raidPtr->numCol - 1 - 1;
@@ -117,15 +122,20 @@
 
        /* fill in the remaining layout parameters */
        layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
-       layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector;
+       layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << 
+               raidPtr->logBytesPerSector;
        layoutPtr->numParityCol = 1;
        layoutPtr->numParityLogCol = 1;
-       layoutPtr->numDataCol = raidPtr->numCol - layoutPtr->numParityCol - layoutPtr->numParityLogCol;
-       layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
+       layoutPtr->numDataCol = raidPtr->numCol - layoutPtr->numParityCol - 
+               layoutPtr->numParityLogCol;
+       layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * 
+               layoutPtr->sectorsPerStripeUnit;
        layoutPtr->dataStripeUnitsPerDisk = layoutPtr->stripeUnitsPerDisk;
-       raidPtr->sectorsPerDisk = layoutPtr->stripeUnitsPerDisk * layoutPtr->sectorsPerStripeUnit;
+       raidPtr->sectorsPerDisk = layoutPtr->stripeUnitsPerDisk * 
+               layoutPtr->sectorsPerStripeUnit;
 
-       raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
+       raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * 
+               layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
 
        /* configure parity log parameters
         * 
@@ -160,37 +170,51 @@
        fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog;
        if (fragmentation > 0)
                for (i = 1; i < (raidPtr->numSectorsPerLog / 2); i++) {
-                       if (((totalLogCapacity / (rf_numParityRegions + i)) % raidPtr->numSectorsPerLog) < fragmentation) {
+                       if (((totalLogCapacity / (rf_numParityRegions + i)) % 
+                            raidPtr->numSectorsPerLog) < fragmentation) {
                                rf_numParityRegions++;
-                               raidPtr->regionLogCapacity = totalLogCapacity / rf_numParityRegions;
-                               fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog;
+                               raidPtr->regionLogCapacity = totalLogCapacity /
+                                       rf_numParityRegions;
+                               fragmentation = raidPtr->regionLogCapacity % 
+                                       raidPtr->numSectorsPerLog;
                        }
-                       if (((totalLogCapacity / (rf_numParityRegions - i)) % raidPtr->numSectorsPerLog) < fragmentation) {
+                       if (((totalLogCapacity / (rf_numParityRegions - i)) % 
+                            raidPtr->numSectorsPerLog) < fragmentation) {
                                rf_numParityRegions--;
-                               raidPtr->regionLogCapacity = totalLogCapacity / rf_numParityRegions;
-                               fragmentation = raidPtr->regionLogCapacity % raidPtr->numSectorsPerLog;
+                               raidPtr->regionLogCapacity = totalLogCapacity /
+                                       rf_numParityRegions;
+                               fragmentation = raidPtr->regionLogCapacity % 
+                                       raidPtr->numSectorsPerLog;
                        }
                }
        /* ensure integral number of regions per log */
-       raidPtr->regionLogCapacity = (raidPtr->regionLogCapacity / raidPtr->numSectorsPerLog) * raidPtr->numSectorsPerLog;
+       raidPtr->regionLogCapacity = (raidPtr->regionLogCapacity / 
+                                     raidPtr->numSectorsPerLog) * 
+               raidPtr->numSectorsPerLog;
 
-       raidPtr->numParityLogs = rf_totalInCoreLogCapacity / (raidPtr->bytesPerSector * raidPtr->numSectorsPerLog);
+       raidPtr->numParityLogs = rf_totalInCoreLogCapacity / 
+               (raidPtr->bytesPerSector * raidPtr->numSectorsPerLog);
        /* to avoid deadlock, must ensure that enough logs exist for each
         * region to have one simultaneously */
        if (raidPtr->numParityLogs < rf_numParityRegions)
                raidPtr->numParityLogs = rf_numParityRegions;
 
        /* create region information structs */
-       RF_Malloc(raidPtr->regionInfo, (rf_numParityRegions * sizeof(RF_RegionInfo_t)), (RF_RegionInfo_t *));
+       RF_Malloc(raidPtr->regionInfo, 
+                 (rf_numParityRegions * sizeof(RF_RegionInfo_t)), 
+                 (RF_RegionInfo_t *));
        if (raidPtr->regionInfo == NULL)
                return (ENOMEM);
 
        /* last region may not be full capacity */
        lastRegionCapacity = raidPtr->regionLogCapacity;
-       while ((rf_numParityRegions - 1) * raidPtr->regionLogCapacity + lastRegionCapacity > totalLogCapacity)
-               lastRegionCapacity = lastRegionCapacity - raidPtr->numSectorsPerLog;
+       while ((rf_numParityRegions - 1) * raidPtr->regionLogCapacity + 
+              lastRegionCapacity > totalLogCapacity)
+               lastRegionCapacity = lastRegionCapacity - 
+                       raidPtr->numSectorsPerLog;
 
-       raidPtr->regionParityRange = raidPtr->sectorsPerDisk / rf_numParityRegions;
+       raidPtr->regionParityRange = raidPtr->sectorsPerDisk / 
+               rf_numParityRegions;
        maxRegionParityRange = raidPtr->regionParityRange;
 
 /* i can't remember why this line is in the code -wvcii 6/30/95 */
@@ -198,30 +222,43 @@
     regionParityRange++; */
 
        /* build pool of unused parity logs */
-       RF_Malloc(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector, (caddr_t));
+       RF_Malloc(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * 
+                 raidPtr->numSectorsPerLog * raidPtr->bytesPerSector, 
+                 (caddr_t));
        if (raidPtr->parityLogBufferHeap == NULL)
                return (ENOMEM);
        lHeapPtr = raidPtr->parityLogBufferHeap;
        rc = rf_mutex_init(&raidPtr->parityLogPool.mutex);
        if (rc) {
-               RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__,
-                   __LINE__, rc);
-               RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
+               RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", 
+                            __FILE__, __LINE__, rc);
+               RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * 
+                       raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
                return (ENOMEM);
        }
        for (i = 0; i < raidPtr->numParityLogs; i++) {
                if (i == 0) {
-                       RF_Calloc(raidPtr->parityLogPool.parityLogs, 1, sizeof(RF_ParityLog_t), (RF_ParityLog_t *));
+                       RF_Calloc(raidPtr->parityLogPool.parityLogs, 1, 
+                                 sizeof(RF_ParityLog_t), (RF_ParityLog_t *));
                        if (raidPtr->parityLogPool.parityLogs == NULL) {
-                               RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
+                               RF_Free(raidPtr->parityLogBufferHeap, 
+                                       raidPtr->numParityLogs * 
+                                       raidPtr->numSectorsPerLog * 
+                                       raidPtr->bytesPerSector);
                                return (ENOMEM);
                        }
                        l = raidPtr->parityLogPool.parityLogs;
                } else {
-                       RF_Calloc(l->next, 1, sizeof(RF_ParityLog_t), (RF_ParityLog_t *));
+                       RF_Calloc(l->next, 1, sizeof(RF_ParityLog_t), 
+                                 (RF_ParityLog_t *));
                        if (l->next == NULL) {
-                               RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
-                               for (l = raidPtr->parityLogPool.parityLogs; l; l = next) {
+                               RF_Free(raidPtr->parityLogBufferHeap, 
+                                       raidPtr->numParityLogs * 
+                                       raidPtr->numSectorsPerLog * 
+                                       raidPtr->bytesPerSector);
+                               for (l = raidPtr->parityLogPool.parityLogs; 
+                                    l;
+                                    l = next) {
                                        next = l->next;
                                        if (l->records)
                                                RF_Free(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t)));
@@ -232,14 +269,24 @@
                        l = l->next;
                }
                l->bufPtr = lHeapPtr;
-               lHeapPtr += raidPtr->numSectorsPerLog * raidPtr->bytesPerSector;
-               RF_Malloc(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t)), (RF_ParityLogRecord_t *));
+               lHeapPtr += raidPtr->numSectorsPerLog * 
+                       raidPtr->bytesPerSector;
+               RF_Malloc(l->records, (raidPtr->numSectorsPerLog * 
+                                      sizeof(RF_ParityLogRecord_t)), 
+                         (RF_ParityLogRecord_t *));
                if (l->records == NULL) {
-                       RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector);
-                       for (l = raidPtr->parityLogPool.parityLogs; l; l = next) {
+                       RF_Free(raidPtr->parityLogBufferHeap, 
+                               raidPtr->numParityLogs * 
+                               raidPtr->numSectorsPerLog * 
+                               raidPtr->bytesPerSector);
+                       for (l = raidPtr->parityLogPool.parityLogs; 
+                            l; 
+                            l = next) {
                                next = l->next;
                                if (l->records)
-                                       RF_Free(l->records, (raidPtr->numSectorsPerLog * sizeof(RF_ParityLogRecord_t)));
+                                       RF_Free(l->records, 
+                                               (raidPtr->numSectorsPerLog * 
+                                                sizeof(RF_ParityLogRecord_t)));
                                RF_Free(l, sizeof(RF_ParityLog_t));
                        }
                        return (ENOMEM);
@@ -255,46 +302,60 @@
        /* build pool of region buffers */
        rc = rf_mutex_init(&raidPtr->regionBufferPool.mutex);
        if (rc) {
-               RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__,
-                   __LINE__, rc);
+               RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", 
+                            __FILE__, __LINE__, rc);
                return (ENOMEM);
        }
        rc = rf_cond_init(&raidPtr->regionBufferPool.cond);
        if (rc) {
-               RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__,
-                   __LINE__, rc);
+               RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", 
+                            __FILE__, __LINE__, rc);
                rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
                return (ENOMEM);
        }
-       raidPtr->regionBufferPool.bufferSize = raidPtr->regionLogCapacity * raidPtr->bytesPerSector;
-       printf("regionBufferPool.bufferSize %d\n", raidPtr->regionBufferPool.bufferSize);
-       raidPtr->regionBufferPool.totalBuffers = 1;     /* for now, only one
-                                                        * region at a time may
-                                                        * be reintegrated */
-       raidPtr->regionBufferPool.availableBuffers = raidPtr->regionBufferPool.totalBuffers;
+       raidPtr->regionBufferPool.bufferSize = raidPtr->regionLogCapacity * 
+               raidPtr->bytesPerSector;
+       printf("regionBufferPool.bufferSize %d\n", 
+              raidPtr->regionBufferPool.bufferSize);
+
+       /* for now, only one region at a time may be reintegrated */
+       raidPtr->regionBufferPool.totalBuffers = 1;     
+
+       raidPtr->regionBufferPool.availableBuffers = 
+               raidPtr->regionBufferPool.totalBuffers;
        raidPtr->regionBufferPool.availBuffersIndex = 0;
        raidPtr->regionBufferPool.emptyBuffersIndex = 0;
-       RF_Malloc(raidPtr->regionBufferPool.buffers, raidPtr->regionBufferPool.totalBuffers * sizeof(caddr_t), (caddr_t *));
+       RF_Malloc(raidPtr->regionBufferPool.buffers, 
+                 raidPtr->regionBufferPool.totalBuffers * sizeof(caddr_t), 
+                 (caddr_t *));
        if (raidPtr->regionBufferPool.buffers == NULL) {
                rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
                rf_cond_destroy(&raidPtr->regionBufferPool.cond);
                return (ENOMEM);
        }
        for (i = 0; i < raidPtr->regionBufferPool.totalBuffers; i++) {
-               RF_Malloc(raidPtr->regionBufferPool.buffers[i], raidPtr->regionBufferPool.bufferSize * sizeof(char), (caddr_t));
+               RF_Malloc(raidPtr->regionBufferPool.buffers[i], 
+                         raidPtr->regionBufferPool.bufferSize * sizeof(char),
+                         (caddr_t));
                if (raidPtr->regionBufferPool.buffers[i] == NULL) {
                        rf_mutex_destroy(&raidPtr->regionBufferPool.mutex);
                        rf_cond_destroy(&raidPtr->regionBufferPool.cond);
                        for (j = 0; j < i; j++) {
-                               RF_Free(raidPtr->regionBufferPool.buffers[i], raidPtr->regionBufferPool.bufferSize * sizeof(char));
+                               RF_Free(raidPtr->regionBufferPool.buffers[i], 
+                                       raidPtr->regionBufferPool.bufferSize *
+                                       sizeof(char));
                        }
-                       RF_Free(raidPtr->regionBufferPool.buffers, raidPtr->regionBufferPool.totalBuffers * sizeof(caddr_t));
+                       RF_Free(raidPtr->regionBufferPool.buffers, 
+                               raidPtr->regionBufferPool.totalBuffers * 
+                               sizeof(caddr_t));
                        return (ENOMEM);
                }
                printf("raidPtr->regionBufferPool.buffers[%d] = %lx\n", i,
                    (long) raidPtr->regionBufferPool.buffers[i]);
        }
-       rc = rf_ShutdownCreate(listp, rf_ShutdownParityLoggingRegionBufferPool, raidPtr);
+       rc = rf_ShutdownCreate(listp, 
+                              rf_ShutdownParityLoggingRegionBufferPool,
+                              raidPtr);
        if (rc) {
                RF_ERRORMSG3("Unable to create shutdown entry file %s line %d rc=%d\n", __FILE__,
                    __LINE__, rc);
@@ -305,46 +366,60 @@
        parityBufferCapacity = maxRegionParityRange;
        rc = rf_mutex_init(&raidPtr->parityBufferPool.mutex);
        if (rc) {
-               RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__,
-                   __LINE__, rc);
+               RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", 
+                            __FILE__, __LINE__, rc);
                return (rc);
        }
        rc = rf_cond_init(&raidPtr->parityBufferPool.cond);



Home | Main Index | Thread Index | Old Index