Only mark the components as CLEAN if it's the last thing we're doing.

Marking them CLEAN earlier is (currently) asking for trouble.
(XXX This could have been done more elegantly.)
This commit is contained in:
oster 2000-02-27 01:50:22 +00:00
parent 1d76239646
commit 82419f5ae9
1 changed files with 92 additions and 28 deletions

View File

@ -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,10 +2279,94 @@ 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);
}
/* else we don't touch it.. */
}
}
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 = rf_ds_optimal;
/* bump the counter */
clabel.mod_counter = raidPtr->mod_counter;
raidwrite_component_label(
raidPtr->Disks[r][c].dev,
@ -2295,28 +2380,6 @@ rf_update_component_labels( raidPtr )
}
}
/* else we don't touch it.. */
#if 0
else if (raidPtr->Disks[r][c].status !=
rf_ds_failed) {
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;
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);
}
}
#endif
}
}
@ -2373,6 +2436,7 @@ rf_update_component_labels( raidPtr )
/* printf("Component labels updated\n"); */
}
void
rf_ReconThread(req)
struct rf_recon_req *req;