diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/softraid.c | 34 | ||||
-rw-r--r-- | sys/dev/softraid_crypto.c | 20 | ||||
-rw-r--r-- | sys/dev/softraid_raid0.c | 22 | ||||
-rw-r--r-- | sys/dev/softraid_raid1.c | 22 | ||||
-rw-r--r-- | sys/dev/softraidvar.h | 3 |
5 files changed, 42 insertions, 59 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 488d2566526..5616185c256 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.100 2008/02/05 16:24:12 marco Exp $ */ +/* $OpenBSD: softraid.c,v 1.101 2008/02/05 16:49:25 marco Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * @@ -2228,6 +2228,38 @@ bad: return (rv); } +int +sr_check_io_collision(struct sr_workunit *wu) +{ + struct sr_discipline *sd = wu->swu_dis; + struct sr_workunit *wup; + + splassert(IPL_BIO); + + /* walk queue backwards and fill in collider if we have one */ + TAILQ_FOREACH_REVERSE(wup, &sd->sd_wu_pendq, sr_wu_list, swu_link) { + if (wu->swu_blk_end < wup->swu_blk_start || + wup->swu_blk_end < wu->swu_blk_start) + continue; + + /* we have an LBA collision, defer wu */ + wu->swu_state = SR_WU_DEFERRED; + if (wup->swu_collider) + /* wu is on deferred queue, append to last wu */ + while (wup->swu_collider) + wup = wup->swu_collider; + + wup->swu_collider = wu; + TAILQ_INSERT_TAIL(&sd->sd_wu_defq, wu, swu_link); + sd->sd_wu_collisions++; + goto queued; + } + + return (0); +queued: + return (1); +} + #ifndef SMALL_KERNEL int sr_create_sensors(struct sr_discipline *sd) diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c index 44629f93879..28979c249cf 100644 --- a/sys/dev/softraid_crypto.c +++ b/sys/dev/softraid_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_crypto.c,v 1.7 2008/02/05 16:15:35 marco Exp $ */ +/* $OpenBSD: softraid_crypto.c,v 1.8 2008/02/05 16:49:25 marco Exp $ */ /* * Copyright (c) 2007 Ted Unangst <tedu@openbsd.org> * Copyright (c) 2008 Marco Peereboom <marco@openbsd.org> @@ -240,7 +240,6 @@ sr_crypto_rw2(struct sr_workunit *wu, struct cryptop *crp) { struct sr_discipline *sd = wu->swu_dis; struct scsi_xfer *xs = wu->swu_xs; - struct sr_workunit *wup; struct sr_ccb *ccb; struct uio *uio; int s; @@ -299,25 +298,10 @@ sr_crypto_rw2(struct sr_workunit *wu, struct cryptop *crp) ccb->ccb_buf.b_flags, ccb->ccb_buf.b_data); - /* walk queue backwards and fill in collider if we have one */ s = splbio(); - TAILQ_FOREACH_REVERSE(wup, &sd->sd_wu_pendq, sr_wu_list, swu_link) { - if (wu->swu_blk_end < wup->swu_blk_start || - wup->swu_blk_end < wu->swu_blk_start) - continue; - - /* we have an LBA collision, defer wu */ - wu->swu_state = SR_WU_DEFERRED; - if (wup->swu_collider) - /* wu is on deferred queue, append to last wu */ - while (wup->swu_collider) - wup = wup->swu_collider; - wup->swu_collider = wu; - TAILQ_INSERT_TAIL(&sd->sd_wu_defq, wu, swu_link); - sd->sd_wu_collisions++; + if (sr_check_io_collision(wu)) goto queued; - } sr_raid_startwu(wu); diff --git a/sys/dev/softraid_raid0.c b/sys/dev/softraid_raid0.c index 97833c47bdd..d8994687878 100644 --- a/sys/dev/softraid_raid0.c +++ b/sys/dev/softraid_raid0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid0.c,v 1.7 2008/02/05 16:15:35 marco Exp $ */ +/* $OpenBSD: softraid_raid0.c,v 1.8 2008/02/05 16:49:25 marco Exp $ */ /* * Copyright (c) 2008 Marco Peereboom <marco@peereboom.us> * @@ -203,7 +203,6 @@ sr_raid0_rw(struct sr_workunit *wu) { struct sr_discipline *sd = wu->swu_dis; struct scsi_xfer *xs = wu->swu_xs; - struct sr_workunit *wup; struct sr_ccb *ccb; struct sr_chunk *scp; int s; @@ -299,24 +298,9 @@ sr_raid0_rw(struct sr_workunit *wu) s = splbio(); - /* walk queue backwards and fill in collider if we have one */ - TAILQ_FOREACH_REVERSE(wup, &sd->sd_wu_pendq, sr_wu_list, swu_link) { - if (wu->swu_blk_end < wup->swu_blk_start || - wup->swu_blk_end < wu->swu_blk_start) - continue; - - /* we have an LBA collision, defer wu */ - wu->swu_state = SR_WU_DEFERRED; - if (wup->swu_collider) - /* wu is on deferred queue, append to last wu */ - while (wup->swu_collider) - wup = wup->swu_collider; - - wup->swu_collider = wu; - TAILQ_INSERT_TAIL(&sd->sd_wu_defq, wu, swu_link); - sd->sd_wu_collisions++; + if (sr_check_io_collision(wu)) goto queued; - } + sr_raid_startwu(wu); queued: splx(s); diff --git a/sys/dev/softraid_raid1.c b/sys/dev/softraid_raid1.c index 430c9ed033c..85a789ffc0c 100644 --- a/sys/dev/softraid_raid1.c +++ b/sys/dev/softraid_raid1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid1.c,v 1.4 2008/02/05 16:15:35 marco Exp $ */ +/* $OpenBSD: softraid_raid1.c,v 1.5 2008/02/05 16:49:25 marco Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * @@ -287,7 +287,6 @@ sr_raid1_rw(struct sr_workunit *wu) { struct sr_discipline *sd = wu->swu_dis; struct scsi_xfer *xs = wu->swu_xs; - struct sr_workunit *wup; struct sr_ccb *ccb; struct sr_chunk *scp; int ios, x, i, s, rt; @@ -407,26 +406,9 @@ ragain: if (wu->swu_state == SR_WU_REQUEUE) goto queued; - /* walk queue backwards and fill in collider if we have one */ - TAILQ_FOREACH_REVERSE(wup, &sd->sd_wu_pendq, sr_wu_list, swu_link) { - if (wu->swu_blk_end < wup->swu_blk_start || - wup->swu_blk_end < wu->swu_blk_start) - continue; - - /* we have an LBA collision, defer wu */ - wu->swu_state = SR_WU_DEFERRED; - if (wup->swu_collider) - /* wu is on deferred queue, append to last wu */ - while (wup->swu_collider) - wup = wup->swu_collider; - - wup->swu_collider = wu; - TAILQ_INSERT_TAIL(&sd->sd_wu_defq, wu, swu_link); - sd->sd_wu_collisions++; + if (sr_check_io_collision(wu)) goto queued; - } - /* XXX deal with polling */ start: sr_raid_startwu(wu); queued: diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h index 34b65d29253..1d6aa3bf2e3 100644 --- a/sys/dev/softraidvar.h +++ b/sys/dev/softraidvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: softraidvar.h,v 1.42 2008/02/05 16:15:35 marco Exp $ */ +/* $OpenBSD: softraidvar.h,v 1.43 2008/02/05 16:49:25 marco Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -367,6 +367,7 @@ int32_t sr_validate_stripsize(u_int32_t); void sr_save_metadata_callback(void *, void *); int sr_validate_io(struct sr_workunit *, daddr64_t *, char *); +int sr_check_io_collision(struct sr_workunit *); /* discipline functions */ int sr_raid_inquiry(struct sr_workunit *); |