summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2013-03-29 11:46:46 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2013-03-29 11:46:46 +0000
commit47402ef2aa149da75c4b1dba5a74866f852074f1 (patch)
treef23724f075a2b791b99b797373affa842c135295
parent8673b11d01f804ff5d1c8397d6a911754b8b9c55 (diff)
sd_wu_pending is only decremented when scsi_done() or scsi_io_put() are
called. As a result, factor out the the sd_sync check/wakeup code and move it to after the scsi_done() call in sr_scsi_done(). Perform the same sd_sync check/wakeup after scsi_io_put() calls (including the addition of some that were previously missed). ok krw@
-rw-r--r--sys/dev/softraid.c22
-rw-r--r--sys/dev/softraid_crypto.c5
-rw-r--r--sys/dev/softraid_raid1.c5
-rw-r--r--sys/dev/softraid_raid6.c14
-rw-r--r--sys/dev/softraid_raidp.c14
5 files changed, 27 insertions, 33 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 74d7f37a6fb..380d8032cb2 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.291 2013/03/25 16:01:48 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.292 2013/03/29 11:46:43 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -2278,16 +2278,11 @@ sr_wu_done_callback(void *arg1, void *arg2)
* If a discipline provides its own sd_scsi_done function, then it
* is responsible for calling sr_scsi_done() once I/O is complete.
*/
- if (sd->sd_scsi_done) {
+ if (sd->sd_scsi_done)
sd->sd_scsi_done(wu);
- } else {
+ else
sr_scsi_done(sd, xs);
- /* XXX - move to sr_scsi_done? */
- if (sd->sd_sync && sd->sd_wu_pending == 0)
- wakeup(sd);
- }
-
splx(s);
}
@@ -2300,6 +2295,9 @@ sr_scsi_done(struct sr_discipline *sd, struct scsi_xfer *xs)
xs->resid = 0;
scsi_done(xs);
+
+ if (sd->sd_sync && sd->sd_wu_pending == 0)
+ wakeup(sd);
}
void
@@ -4068,15 +4066,14 @@ sr_raid_sync(struct sr_workunit *wu)
s = splbio();
sd->sd_sync = 1;
-
- while (sd->sd_wu_pending > ios)
+ while (sd->sd_wu_pending > ios) {
if (tsleep(sd, PRIBIO, "sr_sync", 15 * hz) == EWOULDBLOCK) {
DNPRINTF(SR_D_DIS, "%s: sr_raid_sync timeout\n",
DEVNAME(sd->sd_sc));
rv = 1;
break;
}
-
+ }
sd->sd_sync = 0;
splx(s);
@@ -4611,6 +4608,9 @@ queued:
scsi_io_put(&sd->sd_iopool, wu_r);
scsi_io_put(&sd->sd_iopool, wu_w);
+ if (sd->sd_sync && sd->sd_wu_pending == 0)
+ wakeup(sd);
+
sd->sd_meta->ssd_rebuild = lba;
/* save metadata every percent */
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index bae844b6857..2e8b27436db 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.87 2013/03/02 12:50:01 jsing Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.88 2013/03/29 11:46:45 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
@@ -1334,9 +1334,6 @@ sr_crypto_finish_io(struct sr_workunit *wu)
}
sr_scsi_done(sd, xs);
-
- if (sd->sd_sync && sd->sd_wu_pending == 0)
- wakeup(sd);
}
int
diff --git a/sys/dev/softraid_raid1.c b/sys/dev/softraid_raid1.c
index 5a281112f52..d94f6c59436 100644
--- a/sys/dev/softraid_raid1.c
+++ b/sys/dev/softraid_raid1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid1.c,v 1.43 2013/03/27 14:30:11 jsing Exp $ */
+/* $OpenBSD: softraid_raid1.c,v 1.44 2013/03/29 11:46:45 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
*
@@ -541,9 +541,6 @@ sr_raid1_intr(struct buf *bp)
sr_scsi_done(sd, xs);
}
- if (sd->sd_sync && sd->sd_wu_pending == 0)
- wakeup(sd);
-
done:
splx(s);
}
diff --git a/sys/dev/softraid_raid6.c b/sys/dev/softraid_raid6.c
index 7a29fd0772f..1eeff435468 100644
--- a/sys/dev/softraid_raid6.c
+++ b/sys/dev/softraid_raid6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid6.c,v 1.36 2013/03/27 14:30:11 jsing Exp $ */
+/* $OpenBSD: softraid_raid6.c,v 1.37 2013/03/29 11:46:45 jsing Exp $ */
/*
* Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org>
@@ -826,15 +826,15 @@ sr_raid6_intr(struct buf *bp)
wakeup(wu);
}
} else {
- if (xs != NULL)
- sr_scsi_done(sd, xs);
- else
+ if (xs == NULL) {
scsi_io_put(&sd->sd_iopool, wu);
+ if (sd->sd_sync && sd->sd_wu_pending == 0)
+ wakeup(sd);
+ } else {
+ sr_scsi_done(sd, xs);
+ }
}
- if (sd->sd_sync && sd->sd_wu_pending == 0)
- wakeup(sd);
-
done:
splx(s);
}
diff --git a/sys/dev/softraid_raidp.c b/sys/dev/softraid_raidp.c
index 2b69dec5515..e01bc7b8776 100644
--- a/sys/dev/softraid_raidp.c
+++ b/sys/dev/softraid_raidp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raidp.c,v 1.33 2013/03/27 14:30:11 jsing Exp $ */
+/* $OpenBSD: softraid_raidp.c,v 1.34 2013/03/29 11:46:45 jsing Exp $ */
/*
* Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org>
@@ -642,15 +642,15 @@ sr_raidp_intr(struct buf *bp)
wakeup(wu);
}
} else {
- if (xs != NULL)
- sr_scsi_done(sd, xs);
- else
+ if (xs == NULL) {
scsi_io_put(&sd->sd_iopool, wu);
+ if (sd->sd_sync && sd->sd_wu_pending == 0)
+ wakeup(sd);
+ } else {
+ sr_scsi_done(sd, xs);
+ }
}
- if (sd->sd_sync && sd->sd_wu_pending == 0)
- wakeup(sd);
-
done:
splx(s);
}