summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2014-01-18 09:33:54 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2014-01-18 09:33:54 +0000
commita954e4dc94b46b1babdef7686c7774085afd3bf4 (patch)
tree23e2c13133bc5b5cdee9dd28f53b7d7d74466589 /sys
parent1687d98ceedb9b7264f9f3b4ad279f732cb2bdef (diff)
Move the block get/put routines into the common code, instead of having
RAID 6 borrow them from RAID 5.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/softraid.c14
-rw-r--r--sys/dev/softraid_raid5.c28
-rw-r--r--sys/dev/softraid_raid6.c15
-rw-r--r--sys/dev/softraidvar.h4
4 files changed, 28 insertions, 33 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 3cafbf392f4..a853d43f72b 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.317 2014/01/18 09:23:26 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.318 2014/01/18 09:33:53 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -4382,6 +4382,18 @@ die:
sd->sd_vol_status = new_state;
}
+void *
+sr_block_get(struct sr_discipline *sd, int length)
+{
+ return dma_alloc(length, PR_NOWAIT | PR_ZERO);
+}
+
+void
+sr_block_put(struct sr_discipline *sd, void *ptr, int length)
+{
+ dma_free(ptr, length);
+}
+
void
sr_checksum_print(u_int8_t *md5)
{
diff --git a/sys/dev/softraid_raid5.c b/sys/dev/softraid_raid5.c
index 23b08f0b1b9..a370cc867e8 100644
--- a/sys/dev/softraid_raid5.c
+++ b/sys/dev/softraid_raid5.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid5.c,v 1.1 2014/01/18 09:23:26 jsing Exp $ */
+/* $OpenBSD: softraid_raid5.c,v 1.2 2014/01/18 09:33:53 jsing Exp $ */
/*
* Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org>
@@ -64,9 +64,6 @@ int sr_raid5_addio(struct sr_workunit *wu, int, daddr_t, daddr_t,
void sr_dump(void *, int);
void sr_raid5_scrub(struct sr_discipline *);
-void *sr_get_block(struct sr_discipline *, int);
-void sr_put_block(struct sr_discipline *, void *, int);
-
/* discipline initialisation. */
void
sr_raid5_discipline_init(struct sr_discipline *sd)
@@ -439,7 +436,7 @@ sr_raid5_rw(struct sr_workunit *wu)
* parity in the intr routine. The result in xorbuf
* is the new parity data.
*/
- xorbuf = sr_get_block(sd, length);
+ xorbuf = sr_block_get(sd, length);
if (xorbuf == NULL)
goto bad;
memcpy(xorbuf, data, length);
@@ -520,7 +517,7 @@ sr_raid5_intr(struct buf *bp)
/* Free allocated data buffer. */
if (ccb->ccb_flags & SR_CCBF_FREEBUF) {
- sr_put_block(sd, ccb->ccb_buf.b_data, ccb->ccb_buf.b_bcount);
+ sr_block_put(sd, ccb->ccb_buf.b_data, ccb->ccb_buf.b_bcount);
ccb->ccb_buf.b_data = NULL;
}
@@ -575,7 +572,7 @@ sr_raid5_addio(struct sr_workunit *wu, int chunk, daddr_t blkno,
/* Allocate temporary buffer. */
if (data == NULL) {
- data = sr_get_block(sd, len);
+ data = sr_block_get(sd, len);
if (data == NULL)
return (-1);
ccbflags |= SR_CCBF_FREEBUF;
@@ -584,7 +581,7 @@ sr_raid5_addio(struct sr_workunit *wu, int chunk, daddr_t blkno,
ccb = sr_ccb_rw(sd, chunk, blkno, len, data, xsflags, ccbflags);
if (ccb == NULL) {
if (ccbflags & SR_CCBF_FREEBUF)
- sr_put_block(sd, data, len);
+ sr_block_put(sd, data, len);
return (-1);
}
ccb->ccb_opaque = xorbuf;
@@ -644,7 +641,7 @@ sr_raid5_scrub(struct sr_discipline *sd)
for (strip_no = 0; strip_no < max_strip; strip_no++) {
parity = no_chunk - ((strip_no / no_chunk) % (no_chunk + 1));
- xorbuf = sr_get_block(sd, strip_size);
+ xorbuf = sr_block_get(sd, strip_size);
for (i = 0; i <= no_chunk; i++) {
if (i != parity)
sr_raid5_addio(wu_r, i, 0xBADCAFE, strip_size,
@@ -679,16 +676,3 @@ done:
return;
}
#endif
-
-void *
-sr_get_block(struct sr_discipline *sd, int length)
-{
- return dma_alloc(length, PR_NOWAIT | PR_ZERO);
-}
-
-void
-sr_put_block(struct sr_discipline *sd, void *ptr, int length)
-{
- dma_free(ptr, length);
-}
-
diff --git a/sys/dev/softraid_raid6.c b/sys/dev/softraid_raid6.c
index 747e858060e..5cfb22dedb7 100644
--- a/sys/dev/softraid_raid6.c
+++ b/sys/dev/softraid_raid6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid6.c,v 1.57 2013/11/21 17:06:45 krw Exp $ */
+/* $OpenBSD: softraid_raid6.c,v 1.58 2014/01/18 09:33:53 jsing Exp $ */
/*
* Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org>
@@ -69,9 +69,6 @@ void sr_dump(void *, int);
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 *, int);
-
void gf_init(void);
uint8_t gf_inv(uint8_t);
int gf_premul(uint8_t);
@@ -569,11 +566,11 @@ sr_raid6_rw(struct sr_workunit *wu)
* parity in the intr routine. The result in pbuf
* is the new parity data.
*/
- qbuf = sr_get_block(sd, length);
+ qbuf = sr_block_get(sd, length);
if (qbuf == NULL)
goto bad;
- pbuf = sr_get_block(sd, length);
+ pbuf = sr_block_get(sd, length);
if (pbuf == NULL)
goto bad;
@@ -693,7 +690,7 @@ sr_raid6_intr(struct buf *bp)
/* Free allocated data buffer. */
if (ccb->ccb_flags & SR_CCBF_FREEBUF) {
- sr_put_block(sd, ccb->ccb_buf.b_data, ccb->ccb_buf.b_bcount);
+ sr_block_put(sd, ccb->ccb_buf.b_data, ccb->ccb_buf.b_bcount);
ccb->ccb_buf.b_data = NULL;
}
@@ -751,7 +748,7 @@ sr_raid6_addio(struct sr_workunit *wu, int chunk, daddr_t blkno,
/* Allocate temporary buffer. */
if (data == NULL) {
- data = sr_get_block(sd, len);
+ data = sr_block_get(sd, len);
if (data == NULL)
return (-1);
ccbflags |= SR_CCBF_FREEBUF;
@@ -760,7 +757,7 @@ sr_raid6_addio(struct sr_workunit *wu, int chunk, daddr_t blkno,
ccb = sr_ccb_rw(sd, chunk, blkno, len, data, xsflags, ccbflags);
if (ccb == NULL) {
if (ccbflags & SR_CCBF_FREEBUF)
- sr_put_block(sd, data, len);
+ sr_block_put(sd, data, len);
return (-1);
}
if (pbuf || qbuf) {
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index a541e115894..72a51693530 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.143 2014/01/18 09:23:26 jsing Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.144 2014/01/18 09:33:53 jsing Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -682,6 +682,8 @@ void sr_meta_getdevname(struct sr_softc *, dev_t, char *,
int);
void sr_meta_opt_load(struct sr_softc *,
struct sr_metadata *, struct sr_meta_opt_head *);
+void *sr_block_get(struct sr_discipline *, int);
+void sr_block_put(struct sr_discipline *, void *, int);
void sr_checksum(struct sr_softc *, void *, void *,
u_int32_t);
int sr_validate_io(struct sr_workunit *, daddr_t *,