From bd131be7d168df5bfcb982ddd4cbfdd2b8ded991 Mon Sep 17 00:00:00 2001 From: Greg Lehey Date: Thu, 6 Apr 2000 03:03:31 +0000 Subject: [PATCH] complete_rqe: Remove a race condition in RAID-4 and RAID-5 where a request could be deallocated before the top half had finished issuing it. The problem seems only to happen with IDE drives and vn devices, but theoretically it could happen with any drive. This is the most important part of a possible series of fixes designed to remove race conditions without locking out interrupts for longer than absolutely necessary. Reported-by: sos Fix-supplied-by: dillon --- sys/dev/vinum/vinuminterrupt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/vinum/vinuminterrupt.c b/sys/dev/vinum/vinuminterrupt.c index dee1bbe5b79..1a1725c9d36 100644 --- a/sys/dev/vinum/vinuminterrupt.c +++ b/sys/dev/vinum/vinuminterrupt.c @@ -124,7 +124,6 @@ complete_rqe(struct buf *bp) if (PLEX[rqe->rqg->plexno].volno >= 0) VOL[PLEX[rqe->rqg->plexno].volno].bytes_written += bp->b_bcount; } - rqg->active--; /* one less request active */ if (rqg->flags & XFR_RECOVERY_READ) { /* recovery read, */ int *sdata; /* source */ int *data; /* and group data */ @@ -155,8 +154,9 @@ complete_rqe(struct buf *bp) bcopy(src, dst, length); /* move it */ } } else if ((rqg->flags & (XFR_NORMAL_WRITE | XFR_DEGRADED_WRITE)) /* RAID 4/5 group write operation */ - &&(rqg->active == 0)) /* and we've finished phase 1 */ + &&(rqg->active == 1)) /* and this is the last rq of phase 1 */ complete_raid5_write(rqe); + rqg->active--; /* one less request active */ if (rqg->active == 0) { /* request group finished, */ rq->active--; /* one less */ if (rqg->lock) { /* got a lock? */