VirtualBox

Changeset 78584 in vbox for trunk/src


Ignore:
Timestamp:
May 18, 2019 9:07:57 PM (6 years ago)
Author:
vboxsync
Message:

winnt/vboxsf: Use CcCoherencyFlushAndPurgeCache before writes and reads to ensure mmap coherency. This makes the FsPerf mmap tests happy, however the KPI is only available on windows 7 and later, so we'll have to skip this mmap test aspect on older systems, I fear. bugref:9172

Location:
trunk/src/VBox/Additions/WINNT/SharedFolders/driver
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/file.cpp

    r78577 r78584  
    114114                pReq->PgLst.aPages[iPage] = (RTGCPHYS)paPfns[iPage] << PAGE_SHIFT;
    115115            pReq->PgLst.offFirstPage = offPage;
     116
     117            /*
     118             * Flush dirty cache content before we try read it from the host.  RDBSS calls
     119             * CcFlushCache before it calls us, I think, but CcCoherencyFlushAndPurgeCache
     120             * does the right thing whereas CcFlushCache clearly does (FsPerf mmap+read
     121             * coherency test fails consistently on W10, XP, ++).
     122             */
     123            if (   g_pfnCcCoherencyFlushAndPurgeCache
     124                && !(RxContext->CurrentIrp && (RxContext->CurrentIrp->Flags & IRP_PAGING_IO))
     125                && RxContext->NonPagedFcb != NULL
     126                && RxContext->NonPagedFcb->SectionObjectPointers.DataSectionObject != NULL)
     127            {
     128                LARGE_INTEGER offFlush;
     129                offFlush.QuadPart = offFile;
     130                g_pfnCcCoherencyFlushAndPurgeCache(&RxContext->NonPagedFcb->SectionObjectPointers, &offFlush, cbChunk,
     131                                                   &RxContext->CurrentIrp->IoStatus, CC_FLUSH_AND_PURGE_NO_PURGE);
     132            }
    116133
    117134            /*
     
    294311    AssertReturn(pBufferMdl,  STATUS_INTERNAL_ERROR);
    295312
    296 
    297313    /*
    298314     * We should never get a zero byte request (RDBSS checks), but in case we
     
    358374
    359375            /*
     376             * Flush and purge the cache range we're touching upon now, provided we can and
     377             * really needs to.  The CcCoherencyFlushAndPurgeCache API seems to work better
     378             * than the CcFlushCache + CcPurgeCacheSection that RDBSS does before calling us.
     379             */
     380            if (   g_pfnCcCoherencyFlushAndPurgeCache
     381                && !(RxContext->CurrentIrp && (RxContext->CurrentIrp->Flags & IRP_PAGING_IO))
     382                && RxContext->NonPagedFcb != NULL
     383                && RxContext->NonPagedFcb->SectionObjectPointers.DataSectionObject != NULL)
     384            {
     385                /** @todo locking.   */
     386                LARGE_INTEGER offFlush;
     387                offFlush.QuadPart = offFile;
     388                g_pfnCcCoherencyFlushAndPurgeCache(&RxContext->NonPagedFcb->SectionObjectPointers, &offFlush, cbChunk,
     389                                                   &RxContext->CurrentIrp->IoStatus, 0 /*fFlags*/);
     390            }
     391
     392            /*
    360393             * Issue the request and unlock the pages.
    361394             */
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.cpp

    r78575 r78584  
    5252 */
    5353PRDBSS_DEVICE_OBJECT VBoxMRxDeviceObject;
     54
     55/** Pointer to CcCoherencyFlushAndPurgeCache if present in ntoskrnl. */
     56PFNCCCOHERENCYFLUSHANDPURGECACHE g_pfnCcCoherencyFlushAndPurgeCache;
    5457
    5558/** The shared folder service client structure. */
     
    659662    }
    660663
     664    /* Resolve newer kernel APIs we might want to use: */
     665    UNICODE_STRING RoutineName;
     666    RtlInitUnicodeString(&RoutineName, L"CcCoherencyFlushAndPurgeCache");
     667    g_pfnCcCoherencyFlushAndPurgeCache = (PFNCCCOHERENCYFLUSHANDPURGECACHE)MmGetSystemRoutineAddress(&RoutineName);
     668
    661669    /* Init the driver object. */
    662670    DriverObject->DriverUnload = VBoxMRxUnload;
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.h

    r78487 r78584  
    5757extern PRDBSS_DEVICE_OBJECT VBoxMRxDeviceObject;
    5858extern uint32_t             g_uSfLastFunction;
     59/** Pointer to the CcCoherencyFlushAndPurgeCache API (since win 7). */
     60typedef VOID (NTAPI *PFNCCCOHERENCYFLUSHANDPURGECACHE)(PSECTION_OBJECT_POINTERS, PLARGE_INTEGER, ULONG, PIO_STATUS_BLOCK,ULONG);
     61extern PFNCCCOHERENCYFLUSHANDPURGECACHE g_pfnCcCoherencyFlushAndPurgeCache;
     62#ifndef CC_FLUSH_AND_PURGE_NO_PURGE
     63# define CC_FLUSH_AND_PURGE_NO_PURGE 1
     64#endif
     65
    5966
    6067/**
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette