From 63316219249037d4b3ca15ee2c9e5d37341cad18 Mon Sep 17 00:00:00 2001 From: Olga Kornievskaia Date: Fri, 17 Dec 2010 13:31:23 -0500 Subject: [PATCH] turning unmap on previously we noticed that calling MmUnmapLockedPages() causes kernel crashes (thus the code is if 0-ed). however, when we don't unmap memory, it keeps accumulating in the nfsd's process memory (and is never "freed"). in this patch (a) calling unmap (b) checking if MmMapLockedPagesSpecifyCache() returns us a NULL pointer which is a type of failure that doesn't throw an exception but still is a failure. (c) cosmetic change to printf. NOTE: this cause still leads to failures for general tests. Running them in a loop (previously produced kernel crashes) now just leads to test failing. the cause is unknown! --- sys/nfs41_driver.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c index 5e0437f..c77824f 100644 --- a/sys/nfs41_driver.c +++ b/sys/nfs41_driver.c @@ -649,13 +649,18 @@ NTSTATUS marshal_nfs41_rw(nfs41_updowncall_entry *entry, __try { entry->u.ReadWrite.buf = MmMapLockedPagesSpecifyCache(entry->u.ReadWrite.MdlAddress, - UserMode, MmCached, NULL, FALSE, NormalPagePriority); + UserMode, MmNonCached, NULL, TRUE, NormalPagePriority); DbgP("MdlAddress=%p Userspace=%p\n", entry->u.ReadWrite.MdlAddress, entry->u.ReadWrite.buf); + if (entry->u.ReadWrite.buf == NULL) { + print_error("MmMapLockedPagesSpecifyCache failed to map pages\n"); + status = STATUS_INSUFFICIENT_RESOURCES; + goto out; + } } __except(EXCEPTION_EXECUTE_HANDLER) { NTSTATUS code; code = GetExceptionCode(); - print_error("Call to MmMapLocked failed due to exception 0x%0x\n", code); + print_error("Call to MmMapLocked failed due to exception 0x%x\n", code); status = STATUS_ACCESS_DENIED; goto out; } @@ -1396,7 +1401,7 @@ nfs41_downcall ( case NFS41_READ: RtlCopyMemory(&cur->u.ReadWrite.len, buf, sizeof(cur->u.ReadWrite.len)); DbgP("[read/write] returned len %ld\n", cur->u.ReadWrite.len); -#if 0 +#if 1 /* 08/27/2010: it looks like we really don't need to call MmUnmapLockedPages() * eventhough we called MmMapLockedPagesSpecifyCache() as the MDL passed to us * is already locked.