VirtualBox

Changeset 3381 in kBuild for trunk/src


Ignore:
Timestamp:
Jun 12, 2020 11:36:10 AM (5 years ago)
Author:
bird
Message:

kFsCache: Account of race between us reading a directory and someone changing it, requiring re-reading the directory till at least 10ms has passed since the last direction change.

Location:
trunk/src/lib/nt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/kFsCache.c

    r3379 r3381  
    6464# define KFSCACHE_LOG2(a) do { } while (0)
    6565#endif
     66
     67/** The minimum time between a directory last populated time and its
     68 * modification time for the cache to consider it up-to-date.
     69 *
     70 * This helps work around races between us reading a directory and someone else
     71 * adding / removing files and directories to /from it.  Given that the
     72 * effective time resolution typically is around 2000Hz these days, unless you
     73 * use the new *TimePrecise API variants, there is plenty of room for a race
     74 * here.
     75 *
     76 * The current value is 20ms in NT time units (100ns each), which translates
     77 * to a 50Hz time update frequency. */
     78#define KFSCACHE_MIN_LAST_POPULATED_VS_WRITE (20*1000*10)
    6679
    6780
     
    662675            pDirObj->uDevNo             = pParent->uDevNo;
    663676            pDirObj->iLastWrite         = 0;
     677            pDirObj->iLastPopulated     = 0;
    664678            pDirObj->fPopulated         = K_FALSE;
    665679        }
     
    13161330    KFSDIRREPOP                 DirRePop    = { NULL, 0, 0, 0, NULL };
    13171331    MY_UNICODE_STRING           UniStrStar  = { 1 * sizeof(wchar_t), 2 * sizeof(wchar_t), L"*" };
     1332    FILETIME                    Now;
    13181333
    13191334    /** @todo May have to make this more flexible wrt information classes since
     
    14371452     *       restart that single file name query.
    14381453     */
     1454    GetSystemTimeAsFileTime(&Now);
     1455    pDir->iLastPopulated = ((KI64)Now.dwHighDateTime << 32) | Now.dwLowDateTime;
    14391456    Ios.Information = -1;
    14401457    Ios.u.Status    = -1;
     
    15261543                                if (   !pCurDir->fPopulated
    15271544                                    ||  (   pCurDir->iLastWrite == uPtr.pWithId->LastWriteTime.QuadPart
    1528                                          && (pCur->fFlags & KFSOBJ_F_WORKING_DIR_MTIME) ) )
     1545                                         && (pCur->fFlags & KFSOBJ_F_WORKING_DIR_MTIME)
     1546                                         &&    pCurDir->iLastPopulated - pCurDir->iLastWrite
     1547                                            >= KFSCACHE_MIN_LAST_POPULATED_VS_WRITE ))
    15291548                                { /* kind of likely */ }
    15301549                                else
     
    17751794            if (MY_NT_SUCCESS(rcNt))
    17761795            {
    1777                 if (BasicInfo.LastWriteTime.QuadPart != pDir->iLastWrite)
     1796                if (   BasicInfo.LastWriteTime.QuadPart != pDir->iLastWrite
     1797                    || pDir->iLastPopulated - pDir->iLastWrite < KFSCACHE_MIN_LAST_POPULATED_VS_WRITE)
    17781798                {
    17791799                    pDir->fNeedRePopulating = K_TRUE;
     
    20592079
    20602080                if (   pDir->iLastWrite == uBuf.FullInfo.LastWriteTime.QuadPart
    2061                     && (pObj->fFlags & KFSOBJ_F_WORKING_DIR_MTIME) )
     2081                    && (pObj->fFlags & KFSOBJ_F_WORKING_DIR_MTIME)
     2082                    && pDir->iLastPopulated - pDir->iLastWrite >= KFSCACHE_MIN_LAST_POPULATED_VS_WRITE)
    20622083                    KFSCACHE_LOG(("Refreshing %s/%s/ - no re-populating necessary.\n",
    20632084                                  pObj->pParent->Obj.pszName, pObj->pszName));
  • trunk/src/lib/nt/kFsCache.h

    r3372 r3381  
    275275     *          parent directory is refreshed. */
    276276    KI64                iLastWrite;
     277    /** The time that iLastWrite was read. */
     278    KI64                iLastPopulated;
    277279
    278280    /** Set if populated. */
  • trunk/src/lib/nt/tstkFsCache.c

    r3380 r3381  
    138138    /*
    139139     * Try emulate the temp issue above.  Seem to require several files.
     140     * (The problem was related to long/short filename updating.)
    140141     */
    141142    szPath[cchWorkDir++] = '\\';
     
    165166    CHECK(pFsObj && pFsObj->bObjType == KFSOBJ_TYPE_MISSING);
    166167
    167 Sleep(100);
    168168    sprintf(&szPath[cchWorkDir], "longfilename3.txt");
    169169    CHECK(myCreateFile(szPath) == 0);
Note: See TracChangeset for help on using the changeset viewer.

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