Create a new rf_close_component() to handle vnode operations for closing

components.  Teach rf_UnconfigureVnodes() how to use it, and tell
the copyback and reconstruction code about it too.
This commit is contained in:
oster 2000-03-07 02:59:50 +00:00
parent ddebc1cad0
commit 51ffb0924c
4 changed files with 51 additions and 59 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_copyback.c,v 1.13 2000/02/23 02:03:03 oster Exp $ */
/* $NetBSD: rf_copyback.c,v 1.14 2000/03/07 02:59:50 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -98,6 +98,8 @@ rf_CopybackReconstructedData(raidPtr)
struct vattr va;
struct proc *proc;
int ac;
done = 0;
fcol = 0;
for (frow = 0; frow < raidPtr->numRow; frow++) {
@ -126,15 +128,9 @@ rf_CopybackReconstructedData(raidPtr)
if (raidPtr->raid_cinfo[frow][fcol].ci_vp != NULL) {
printf("Closed the open device: %s\n",
raidPtr->Disks[frow][fcol].devname);
if (raidPtr->Disks[frow][fcol].auto_configured == 1) {
VOP_CLOSE(raidPtr->raid_cinfo[frow][fcol].ci_vp,
FREAD, NOCRED, 0);
vput(raidPtr->raid_cinfo[frow][fcol].ci_vp);
} else {
VOP_UNLOCK(raidPtr->raid_cinfo[frow][fcol].ci_vp, 0);
(void) vn_close(raidPtr->raid_cinfo[frow][fcol].ci_vp,
FREAD | FWRITE, proc->p_ucred, proc);
}
vp = raidPtr->raid_cinfo[frow][fcol].ci_vp;
ac = raidPtr->Disks[frow][fcol].auto_configured;
rf_close_component(raidPtr, vp, ac);
raidPtr->raid_cinfo[frow][fcol].ci_vp = NULL;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_kintf.h,v 1.11 2000/03/07 02:28:05 oster Exp $ */
/* $NetBSD: rf_kintf.h,v 1.12 2000/03/07 02:59:50 oster Exp $ */
/*
* rf_kintf.h
*
@ -51,5 +51,5 @@ int raidmarkdirty(dev_t dev, struct vnode *b_vp, int);
void raid_init_component_label __P((RF_Raid_t *, RF_ComponentLabel_t *));
void rf_print_component_label __P((RF_ComponentLabel_t *));
void rf_UnconfigureVnodes( RF_Raid_t * );
void rf_close_component( RF_Raid_t *, struct vnode *, int);
#endif /* _RF__RF_KINTF_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_netbsdkintf.c,v 1.68 2000/03/07 02:28:05 oster Exp $ */
/* $NetBSD: rf_netbsdkintf.c,v 1.69 2000/03/07 02:59:50 oster Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@ -2432,12 +2432,39 @@ rf_final_update_component_labels( raidPtr )
/* printf("Component labels updated\n"); */
}
void
rf_close_component( raidPtr, vp, auto_configured )
RF_Raid_t *raidPtr;
struct vnode *vp;
int auto_configured;
{
struct proc *p;
p = raidPtr->engine_thread;
if (vp != NULL) {
if (auto_configured == 1) {
VOP_CLOSE(vp, FREAD, NOCRED, 0);
vput(vp);
} else {
VOP_UNLOCK(vp, 0);
(void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p);
}
} else {
printf("vnode was NULL\n");
}
}
void
rf_UnconfigureVnodes( raidPtr )
RF_Raid_t *raidPtr;
{
int r,c;
struct proc *p;
struct vnode *vp;
int acd;
/* We take this opportunity to close the vnodes like we should.. */
@ -2447,46 +2474,21 @@ rf_UnconfigureVnodes( raidPtr )
for (r = 0; r < raidPtr->numRow; r++) {
for (c = 0; c < raidPtr->numCol; c++) {
printf("Closing vnode for row: %d col: %d\n", r, c);
if (raidPtr->raid_cinfo[r][c].ci_vp != NULL) {
if (raidPtr->Disks[r][c].auto_configured == 1) {
VOP_CLOSE(raidPtr->raid_cinfo[r][c].ci_vp,
FREAD, NOCRED, 0);
vput(raidPtr->raid_cinfo[r][c].ci_vp);
} else {
VOP_UNLOCK(raidPtr->raid_cinfo[r][c].ci_vp, 0);
(void) vn_close(raidPtr->raid_cinfo[r][c].ci_vp,
FREAD | FWRITE, p->p_ucred, p);
}
raidPtr->raid_cinfo[r][c].ci_vp = NULL;
raidPtr->Disks[r][c].auto_configured = 0;
} else {
printf("vnode was NULL\n");
}
vp = raidPtr->raid_cinfo[r][c].ci_vp;
acd = raidPtr->Disks[r][c].auto_configured;
rf_close_component(raidPtr, vp, acd);
raidPtr->raid_cinfo[r][c].ci_vp = NULL;
raidPtr->Disks[r][c].auto_configured = 0;
}
}
for (r = 0; r < raidPtr->numSpare; r++) {
printf("Closing vnode for spare: %d\n", r);
if (raidPtr->raid_cinfo[0][raidPtr->numCol + r].ci_vp) {
if (raidPtr->Disks[0][raidPtr->numCol + r].auto_configured == 1) {
VOP_CLOSE(raidPtr->raid_cinfo[0][raidPtr->numCol +r].ci_vp,
FREAD, NOCRED, 0);
vput(raidPtr->raid_cinfo[0][raidPtr->numCol +r].ci_vp);
} else {
VOP_UNLOCK(raidPtr->raid_cinfo[0][raidPtr->numCol + r].ci_vp, 0);
(void) vn_close(raidPtr->raid_cinfo[0][raidPtr->numCol + r].ci_vp,
FREAD | FWRITE, p->p_ucred, p);
}
raidPtr->raid_cinfo[0][raidPtr->numCol + r].ci_vp = NULL;
raidPtr->Disks[0][raidPtr->numCol + r].auto_configured = 0;
} else {
printf("vnode was NULL\n");
}
vp = raidPtr->raid_cinfo[0][raidPtr->numCol + r].ci_vp;
acd = raidPtr->Disks[0][raidPtr->numCol + r].auto_configured;
rf_close_component(raidPtr, vp, acd);
raidPtr->raid_cinfo[0][raidPtr->numCol + r].ci_vp = NULL;
raidPtr->Disks[0][raidPtr->numCol + r].auto_configured = 0;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_reconstruct.c,v 1.20 2000/02/25 17:14:18 oster Exp $ */
/* $NetBSD: rf_reconstruct.c,v 1.21 2000/03/07 02:59:50 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -400,6 +400,7 @@ rf_ReconstructInPlace(raidPtr, row, col)
struct vattr va;
struct proc *proc;
int retcode;
int ac;
lp = raidPtr->Layout.map;
if (lp->SubmitReconBuffer) {
@ -477,16 +478,9 @@ rf_ReconstructInPlace(raidPtr, row, col)
if (raidPtr->raid_cinfo[row][col].ci_vp != NULL) {
printf("Closed the open device: %s\n",
raidPtr->Disks[row][col].devname);
if (raidPtr->Disks[row][col].auto_configured == 1) {
VOP_CLOSE(raidPtr->raid_cinfo[row][col].ci_vp,
FREAD, NOCRED, 0);
vput(raidPtr->raid_cinfo[row][col].ci_vp);
} else {
VOP_UNLOCK(raidPtr->raid_cinfo[row][col].ci_vp, 0);
(void) vn_close(raidPtr->raid_cinfo[row][col].ci_vp,
FREAD | FWRITE, proc->p_ucred, proc);
}
vp = raidPtr->raid_cinfo[row][col].ci_vp;
ac = raidPtr->Disks[row][col].auto_configured;
rf_close_component(raidPtr, vp, ac);
raidPtr->raid_cinfo[row][col].ci_vp = NULL;
}
/* note that this disk was *not* auto_configured (any longer)*/