From 401c72026168bcd0604cb05f2074b300c1f84a9e Mon Sep 17 00:00:00 2001 From: dillon Date: Sat, 25 Jan 2003 19:06:30 +0000 Subject: Readjust the cache initialization code to make it more obvious that the cache is bypassed when disabled. --- sbin/dump/cache.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'sbin/dump') diff --git a/sbin/dump/cache.c b/sbin/dump/cache.c index c049466..906ac27 100644 --- a/sbin/dump/cache.c +++ b/sbin/dump/cache.c @@ -88,14 +88,14 @@ cread(int fd, void *buf, size_t nbytes, off_t offset) off_t mask; /* - * If the cache is disabled, revert to pread. If the - * cache has not been initialized, initialize the cache. + * If the cache is disabled, or we do not yet know the filesystem + * block size, then revert to pread. Otherwise initialize the + * cache as necessary and continue. */ - if (sblock->fs_bsize && DataBase == NULL) { - if (cachesize <= 0) - return(pread(fd, buf, nbytes, offset)); + if (cachesize <= 0 || sblock->fs_bsize == 0) + return(pread(fd, buf, nbytes, offset)); + if (DataBase == NULL) cinit(); - } /* * If the request crosses a cache block boundary, or the @@ -118,13 +118,8 @@ cread(int fd, void *buf, size_t nbytes, off_t offset) pblk = &BlockHash[hi]; ppblk = NULL; while ((blk = *pblk) != NULL) { - if (((blk->b_Offset ^ offset) & mask) == 0) { -#if 0 - fprintf(stderr, "%08llx %d (%08x)\n", offset, nbytes, - sblock->fs_size * sblock->fs_fsize); -#endif + if (((blk->b_Offset ^ offset) & mask) == 0) break; - } ppblk = pblk; pblk = &blk->b_HNext; } -- cgit v1.1