tech-kern archive

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

partitionSizeHi in raidframe component label



It looks like there is two place where partitionSizeHi is ignored in
rf_netbsdkintf.c.  I guess we should define access macros for it (and
also for numBlocks) to prevent further mistakes.

The patch below is against netbsd-5 branch.

enami.

Index: raidframevar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/raidframevar.h,v
retrieving revision 1.12.10.2
diff -u -r1.12.10.2 raidframevar.h
--- raidframevar.h      21 Nov 2010 22:06:53 -0000      1.12.10.2
+++ raidframevar.h      13 Feb 2011 06:04:27 -0000
@@ -475,6 +475,22 @@
        u_int partitionSizeHi;/* The top 32-bits of the partitionSize member. */
        int future_use2[42];  /* More future expansion */
 } RF_ComponentLabel_t;
+#define        RF_COMPONENT_LABEL_NUMBLOCKS(cl)                        \
+       ((((RF_SectorCount_t)(cl)->numBlocksHi) << 32) |        \
+           (cl)->numBlocks)
+#define        RF_COMPONENT_LABEL_SET_NUMBLOCKS(cl, siz)       \
+       do {                                            \
+               (cl)->numBlocksHi = (siz) >> 32;        \
+               (cl)->numBlocks = (siz);                \
+       } while (0)
+#define        RF_COMPONENT_LABEL_PARTITIONSIZE(cl)                    \
+       ((((RF_SectorCount_t)(cl)->partitionSizeHi) << 32) |    \
+           (cl)->partitionSize)
+#define        RF_COMPONENT_LABEL_SET_PARTITIONSIZE(cl, siz)   \
+       do {                                            \
+               (cl)->partitionSizeHi = (siz) >> 32;    \
+               (cl)->partitionSize = (siz);            \
+       } while (0)
 
 typedef struct RF_SingleComponent_s {
        int row;
Index: rf_copyback.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_copyback.c,v
retrieving revision 1.41.20.2
diff -u -r1.41.20.2 rf_copyback.c
--- rf_copyback.c       21 Nov 2010 22:06:53 -0000      1.41.20.2
+++ rf_copyback.c       13 Feb 2011 06:04:28 -0000
@@ -212,8 +212,8 @@
 
        c_label->row = 0;
        c_label->column = fcol;
-       c_label->partitionSize = raidPtr->Disks[fcol].partitionSize;
-       c_label->partitionSizeHi = raidPtr->Disks[fcol].partitionSize >> 32;
+       RF_COMPONENT_LABEL_SET_PARTITIONSIZE(c_label,
+           raidPtr->Disks[fcol].partitionSize);
 
        raidflush_component_label(raidPtr, fcol);
 
Index: rf_disks.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_disks.c,v
retrieving revision 1.70.10.4
diff -u -r1.70.10.4 rf_disks.c
--- rf_disks.c  7 Jan 2011 23:25:59 -0000       1.70.10.4
+++ rf_disks.c  13 Feb 2011 06:04:29 -0000
@@ -452,9 +452,8 @@
                if (ac!=NULL) {
                        /* Found it.  Configure it.. */
                        diskPtr->blockSize = ac->clabel->blockSize;
-                       diskPtr->numBlocks = ac->clabel->numBlocks;
-                       diskPtr->numBlocks |=
-                           (uint64_t)ac->clabel->numBlocksHi << 32;
+                       diskPtr->numBlocks =
+                           RF_COMPONENT_LABEL_NUMBLOCKS(ac->clabel);
                        /* Note: rf_protectedSectors is already
                           factored into numBlocks here */
                        raidPtr->raid_cinfo[c].ci_vp = ac->vp;
Index: rf_netbsdkintf.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_netbsdkintf.c,v
retrieving revision 1.250.4.10
diff -u -r1.250.4.10 rf_netbsdkintf.c
--- rf_netbsdkintf.c    7 Jan 2011 23:27:51 -0000       1.250.4.10
+++ rf_netbsdkintf.c    13 Feb 2011 06:04:31 -0000
@@ -1304,8 +1304,8 @@
                                ci_label->serial_number = 
                                    raidPtr->serial_number;
                                ci_label->row = 0; /* we dont' pretend to 
support more */
-                               ci_label->partitionSize =
-                                   diskPtr->partitionSize;
+                               RF_COMPONENT_LABEL_SET_PARTITIONSIZE(ci_label,
+                                   diskPtr->partitionSize);
                                ci_label->column = column;
                                raidflush_component_label(raidPtr, column);
                        }
@@ -2947,7 +2947,7 @@
        if (!raidread_component_label(secsize, dev, vp, clabel)) {
                /* Got the label.  Does it look reasonable? */
                if (rf_reasonable_label(clabel) && 
-                   (clabel->partitionSize <= size)) {
+                   (RF_COMPONENT_LABEL_PARTITIONSIZE(clabel) <= size)) {
                        rf_fix_old_label_size(clabel, numsecs);
 #ifdef DEBUG
                        printf("Component on: %s: %llu\n",
@@ -3177,9 +3177,9 @@
 void
 rf_print_component_label(RF_ComponentLabel_t *clabel)
 {
-       uint64_t numBlocks = clabel->numBlocks;
+       uint64_t numBlocks;
 
-       numBlocks |= (uint64_t)clabel->numBlocksHi << 32;
+       numBlocks = RF_COMPONENT_LABEL_NUMBLOCKS(clabel);
 
        printf("   Row: %d Column: %d Num Rows: %d Num Columns: %d\n",
               clabel->row, clabel->column,
@@ -3312,8 +3312,8 @@
            (clabel1->parityConfig == clabel2->parityConfig) &&
            (clabel1->maxOutstanding == clabel2->maxOutstanding) &&
            (clabel1->blockSize == clabel2->blockSize) &&
-           (clabel1->numBlocks == clabel2->numBlocks) &&
-           (clabel1->numBlocksHi == clabel2->numBlocksHi) &&
+           RF_COMPONENT_LABEL_NUMBLOCKS(clabel1) ==
+           RF_COMPONENT_LABEL_NUMBLOCKS(clabel2) &&
            (clabel1->autoconfigure == clabel2->autoconfigure) &&
            (clabel1->root_partition == clabel2->root_partition) &&
            (clabel1->last_unit == clabel2->last_unit) &&
@@ -3577,8 +3577,7 @@
        clabel->SUsPerRU = raidPtr->Layout.SUsPerRU;
 
        clabel->blockSize = raidPtr->bytesPerSector;
-       clabel->numBlocks = raidPtr->sectorsPerDisk;
-       clabel->numBlocksHi = raidPtr->sectorsPerDisk >> 32;
+       RF_COMPONENT_LABEL_SET_NUMBLOCKS(clabel, raidPtr->sectorsPerDisk);
 
        /* XXX not portable */
        clabel->parityConfig = raidPtr->Layout.map->parityConfig;
Index: rf_reconstruct.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_reconstruct.c,v
retrieving revision 1.105.4.4
diff -u -r1.105.4.4 rf_reconstruct.c
--- rf_reconstruct.c    21 Nov 2010 22:06:53 -0000      1.105.4.4
+++ rf_reconstruct.c    13 Feb 2011 06:04:32 -0000
@@ -296,9 +296,8 @@
                c_label->column = col;
                c_label->clean = RF_RAID_DIRTY;
                c_label->status = rf_ds_optimal;
-               c_label->partitionSize = raidPtr->Disks[scol].partitionSize;
-               c_label->partitionSizeHi =
-                  raidPtr->Disks[scol].partitionSize >> 32;
+               RF_COMPONENT_LABEL_SET_PARTITIONSIZE(c_label,
+                   raidPtr->Disks[scol].partitionSize);
 
                /* We've just done a rebuild based on all the other
                   disks, so at this point the parity is known to be



Home | Main Index | Thread Index | Old Index