Home | History | Annotate | Line # | Download | only in raidframe
rf_declusterPQ.c revision 1.6
      1 /*	$NetBSD: rf_declusterPQ.c,v 1.6 2001/10/04 15:58:52 oster Exp $	*/
      2 /*
      3  * Copyright (c) 1995 Carnegie-Mellon University.
      4  * All rights reserved.
      5  *
      6  * Authors: Daniel Stodolsky, Mark Holland, Jim Zelenka
      7  *
      8  * Permission to use, copy, modify and distribute this software and
      9  * its documentation is hereby granted, provided that both the copyright
     10  * notice and this permission notice appear in all copies of the
     11  * software, derivative works or modified versions, and any portions
     12  * thereof, and that both notices appear in supporting documentation.
     13  *
     14  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     15  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     16  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     17  *
     18  * Carnegie Mellon requests users of this software to return to
     19  *
     20  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     21  *  School of Computer Science
     22  *  Carnegie Mellon University
     23  *  Pittsburgh PA 15213-3890
     24  *
     25  * any improvements or extensions that they make and grant Carnegie the
     26  * rights to redistribute these changes.
     27  */
     28 
     29 /*--------------------------------------------------
     30  * rf_declusterPQ.c
     31  *
     32  * mapping code for declustered P & Q or declustered EvenOdd
     33  * much code borrowed from rf_decluster.c
     34  *
     35  *--------------------------------------------------*/
     36 
     37 #include <dev/raidframe/raidframevar.h>
     38 
     39 #include "rf_archs.h"
     40 #include "rf_raid.h"
     41 #include "rf_decluster.h"
     42 #include "rf_declusterPQ.h"
     43 #include "rf_debugMem.h"
     44 #include "rf_utils.h"
     45 #include "rf_alloclist.h"
     46 #include "rf_general.h"
     47 
     48 #if (RF_INCLUDE_PARITY_DECLUSTERING_PQ > 0) || (RF_INCLUDE_EVENODD > 0)
     49 /* configuration code */
     50 
     51 int
     52 rf_ConfigureDeclusteredPQ(
     53     RF_ShutdownList_t ** listp,
     54     RF_Raid_t * raidPtr,
     55     RF_Config_t * cfgPtr)
     56 {
     57 	RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);
     58 	int     b, v, k, r, lambda;	/* block design params */
     59 	int     i, j, l;
     60 	int    *first_avail_slot;
     61 	int     complete_FT_count, SUID;
     62 	RF_DeclusteredConfigInfo_t *info;
     63 	int     numCompleteFullTablesPerDisk;
     64 	int     PUsPerDisk, spareRegionDepthInPUs, numCompleteSpareRegionsPerDisk = 0,
     65 	        extraPUsPerDisk;
     66 	int     totSparePUsPerDisk;
     67 	int     diskOffsetOfLastFullTableInSUs, SpareSpaceInSUs;
     68 	char   *cfgBuf = (char *) (cfgPtr->layoutSpecific);
     69 
     70 	cfgBuf += RF_SPAREMAP_NAME_LEN;
     71 
     72 	b = *((int *) cfgBuf);
     73 	cfgBuf += sizeof(int);
     74 	v = *((int *) cfgBuf);
     75 	cfgBuf += sizeof(int);
     76 	k = *((int *) cfgBuf);
     77 	cfgBuf += sizeof(int);
     78 	r = *((int *) cfgBuf);
     79 	cfgBuf += sizeof(int);
     80 	lambda = *((int *) cfgBuf);
     81 	cfgBuf += sizeof(int);
     82 	raidPtr->noRotate = *((int *) cfgBuf);
     83 	cfgBuf += sizeof(int);
     84 
     85 	if (k <= 2) {
     86 		printf("RAIDFRAME: k=%d, minimum value 2\n", k);
     87 		return (EINVAL);
     88 	}
     89 	/* 1. create layout specific structure */
     90 	RF_MallocAndAdd(info, sizeof(RF_DeclusteredConfigInfo_t), (RF_DeclusteredConfigInfo_t *), raidPtr->cleanupList);
     91 	if (info == NULL)
     92 		return (ENOMEM);
     93 	layoutPtr->layoutSpecificInfo = (void *) info;
     94 
     95 	/* the sparemaps are generated assuming that parity is rotated, so we
     96 	 * issue a warning if both distributed sparing and no-rotate are on at
     97 	 * the same time */
     98 	if ((raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE) && raidPtr->noRotate) {
     99 		RF_ERRORMSG("Warning:  distributed sparing specified without parity rotation.\n");
    100 	}
    101 	if (raidPtr->numCol != v) {
    102 		RF_ERRORMSG2("RAID: config error: table element count (%d) not equal to no. of cols (%d)\n", v, raidPtr->numCol);
    103 		return (EINVAL);
    104 	}
    105 	/* 3.  set up the values used in devRaidMap */
    106 	info->BlocksPerTable = b;
    107 	info->NumParityReps = info->groupSize = k;
    108 	info->PUsPerBlock = k - 2;	/* PQ */
    109 	info->SUsPerTable = b * info->PUsPerBlock * layoutPtr->SUsPerPU;	/* b blks, k-1 SUs each */
    110 	info->SUsPerFullTable = k * info->SUsPerTable;	/* rot k times */
    111 	info->SUsPerBlock = info->PUsPerBlock * layoutPtr->SUsPerPU;
    112 	info->TableDepthInPUs = (b * k) / v;
    113 	info->FullTableDepthInPUs = info->TableDepthInPUs * k;	/* k repetitions */
    114 
    115 	/* used only in distributed sparing case */
    116 	info->FullTablesPerSpareRegion = (v - 1) / rf_gcd(r, v - 1);	/* (v-1)/gcd fulltables */
    117 	info->TablesPerSpareRegion = k * info->FullTablesPerSpareRegion;
    118 	info->SpareSpaceDepthPerRegionInSUs = (r * info->TablesPerSpareRegion / (v - 1)) * layoutPtr->SUsPerPU;
    119 
    120 	/* check to make sure the block design is sufficiently small */
    121 	if ((raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE)) {
    122 		if (info->FullTableDepthInPUs * layoutPtr->SUsPerPU + info->SpareSpaceDepthPerRegionInSUs > layoutPtr->stripeUnitsPerDisk) {
    123 			RF_ERRORMSG3("RAID: config error: Full Table depth (%d) + Spare Space (%d) larger than disk size (%d) (BD too big)\n",
    124 			    (int) info->FullTableDepthInPUs,
    125 			    (int) info->SpareSpaceDepthPerRegionInSUs,
    126 			    (int) layoutPtr->stripeUnitsPerDisk);
    127 			return (EINVAL);
    128 		}
    129 	} else {
    130 		if (info->TableDepthInPUs * layoutPtr->SUsPerPU > layoutPtr->stripeUnitsPerDisk) {
    131 			RF_ERRORMSG2("RAID: config error: Table depth (%d) larger than disk size (%d) (BD too big)\n",
    132 			    (int) (info->TableDepthInPUs * layoutPtr->SUsPerPU),
    133 			    (int) layoutPtr->stripeUnitsPerDisk);
    134 			return (EINVAL);
    135 		}
    136 	}
    137 
    138 
    139 	/* compute the size of each disk, and the number of tables in the last
    140 	 * fulltable (which need not be complete) */
    141 	if ((raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE)) {
    142 
    143 		PUsPerDisk = layoutPtr->stripeUnitsPerDisk / layoutPtr->SUsPerPU;
    144 		spareRegionDepthInPUs = (info->TablesPerSpareRegion * info->TableDepthInPUs +
    145 		    (info->TablesPerSpareRegion * info->TableDepthInPUs) / (v - 1));
    146 		info->SpareRegionDepthInSUs = spareRegionDepthInPUs * layoutPtr->SUsPerPU;
    147 
    148 		numCompleteSpareRegionsPerDisk = PUsPerDisk / spareRegionDepthInPUs;
    149 		info->NumCompleteSRs = numCompleteSpareRegionsPerDisk;
    150 		extraPUsPerDisk = PUsPerDisk % spareRegionDepthInPUs;
    151 
    152 		/* assume conservatively that we need the full amount of spare
    153 		 * space in one region in order to provide spares for the
    154 		 * partial spare region at the end of the array.  We set "i"
    155 		 * to the number of tables in the partial spare region.  This
    156 		 * may actually include some fulltables. */
    157 		extraPUsPerDisk -= (info->SpareSpaceDepthPerRegionInSUs / layoutPtr->SUsPerPU);
    158 		if (extraPUsPerDisk <= 0)
    159 			i = 0;
    160 		else
    161 			i = extraPUsPerDisk / info->TableDepthInPUs;
    162 
    163 		complete_FT_count = raidPtr->numRow * (numCompleteSpareRegionsPerDisk * (info->TablesPerSpareRegion / k) + i / k);
    164 		info->FullTableLimitSUID = complete_FT_count * info->SUsPerFullTable;
    165 		info->ExtraTablesPerDisk = i % k;
    166 
    167 		/* note that in the last spare region, the spare space is
    168 		 * complete even though data/parity space is not */
    169 		totSparePUsPerDisk = (numCompleteSpareRegionsPerDisk + 1) * (info->SpareSpaceDepthPerRegionInSUs / layoutPtr->SUsPerPU);
    170 		info->TotSparePUsPerDisk = totSparePUsPerDisk;
    171 
    172 		layoutPtr->stripeUnitsPerDisk =
    173 		    ((complete_FT_count / raidPtr->numRow) * info->FullTableDepthInPUs +	/* data & parity space */
    174 		    info->ExtraTablesPerDisk * info->TableDepthInPUs +
    175 		    totSparePUsPerDisk	/* spare space */
    176 		    ) * layoutPtr->SUsPerPU;
    177 		layoutPtr->dataStripeUnitsPerDisk =
    178 		    (complete_FT_count * info->FullTableDepthInPUs + info->ExtraTablesPerDisk * info->TableDepthInPUs)
    179 		    * layoutPtr->SUsPerPU * (k - 1) / k;
    180 
    181 	} else {
    182 		/* non-dist spare case:  force each disk to contain an
    183 		 * integral number of tables */
    184 		layoutPtr->stripeUnitsPerDisk /= (info->TableDepthInPUs * layoutPtr->SUsPerPU);
    185 		layoutPtr->stripeUnitsPerDisk *= (info->TableDepthInPUs * layoutPtr->SUsPerPU);
    186 
    187 		/* compute the number of tables in the last fulltable, which
    188 		 * need not be complete */
    189 		complete_FT_count =
    190 		    ((layoutPtr->stripeUnitsPerDisk / layoutPtr->SUsPerPU) / info->FullTableDepthInPUs) * raidPtr->numRow;
    191 
    192 		info->FullTableLimitSUID = complete_FT_count * info->SUsPerFullTable;
    193 		info->ExtraTablesPerDisk =
    194 		    ((layoutPtr->stripeUnitsPerDisk / layoutPtr->SUsPerPU) / info->TableDepthInPUs) % k;
    195 	}
    196 
    197 	raidPtr->sectorsPerDisk = layoutPtr->stripeUnitsPerDisk * layoutPtr->sectorsPerStripeUnit;
    198 
    199 	/* find the disk offset of the stripe unit where the last fulltable
    200 	 * starts */
    201 	numCompleteFullTablesPerDisk = complete_FT_count / raidPtr->numRow;
    202 	diskOffsetOfLastFullTableInSUs = numCompleteFullTablesPerDisk * info->FullTableDepthInPUs * layoutPtr->SUsPerPU;
    203 	if ((raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE)) {
    204 		SpareSpaceInSUs = numCompleteSpareRegionsPerDisk * info->SpareSpaceDepthPerRegionInSUs;
    205 		diskOffsetOfLastFullTableInSUs += SpareSpaceInSUs;
    206 		info->DiskOffsetOfLastSpareSpaceChunkInSUs =
    207 		    diskOffsetOfLastFullTableInSUs + info->ExtraTablesPerDisk * info->TableDepthInPUs * layoutPtr->SUsPerPU;
    208 	}
    209 	info->DiskOffsetOfLastFullTableInSUs = diskOffsetOfLastFullTableInSUs;
    210 	info->numCompleteFullTablesPerDisk = numCompleteFullTablesPerDisk;
    211 
    212 	/* 4.  create and initialize the lookup tables */
    213 	info->LayoutTable = rf_make_2d_array(b, k, raidPtr->cleanupList);
    214 	if (info->LayoutTable == NULL)
    215 		return (ENOMEM);
    216 	info->OffsetTable = rf_make_2d_array(b, k, raidPtr->cleanupList);
    217 	if (info->OffsetTable == NULL)
    218 		return (ENOMEM);
    219 	info->BlockTable = rf_make_2d_array(info->TableDepthInPUs * layoutPtr->SUsPerPU, raidPtr->numCol, raidPtr->cleanupList);
    220 	if (info->BlockTable == NULL)
    221 		return (ENOMEM);
    222 
    223 	first_avail_slot = (int *) rf_make_1d_array(v, NULL);
    224 	if (first_avail_slot == NULL)
    225 		return (ENOMEM);
    226 
    227 	for (i = 0; i < b; i++)
    228 		for (j = 0; j < k; j++)
    229 			info->LayoutTable[i][j] = *cfgBuf++;
    230 
    231 	/* initialize offset table */
    232 	for (i = 0; i < b; i++)
    233 		for (j = 0; j < k; j++) {
    234 			info->OffsetTable[i][j] = first_avail_slot[info->LayoutTable[i][j]];
    235 			first_avail_slot[info->LayoutTable[i][j]]++;
    236 		}
    237 
    238 	/* initialize block table */
    239 	for (SUID = l = 0; l < layoutPtr->SUsPerPU; l++) {
    240 		for (i = 0; i < b; i++) {
    241 			for (j = 0; j < k; j++) {
    242 				info->BlockTable[(info->OffsetTable[i][j] * layoutPtr->SUsPerPU) + l]
    243 				    [info->LayoutTable[i][j]] = SUID;
    244 			}
    245 			SUID++;
    246 		}
    247 	}
    248 
    249 	rf_free_1d_array(first_avail_slot, v);
    250 
    251 	/* 5.  set up the remaining redundant-but-useful parameters */
    252 
    253 	raidPtr->totalSectors = (k * complete_FT_count + raidPtr->numRow * info->ExtraTablesPerDisk) *
    254 	    info->SUsPerTable * layoutPtr->sectorsPerStripeUnit;
    255 	layoutPtr->numStripe = (raidPtr->totalSectors / layoutPtr->sectorsPerStripeUnit) / (k - 2);
    256 
    257 	/* strange evaluation order below to try and minimize overflow
    258 	 * problems */
    259 
    260 	layoutPtr->dataSectorsPerStripe = (k - 2) * layoutPtr->sectorsPerStripeUnit;
    261 	layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector;
    262 	layoutPtr->numDataCol = k - 2;
    263 	layoutPtr->numParityCol = 2;
    264 
    265 	return (0);
    266 }
    267 
    268 int
    269 rf_GetDefaultNumFloatingReconBuffersPQ(RF_Raid_t * raidPtr)
    270 {
    271 	int     def_decl;
    272 
    273 	def_decl = rf_GetDefaultNumFloatingReconBuffersDeclustered(raidPtr);
    274 	return (RF_MAX(3 * raidPtr->numCol, def_decl));
    275 }
    276 
    277 void
    278 rf_MapSectorDeclusteredPQ(
    279     RF_Raid_t * raidPtr,
    280     RF_RaidAddr_t raidSector,
    281     RF_RowCol_t * row,
    282     RF_RowCol_t * col,
    283     RF_SectorNum_t * diskSector,
    284     int remap)
    285 {
    286 	RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);
    287 	RF_DeclusteredConfigInfo_t *info = (RF_DeclusteredConfigInfo_t *) layoutPtr->layoutSpecificInfo;
    288 	RF_StripeNum_t SUID = raidSector / layoutPtr->sectorsPerStripeUnit;
    289 	RF_StripeNum_t FullTableID, FullTableOffset, TableID, TableOffset;
    290 	RF_StripeNum_t BlockID, BlockOffset, RepIndex;
    291 	RF_StripeCount_t sus_per_fulltable = info->SUsPerFullTable;
    292 	RF_StripeCount_t fulltable_depth = info->FullTableDepthInPUs * layoutPtr->SUsPerPU;
    293 	RF_StripeNum_t base_suid = 0, outSU, SpareRegion = 0, SpareSpace = 0;
    294 
    295 	rf_decluster_adjust_params(layoutPtr, &SUID, &sus_per_fulltable, &fulltable_depth, &base_suid);
    296 
    297 	FullTableID = SUID / sus_per_fulltable;	/* fulltable ID within array
    298 						 * (across rows) */
    299 	*row = FullTableID % raidPtr->numRow;
    300 	FullTableID /= raidPtr->numRow;	/* convert to fulltable ID on this
    301 					 * disk */
    302 	if ((raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE)) {
    303 		SpareRegion = FullTableID / info->FullTablesPerSpareRegion;
    304 		SpareSpace = SpareRegion * info->SpareSpaceDepthPerRegionInSUs;
    305 	}
    306 	FullTableOffset = SUID % sus_per_fulltable;
    307 	TableID = FullTableOffset / info->SUsPerTable;
    308 	TableOffset = FullTableOffset - TableID * info->SUsPerTable;
    309 	BlockID = TableOffset / info->PUsPerBlock;
    310 	BlockOffset = TableOffset - BlockID * info->PUsPerBlock;
    311 	BlockID %= info->BlocksPerTable;
    312 	RF_ASSERT(BlockOffset < info->groupSize - 2);
    313 	/*
    314            TableIDs go from 0 .. GroupSize-1 inclusive.
    315            PUsPerBlock is k-2.
    316            We want the tableIDs to rotate from the
    317            right, so use GroupSize
    318            */
    319 	RepIndex = info->groupSize - 1 - TableID;
    320 	RF_ASSERT(RepIndex >= 0);
    321 	if (!raidPtr->noRotate) {
    322 		if (TableID == 0)
    323 			BlockOffset++;	/* P on last drive, Q on first */
    324 		else
    325 			BlockOffset += ((BlockOffset >= RepIndex) ? 2 : 0);	/* skip over PQ */
    326 		RF_ASSERT(BlockOffset < info->groupSize);
    327 		*col = info->LayoutTable[BlockID][BlockOffset];
    328 	}
    329 	/* remap to distributed spare space if indicated */
    330 	if (remap) {
    331 		rf_remap_to_spare_space(layoutPtr, info, *row, FullTableID, TableID, BlockID, (base_suid) ? 1 : 0, SpareRegion, col, &outSU);
    332 	} else {
    333 
    334 		outSU = base_suid;
    335 		outSU += FullTableID * fulltable_depth;	/* offs to strt of FT */
    336 		outSU += SpareSpace;	/* skip rsvd spare space */
    337 		outSU += TableID * info->TableDepthInPUs * layoutPtr->SUsPerPU;	/* offs to strt of tble */
    338 		outSU += info->OffsetTable[BlockID][BlockOffset] * layoutPtr->SUsPerPU;	/* offs to the PU */
    339 	}
    340 	outSU += TableOffset / (info->BlocksPerTable * info->PUsPerBlock);	/* offs to the SU within
    341 										 * a PU */
    342 
    343 	/* convert SUs to sectors, and, if not aligned to SU boundary, add in
    344 	 * offset to sector */
    345 	*diskSector = outSU * layoutPtr->sectorsPerStripeUnit + (raidSector % layoutPtr->sectorsPerStripeUnit);
    346 }
    347 
    348 
    349 void
    350 rf_MapParityDeclusteredPQ(
    351     RF_Raid_t * raidPtr,
    352     RF_RaidAddr_t raidSector,
    353     RF_RowCol_t * row,
    354     RF_RowCol_t * col,
    355     RF_SectorNum_t * diskSector,
    356     int remap)
    357 {
    358 	RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);
    359 	RF_DeclusteredConfigInfo_t *info = (RF_DeclusteredConfigInfo_t *) layoutPtr->layoutSpecificInfo;
    360 	RF_StripeNum_t SUID = raidSector / layoutPtr->sectorsPerStripeUnit;
    361 	RF_StripeNum_t FullTableID, FullTableOffset, TableID, TableOffset;
    362 	RF_StripeNum_t BlockID, BlockOffset, RepIndex;
    363 	RF_StripeCount_t sus_per_fulltable = info->SUsPerFullTable;
    364 	RF_StripeCount_t fulltable_depth = info->FullTableDepthInPUs * layoutPtr->SUsPerPU;
    365 	RF_StripeNum_t base_suid = 0, outSU, SpareRegion, SpareSpace = 0;
    366 
    367 	rf_decluster_adjust_params(layoutPtr, &SUID, &sus_per_fulltable, &fulltable_depth, &base_suid);
    368 
    369 	/* compute row & (possibly) spare space exactly as before */
    370 	FullTableID = SUID / sus_per_fulltable;
    371 	*row = FullTableID % raidPtr->numRow;
    372 	FullTableID /= raidPtr->numRow;	/* convert to fulltable ID on this
    373 					 * disk */
    374 	if ((raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE)) {
    375 		SpareRegion = FullTableID / info->FullTablesPerSpareRegion;
    376 		SpareSpace = SpareRegion * info->SpareSpaceDepthPerRegionInSUs;
    377 	}
    378 	/* compute BlockID and RepIndex exactly as before */
    379 	FullTableOffset = SUID % sus_per_fulltable;
    380 	TableID = FullTableOffset / info->SUsPerTable;
    381 	TableOffset = FullTableOffset - TableID * info->SUsPerTable;
    382 	BlockID = TableOffset / info->PUsPerBlock;
    383 	BlockOffset = TableOffset - BlockID * info->PUsPerBlock;
    384 	BlockID %= info->BlocksPerTable;
    385 
    386 	/* the parity block is in the position indicated by RepIndex */
    387 	RepIndex = (raidPtr->noRotate) ? info->PUsPerBlock : info->groupSize - 1 - TableID;
    388 	*col = info->LayoutTable[BlockID][RepIndex];
    389 
    390 	if (remap)
    391 		RF_PANIC();
    392 
    393 	/* compute sector as before, except use RepIndex instead of
    394 	 * BlockOffset */
    395 	outSU = base_suid;
    396 	outSU += FullTableID * fulltable_depth;
    397 	outSU += SpareSpace;	/* skip rsvd spare space */
    398 	outSU += TableID * info->TableDepthInPUs * layoutPtr->SUsPerPU;
    399 	outSU += info->OffsetTable[BlockID][RepIndex] * layoutPtr->SUsPerPU;
    400 	outSU += TableOffset / (info->BlocksPerTable * info->PUsPerBlock);
    401 
    402 	*diskSector = outSU * layoutPtr->sectorsPerStripeUnit + (raidSector % layoutPtr->sectorsPerStripeUnit);
    403 }
    404 
    405 void
    406 rf_MapQDeclusteredPQ(
    407     RF_Raid_t * raidPtr,
    408     RF_RaidAddr_t raidSector,
    409     RF_RowCol_t * row,
    410     RF_RowCol_t * col,
    411     RF_SectorNum_t * diskSector,
    412     int remap)
    413 {
    414 	RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);
    415 	RF_DeclusteredConfigInfo_t *info = (RF_DeclusteredConfigInfo_t *) layoutPtr->layoutSpecificInfo;
    416 	RF_StripeNum_t SUID = raidSector / layoutPtr->sectorsPerStripeUnit;
    417 	RF_StripeNum_t FullTableID, FullTableOffset, TableID, TableOffset;
    418 	RF_StripeNum_t BlockID, BlockOffset, RepIndex, RepIndexQ;
    419 	RF_StripeCount_t sus_per_fulltable = info->SUsPerFullTable;
    420 	RF_StripeCount_t fulltable_depth = info->FullTableDepthInPUs * layoutPtr->SUsPerPU;
    421 	RF_StripeNum_t base_suid = 0, outSU, SpareRegion, SpareSpace = 0;
    422 
    423 	rf_decluster_adjust_params(layoutPtr, &SUID, &sus_per_fulltable, &fulltable_depth, &base_suid);
    424 
    425 	/* compute row & (possibly) spare space exactly as before */
    426 	FullTableID = SUID / sus_per_fulltable;
    427 	*row = FullTableID % raidPtr->numRow;
    428 	FullTableID /= raidPtr->numRow;	/* convert to fulltable ID on this
    429 					 * disk */
    430 	if ((raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE)) {
    431 		SpareRegion = FullTableID / info->FullTablesPerSpareRegion;
    432 		SpareSpace = SpareRegion * info->SpareSpaceDepthPerRegionInSUs;
    433 	}
    434 	/* compute BlockID and RepIndex exactly as before */
    435 	FullTableOffset = SUID % sus_per_fulltable;
    436 	TableID = FullTableOffset / info->SUsPerTable;
    437 	TableOffset = FullTableOffset - TableID * info->SUsPerTable;
    438 	BlockID = TableOffset / info->PUsPerBlock;
    439 	BlockOffset = TableOffset - BlockID * info->PUsPerBlock;
    440 	BlockID %= info->BlocksPerTable;
    441 
    442 	/* the q block is in the position indicated by RepIndex */
    443 	RepIndex = (raidPtr->noRotate) ? info->PUsPerBlock : info->groupSize - 1 - TableID;
    444 	RepIndexQ = ((RepIndex == (info->groupSize - 1)) ? 0 : RepIndex + 1);
    445 	*col = info->LayoutTable[BlockID][RepIndexQ];
    446 
    447 	if (remap)
    448 		RF_PANIC();
    449 
    450 	/* compute sector as before, except use RepIndex instead of
    451 	 * BlockOffset */
    452 	outSU = base_suid;
    453 	outSU += FullTableID * fulltable_depth;
    454 	outSU += SpareSpace;	/* skip rsvd spare space */
    455 	outSU += TableID * info->TableDepthInPUs * layoutPtr->SUsPerPU;
    456 	outSU += TableOffset / (info->BlocksPerTable * info->PUsPerBlock);
    457 
    458 	outSU += info->OffsetTable[BlockID][RepIndexQ] * layoutPtr->SUsPerPU;
    459 	*diskSector = outSU * layoutPtr->sectorsPerStripeUnit + (raidSector % layoutPtr->sectorsPerStripeUnit);
    460 }
    461 /* returns an array of ints identifying the disks that comprise the stripe containing the indicated address.
    462  * the caller must _never_ attempt to modify this array.
    463  */
    464 void
    465 rf_IdentifyStripeDeclusteredPQ(
    466     RF_Raid_t * raidPtr,
    467     RF_RaidAddr_t addr,
    468     RF_RowCol_t ** diskids,
    469     RF_RowCol_t * outRow)
    470 {
    471 	RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);
    472 	RF_DeclusteredConfigInfo_t *info = (RF_DeclusteredConfigInfo_t *) layoutPtr->layoutSpecificInfo;
    473 	RF_StripeCount_t sus_per_fulltable = info->SUsPerFullTable;
    474 	RF_StripeCount_t fulltable_depth = info->FullTableDepthInPUs * layoutPtr->SUsPerPU;
    475 	RF_StripeNum_t base_suid = 0;
    476 	RF_StripeNum_t SUID = rf_RaidAddressToStripeUnitID(layoutPtr, addr);
    477 	RF_StripeNum_t stripeID, FullTableID;
    478 	int     tableOffset;
    479 
    480 	rf_decluster_adjust_params(layoutPtr, &SUID, &sus_per_fulltable, &fulltable_depth, &base_suid);
    481 	FullTableID = SUID / sus_per_fulltable;	/* fulltable ID within array
    482 						 * (across rows) */
    483 	*outRow = FullTableID % raidPtr->numRow;
    484 	stripeID = rf_StripeUnitIDToStripeID(layoutPtr, SUID);	/* find stripe offset
    485 								 * into array */
    486 	tableOffset = (stripeID % info->BlocksPerTable);	/* find offset into
    487 								 * block design table */
    488 	*diskids = info->LayoutTable[tableOffset];
    489 }
    490 #endif /* (RF_INCLUDE_PARITY_DECLUSTERING_PQ > 0) || (RF_INCLUDE_EVENODD > 0) */
    491