summaryrefslogtreecommitdiffstats
path: root/sys/vm/swap_pager.c
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1998-10-13 08:24:45 +0000
committerdg <dg@FreeBSD.org>1998-10-13 08:24:45 +0000
commit3defb6d13f481d8c8bb2d9014db42c8a5ee19f9d (patch)
tree64822d97637c55a2d7aeb4a999c847a5869bac46 /sys/vm/swap_pager.c
parent3280e5edc1739224a3e662ea57aa1746d1eb9105 (diff)
downloadFreeBSD-src-3defb6d13f481d8c8bb2d9014db42c8a5ee19f9d.zip
FreeBSD-src-3defb6d13f481d8c8bb2d9014db42c8a5ee19f9d.tar.gz
Fixed two potentially serious classes of bugs:
1) The vnode pager wasn't properly tracking the file size due to "size" being page rounded in some cases and not in others. This sometimes resulted in corrupted files. First noticed by Terry Lambert. Fixed by changing the "size" pager_alloc parameter to be a 64bit byte value (as opposed to a 32bit page index) and changing the pagers and their callers to deal with this properly. 2) Fixed a bogus type cast in round_page() and trunc_page() that caused some 64bit offsets and sizes to be scrambled. Removing the cast required adding casts at a few dozen callers. There may be problems with other bogus casts in close-by macros. A quick check seemed to indicate that those were okay, however.
Diffstat (limited to 'sys/vm/swap_pager.c')
-rw-r--r--sys/vm/swap_pager.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index e193eca..6c58e0f 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -39,7 +39,7 @@
* from: Utah $Hdr: swap_pager.c 1.4 91/04/30$
*
* @(#)swap_pager.c 8.9 (Berkeley) 3/21/94
- * $Id: swap_pager.c,v 1.100 1998/08/24 08:39:37 dfr Exp $
+ * $Id: swap_pager.c,v 1.101 1998/09/04 08:06:56 dfr Exp $
*/
/*
@@ -136,7 +136,7 @@ static struct pagerlst *swp_qs[] = {
* pagerops for OBJT_SWAP - "swap pager".
*/
static vm_object_t
- swap_pager_alloc __P((void *handle, vm_size_t size,
+ swap_pager_alloc __P((void *handle, vm_ooffset_t size,
vm_prot_t prot, vm_ooffset_t offset));
static void swap_pager_dealloc __P((vm_object_t object));
static boolean_t
@@ -295,7 +295,7 @@ swap_pager_swp_alloc(object, wait)
* we should not wait for memory as it could resulting in deadlock.
*/
static vm_object_t
-swap_pager_alloc(void *handle, vm_size_t size, vm_prot_t prot,
+swap_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
vm_ooffset_t offset)
{
vm_object_t object;
@@ -317,13 +317,13 @@ swap_pager_alloc(void *handle, vm_size_t size, vm_prot_t prot,
* rip support of "named anonymous regions" out altogether.
*/
object = vm_object_allocate(OBJT_SWAP,
- OFF_TO_IDX(offset + PAGE_MASK) + size);
+ OFF_TO_IDX(offset + PAGE_MASK + size));
object->handle = handle;
(void) swap_pager_swp_alloc(object, M_WAITOK);
}
} else {
object = vm_object_allocate(OBJT_SWAP,
- OFF_TO_IDX(offset + PAGE_MASK) + size);
+ OFF_TO_IDX(offset + PAGE_MASK + size));
(void) swap_pager_swp_alloc(object, M_WAITOK);
}
OpenPOWER on IntegriCloud