summaryrefslogtreecommitdiff
path: root/sys/dev/softraid.c
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2008-02-05 16:49:26 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2008-02-05 16:49:26 +0000
commit6efcb5353e2a858c7b4ce8ea28567db393411616 (patch)
treedb78619bdc43d1da9b3e9c7227091a65b24cf65a /sys/dev/softraid.c
parent160689e7f2fa5c1b58b2a09c19be1a697f55235d (diff)
Shave off a few more bytes by moving IO collision detection into a generic
fucntion. Fix bug in the crypto code that could casuse data corruption as a bonus, bad cut & past tedu!
Diffstat (limited to 'sys/dev/softraid.c')
-rw-r--r--sys/dev/softraid.c34
1 files changed, 33 insertions, 1 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)