Define accessors for number of blocks and partition size in the

component label and use them where appropriate.  Disscussed on tech-kern.
This commit is contained in:
enami 2011-02-19 07:11:09 +00:00
parent 03dc8ab333
commit ec02ea412c
6 changed files with 72 additions and 33 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: raidctl.c,v 1.51 2011/02/09 11:22:49 pooka Exp $ */ /* $NetBSD: raidctl.c,v 1.52 2011/02/19 07:11:10 enami Exp $ */
/*- /*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: raidctl.c,v 1.51 2011/02/09 11:22:49 pooka Exp $"); __RCSID("$NetBSD: raidctl.c,v 1.52 2011/02/19 07:11:10 enami Exp $");
#endif #endif
@ -743,9 +743,9 @@ get_component_label(int fd, char *component)
printf(" sectPerSU: %d, SUsPerPU: %d, SUsPerRU: %d\n", printf(" sectPerSU: %d, SUsPerPU: %d, SUsPerRU: %d\n",
component_label.sectPerSU, component_label.SUsPerPU, component_label.sectPerSU, component_label.SUsPerPU,
component_label.SUsPerRU); 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.maxOutstanding, component_label.blockSize,
component_label.numBlocks); rf_component_label_numblocks(&component_label));
printf(" RAID Level: %c\n", (char) component_label.parityConfig); printf(" RAID Level: %c\n", (char) component_label.parityConfig);
printf(" Autoconfig: %s\n", printf(" Autoconfig: %s\n",
component_label.autoconfigure ? "Yes" : "No" ); component_label.autoconfigure ? "Yes" : "No" );

View File

@ -1,4 +1,4 @@
/* $NetBSD: raidframevar.h,v 1.14 2010/11/01 02:35:24 mrg Exp $ */ /* $NetBSD: raidframevar.h,v 1.15 2011/02/19 07:11:09 enami Exp $ */
/*- /*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -444,9 +444,9 @@ typedef struct RF_ComponentLabel_s {
int maxOutstanding; /* maxOutstanding disk requests */ int maxOutstanding; /* maxOutstanding disk requests */
int blockSize; /* size of component block. int blockSize; /* size of component block.
(disklabel->d_secsize) */ (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. */ 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 Must exactly match the partition size
from the disklabel. */ from the disklabel. */
/* Parity map stuff. */ /* Parity map stuff. */
@ -476,6 +476,43 @@ typedef struct RF_ComponentLabel_s {
int future_use2[42]; /* More future expansion */ int future_use2[42]; /* More future expansion */
} RF_ComponentLabel_t; } 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 { typedef struct RF_SingleComponent_s {
int row; int row;
int column; int column;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_copyback.c,v 1.44 2010/11/19 06:44:40 dholland Exp $ */ /* $NetBSD: rf_copyback.c,v 1.45 2011/02/19 07:11:09 enami Exp $ */
/* /*
* Copyright (c) 1995 Carnegie-Mellon University. * Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved. * All rights reserved.
@ -38,7 +38,7 @@
****************************************************************************/ ****************************************************************************/
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.44 2010/11/19 06:44:40 dholland Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.45 2011/02/19 07:11:09 enami Exp $");
#include <dev/raidframe/raidframevar.h> #include <dev/raidframe/raidframevar.h>
@ -222,8 +222,8 @@ rf_CopybackReconstructedData(RF_Raid_t *raidPtr)
c_label->row = 0; c_label->row = 0;
c_label->column = fcol; c_label->column = fcol;
c_label->partitionSize = raidPtr->Disks[fcol].partitionSize; rf_component_label_set_partitionsize(c_label,
c_label->partitionSizeHi = raidPtr->Disks[fcol].partitionSize >> 32; raidPtr->Disks[fcol].partitionSize);
raidflush_component_label(raidPtr, fcol); raidflush_component_label(raidPtr, fcol);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_disks.c,v 1.77 2011/02/13 06:17:35 enami Exp $ */ /* $NetBSD: rf_disks.c,v 1.78 2011/02/19 07:11:09 enami Exp $ */
/*- /*-
* Copyright (c) 1999 The NetBSD Foundation, Inc. * Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -60,7 +60,7 @@
***************************************************************/ ***************************************************************/
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.77 2011/02/13 06:17:35 enami Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.78 2011/02/19 07:11:09 enami Exp $");
#include <dev/raidframe/raidframevar.h> #include <dev/raidframe/raidframevar.h>
@ -455,9 +455,8 @@ rf_AutoConfigureDisks(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr,
if (ac!=NULL) { if (ac!=NULL) {
/* Found it. Configure it.. */ /* Found it. Configure it.. */
diskPtr->blockSize = ac->clabel->blockSize; diskPtr->blockSize = ac->clabel->blockSize;
diskPtr->numBlocks = ac->clabel->numBlocks; diskPtr->numBlocks =
diskPtr->numBlocks |= rf_component_label_numblocks(ac->clabel);
(uint64_t)ac->clabel->numBlocksHi << 32;
/* Note: rf_protectedSectors is already /* Note: rf_protectedSectors is already
factored into numBlocks here */ factored into numBlocks here */
raidPtr->raid_cinfo[c].ci_vp = ac->vp; raidPtr->raid_cinfo[c].ci_vp = ac->vp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_netbsdkintf.c,v 1.281 2011/02/08 20:20:27 rmind Exp $ */ /* $NetBSD: rf_netbsdkintf.c,v 1.282 2011/02/19 07:11:09 enami Exp $ */
/*- /*-
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@ -101,7 +101,7 @@
***********************************************************/ ***********************************************************/
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.281 2011/02/08 20:20:27 rmind Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.282 2011/02/19 07:11:09 enami Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h" #include "opt_compat_netbsd.h"
@ -1299,8 +1299,8 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
ci_label->serial_number = ci_label->serial_number =
raidPtr->serial_number; raidPtr->serial_number;
ci_label->row = 0; /* we dont' pretend to support more */ ci_label->row = 0; /* we dont' pretend to support more */
ci_label->partitionSize = rf_component_label_set_partitionsize(ci_label,
diskPtr->partitionSize; diskPtr->partitionSize);
ci_label->column = column; ci_label->column = column;
raidflush_component_label(raidPtr, column); raidflush_component_label(raidPtr, column);
} }
@ -2949,7 +2949,7 @@ oomem:
if (!raidread_component_label(secsize, dev, vp, clabel)) { if (!raidread_component_label(secsize, dev, vp, clabel)) {
/* Got the label. Does it look reasonable? */ /* Got the label. Does it look reasonable? */
if (rf_reasonable_label(clabel) && if (rf_reasonable_label(clabel) &&
(clabel->partitionSize <= size)) { (rf_component_label_partitionsize(clabel) <= size)) {
rf_fix_old_label_size(clabel, numsecs); rf_fix_old_label_size(clabel, numsecs);
#ifdef DEBUG #ifdef DEBUG
printf("Component on: %s: %llu\n", printf("Component on: %s: %llu\n",
@ -3151,7 +3151,12 @@ rf_reasonable_label(RF_ComponentLabel_t *clabel)
clabel->row < clabel->num_rows && clabel->row < clabel->num_rows &&
clabel->column < clabel->num_columns && clabel->column < clabel->num_columns &&
clabel->blockSize > 0 && 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... */ /* label looks reasonable enough... */
return(1); return(1);
} }
@ -3181,9 +3186,9 @@ rf_fix_old_label_size(RF_ComponentLabel_t *clabel, uint64_t numsecs)
void void
rf_print_component_label(RF_ComponentLabel_t *clabel) 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", printf(" Row: %d Column: %d Num Rows: %d Num Columns: %d\n",
clabel->row, clabel->column, clabel->row, clabel->column,
@ -3316,8 +3321,8 @@ rf_does_it_fit(RF_ConfigSet_t *cset, RF_AutoConfig_t *ac)
(clabel1->parityConfig == clabel2->parityConfig) && (clabel1->parityConfig == clabel2->parityConfig) &&
(clabel1->maxOutstanding == clabel2->maxOutstanding) && (clabel1->maxOutstanding == clabel2->maxOutstanding) &&
(clabel1->blockSize == clabel2->blockSize) && (clabel1->blockSize == clabel2->blockSize) &&
(clabel1->numBlocks == clabel2->numBlocks) && rf_component_label_numblocks(clabel1) ==
(clabel1->numBlocksHi == clabel2->numBlocksHi) && rf_component_label_numblocks(clabel2) &&
(clabel1->autoconfigure == clabel2->autoconfigure) && (clabel1->autoconfigure == clabel2->autoconfigure) &&
(clabel1->root_partition == clabel2->root_partition) && (clabel1->root_partition == clabel2->root_partition) &&
(clabel1->last_unit == clabel2->last_unit) && (clabel1->last_unit == clabel2->last_unit) &&
@ -3581,8 +3586,7 @@ raid_init_component_label(RF_Raid_t *raidPtr, RF_ComponentLabel_t *clabel)
clabel->SUsPerRU = raidPtr->Layout.SUsPerRU; clabel->SUsPerRU = raidPtr->Layout.SUsPerRU;
clabel->blockSize = raidPtr->bytesPerSector; clabel->blockSize = raidPtr->bytesPerSector;
clabel->numBlocks = raidPtr->sectorsPerDisk; rf_component_label_set_numblocks(clabel, raidPtr->sectorsPerDisk);
clabel->numBlocksHi = raidPtr->sectorsPerDisk >> 32;
/* XXX not portable */ /* XXX not portable */
clabel->parityConfig = raidPtr->Layout.map->parityConfig; clabel->parityConfig = raidPtr->Layout.map->parityConfig;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_reconstruct.c,v 1.110 2010/11/19 06:44:40 dholland Exp $ */ /* $NetBSD: rf_reconstruct.c,v 1.111 2011/02/19 07:11:09 enami Exp $ */
/* /*
* Copyright (c) 1995 Carnegie-Mellon University. * Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved. * All rights reserved.
@ -33,7 +33,7 @@
************************************************************/ ************************************************************/
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.110 2010/11/19 06:44:40 dholland Exp $"); __KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.111 2011/02/19 07:11:09 enami Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/time.h> #include <sys/time.h>
@ -297,9 +297,8 @@ rf_ReconstructFailedDiskBasic(RF_Raid_t *raidPtr, RF_RowCol_t col)
c_label->column = col; c_label->column = col;
c_label->clean = RF_RAID_DIRTY; c_label->clean = RF_RAID_DIRTY;
c_label->status = rf_ds_optimal; c_label->status = rf_ds_optimal;
c_label->partitionSize = raidPtr->Disks[scol].partitionSize; rf_component_label_set_partitionsize(c_label,
c_label->partitionSizeHi = raidPtr->Disks[scol].partitionSize);
raidPtr->Disks[scol].partitionSize >> 32;
/* We've just done a rebuild based on all the other /* We've just done a rebuild based on all the other
disks, so at this point the parity is known to be disks, so at this point the parity is known to be