Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/fsck_lfs PR 51264 Jose Luis Rodriguez Garcia: lfs userl...



details:   https://anonhg.NetBSD.org/src/rev/b1c84f5a1cbc
branches:  trunk
changeset: 816886:b1c84f5a1cbc
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jul 31 18:27:26 2016 +0000

description:
PR 51264 Jose Luis Rodriguez Garcia: lfs userland bufcache rehash is broken

diffstat:

 sbin/fsck_lfs/bufcache.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 50f21c24586f -r b1c84f5a1cbc sbin/fsck_lfs/bufcache.c
--- a/sbin/fsck_lfs/bufcache.c  Sun Jul 31 18:14:36 2016 +0000
+++ b/sbin/fsck_lfs/bufcache.c  Sun Jul 31 18:27:26 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufcache.c,v 1.15 2015/03/29 19:35:58 chopps Exp $ */
+/* $NetBSD: bufcache.c,v 1.16 2016/07/31 18:27:26 dholland Exp $ */
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -101,17 +101,19 @@
 /* Widen the hash table. */
 void bufrehash(int max)
 {
-       int i, newhashmax, newhashmask;
+       int i, newhashmax;
        struct ubuf *bp, *nbp;
        struct bufhash_struct *np;
 
-       if (max < 0 || max < hashmax)
+       if (max < 0 || max <= hashmax)
                return;
 
        /* Round up to a power of two */
        for (newhashmax = 1; newhashmax < max; newhashmax <<= 1)
                ;
-       newhashmask = newhashmax - 1;
+
+       /* update the mask right away so vl_hash() uses it */
+       hashmask = newhashmax - 1;
 
        /* Allocate new empty hash table, if we can */
        np = emalloc(newhashmax * sizeof(*bufhash));
@@ -134,7 +136,6 @@
        free(bufhash);
        bufhash = np;
        hashmax = newhashmax;
-       hashmask = newhashmask;
 }
 
 /* Print statistics of buffer cache usage */



Home | Main Index | Thread Index | Old Index