- Timestamp:
- Mar 29, 2019 9:12:05 PM (6 years ago)
- Location:
- trunk/src/VBox/Additions/linux/sharedfolders
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r77953 r77959 929 929 /* Check that we don't have signals pending before we issue the write, as 930 930 we'll only end up having to cancel the HGCM request 99% of the time: */ 931 if (!signal_pending(current)) 931 if (!signal_pending(current)) { 932 932 vrc = VbglR0SfHostReqWritePgLst(pSuperInfo->map.root, pReq, sf_r->Handle.hHost, offFile, 933 933 cbToWrite, cPagesToWrite); 934 else 934 sf_i->ModificationTimeAtOurLastWrite = sf_i->ModificationTime; 935 } else 935 936 vrc = VERR_INTERRUPTED; 936 937 if (RT_SUCCESS(vrc)) { … … 1813 1814 */ 1814 1815 rc = VbglR0SfHostReqWritePgLst(pSuperInfo->map.root, pReq, sf_r->Handle.hHost, offFile, cbChunk, cPages); 1816 sf_i->ModificationTimeAtOurLastWrite = sf_i->ModificationTime; 1815 1817 if (RT_SUCCESS(rc)) { 1816 1818 /* … … 1939 1941 int vrc = VbglR0SfHostReqWriteEmbedded(pSuperInfo->map.root, pReq, sf_r->Handle.hHost, 1940 1942 pos, (uint32_t)size); 1943 sf_i->ModificationTimeAtOurLastWrite = sf_i->ModificationTime; 1941 1944 if (RT_SUCCESS(vrc)) { 1942 1945 cbRet = pReq->Parms.cb32Write.u.value32; … … 1973 1976 ssize_t cbRet; 1974 1977 int vrc = VbglR0SfHostReqWriteContig(pSuperInfo->map.root, pReq, sf_r->handle, pos, 1975 (uint32_t)size, pvBounce, virt_to_phys(pvBounce)); 1978 (uint32_t)size, pvBounce, virt_to_phys(pvBounce)); 1979 sf_i->ModificationTimeAtOurLastWrite = sf_i->ModificationTime; 1976 1980 if (RT_SUCCESS(vrc)) { 1977 1981 cbRet = pReq->Parms.cb32Write.u.value32; … … 2636 2640 */ 2637 2641 rc = VbglR0SfHostReqWritePgLst(pSuperInfo->map.root, pReq, sf_r->Handle.hHost, offFile, cbChunk, cPages); 2642 sf_i->ModificationTimeAtOurLastWrite = sf_i->ModificationTime; 2638 2643 SFLOGFLOW(("vbsf_reg_write_iter_locking: VbglR0SfHostReqWritePgLst -> %d (cbActual=%#x cbChunk=%#zx of %#zx cPages=%#zx offPage0=%#x\n", 2639 2644 rc, pReq->Parms.cb32Write.u.value32, cbChunk, cbToWrite, cPages, offPage0)); … … 2794 2799 int vrc = VbglR0SfHostReqWriteEmbedded(pSuperInfo->map.root, pReq, sf_r->Handle.hHost, 2795 2800 offFile, (uint32_t)cbToWrite); 2801 sf_i->ModificationTimeAtOurLastWrite = sf_i->ModificationTime; 2796 2802 if (RT_SUCCESS(vrc)) { 2797 2803 cbRet = pReq->Parms.cb32Write.u.value32; … … 3549 3555 cbToWrite, 3550 3556 1 /*cPages*/); 3557 sf_i->ModificationTimeAtOurLastWrite = sf_i->ModificationTime; 3551 3558 AssertMsgStmt(pReq->Parms.cb32Write.u.value32 == cbToWrite || RT_FAILURE(vrc), /* lazy bird */ 3552 3559 ("%#x vs %#x\n", pReq->Parms.cb32Write, cbToWrite), -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r77953 r77959 357 357 vbsf_time_to_linux(&inode->i_mtime, &pObjInfo->ModificationTime); 358 358 sf_i->BirthTime = pObjInfo->BirthTime; 359 sf_i->ModificationTime = pObjInfo->ModificationTime; 360 RTTimeSpecSetSeconds(&sf_i->ModificationTimeAtOurLastWrite, 0); 359 361 } 360 362 … … 369 371 { 370 372 PCSHFLFSOBJATTR pAttr = &pObjInfo->Attr; 371 int fMode;373 int fMode; 372 374 373 375 TRACE(); … … 426 428 /* 427 429 * Mark it as up to date. 430 * Best to do this before we start with any expensive map invalidation. 428 431 */ 429 432 pInodeInfo->ts_up_to_date = jiffies; 430 433 pInodeInfo->force_restat = 0; 431 434 435 /* 436 * If the modification time changed, we may have to invalidate the page 437 * cache pages associated with this inode if we suspect the change was 438 * made by the host. How supicious we are depends on the cache mode. 439 * 440 * Note! The invalidate_inode_pages() call is pretty weak. It will _not_ 441 * touch pages that are already mapped into an address space, but it 442 * will help if the file isn't currently mmap'ed or if we're in read 443 * or read/write caching mode. 444 */ 445 if (!RTTimeSpecIsEqual(&pInodeInfo->ModificationTime, &pObjInfo->ModificationTime)) { 446 if (RTFS_IS_FILE(pAttr->fMode)) { 447 bool fInvalidate; 448 if (pSuperInfo->enmCacheMode == kVbsfCacheMode_None) { 449 fInvalidate = true; /* No-caching: always invalidate. */ 450 } else { 451 /** @todo Seeing nano-seconds being chopped off by someone before we get 452 * here. weird weird weird. Must be host side. */ 453 if (RTTimeSpecIsEqual(&pInodeInfo->ModificationTimeAtOurLastWrite, &pInodeInfo->ModificationTime)) { 454 fInvalidate = false; /* Could be our write, so don't invalidate anything */ 455 RTTimeSpecSetSeconds(&pInodeInfo->ModificationTimeAtOurLastWrite, 0); 456 } else { 457 /* RTLogBackdoorPrintf("vbsf_update_inode: Invalidating the mapping %s - %RU64 vs %RU64 vs %RU64\n", 458 pInodeInfo->path->String.ach, RTTimeSpecGetNano(&pInodeInfo->ModificationTimeAtOurLastWrite), 459 RTTimeSpecGetNano(&pInodeInfo->ModificationTime), RTTimeSpecGetNano(&pObjInfo->ModificationTime) ); */ 460 fInvalidate = true; /* We haven't modified the file recently, so probably a host update. */ 461 } 462 } 463 pInodeInfo->ModificationTime = pObjInfo->ModificationTime; 464 465 if (fInvalidate) { 466 struct address_space *mapping = pInode->i_mapping; 467 if (mapping && mapping->nrpages > 0) { 468 SFLOGFLOW(("vbsf_update_inode: Invalidating the mapping (%s)\n", pInodeInfo->path->String.ach)); 469 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) 470 invalidate_mapping_pages(mapping, 0, ~(pgoff_t)0); 471 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41) 472 invalidate_inode_pages(mapping); 473 #else 474 invalidate_inode_pages(pInode); 475 #endif 476 } 477 } 478 } else 479 pInodeInfo->ModificationTime = pObjInfo->ModificationTime; 480 } 481 482 /* 483 * Done. 484 */ 432 485 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) 433 486 if (!fInodeLocked) … … 462 515 if (!ok_to_fail) 463 516 LogFunc(("VbglR0SfHostReqCreate on %s: file does not exist: %d (caller=%s)\n", 464 path->String.utf8, pReq->CreateParms.Result, caller));517 path->String.utf8, pReq->CreateParms.Result, caller)); 465 518 rc = -ENOENT; 466 519 } … … 1081 1134 * and ignore the dentry timestamp for positive entries. 1082 1135 */ 1083 //struct vbsf_inode_info *sf_i = VBSF_GET_INODE_INFO(pInode);1084 1136 unsigned long const cJiffiesAge = jiffies - vbsf_dentry_get_update_jiffies(dentry); 1085 1137 struct vbsf_super_info *pSuperInfo = VBSF_GET_SUPER_INFO(dentry->d_sb); … … 1088 1140 rc = 1; 1089 1141 } else if (!vbsf_inode_revalidate_worker(dentry, true /*fForced*/, false /*fInodeLocked*/)) { 1090 vbsf_dentry_set_update_jiffies(dentry, jiffies); /** @todo get jiffies from inode. */1142 vbsf_dentry_set_update_jiffies(dentry, jiffies); 1091 1143 SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 1\n", cJiffiesAge, pSuperInfo->cJiffiesDirCacheTTL)); 1092 1144 rc = 1; -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
r77953 r77959 352 352 { 353 353 int rc = 0; 354 /** @todo this needs sorting out between 3.19 and 4.11 */355 354 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 356 355 /* Each new shared folder map gets a new uint64_t identifier, 357 356 * allocated in sequence. We ASSUME the sequence will not wrap. */ 358 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)357 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) 359 358 static uint64_t s_u64Sequence = 0; 360 uint64_t u64CurrentSequence = ASMAtomicIncU64(&s_u64Sequence);361 # endif359 uint64_t idSeqMine = ASMAtomicIncU64(&s_u64Sequence); 360 # endif 362 361 struct backing_dev_info *bdi; 363 362 364 363 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) 365 rc = super_setup_bdi_name(sb, "vboxsf-%llu", (unsigned long long) u64CurrentSequence);364 rc = super_setup_bdi_name(sb, "vboxsf-%llu", (unsigned long long)idSeqMine); 366 365 if (!rc) 367 366 bdi = sb->s_bdi; … … 411 410 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) 412 411 if (!rc) 413 rc = bdi_register(&pSuperInfo->bdi, NULL, "vboxsf-%llu", (unsigned long long) u64CurrentSequence);412 rc = bdi_register(&pSuperInfo->bdi, NULL, "vboxsf-%llu", (unsigned long long)idSeqMine); 414 413 # endif /* >= 2.6.26 */ 415 414 # endif /* 4.11.0 > version >= 2.6.24 */ -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
r77953 r77959 221 221 RTTIMESPEC BirthTime; 222 222 223 /** @name Host modification detection stats. 224 * @{ */ 225 /** The raw modification time, for mapping invalidation purposes. */ 226 RTTIMESPEC ModificationTime; 227 /** Copy of ModificationTime from the last time we wrote to the the file. */ 228 RTTIMESPEC ModificationTimeAtOurLastWrite; 229 /** @} */ 230 223 231 /** handle valid if a file was created with vbsf_create_worker until it will 224 232 * be opened with vbsf_reg_open()
Note:
See TracChangeset
for help on using the changeset viewer.