diff options
author | phk <phk@FreeBSD.org> | 2002-09-13 11:28:31 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-13 11:28:31 +0000 |
commit | 725daf0b2d98322fdc86d273333bdbc9b7d1a526 (patch) | |
tree | 9f94a84da337f90a627c0c82f184c5422f3616d9 /sys | |
parent | 4e012cc1d4cadfedb14e953bbc71f695e9a03782 (diff) | |
download | FreeBSD-src-725daf0b2d98322fdc86d273333bdbc9b7d1a526.zip FreeBSD-src-725daf0b2d98322fdc86d273333bdbc9b7d1a526.tar.gz |
Oops, broke the build there. Uninline biodone() now that it is non-trivial.
Introduce biowait() function. Currently there is a race condition and the
mitigation is a timeout/retry. It is not obvious what kind of locking (if any)
is suitable for BIO_DONE, since the majority of users take are of this
themselves, and only a few places actually rely on the wakeup.
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_bio.c | 28 | ||||
-rw-r--r-- | sys/sys/bio.h | 11 |
2 files changed, 30 insertions, 9 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index d5e5898..8490644 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 7f2d64b..173636b 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; |