summaryrefslogtreecommitdiffstats
path: root/sys/cddl
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2007-04-13 18:50:03 +0000
committerpjd <pjd@FreeBSD.org>2007-04-13 18:50:03 +0000
commit07cc016152a495aba24cd4bca7fc449750d28749 (patch)
treefc3f74bb8d0491670d361e1974fa56173cbe3d01 /sys/cddl
parentf858a604e10aec453d5728f201cd0c1668b875ae (diff)
downloadFreeBSD-src-07cc016152a495aba24cd4bca7fc449750d28749.zip
FreeBSD-src-07cc016152a495aba24cd4bca7fc449750d28749.tar.gz
Fix overflow, which was causing endless loops when 32bit machine had more
than 2GB of RAM. This was because our physmem is long and 'physmem*PAGESIZE' can be negative for more than 2GB of memory. Reported by: Andrey V. Elsukov <bu7cher@yandex.ru> It is not yet tested by Andrey, so there can be other problems, but this was definiately a bug, so I'm committing a fix now.
Diffstat (limited to 'sys/cddl')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
index f3d7ee6..6d361d9 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
@@ -624,7 +624,7 @@ buf_init(void)
* with an average 64K block size. The table will take up
* totalmem*sizeof(void*)/64K (eg. 128KB/GB with 8-byte pointers).
*/
- while (hsize * 65536 < physmem * PAGESIZE)
+ while (hsize * 65536 < (uint64_t)physmem * PAGESIZE)
hsize <<= 1;
retry:
buf_hash_table.ht_mask = hsize - 1;
@@ -2801,7 +2801,7 @@ arc_init(void)
#ifdef _KERNEL
/* Warn about ZFS memory requirements. */
- if ((physmem * PAGESIZE) < (256 + 128 + 64) * (1 << 20)) {
+ if (((uint64_t)physmem * PAGESIZE) < (256 + 128 + 64) * (1 << 20)) {
printf("ZFS WARNING: Recomended minimum of RAM size is 512MB, "
"expect unstable behaviour.\n");
} else if (kmem_size() < 256 * (1 << 20)) {
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
index 1fde66f..bd6d50b 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
@@ -250,7 +250,7 @@ dbuf_init(void)
* with an average 4K block size. The table will take up
* totalmem*sizeof(void*)/4K (i.e. 2MB/GB with 8-byte pointers).
*/
- while (hsize * 4096 < physmem * PAGESIZE)
+ while (hsize * 4096 < (uint64_t)physmem * PAGESIZE)
hsize <<= 1;
retry:
OpenPOWER on IntegriCloud