summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_bio.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-01-05 23:00:38 +0000
committermav <mav@FreeBSD.org>2014-01-05 23:00:38 +0000
commit4fb4fef0e1b5459b36de95e5dc3dd29f85ad48a2 (patch)
tree418ee1288eeb5ce945280af95179f0d8fc4caa6a /sys/kern/vfs_bio.c
parent3dd7b80d9aa202dd3ebdba2cff812904269131f3 (diff)
downloadFreeBSD-src-4fb4fef0e1b5459b36de95e5dc3dd29f85ad48a2.zip
FreeBSD-src-4fb4fef0e1b5459b36de95e5dc3dd29f85ad48a2.tar.gz
MFC r256614:
- Take BIO lock in biodone() only when there is no completion callback set and so we should wake up thread waiting in biowait(). - Remove msleep() timeout from biowait(). It was added 11 years ago, when there was no locks used, and it should not be needed any more.
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r--sys/kern/vfs_bio.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 362de37..3812813 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -3559,9 +3559,6 @@ biodone(struct bio *bp)
vm_offset_t start, end;
int transient;
- mtxp = mtx_pool_find(mtxpool_sleep, bp);
- mtx_lock(mtxp);
- bp->bio_flags |= BIO_DONE;
if ((bp->bio_flags & BIO_TRANSIENT_MAPPING) != 0) {
start = trunc_page((vm_offset_t)bp->bio_data);
end = round_page((vm_offset_t)bp->bio_data + bp->bio_length);
@@ -3571,11 +3568,16 @@ biodone(struct bio *bp)
start = end = 0;
}
done = bp->bio_done;
- if (done == NULL)
+ if (done == NULL) {
+ mtxp = mtx_pool_find(mtxpool_sleep, bp);
+ mtx_lock(mtxp);
+ bp->bio_flags |= BIO_DONE;
wakeup(bp);
- mtx_unlock(mtxp);
- if (done != NULL)
+ mtx_unlock(mtxp);
+ } else {
+ bp->bio_flags |= BIO_DONE;
done(bp);
+ }
if (transient) {
pmap_qremove(start, OFF_TO_IDX(end - start));
vmem_free(transient_arena, start, end - start);
@@ -3585,9 +3587,6 @@ biodone(struct bio *bp)
/*
* Wait for a BIO to finish.
- *
- * XXX: resort to a timeout for now. The optimal locking (if any) for this
- * case is not yet clear.
*/
int
biowait(struct bio *bp, const char *wchan)
@@ -3597,7 +3596,7 @@ biowait(struct bio *bp, const char *wchan)
mtxp = mtx_pool_find(mtxpool_sleep, bp);
mtx_lock(mtxp);
while ((bp->bio_flags & BIO_DONE) == 0)
- msleep(bp, mtxp, PRIBIO, wchan, hz / 10);
+ msleep(bp, mtxp, PRIBIO, wchan, 0);
mtx_unlock(mtxp);
if (bp->bio_error != 0)
return (bp->bio_error);
OpenPOWER on IntegriCloud