aboutsummaryrefslogtreecommitdiff
path: root/sys/boot/common/bcache.c
diff options
context:
space:
mode:
authorPaul Richards <paul@FreeBSD.org>1998-11-19 18:12:03 +0000
committerPaul Richards <paul@FreeBSD.org>1998-11-19 18:12:03 +0000
commit9abd5d84acbd650c67c8c511b73d18898fb0e16c (patch)
tree2914b0ddcc7f8dd46c72eeeee56f26a894a4a1b9 /sys/boot/common/bcache.c
parentb2052ac8cffff8b7d2ebb36db784dbef0dfff356 (diff)
downloadsrc-9abd5d84acbd650c67c8c511b73d18898fb0e16c.tar.gz
src-9abd5d84acbd650c67c8c511b73d18898fb0e16c.zip
This fixes a bug in the bcache code whereby false cache hits occur
the first time block 0 is read. This fix initialises the block numbers to -1 which isn't the most correct thing for a daddr_t but it isn't likely to cause a problem in the boot blocks and it could do with a more thought out fix later. The bug is probably benign on the i386 but on the alpha it can cause initial file opens to fail. This is the cause of the "can't open /boot/boot.conf" errors. It appears on the alpha because of a number of combining factors. On the alpha the LABELSECTOR is 0 so block 0 needs to be read in from the media. The first time this happens you get a false hit because the bc_blkno field is zero initially. Also, the timestamp check against this cache hit succeeds because on the alpha a hacked getsecs() function can return 0 when it starts counting so that the zero initial timestamp + BCACHE_TIMEOUT is greater than the current time until getsecs() has counted passed BCACHE_TIMEOUT. The overall effect is that the first open() that occurs gets a false cache hit and returns garbage to the bd_strategy() function which then fails the open() call. This false hit then stays in the cache until BCACHE_TIMEOUT getsecs() ticks have passed; all open() calls during this time fail. This explains why you can generally access the media by the time you get to interp() and start issuing commands but the earlier attempts to run the boot scripts are failing. It's possible that this is causing the problem switching to the mfsroot floppy as well but I haven't confirmed that.
Notes
Notes: svn path=/head/; revision=41254
Diffstat (limited to 'sys/boot/common/bcache.c')
-rw-r--r--sys/boot/common/bcache.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/boot/common/bcache.c b/sys/boot/common/bcache.c
index 77b987a5def1..fc12f578f9fa 100644
--- a/sys/boot/common/bcache.c
+++ b/sys/boot/common/bcache.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: bcache.c,v 1.3 1998/11/04 00:29:01 msmith Exp $
*/
/*
@@ -98,8 +98,10 @@ bcache_init(int nblks, size_t bsize)
}
/* Invalidate the cache */
- for (i = 0; i < bcache_nblks; i++)
+ for (i = 0; i < bcache_nblks; i++) {
bcache_ctl[i].bc_count = -1;
+ bcache_ctl[i].bc_blkno = -1;
+ }
return(0);
}