Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe Clean up comments, and generally make more...



details:   https://anonhg.NetBSD.org/src/rev/e167756aab32
branches:  trunk
changeset: 556893:e167756aab32
user:      oster <oster%NetBSD.org@localhost>
date:      Mon Dec 29 17:13:36 2003 +0000

description:
Clean up comments, and generally make more readable.  No functional changes.

diffstat:

 sys/dev/raidframe/rf_map.c |  169 ++++++++++++++++++++++++--------------------
 1 files changed, 91 insertions(+), 78 deletions(-)

diffs (truncated from 313 to 300 lines):

diff -r 46c54f3ef6e8 -r e167756aab32 sys/dev/raidframe/rf_map.c
--- a/sys/dev/raidframe/rf_map.c        Mon Dec 29 16:57:35 2003 +0000
+++ b/sys/dev/raidframe/rf_map.c        Mon Dec 29 17:13:36 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_map.c,v 1.24 2003/12/29 03:33:48 oster Exp $        */
+/*     $NetBSD: rf_map.c,v 1.25 2003/12/29 17:13:36 oster Exp $        */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  **************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.24 2003/12/29 03:33:48 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.25 2003/12/29 17:13:36 oster Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -43,10 +43,10 @@
 #include "rf_map.h"
 #include "rf_shutdown.h"
 
-static void rf_FreePDAList(RF_PhysDiskAddr_t * start, RF_PhysDiskAddr_t * end, int count);
-static void 
-rf_FreeASMList(RF_AccessStripeMap_t * start, RF_AccessStripeMap_t * end,
-    int count);
+static void rf_FreePDAList(RF_PhysDiskAddr_t * start, RF_PhysDiskAddr_t * end,
+                          int count);
+static void rf_FreeASMList(RF_AccessStripeMap_t * start, 
+                          RF_AccessStripeMap_t * end, int count);
 
 /***************************************************************************
  *
@@ -55,19 +55,19 @@
  * addresses.  The result is returned as a list of AccessStripeMap
  * structures, one per stripe accessed.  Each ASM structure contains a
  * pointer to a list of PhysDiskAddr structures, which describe the
- * physical locations touched by the user access.  Note that this routine
- * returns only static mapping information, i.e. the list of physical
- * addresses returned does not necessarily identify the set of physical
- * locations that will actually be read or written.  The routine also
- * maps the parity.  The physical disk location returned always indicates
- * the entire parity unit, even when only a subset of it is being
- * accessed.  This is because an access that is not stripe unit aligned
- * but that spans a stripe unit boundary may require access two distinct
- * portions of the parity unit, and we can't yet tell which portion(s)
- * we'll actually need.  We leave it up to the algorithm selection code
- * to decide what subset of the parity unit to access.  Note that
- * addresses in the RAID address space must always be maintained as
- * longs, instead of ints.
+ * physical locations touched by the user access.  Note that this
+ * routine returns only static mapping information, i.e. the list of
+ * physical addresses returned does not necessarily identify the set
+ * of physical locations that will actually be read or written.  The
+ * routine also maps the parity.  The physical disk location returned
+ * always indicates the entire parity unit, even when only a subset of
+ * it is being accessed.  This is because an access that is not stripe
+ * unit aligned but that spans a stripe unit boundary may require
+ * access two distinct portions of the parity unit, and we can't yet
+ * tell which portion(s) we'll actually need.  We leave it up to the
+ * algorithm selection code to decide what subset of the parity unit
+ * to access.  Note that addresses in the RAID address space must
+ * always be maintained as longs, instead of ints.
  * 
  * This routine returns NULL if numBlocks is 0
  *
@@ -87,15 +87,15 @@
        RF_AccessStripeMapHeader_t *asm_hdr = NULL;
        RF_AccessStripeMap_t *asm_list = NULL, *asm_p = NULL;
        int     faultsTolerated = layoutPtr->map->faultsTolerated;
-       RF_RaidAddr_t startAddress = raidAddress;       /* we'll change
-                                                        * raidAddress along the
-                                                        * way */
+       /* we'll change raidAddress along the way */
+       RF_RaidAddr_t startAddress = raidAddress;
        RF_RaidAddr_t endAddress = raidAddress + numBlocks;
        RF_RaidDisk_t *disks = raidPtr->Disks;
 
        RF_PhysDiskAddr_t *pda_p, *pda_q;
        RF_StripeCount_t numStripes = 0;
-       RF_RaidAddr_t stripeRealEndAddress, stripeEndAddress, nextStripeUnitAddress;
+       RF_RaidAddr_t stripeRealEndAddress, stripeEndAddress, 
+               nextStripeUnitAddress;
        RF_RaidAddr_t startAddrWithinStripe, lastRaidAddr;
        RF_StripeCount_t totStripes;
        RF_StripeNum_t stripeID, lastSID, SUID, lastSUID;
@@ -111,8 +111,11 @@
        lastSUID = rf_RaidAddressToStripeUnitID(layoutPtr, lastRaidAddr);
 
        asmList = rf_AllocASMList(totStripes);
-       pdaList = rf_AllocPDAList(lastSUID - SUID + 1 + faultsTolerated * totStripes);  /* may also need pda(s)
-                                                                                        * per stripe for parity */
+
+       /* may also need pda(s) per stripe for parity */
+       pdaList = rf_AllocPDAList(lastSUID - SUID + 1 + 
+                                 faultsTolerated * totStripes);        
+
 
        if (raidAddress + numBlocks > raidPtr->totalSectors) {
                RF_ERRORMSG1("Unable to map access because offset (%d) was invalid\n",
@@ -147,10 +150,11 @@
 
                /* map each stripe unit in the stripe */
                pda_p = NULL;
-               startAddrWithinStripe = raidAddress;    /* Raid addr of start of
-                                                        * portion of access
-                                                        * that is within this
-                                                        * stripe */
+
+               /* Raid addr of start of portion of access that is
+                   within this stripe */
+               startAddrWithinStripe = raidAddress;    
+
                for (; raidAddress < stripeEndAddress;) {
                        RF_ASSERT(pdaList);
                        t_pda = pdaList;
@@ -164,13 +168,18 @@
                        }
 
                        pda_p->type = RF_PDA_TYPE_DATA;
-                       (layoutPtr->map->MapSector) (raidPtr, raidAddress, &(pda_p->col), &(pda_p->startSector), remap);
+                       (layoutPtr->map->MapSector) (raidPtr, raidAddress, 
+                                                    &(pda_p->col), 
+                                                    &(pda_p->startSector), 
+                                                    remap);
 
-                       /* mark any failures we find.  failedPDA is don't-care
-                        * if there is more than one failure */
-                       pda_p->raidAddress = raidAddress;       /* the RAID address
-                                                                * corresponding to this
-                                                                * physical disk address */
+                       /* mark any failures we find.  failedPDA is
+                        * don't-care if there is more than one
+                        * failure */
+
+                       /* the RAID address corresponding to this
+                           physical diskaddress */
+                       pda_p->raidAddress = raidAddress;       
                        nextStripeUnitAddress = rf_RaidAddressOfNextStripeUnitBoundary(layoutPtr, raidAddress);
                        pda_p->numSector = RF_MIN(endAddress, nextStripeUnitAddress) - raidAddress;
                        RF_ASSERT(pda_p->numSector != 0);
@@ -183,9 +192,9 @@
                }
 
                /* Map the parity. At this stage, the startSector and
-                * numSector fields for the parity unit are always set to
-                * indicate the entire parity unit. We may modify this after
-                * mapping the data portion. */
+                * numSector fields for the parity unit are always set
+                * to indicate the entire parity unit. We may modify
+                * this after mapping the data portion. */
                switch (faultsTolerated) {
                case 0:
                        break;
@@ -266,7 +275,9 @@
        RF_PhysDiskAddr_t *pda;
 
        for (asmap = asm_h->stripeMap; asmap; asmap = asmap->next) {
-               asmap->numDataFailed = asmap->numParityFailed = asmap->numQFailed = 0;
+               asmap->numDataFailed = 0;
+               asmap->numParityFailed = 0;
+               asmap->numQFailed = 0;
                asmap->numFailedPDAs = 0;
                memset((char *) asmap->failedPDAs, 0,
                    RF_MAX_FAILED_PDA * sizeof(RF_PhysDiskAddr_t *));
@@ -321,7 +332,8 @@
 #define RF_PDA_INC       24
 #define RF_PDA_INITIAL   64
 
-/* called at shutdown time.  So far, all that is necessary is to release all the free lists */
+/* called at shutdown time.  So far, all that is necessary is to
+   release all the free lists */
 static void rf_ShutdownMapModule(void *);
 static void 
 rf_ShutdownMapModule(ignored)
@@ -390,11 +402,11 @@
 
        return (p);
 }
-/* allocates a list of PDAs, locking the free list only once
- * when we have to call calloc, we do it one component at a time to simplify
- * the process of freeing the list at program shutdown.  This should not be
- * much of a performance hit, because it should be very infrequently executed.
- */
+/* allocates a list of PDAs, locking the free list only once when we
+ * have to call calloc, we do it one component at a time to simplify
+ * the process of freeing the list at program shutdown.  This should
+ * not be much of a performance hit, because it should be very
+ * infrequently executed.  */
 RF_PhysDiskAddr_t *
 rf_AllocPDAList(count)
        int     count;
@@ -438,11 +450,11 @@
        }
 }
 
-/* this is essentially identical to AllocPDAList.  I should combine the two.
- * when we have to call calloc, we do it one component at a time to simplify
- * the process of freeing the list at program shutdown.  This should not be
- * much of a performance hit, because it should be very infrequently executed.
- */
+/* this is essentially identical to AllocPDAList.  I should combine
+ * the two.  when we have to call calloc, we do it one component at a
+ * time to simplify the process of freeing the list at program
+ * shutdown.  This should not be much of a performance hit, because it
+ * should be very infrequently executed.  */
 RF_AccessStripeMap_t *
 rf_AllocASMList(count)
        int     count;
@@ -565,12 +577,15 @@
        if (numFailures == 0)
                return (0);
 
-       sosAddr = rf_RaidAddressOfPrevStripeBoundary(layoutPtr, asmap->raidAddress);
-       (layoutPtr->map->IdentifyStripe) (raidPtr, asmap->raidAddress, &diskids);
-       (layoutPtr->map->MapParity) (raidPtr, asmap->raidAddress, &pcol, &poffset, 0);  /* get pcol */
+       sosAddr = rf_RaidAddressOfPrevStripeBoundary(layoutPtr, 
+                                                    asmap->raidAddress);
+       (layoutPtr->map->IdentifyStripe) (raidPtr, asmap->raidAddress, 
+                                         &diskids);
+       (layoutPtr->map->MapParity) (raidPtr, asmap->raidAddress, 
+                                    &pcol, &poffset, 0);       /* get pcol */
 
-       /* this need not be true if we've redirected the access to a spare in
-        * another row RF_ASSERT(row == testrow); */
+       /* this need not be true if we've redirected the access to a
+        * spare in another row RF_ASSERT(row == testrow); */
        stripeOffset = 0;
        for (i = 0; i < layoutPtr->numDataCol + layoutPtr->numParityCol; i++) {
                if (diskids[i] != pcol) {
@@ -616,7 +631,8 @@
                return (0);
        numFailures = 0;
 
-       sosAddr = rf_RaidAddressOfPrevStripeBoundary(layoutPtr, asmap->raidAddress);
+       sosAddr = rf_RaidAddressOfPrevStripeBoundary(layoutPtr, 
+                                                    asmap->raidAddress);
        for (i = 0; i < layoutPtr->numDataCol; i++) {
                (layoutPtr->map->MapSector) (raidPtr, sosAddr + i * layoutPtr->sectorsPerStripeUnit,
                    &trow, &tcol, &diskOffset, 0);
@@ -628,11 +644,11 @@
 }
 #endif
 
-/*****************************************************************************************
+/****************************************************************************
  *
  * debug routines
  *
- ****************************************************************************************/
+ ***************************************************************************/
 #if RF_DEBUG_MAP
 void 
 rf_PrintAccessStripeMap(asm_h)
@@ -717,10 +733,9 @@
            (int) (raidAddr % layoutPtr->sectorsPerStripeUnit));
 }
 #endif
-/*
-   given a parity descriptor and the starting address within a stripe,
-   range restrict the parity descriptor to touch only the correct stuff.
-*/
+/* given a parity descriptor and the starting address within a stripe,
+ * range restrict the parity descriptor to touch only the correct
+ * stuff.  */
 void 
 rf_ASMParityAdjust(
     RF_PhysDiskAddr_t * toAdjust,
@@ -731,17 +746,18 @@
 {
        RF_PhysDiskAddr_t *new_pda;
 
-       /* when we're accessing only a portion of one stripe unit, we want the
-        * parity descriptor to identify only the chunk of parity associated
-        * with the data.  When the access spans exactly one stripe unit
-        * boundary and is less than a stripe unit in size, it uses two
-        * disjoint regions of the parity unit.  When an access spans more
-        * than one stripe unit boundary, it uses all of the parity unit.
+       /* when we're accessing only a portion of one stripe unit, we
+        * want the parity descriptor to identify only the chunk of
+        * parity associated with the data.  When the access spans
+        * exactly one stripe unit boundary and is less than a stripe
+        * unit in size, it uses two disjoint regions of the parity
+        * unit.  When an access spans more than one stripe unit
+        * boundary, it uses all of the parity unit.
         * 
-        * To better handle the case where stripe units are small, we may
-        * eventually want to change the 2nd case so that if the SU size is
-        * below some threshold, we just read/write the whole thing instead of
-        * breaking it up into two accesses. */
+        * To better handle the case where stripe units are small, we
+        * may eventually want to change the 2nd case so that if the
+        * SU size is below some threshold, we just read/write the
+        * whole thing instead of breaking it up into two accesses. */
        if (asm_p->numStripeUnitsAccessed == 1) {
                int     x = (startAddrWithinStripe % layoutPtr->sectorsPerStripeUnit);
                toAdjust->startSector += x;
@@ -775,12 +791,9 @@
                }
 }



Home | Main Index | Thread Index | Old Index