aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/default_pager.c
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1998-10-13 08:24:45 +0000
committerDavid Greenman <dg@FreeBSD.org>1998-10-13 08:24:45 +0000
commit6cde7a165f154ed47b58fc42d6d2041e18384680 (patch)
tree75c32899ed392bb9123cc155f65d0a0b121f6f46 /sys/vm/default_pager.c
parentd74a7fd03e9f6e094bd0d88f544cff2d7052755a (diff)
downloadsrc-6cde7a165f154ed47b58fc42d6d2041e18384680.tar.gz
src-6cde7a165f154ed47b58fc42d6d2041e18384680.zip
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.
Notes
Notes: svn path=/head/; revision=40286
Diffstat (limited to 'sys/vm/default_pager.c')
-rw-r--r--sys/vm/default_pager.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/vm/default_pager.c b/sys/vm/default_pager.c
index 44d27afd65b8..ba92894ed731 100644
--- a/sys/vm/default_pager.c
+++ b/sys/vm/default_pager.c
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: default_pager.c,v 1.14 1998/02/04 22:33:39 eivind Exp $
+ * $Id: default_pager.c,v 1.15 1998/02/06 12:14:20 eivind Exp $
*/
#include <sys/param.h>
@@ -44,7 +44,7 @@
#include <vm/default_pager.h>
#include <vm/swap_pager.h>
-static vm_object_t default_pager_alloc __P((void *, vm_size_t, vm_prot_t,
+static vm_object_t default_pager_alloc __P((void *, vm_ooffset_t, vm_prot_t,
vm_ooffset_t));
static void default_pager_dealloc __P((vm_object_t));
static int default_pager_getpages __P((vm_object_t, vm_page_t *, int, int));
@@ -69,13 +69,13 @@ struct pagerops defaultpagerops = {
* no_pager_alloc just returns an initialized object.
*/
static vm_object_t
-default_pager_alloc(void *handle, vm_size_t size, vm_prot_t prot,
+default_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
vm_ooffset_t offset)
{
if (handle != NULL)
panic("default_pager_alloc: handle specified");
- return vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(offset) + size);
+ return vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(round_page(offset + size)));
}
static void