tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
partitionSizeHi in raidframe component label, take 2 (wasRe: partitionSizeHi in raidframe component label)
Hi. Thanks for your suggestions. Here is updated diff:
- Userland fix is added.
- rf_reasonable_label() is also changed to use accessor. Initially I
thought it is a special case since the comment in
rf_fix_old_label_size implies that the numBlocksHi may be garbarge
when the function is called, but even if it is garbage the result of
comparison is same.
enami.
Index: sys/dev/raidframe/raidframevar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/raidframevar.h,v
retrieving revision 1.14
diff -u -r1.14 raidframevar.h
--- sys/dev/raidframe/raidframevar.h 1 Nov 2010 02:35:24 -0000 1.14
+++ sys/dev/raidframe/raidframevar.h 16 Feb 2011 09:15:39 -0000
@@ -444,9 +444,9 @@
int maxOutstanding; /* maxOutstanding disk requests */
int blockSize; /* size of component block.
(disklabel->d_secsize) */
- u_int numBlocks; /* number of blocks on this component. May
+ u_int __numBlocks; /* number of blocks on this component. May
be smaller than the partition size. */
- u_int partitionSize; /* number of blocks on this *partition*.
+ u_int __partitionSize;/* number of blocks on this *partition*.
Must exactly match the partition size
from the disklabel. */
/* Parity map stuff. */
@@ -476,6 +476,43 @@
int future_use2[42]; /* More future expansion */
} RF_ComponentLabel_t;
+/*
+ * Following four functions are access macros for the number of blocks
+ * and partition size in component label.
+ */
+static inline RF_SectorCount_t
+rf_component_label_numblocks(const RF_ComponentLabel_t *cl)
+{
+
+ return ((RF_SectorCount_t)cl->numBlocksHi << 32) |
+ cl->__numBlocks;
+}
+
+static inline void
+rf_component_label_set_numblocks(RF_ComponentLabel_t *cl, RF_SectorCount_t siz)
+{
+
+ cl->numBlocksHi = siz >> 32;
+ cl->__numBlocks = siz;
+}
+
+static inline RF_SectorCount_t
+rf_component_label_partitionsize(const RF_ComponentLabel_t *cl)
+{
+
+ return ((RF_SectorCount_t)cl->partitionSizeHi << 32) |
+ cl->__partitionSize;
+}
+
+static inline void
+rf_component_label_set_partitionsize(RF_ComponentLabel_t *cl,
+ RF_SectorCount_t siz)
+{
+
+ cl->partitionSizeHi = siz >> 32;
+ cl->__partitionSize = siz;
+}
+
typedef struct RF_SingleComponent_s {
int row;
int column;
Index: sys/dev/raidframe/rf_copyback.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_copyback.c,v
retrieving revision 1.44
diff -u -r1.44 rf_copyback.c
--- sys/dev/raidframe/rf_copyback.c 19 Nov 2010 06:44:40 -0000 1.44
+++ sys/dev/raidframe/rf_copyback.c 16 Feb 2011 09:15:39 -0000
@@ -222,8 +222,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: sys/dev/raidframe/rf_disks.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_disks.c,v
retrieving revision 1.77
diff -u -r1.77 rf_disks.c
--- sys/dev/raidframe/rf_disks.c 13 Feb 2011 06:17:35 -0000 1.77
+++ sys/dev/raidframe/rf_disks.c 16 Feb 2011 09:15:39 -0000
@@ -455,9 +455,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: sys/dev/raidframe/rf_netbsdkintf.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_netbsdkintf.c,v
retrieving revision 1.281
diff -u -r1.281 rf_netbsdkintf.c
--- sys/dev/raidframe/rf_netbsdkintf.c 8 Feb 2011 20:20:27 -0000 1.281
+++ sys/dev/raidframe/rf_netbsdkintf.c 16 Feb 2011 09:15:39 -0000
@@ -1299,8 +1299,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);
}
@@ -2949,7 +2949,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",
@@ -3151,7 +3151,12 @@
clabel->row < clabel->num_rows &&
clabel->column < clabel->num_columns &&
clabel->blockSize > 0 &&
- clabel->numBlocks > 0) {
+ /*
+ * numBlocksHi may contain garbage, but it is ok since
+ * the type is unsigned. If it is really garbage,
+ * rf_fix_old_label_size() will fix it.
+ */
+ rf_component_label_numblocks(clabel) > 0) {
/* label looks reasonable enough... */
return(1);
}
@@ -3181,9 +3186,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,
@@ -3316,8 +3321,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) &&
@@ -3581,8 +3586,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: sys/dev/raidframe/rf_reconstruct.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_reconstruct.c,v
retrieving revision 1.110
diff -u -r1.110 rf_reconstruct.c
--- sys/dev/raidframe/rf_reconstruct.c 19 Nov 2010 06:44:40 -0000 1.110
+++ sys/dev/raidframe/rf_reconstruct.c 16 Feb 2011 09:15:39 -0000
@@ -297,9 +297,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
Index: sbin/raidctl/raidctl.c
===================================================================
RCS file: /cvsroot/src/sbin/raidctl/raidctl.c,v
retrieving revision 1.51
diff -u -r1.51 raidctl.c
--- sbin/raidctl/raidctl.c 9 Feb 2011 11:22:49 -0000 1.51
+++ sbin/raidctl/raidctl.c 16 Feb 2011 09:15:40 -0000
@@ -743,9 +743,9 @@
printf(" sectPerSU: %d, SUsPerPU: %d, SUsPerRU: %d\n",
component_label.sectPerSU, component_label.SUsPerPU,
component_label.SUsPerRU);
- printf(" Queue size: %d, blocksize: %d, numBlocks: %u\n",
+ printf(" Queue size: %d, blocksize: %d, numBlocks: %"PRIu64"\n",
component_label.maxOutstanding, component_label.blockSize,
- component_label.numBlocks);
+ rf_component_label_numblocks(&component_label));
printf(" RAID Level: %c\n", (char) component_label.parityConfig);
printf(" Autoconfig: %s\n",
component_label.autoconfigure ? "Yes" : "No" );
Home |
Main Index |
Thread Index |
Old Index