NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/51264: Fix src/sbin/fsck_lfs/bufcache.c
>Number:         51264
>Category:       bin
>Synopsis:       Fix src/sbin/fsck_lfs/bufcache.c
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 22 18:15:00 +0000 2016
>Originator:     Jose Luis Rodriguez Garcia
>Release:        NetBSD current
>Organization:
>Environment:
>Description:
Two bugs:
1- In function bufrehash,the entries are inserted in the hash table using the old hash function, because the hasmask hasn't been updated.
2- In function bufrehash, it must be :
if (max < 0 || max <= hashmax)
instead of:
if (max < 0 || max < hashmax), 
because in the case of max=hashmax both original an new hash table have the same size. It is a waste to reserve more memory and do the copy.
I think that this fix must be pulled o NetBSD 7 and NetBSD 6 (mainly case 1), because it can affect to the cleaner daemon and fsck_lfs.
>How-To-Repeat:
>Fix:
pc2$ diff -u bufcache.c.orig bufcache.c
--- bufcache.c.orig	2016-06-21 21:54:30.000000000 +0200
+++ bufcache.c	2016-06-22 19:57:06.000000000 +0200
@@ -101,17 +101,17 @@
 /* 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;
+	hashmask = newhashmax - 1;
 
 	/* Allocate new empty hash table, if we can */
 	np = emalloc(newhashmax * sizeof(*bufhash));
@@ -134,7 +134,6 @@
 	free(bufhash);
 	bufhash = np;
 	hashmax = newhashmax;
-	hashmask = newhashmask;
 }
 
 /* Print statistics of buffer cache usage */
Home |
Main Index |
Thread Index |
Old Index