diff options
-rw-r--r-- | sys/dev/softraid.c | 31 | ||||
-rw-r--r-- | sys/dev/softraid_raid6.c | 10 | ||||
-rw-r--r-- | sys/dev/softraid_raidp.c | 16 | ||||
-rw-r--r-- | sys/dev/softraidvar.h | 5 |
4 files changed, 35 insertions, 27 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 1b30c86cdb7..126e3727e78 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.294 2013/03/30 02:02:13 jsing Exp $ */ +/* $OpenBSD: softraid.c,v 1.295 2013/03/30 14:41:36 jsing Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -2286,6 +2286,21 @@ sr_wu_done_callback(void *arg1, void *arg2) splx(s); } +struct sr_workunit * +sr_scsi_wu_get(struct sr_discipline *sd, int flags) +{ + return scsi_io_get(&sd->sd_iopool, flags); +} + +void +sr_scsi_wu_put(struct sr_discipline *sd, struct sr_workunit *wu) +{ + scsi_io_put(&sd->sd_iopool, wu); + + if (sd->sd_sync && sd->sd_wu_pending == 0) + wakeup(sd); +} + void sr_scsi_done(struct sr_discipline *sd, struct scsi_xfer *xs) { @@ -4553,10 +4568,8 @@ sr_rebuild_thread(void *arg) } /* get some wu */ - if ((wu_r = scsi_io_get(&sd->sd_iopool, 0)) == NULL) - panic("%s: rebuild exhausted wu_r", DEVNAME(sc)); - if ((wu_w = scsi_io_get(&sd->sd_iopool, 0)) == NULL) - panic("%s: rebuild exhausted wu_w", DEVNAME(sc)); + wu_r = sr_scsi_wu_get(sd, 0); + wu_w = sr_scsi_wu_get(sd, 0); /* setup read io */ bzero(&xs_r, sizeof xs_r); @@ -4625,14 +4638,12 @@ queued: if (slept == 0) tsleep(sc, PWAIT, "sr_yield", 1); - 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); + sr_scsi_wu_put(sd, wu_r); + sr_scsi_wu_put(sd, wu_w); sd->sd_meta->ssd_rebuild = lba; + /* XXX - this should be based on size, not percentage. */ /* save metadata every percent */ psz = sd->sd_meta->ssdi.ssd_size; rb = sd->sd_meta->ssd_rebuild; diff --git a/sys/dev/softraid_raid6.c b/sys/dev/softraid_raid6.c index 48c9576b85a..a94ceab5df9 100644 --- a/sys/dev/softraid_raid6.c +++ b/sys/dev/softraid_raid6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid6.c,v 1.40 2013/03/29 15:26:45 jsing Exp $ */ +/* $OpenBSD: softraid_raid6.c,v 1.41 2013/03/30 14:41:37 jsing Exp $ */ /* * Copyright (c) 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org> @@ -430,7 +430,7 @@ sr_raid6_rw(struct sr_workunit *wu) if (xs->flags & SCSI_DATA_OUT) /* create write workunit */ - if ((wu_r = scsi_io_get(&sd->sd_iopool, SCSI_NOSLEEP)) == NULL){ + if ((wu_r = sr_scsi_wu_get(sd, SCSI_NOSLEEP)) == NULL){ printf("%s: can't get wu_r", DEVNAME(sd->sd_sc)); goto bad; } @@ -689,7 +689,7 @@ queued: bad: /* wu is unwound by sr_wu_put */ if (wu_r) - scsi_io_put(&sd->sd_iopool, wu_r); + sr_scsi_wu_put(sd, wu_r); return (1); } @@ -804,9 +804,7 @@ sr_raid6_intr(struct buf *bp) wakeup(wu); if (!(wu->swu_flags & SR_WUF_REBUILD)) { if (xs == NULL) { - scsi_io_put(&sd->sd_iopool, wu); - if (sd->sd_sync && sd->sd_wu_pending == 0) - wakeup(sd); + sr_scsi_wu_put(sd, wu); } else { sr_scsi_done(sd, xs); } diff --git a/sys/dev/softraid_raidp.c b/sys/dev/softraid_raidp.c index e996b5a6d5f..28e9a10e6ea 100644 --- a/sys/dev/softraid_raidp.c +++ b/sys/dev/softraid_raidp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raidp.c,v 1.37 2013/03/29 15:26:45 jsing Exp $ */ +/* $OpenBSD: softraid_raidp.c,v 1.38 2013/03/30 14:41:37 jsing Exp $ */ /* * Copyright (c) 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org> @@ -382,7 +382,7 @@ sr_raidp_rw(struct sr_workunit *wu) if (xs->flags & SCSI_DATA_OUT) /* create write workunit */ - if ((wu_r = scsi_io_get(&sd->sd_iopool, SCSI_NOSLEEP)) == NULL){ + if ((wu_r = sr_scsi_wu_get(sd, SCSI_NOSLEEP)) == NULL){ printf("%s: can't get wu_r", DEVNAME(sd->sd_sc)); goto bad; } @@ -534,7 +534,7 @@ queued: bad: /* wu is unwound by sr_wu_put */ if (wu_r) - scsi_io_put(&sd->sd_iopool, wu_r); + sr_scsi_wu_put(sd, wu_r); return (1); } @@ -621,9 +621,7 @@ sr_raidp_intr(struct buf *bp) wakeup(wu); if (!(wu->swu_flags & SR_WUF_REBUILD)) { if (xs == NULL) { - scsi_io_put(&sd->sd_iopool, wu); - if (sd->sd_sync && sd->sd_wu_pending == 0) - wakeup(sd); + sr_scsi_wu_put(sd, wu); } else { sr_scsi_done(sd, xs); } @@ -742,10 +740,8 @@ sr_raidp_scrub(struct sr_discipline *sd) int s, slept; void *xorbuf; - if ((wu_w = scsi_io_get(&sd->sd_iopool, 0)) == NULL) - goto done; - if ((wu_r = scsi_io_get(&sd->sd_iopool, 0)) == NULL) - goto done; + wu_w = sr_scsi_wu_get(sd, 0); + wu_r = sr_scsi_wu_get(sd, 0); no_chunk = sd->sd_meta->ssdi.ssd_chunk_no - 1; strip_size = sd->sd_meta->ssdi.ssd_strip_size; diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h index dbbcd78ec2b..344f8ac79b3 100644 --- a/sys/dev/softraidvar.h +++ b/sys/dev/softraidvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: softraidvar.h,v 1.131 2013/03/30 02:02:14 jsing Exp $ */ +/* $OpenBSD: softraidvar.h,v 1.132 2013/03/30 14:41:36 jsing Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -688,6 +688,9 @@ int sr_validate_io(struct sr_workunit *, daddr64_t *, int sr_check_io_collision(struct sr_workunit *); void sr_scsi_done(struct sr_discipline *, struct scsi_xfer *); +struct sr_workunit *sr_scsi_wu_get(struct sr_discipline *, int); +void sr_scsi_wu_put(struct sr_discipline *, + struct sr_workunit *); int sr_chunk_in_use(struct sr_softc *, dev_t); /* discipline functions */ |