summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2013-01-16 06:29:15 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2013-01-16 06:29:15 +0000
commit86011245cc4f8fc88420a96d7045e510339a4f6b (patch)
tree9ed38cf56fb8975a460cdd08696e4460f4fbfb03 /sys/dev
parentb7b5f47d3aa4b1e6b10c98ec0ab96cdcdee3b617 (diff)
Factor out code used to release ccbs from a workunit.
ok krw@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/softraid.c27
-rw-r--r--sys/dev/softraid_raid1.c11
-rw-r--r--sys/dev/softraid_raid6.c9
-rw-r--r--sys/dev/softraid_raidp.c9
-rw-r--r--sys/dev/softraidvar.h5
5 files changed, 27 insertions, 34 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 886af9ea9ef..a6ce2e3725c 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.281 2013/01/15 09:51:22 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.282 2013/01/16 06:29:14 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -2076,7 +2076,7 @@ sr_wu_alloc(struct sr_discipline *sd)
TAILQ_INIT(&sd->sd_wu_defq);
for (i = 0; i < no_wu; i++) {
wu = &sd->sd_wu[i];
- wu->swu_dis = sd;
+ TAILQ_INIT(&wu->swu_ccb);
sr_wu_put(sd, wu);
}
@@ -2131,6 +2131,7 @@ sr_wu_put(void *xsd, void *xwu)
DNPRINTF(SR_D_WU, "%s: sr_wu_put: %p\n", DEVNAME(sd->sd_sc), wu);
+ sr_wu_release_ccbs(wu);
sr_wu_init(sd, wu);
mtx_enter(&sd->sd_wu_mtx);
@@ -2142,16 +2143,11 @@ sr_wu_put(void *xsd, void *xwu)
void
sr_wu_init(struct sr_discipline *sd, struct sr_workunit *wu)
{
- struct sr_ccb *ccb;
int s;
s = splbio();
if (wu->swu_cb_active == 1)
panic("%s: sr_wu_init got active wu", DEVNAME(sd->sd_sc));
- while ((ccb = TAILQ_FIRST(&wu->swu_ccb)) != NULL) {
- TAILQ_REMOVE(&wu->swu_ccb, ccb, ccb_link);
- sr_ccb_put(ccb);
- }
splx(s);
bzero(wu, sizeof(*wu));
@@ -2160,14 +2156,14 @@ sr_wu_init(struct sr_discipline *sd, struct sr_workunit *wu)
}
void
-sr_wu_ccb_enqueue(struct sr_workunit *wu, struct sr_ccb *ccb)
+sr_wu_enqueue_ccb(struct sr_workunit *wu, struct sr_ccb *ccb)
{
struct sr_discipline *sd = wu->swu_dis;
int s;
s = splbio();
if (wu->swu_cb_active == 1)
- panic("%s: sr_wu_ccb_enqueue got active wu",
+ panic("%s: sr_wu_enqueue_ccb got active wu",
DEVNAME(sd->sd_sc));
ccb->ccb_wu = wu;
wu->swu_io_count++;
@@ -2176,6 +2172,18 @@ sr_wu_ccb_enqueue(struct sr_workunit *wu, struct sr_ccb *ccb)
}
void
+sr_wu_release_ccbs(struct sr_workunit *wu)
+{
+ struct sr_ccb *ccb;
+
+ /* Return all ccbs that are associated with this workunit. */
+ while ((ccb = TAILQ_FIRST(&wu->swu_ccb)) != NULL) {
+ TAILQ_REMOVE(&wu->swu_ccb, ccb, ccb_link);
+ sr_ccb_put(ccb);
+ }
+}
+
+void
sr_scsi_done(struct sr_discipline *sd, struct scsi_xfer *xs)
{
DNPRINTF(SR_D_DIS, "%s: sr_scsi_done: xs %p\n", DEVNAME(sd->sd_sc), xs);
@@ -2207,6 +2215,7 @@ sr_scsi_cmd(struct scsi_xfer *xs)
}
/* scsi layer *can* re-send wu without calling sr_wu_put(). */
+ sr_wu_release_ccbs(wu);
sr_wu_init(sd, wu);
wu->swu_state = SR_WU_INPROGRESS;
wu->swu_xs = xs;
diff --git a/sys/dev/softraid_raid1.c b/sys/dev/softraid_raid1.c
index 73e82017e92..832bf76341a 100644
--- a/sys/dev/softraid_raid1.c
+++ b/sys/dev/softraid_raid1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid1.c,v 1.34 2013/01/15 09:28:29 jsing Exp $ */
+/* $OpenBSD: softraid_raid1.c,v 1.35 2013/01/16 06:29:14 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
*
@@ -640,19 +640,12 @@ sr_raid1_recreate_wu(struct sr_workunit *wu)
{
struct sr_discipline *sd = wu->swu_dis;
struct sr_workunit *wup = wu;
- struct sr_ccb *ccb;
do {
DNPRINTF(SR_D_INTR, "%s: sr_raid1_recreate_wu: %p\n", wup);
/* toss all ccbs */
- if (wu->swu_cb_active == 1)
- panic("%s: sr_raid1_recreate_wu", DEVNAME(sd->sd_sc));
- while ((ccb = TAILQ_FIRST(&wup->swu_ccb)) != NULL) {
- TAILQ_REMOVE(&wup->swu_ccb, ccb, ccb_link);
- sr_ccb_put(ccb);
- }
- TAILQ_INIT(&wup->swu_ccb);
+ sr_wu_release_ccbs(wup);
/* recreate ccbs */
wup->swu_state = SR_WU_REQUEUE;
diff --git a/sys/dev/softraid_raid6.c b/sys/dev/softraid_raid6.c
index 6a4261cdc83..a7f34cda73e 100644
--- a/sys/dev/softraid_raid6.c
+++ b/sys/dev/softraid_raid6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid6.c,v 1.29 2013/01/15 09:28:29 jsing Exp $ */
+/* $OpenBSD: softraid_raid6.c,v 1.30 2013/01/16 06:29:14 jsing Exp $ */
/*
* Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org>
@@ -870,17 +870,12 @@ sr_raid6_recreate_wu(struct sr_workunit *wu)
{
struct sr_discipline *sd = wu->swu_dis;
struct sr_workunit *wup = wu;
- struct sr_ccb *ccb;
do {
DNPRINTF(SR_D_INTR, "%s: sr_raid6_recreate_wu: %p\n", wup);
/* toss all ccbs */
- while ((ccb = TAILQ_FIRST(&wup->swu_ccb)) != NULL) {
- TAILQ_REMOVE(&wup->swu_ccb, ccb, ccb_link);
- sr_ccb_put(ccb);
- }
- TAILQ_INIT(&wup->swu_ccb);
+ sr_wu_release_ccbs(wup);
/* recreate ccbs */
wup->swu_state = SR_WU_REQUEUE;
diff --git a/sys/dev/softraid_raidp.c b/sys/dev/softraid_raidp.c
index ed1bd07394e..66cbb7e1fc5 100644
--- a/sys/dev/softraid_raidp.c
+++ b/sys/dev/softraid_raidp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raidp.c,v 1.26 2013/01/15 09:28:29 jsing Exp $ */
+/* $OpenBSD: softraid_raidp.c,v 1.27 2013/01/16 06:29:14 jsing Exp $ */
/*
* Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org>
@@ -686,17 +686,12 @@ sr_raidp_recreate_wu(struct sr_workunit *wu)
{
struct sr_discipline *sd = wu->swu_dis;
struct sr_workunit *wup = wu;
- struct sr_ccb *ccb;
do {
DNPRINTF(SR_D_INTR, "%s: sr_raidp_recreate_wu: %p\n", wup);
/* toss all ccbs */
- while ((ccb = TAILQ_FIRST(&wup->swu_ccb)) != NULL) {
- TAILQ_REMOVE(&wup->swu_ccb, ccb, ccb_link);
- sr_ccb_put(ccb);
- }
- TAILQ_INIT(&wup->swu_ccb);
+ sr_wu_release_ccbs(wup);
/* recreate ccbs */
wup->swu_state = SR_WU_REQUEUE;
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index 84fa8bba928..2b12c240046 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.122 2013/01/15 09:51:22 jsing Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.123 2013/01/16 06:29:14 jsing Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -654,8 +654,9 @@ void *sr_wu_get(void *);
void sr_wu_put(void *, void *);
void sr_wu_init(struct sr_discipline *,
struct sr_workunit *);
-void sr_wu_ccb_enqueue(struct sr_workunit *,
+void sr_wu_enqueue_ccb(struct sr_workunit *,
struct sr_ccb *);
+void sr_wu_release_ccbs(struct sr_workunit *);
/* misc functions */
void sr_info(struct sr_softc *, const char *, ...);