diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2012-11-17 23:08:23 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2012-11-17 23:08:23 +0000 |
commit | d61772fd2a28c4d68abf20354d6a30324357f557 (patch) | |
tree | 821e69a0d17cde66bcfa6018f8e5d8a090937825 /sys/kern/vfs_biomem.c | |
parent | 49175dac6e732dd877e6aa295f301ab21e422c75 (diff) |
Don't map a buffer (and potentially sleep) when invalidating it in vinvalbuf.
This fixes a problem where we could sleep for kva and then our pointers
would not be valid on the next pass through the loop. We do this
by adding buf_acquire_nomap() - which can be used to busy up the buffer
without changing its mapped or unmapped state. We do not need to have
the buffer mapped to invalidate it, so it is sufficient to acquire it
for that. In the case where we write the buffer, we do map the buffer, and
potentially sleep.
Diffstat (limited to 'sys/kern/vfs_biomem.c')
-rw-r--r-- | sys/kern/vfs_biomem.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/kern/vfs_biomem.c b/sys/kern/vfs_biomem.c index 2a1e342c62b..c0149d83624 100644 --- a/sys/kern/vfs_biomem.c +++ b/sys/kern/vfs_biomem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_biomem.c,v 1.18 2011/09/19 14:48:04 beck Exp $ */ +/* $OpenBSD: vfs_biomem.c,v 1.19 2012/11/17 23:08:22 beck Exp $ */ /* * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> * @@ -105,6 +105,23 @@ buf_acquire_unmapped(struct buf *bp) splx(s); } +/* + * Acquire a buf but do not map it. Preserve any mapping it did have. + */ +void +buf_acquire_nomap(struct buf *bp) +{ + splassert(IPL_BIO); + SET(bp->b_flags, B_BUSY); + if (bp->b_data == NULL) + SET(bp->b_flags, B_NOTMAPPED); + else { + TAILQ_REMOVE(&buf_valist, bp, b_valist); + bcstats.kvaslots_avail--; + bcstats.busymapped++; + } +} + void buf_map(struct buf *bp) { |