diff options
author | Jordan Hargrave <jordan@cvs.openbsd.org> | 2011-04-08 00:12:55 +0000 |
---|---|---|
committer | Jordan Hargrave <jordan@cvs.openbsd.org> | 2011-04-08 00:12:55 +0000 |
commit | c6e100087526923d0540194ca1ec13397719273f (patch) | |
tree | edd738f1bd582a376e0b717b94e41c23ae873ec8 /sys | |
parent | df496a5ea3ec13084aaf0315b73a160b02b0dd47 (diff) |
Fix raidp/raid6 to work with new iopool code, needed to swap wu's
Update to use dma_malloc for I/O blocks
ok marco@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/softraid_raid6.c | 55 | ||||
-rw-r--r-- | sys/dev/softraid_raidp.c | 49 |
2 files changed, 47 insertions, 57 deletions
diff --git a/sys/dev/softraid_raid6.c b/sys/dev/softraid_raid6.c index ba963b50c18..3f3bdc33567 100644 --- a/sys/dev/softraid_raid6.c +++ b/sys/dev/softraid_raid6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid6.c,v 1.21 2011/04/06 02:45:55 marco Exp $ */ +/* $OpenBSD: softraid_raid6.c,v 1.22 2011/04/08 00:12:54 jordan Exp $ */ /* * Copyright (c) 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org> @@ -71,7 +71,7 @@ void sr_raid6_scrub(struct sr_discipline *); int sr_failio(struct sr_workunit *); void *sr_get_block(struct sr_discipline *, int); -void sr_put_block(struct sr_discipline *, void *); +void sr_put_block(struct sr_discipline *, void *, int); void gf_init(void); uint8_t gf_inv(uint8_t); @@ -454,7 +454,7 @@ die: int sr_raid6_rw(struct sr_workunit *wu) { - struct sr_workunit *wu_w = NULL; + struct sr_workunit *wu_r = NULL; struct sr_discipline *sd = wu->swu_dis; struct scsi_xfer *xs = wu->swu_xs; struct sr_chunk *scp; @@ -480,8 +480,8 @@ sr_raid6_rw(struct sr_workunit *wu) rwmode = (xs->flags & SCSI_DATA_IN) ? M_RFLG : M_WFLG; if (xs->flags & SCSI_DATA_OUT) /* create write workunit */ - if ((wu_w = scsi_io_get(&sd->sd_iopool, SCSI_NOSLEEP)) == NULL){ - printf("%s: can't get wu_w", DEVNAME(sd->sd_sc)); + if ((wu_r = scsi_io_get(&sd->sd_iopool, SCSI_NOSLEEP)) == NULL){ + printf("%s: can't get wu_r", DEVNAME(sd->sd_sc)); goto bad; } @@ -666,33 +666,33 @@ sr_raid6_rw(struct sr_workunit *wu) sr_raid6_xorq(qbuf, data, length, gf_pow[chunk]); /* Read old data: P ^= Dn' ; Q ^= (gn * Dn') */ - if (sr_raid6_addio(wu, chunk, lba, length, NULL, + if (sr_raid6_addio(wu_r, chunk, lba, length, NULL, SCSI_DATA_IN, SR_CCBF_FREEBUF, pbuf, qbuf, gf_pow[chunk])) goto bad; /* Read old xor-parity: P ^= P' */ - if (sr_raid6_addio(wu, pchunk, lba, length, NULL, + if (sr_raid6_addio(wu_r, pchunk, lba, length, NULL, SCSI_DATA_IN, SR_CCBF_FREEBUF, pbuf, NULL, 0)) goto bad; /* Read old q-parity: Q ^= Q' */ - if (sr_raid6_addio(wu, qchunk, lba, length, NULL, + if (sr_raid6_addio(wu_r, qchunk, lba, length, NULL, SCSI_DATA_IN, SR_CCBF_FREEBUF, qbuf, NULL, 0)) goto bad; /* write new data */ - if (sr_raid6_addio(wu_w, chunk, lba, length, data, + if (sr_raid6_addio(wu, chunk, lba, length, data, xs->flags, 0, NULL, NULL, 0)) goto bad; /* write new xor-parity */ - if (sr_raid6_addio(wu_w, pchunk, lba, length, pbuf, + if (sr_raid6_addio(wu, pchunk, lba, length, pbuf, xs->flags, SR_CCBF_FREEBUF, NULL, NULL, 0)) goto bad; /* write new q-parity */ - if (sr_raid6_addio(wu_w, qchunk, lba, length, qbuf, + if (sr_raid6_addio(wu, qchunk, lba, length, qbuf, xs->flags, SR_CCBF_FREEBUF, NULL, NULL, 0)) goto bad; } @@ -704,21 +704,16 @@ sr_raid6_rw(struct sr_workunit *wu) } s = splbio(); - if (wu_w) { + if (wu_r) { /* collide write request with reads */ - wu_w->swu_blk_start = wu->swu_blk_start; - wu_w->swu_blk_end = wu->swu_blk_end; - - /* - * put xs block in write request (scsi_done not called till - * write completes) - */ - wu_w->swu_xs = wu->swu_xs; - wu->swu_xs = NULL; - - wu_w->swu_state = SR_WU_DEFERRED; - wu->swu_collider = wu_w; - TAILQ_INSERT_TAIL(&sd->sd_wu_defq, wu_w, swu_link); + wu_r->swu_blk_start = wu->swu_blk_start; + wu_r->swu_blk_end = wu->swu_blk_end; + + wu->swu_state = SR_WU_DEFERRED; + wu_r->swu_collider = wu; + TAILQ_INSERT_TAIL(&sd->sd_wu_defq, wu, swu_link); + + wu = wu_r; } /* rebuild io, let rebuild routine deal with it */ @@ -743,8 +738,8 @@ queued: return (0); bad: /* wu is unwound by sr_wu_put */ - if (wu_w) - scsi_io_put(&sd->sd_iopool, wu_w); + if (wu_r) + scsi_io_put(&sd->sd_iopool, wu_r); return (1); } @@ -818,7 +813,7 @@ sr_raid6_intr(struct buf *bp) /* free allocated data buffer */ if (ccb->ccb_flag & SR_CCBF_FREEBUF) { - sr_put_block(sd, ccb->ccb_buf.b_data); + sr_put_block(sd, ccb->ccb_buf.b_data, ccb->ccb_buf.b_bcount); ccb->ccb_buf.b_data = NULL; } wu->swu_ios_complete++; @@ -997,7 +992,7 @@ sr_raid6_addio(struct sr_workunit *wu, int dsk, daddr64_t blk, daddr64_t len, if (qbuf && gf_premul(gn)) return (-1); - pqbuf = malloc(sizeof(struct sr_raid6_opaque), M_DEVBUF, M_CANFAIL); + pqbuf = malloc(sizeof(struct sr_raid6_opaque), M_DEVBUF, M_ZERO | M_NOWAIT); if (pqbuf == NULL) { sr_ccb_put(ccb); return (-1); @@ -1082,7 +1077,7 @@ gf_premul(uint8_t gn) if (gf_map[gn] != NULL) return (0); - if ((gf_map[gn] = malloc(256, M_DEVBUF, M_CANFAIL)) == NULL) + if ((gf_map[gn] = malloc(256, M_DEVBUF, M_ZERO | M_NOWAIT)) == NULL) return (-1); for (i=0; i<256; i++) diff --git a/sys/dev/softraid_raidp.c b/sys/dev/softraid_raidp.c index 31732617bdd..f7fe59c7ef6 100644 --- a/sys/dev/softraid_raidp.c +++ b/sys/dev/softraid_raidp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raidp.c,v 1.21 2011/04/06 02:45:55 marco Exp $ */ +/* $OpenBSD: softraid_raidp.c,v 1.22 2011/04/08 00:12:54 jordan Exp $ */ /* * Copyright (c) 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org> @@ -65,7 +65,7 @@ void sr_dump(void *, int); void sr_raidp_scrub(struct sr_discipline *); void *sr_get_block(struct sr_discipline *, int); -void sr_put_block(struct sr_discipline *, void *); +void sr_put_block(struct sr_discipline *, void *, int); /* discipline initialisation. */ void @@ -371,7 +371,7 @@ die: int sr_raidp_rw(struct sr_workunit *wu) { - struct sr_workunit *wu_w = NULL; + struct sr_workunit *wu_r = NULL; struct sr_discipline *sd = wu->swu_dis; struct scsi_xfer *xs = wu->swu_xs; struct sr_chunk *scp; @@ -396,8 +396,8 @@ sr_raidp_rw(struct sr_workunit *wu) if (xs->flags & SCSI_DATA_OUT) /* create write workunit */ - if ((wu_w = scsi_io_get(&sd->sd_iopool, SCSI_NOSLEEP)) == NULL){ - printf("%s: can't get wu_w", DEVNAME(sd->sd_sc)); + if ((wu_r = scsi_io_get(&sd->sd_iopool, SCSI_NOSLEEP)) == NULL){ + printf("%s: can't get wu_r", DEVNAME(sd->sd_sc)); goto bad; } @@ -486,22 +486,22 @@ sr_raidp_rw(struct sr_workunit *wu) memcpy(xorbuf, data, length); /* xor old data */ - if (sr_raidp_addio(wu, chunk, lba, length, NULL, + if (sr_raidp_addio(wu_r, chunk, lba, length, NULL, SCSI_DATA_IN, SR_CCBF_FREEBUF, xorbuf)) goto bad; /* xor old parity */ - if (sr_raidp_addio(wu, parity, lba, length, NULL, + if (sr_raidp_addio(wu_r, parity, lba, length, NULL, SCSI_DATA_IN, SR_CCBF_FREEBUF, xorbuf)) goto bad; /* write new data */ - if (sr_raidp_addio(wu_w, chunk, lba, length, data, + if (sr_raidp_addio(wu, chunk, lba, length, data, xs->flags, 0, NULL)) goto bad; /* write new parity */ - if (sr_raidp_addio(wu_w, parity, lba, length, xorbuf, + if (sr_raidp_addio(wu, parity, lba, length, xorbuf, xs->flags, SR_CCBF_FREEBUF, NULL)) goto bad; } @@ -513,21 +513,16 @@ sr_raidp_rw(struct sr_workunit *wu) } s = splbio(); - if (wu_w) { + if (wu_r) { /* collide write request with reads */ - wu_w->swu_blk_start = wu->swu_blk_start; - wu_w->swu_blk_end = wu->swu_blk_end; + wu_r->swu_blk_start = wu->swu_blk_start; + wu_r->swu_blk_end = wu->swu_blk_end; - /* - * put xs block in write request (scsi_done not called till - * write completes) - */ - wu_w->swu_xs = wu->swu_xs; - wu->swu_xs = NULL; + wu->swu_state = SR_WU_DEFERRED; + wu_r->swu_collider = wu; + TAILQ_INSERT_TAIL(&sd->sd_wu_defq, wu, swu_link); - wu_w->swu_state = SR_WU_DEFERRED; - wu->swu_collider = wu_w; - TAILQ_INSERT_TAIL(&sd->sd_wu_defq, wu_w, swu_link); + wu = wu_r; } /* rebuild io, let rebuild routine deal with it */ @@ -552,8 +547,8 @@ queued: return (0); bad: /* wu is unwound by sr_wu_put */ - if (wu_w) - scsi_io_put(&sd->sd_iopool, wu_w); + if (wu_r) + scsi_io_put(&sd->sd_iopool, wu_r); return (1); } @@ -599,7 +594,7 @@ sr_raidp_intr(struct buf *bp) /* free allocated data buffer */ if (ccb->ccb_flag & SR_CCBF_FREEBUF) { - sr_put_block(sd, ccb->ccb_buf.b_data); + sr_put_block(sd, ccb->ccb_buf.b_data, ccb->ccb_buf.b_bcount); ccb->ccb_buf.b_data = NULL; } wu->swu_ios_complete++; @@ -887,12 +882,12 @@ done: void * sr_get_block(struct sr_discipline *sd, int length) { - return malloc(length, M_DEVBUF, M_ZERO | M_NOWAIT | M_CANFAIL); + return dma_alloc(length, PR_NOWAIT | PR_ZERO); } void -sr_put_block(struct sr_discipline *sd, void *ptr) +sr_put_block(struct sr_discipline *sd, void *ptr, int length) { - free(ptr, M_DEVBUF); + dma_free(ptr, length); } |