diff options
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_netbsdkintf.c | 102 |
1 files changed, 83 insertions, 19 deletions
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 7043a40ebd8..b7c1a64b52a 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.62 2000/02/26 17:35:43 oster Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.63 2000/02/27 01:50:22 oster Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -279,6 +279,7 @@ void rf_RewriteParityThread __P((RF_Raid_t *raidPtr)); void rf_CopybackThread __P((RF_Raid_t *raidPtr)); void rf_ReconstructInPlaceThread __P((struct rf_recon_req *)); void rf_buildroothack __P((void *)); +void rf_final_update_component_labels __P((RF_Raid_t *)); RF_AutoConfig_t *rf_find_raid_components __P((void)); void print_component_label __P((RF_ComponentLabel_t *)); @@ -638,7 +639,7 @@ raidclose(dev, flags, fmt, p) #if 1 printf("Last one on raid%d. Updating status.\n",unit); #endif - rf_update_component_labels( raidPtrs[unit] ); + rf_final_update_component_labels( raidPtrs[unit] ); } raidunlock(rs); @@ -2278,33 +2279,95 @@ rf_update_component_labels( raidPtr ) clabel.status = rf_ds_optimal; /* bump the counter */ clabel.mod_counter = raidPtr->mod_counter; -#if 0 - /* note where this set was configured last */ - clabel.last_unit = raidPtr->raidid; -#endif raidwrite_component_label( raidPtr->Disks[r][c].dev, raidPtr->raid_cinfo[r][c].ci_vp, &clabel); - if (raidPtr->parity_good == RF_RAID_CLEAN) { - raidmarkclean( - raidPtr->Disks[r][c].dev, - raidPtr->raid_cinfo[r][c].ci_vp, - raidPtr->mod_counter); - } } /* else we don't touch it.. */ -#if 0 - else if (raidPtr->Disks[r][c].status != - rf_ds_failed) { + } + } + + for( c = 0; c < raidPtr->numSpare ; c++) { + sparecol = raidPtr->numCol + c; + if (raidPtr->Disks[0][sparecol].status == rf_ds_used_spare) { + /* + + we claim this disk is "optimal" if it's + rf_ds_used_spare, as that means it should be + directly substitutable for the disk it replaced. + We note that too... + + */ + + for(i=0;i<raidPtr->numRow;i++) { + for(j=0;j<raidPtr->numCol;j++) { + if ((raidPtr->Disks[i][j].spareRow == + 0) && + (raidPtr->Disks[i][j].spareCol == + sparecol)) { + srow = i; + scol = j; + break; + } + } + } + + /* XXX shouldn't *really* need this... */ + raidread_component_label( + raidPtr->Disks[0][sparecol].dev, + raidPtr->raid_cinfo[0][sparecol].ci_vp, + &clabel); + /* make sure status is noted */ + + raid_init_component_label(raidPtr, &clabel); + + clabel.mod_counter = raidPtr->mod_counter; + clabel.row = srow; + clabel.column = scol; + clabel.status = rf_ds_optimal; + + raidwrite_component_label( + raidPtr->Disks[0][sparecol].dev, + raidPtr->raid_cinfo[0][sparecol].ci_vp, + &clabel); + } + } + /* printf("Component labels updated\n"); */ +} + + +void +rf_final_update_component_labels( raidPtr ) + RF_Raid_t *raidPtr; +{ + RF_ComponentLabel_t clabel; + int sparecol; + int r,c; + int i,j; + int srow, scol; + + srow = -1; + scol = -1; + + /* XXX should do extra checks to make sure things really are clean, + rather than blindly setting the clean bit... */ + + raidPtr->mod_counter++; + + for (r = 0; r < raidPtr->numRow; r++) { + for (c = 0; c < raidPtr->numCol; c++) { + if (raidPtr->Disks[r][c].status == rf_ds_optimal) { raidread_component_label( raidPtr->Disks[r][c].dev, raidPtr->raid_cinfo[r][c].ci_vp, &clabel); /* make sure status is noted */ - clabel.status = - raidPtr->Disks[r][c].status; + clabel.status = rf_ds_optimal; + /* bump the counter */ + clabel.mod_counter = raidPtr->mod_counter; + raidwrite_component_label( raidPtr->Disks[r][c].dev, raidPtr->raid_cinfo[r][c].ci_vp, @@ -2315,8 +2378,8 @@ rf_update_component_labels( raidPtr ) raidPtr->raid_cinfo[r][c].ci_vp, raidPtr->mod_counter); } - } -#endif + } + /* else we don't touch it.. */ } } @@ -2373,6 +2436,7 @@ rf_update_component_labels( raidPtr ) /* printf("Component labels updated\n"); */ } + void rf_ReconThread(req) struct rf_recon_req *req; |
