aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2002-09-13 11:28:31 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2002-09-13 11:28:31 +0000
commitc7143e71505ac146245e3db3eadedda2fa034298 (patch)
tree9f94a84da337f90a627c0c82f184c5422f3616d9 /sys
parent9f6f6b7c2be500cef29b6d2ef84c9eec332ff8e1 (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_bio.c28
-rw-r--r--sys/sys/bio.h11
2 files changed, 30 insertions, 9 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index d5e5898094ea..8490644fc8f1 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -2805,6 +2805,34 @@ allocbuf(struct buf *bp, int size)
return 1;
}
+void
+biodone(struct bio *bp)
+{
+ bp->bio_flags |= BIO_DONE;
+ if (bp->bio_done != NULL)
+ bp->bio_done(bp);
+ else
+ wakeup(bp);
+}
+
+/*
+ * Wait for a BIO to finish.
+ * XXX: For now resort to a timeout, the optimal locking (if any) for this
+ * case is not at this point obvious.
+ */
+int
+biowait(struct bio *bp, const char *wchan)
+{
+
+ while ((bp->bio_flags & BIO_DONE) == 0)
+ msleep(bp, NULL, 0, wchan, hz);
+ if (!(bp->bio_flags & BIO_ERROR))
+ return (0);
+ if (bp->bio_error)
+ return (bp->bio_error);
+ return (EIO);
+}
+
/*
* bufwait:
*
diff --git a/sys/sys/bio.h b/sys/sys/bio.h
index 7f2d64b6e68e..173636bf9c39 100644
--- a/sys/sys/bio.h
+++ b/sys/sys/bio.h
@@ -107,15 +107,8 @@ struct bio {
struct uio;
-static __inline__ void
-biodone(struct bio *bp)
-{
- bp->bio_flags |= BIO_DONE;
- if (bp->bio_done != NULL)
- bp->bio_done(bp);
- else
- wakeup(bp);
-}
+void biodone(struct bio *bp);
+int biowait(struct bio *bp, const char *wchan);
#ifndef _DEVICESTAT_H
struct devstat;