- Timestamp:
- Mar 29, 2019 5:07:16 PM (6 years ago)
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
r77492 r77953 376 376 struct vbsf_mount_opts Opts = 377 377 { 378 -1, /* ttl */ 379 -1, /* msDirCacheTTL */ 380 -1, /* msInodeTTL */ 381 0, /* cMaxIoPages */ 382 0, /* cbDirBuf */ 383 kVbsfCacheMode_Default, 378 384 0, /* uid */ 379 385 (int)grp_vboxsf->gr_gid, /* gid */ 380 -1, /* ttl */381 386 0770, /* dmode, owner and group "vboxsf" have full access */ 382 387 0770, /* fmode, owner and group "vboxsf" have full access */ … … 391 396 "\0", /* nls_name */ 392 397 NULL, /* convertcp */ 393 0, /* cMaxIoPages */394 398 }; 395 399 … … 439 443 mntinf.fmask = Opts.fmask; 440 444 mntinf.cMaxIoPages = Opts.cMaxIoPages; 441 mntinf. tag[0] = '\0';445 mntinf.szTag[0] = '\0'; 442 446 443 447 strcpy(mntinf.name, pszShareName); … … 1473 1477 MntInfo.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2; 1474 1478 MntInfo.length = sizeof(MntInfo); 1475 MntInfo.ttl = MntOpts.uid = -1; 1479 MntInfo.ttl = MntOpts.uid = -1 /*default*/; 1480 MntInfo.msDirCacheTTL= MntOpts.msDirCacheTTL = -1 /*default*/; 1481 MntInfo.msInodeTTL = MntOpts.msInodeTTL = -1 /*default*/; 1482 MntInfo.cMaxIoPages = MntOpts.cMaxIoPages = 0 /*default*/; 1483 MntInfo.cbDirBuf = MntOpts.cbDirBuf = 0 /*default*/; 1484 MntInfo.enmCacheMode = MntOpts.enmCacheMode = kVbsfCacheMode_Default; 1476 1485 MntInfo.uid = MntOpts.uid = 0; 1477 1486 MntInfo.gid = MntOpts.gid = gidMount; … … 1480 1489 MntInfo.dmask = MntOpts.dmask = 0000; 1481 1490 MntInfo.fmask = MntOpts.fmask = 0000; 1482 MntInfo.cMaxIoPages = MntOpts.cMaxIoPages = 0 /*default*/; 1483 memcpy(MntInfo.tag, g_szTag, sizeof(g_szTag)); AssertCompile(sizeof(MntInfo.tag) >= sizeof(g_szTag)); 1491 memcpy(MntInfo.szTag, g_szTag, sizeof(g_szTag)); AssertCompile(sizeof(MntInfo.szTag) >= sizeof(g_szTag)); 1484 1492 rc = RTStrCopy(MntInfo.name, sizeof(MntInfo.name), pEntry->pszName); 1485 1493 if (RT_FAILURE(rc)) -
trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
r77859 r77953 94 94 } 95 95 96 static unsigned 97 safe_atoiu(const char *s, size_t size, int base) 98 { 99 char *endptr; 100 long long int val = strtoll(s, &endptr, base); 101 102 if ( val < 0 103 || val > UINT_MAX 104 || endptr < s + size) 105 { 106 errno = ERANGE; 107 panic_err("could not convert %.*s to unsigned integer, result = %lld (%#llx)", 108 (int)size, s, val, val); 109 } 110 return (unsigned)val; 111 } 112 96 113 static void 97 114 process_mount_opts(const char *s, struct vbsf_mount_opts *opts) … … 106 123 HO_GID, 107 124 HO_TTL, 125 HO_DENTRY_TTL, 126 HO_INODE_TTL, 127 HO_MAX_IO_PAGES, 128 HO_DIR_BUF, 129 HO_CACHE, 108 130 HO_DMODE, 109 131 HO_FMODE, … … 113 135 HO_IOCHARSET, 114 136 HO_CONVERTCP, 115 HO_MAX_IO_PAGES,116 137 HO_NOEXEC, 117 138 HO_EXEC, … … 136 157 {"uid", HO_UID, 1, "default file owner user id"}, 137 158 {"gid", HO_GID, 1, "default file owner group id"}, 138 {"ttl", HO_TTL, 1, "time to live for dentry"}, 159 {"ttl", HO_TTL, 1, "time to live for dentries & inode info"}, 160 {"dcachettl", HO_DENTRY_TTL, 1, "time to live for dentries"}, 161 {"inodettl", HO_INODE_TTL, 1, "time to live for inode info"}, 162 {"maxiopages", HO_MAX_IO_PAGES, 1, "max buffer size for I/O with host"}, 163 {"dirbuf", HO_DIR_BUF, 1, "directory buffer size (0 for default)"}, 164 {"cache", HO_CACHE, 1, "cache mode: none, strict (default), read, readwrite"}, 139 165 {"iocharset", HO_IOCHARSET, 1, "i/o charset (default utf8)"}, 140 166 {"convertcp", HO_CONVERTCP, 1, "convert share name from given charset to utf8"}, … … 144 170 {"dmask", HO_DMASK, 1, "umask of directories"}, 145 171 {"fmask", HO_FMASK, 1, "umask of regular files"}, 146 {"maxiopages", HO_MAX_IO_PAGES, 1, "max buffer size for I/O with host"},147 172 {"noexec", HO_NOEXEC, 0, NULL}, /* don't document these options directly here */ 148 173 {"exec", HO_EXEC, 0, NULL}, /* as they are well known and described in the */ … … 238 263 opts->remount = 1; 239 264 break; 265 case HO_TTL: 266 opts->ttl = safe_atoi(val, val_len, 10); 267 break; 268 case HO_DENTRY_TTL: 269 opts->msDirCacheTTL = safe_atoi(val, val_len, 10); 270 break; 271 case HO_INODE_TTL: 272 opts->msInodeTTL = safe_atoi(val, val_len, 10); 273 break; 274 case HO_MAX_IO_PAGES: 275 opts->cMaxIoPages = safe_atoiu(val, val_len, 10); 276 break; 277 case HO_DIR_BUF: 278 opts->cbDirBuf = safe_atoiu(val, val_len, 10); 279 break; 280 case HO_CACHE: 281 #define IS_EQUAL(a_sz) (val_len == sizeof(a_sz) - 1U && strncmp(val, a_sz, sizeof(a_sz) - 1U) == 0) 282 if (IS_EQUAL("default")) 283 opts->enmCacheMode = kVbsfCacheMode_Default; 284 else if (IS_EQUAL("none")) 285 opts->enmCacheMode = kVbsfCacheMode_None; 286 else if (IS_EQUAL("strict")) 287 opts->enmCacheMode = kVbsfCacheMode_Strict; 288 else if (IS_EQUAL("read")) 289 opts->enmCacheMode = kVbsfCacheMode_Read; 290 else if (IS_EQUAL("readwrite")) 291 opts->enmCacheMode = kVbsfCacheMode_ReadWrite; 292 else 293 panic("invalid cache mode '%.*s'\n" 294 "Valid cache modes are: default, none, strict, read, readwrite\n", 295 (int)val_len, val); 296 break; 240 297 case HO_UID: 241 298 /** @todo convert string to id. */ … … 246 303 opts->gid = safe_atoi(val, val_len, 10); 247 304 break; 248 case HO_TTL:249 opts->ttl = safe_atoi(val, val_len, 10);250 break;251 305 case HO_DMODE: 252 306 opts->dmode = safe_atoi(val, val_len, 8); … … 263 317 case HO_FMASK: 264 318 opts->fmask = safe_atoi(val, val_len, 8); 265 break;266 case HO_MAX_IO_PAGES:267 opts->cMaxIoPages = safe_atoi(val, val_len, 10);268 319 break; 269 320 case HO_IOCHARSET: … … 360 411 " ro mount read only\n" 361 412 " uid=UID set the default file owner user id to UID\n" 362 " gid=GID set the default file owner group id to GID\n" 363 " ttl=TTL set the \"time to live\" to TID for the dentry\n"); 413 " gid=GID set the default file owner group id to GID\n"); 414 printf(" ttl=MILLIESECSONDS set the \"time to live\" for both the directory cache\n" 415 " and inode info. -1 for kernel default, 0 disables it.\n" 416 " dcachettl=MILLIES set the \"time to live\" for the directory cache,\n" 417 " overriding the 'ttl' option. Ignored if negative.\n" 418 " inodettl=MILLIES set the \"time to live\" for the inode information,\n" 419 " overriding the 'ttl' option. Ignored if negative.\n"); 420 printf(" maxiopages=PAGES set the max host I/O buffers size in pages. Uses\n" 421 " default if zero.\n" 422 " dirbuf=BYTES set the directory enumeration buffer size in bytes.\n" 423 " Uses default size if zero.\n"); 424 printf(" cache=MODE set the caching mode for the mount. Allowed values:\n" 425 " default: use the kernel default (strict)\n" 426 " none: no caching; may experience guest side\n" 427 " coherence issues between mmap and read.\n" 428 " strict: no caching, except for writably mapped\n" 429 " files (for guest side coherence)\n" 430 " read: read via the page cache; host changes\n" 431 " may be completely ignored\n" 432 " readwrite: read and write via the page cache; host\n" 433 " changes may be completely ignored and\n" 434 " guest changes takes a while to reach the host\n"); 364 435 printf(" dmode=MODE override the mode of all directories to (octal) MODE\n" 365 436 " fmode=MODE override the mode of all regular files to (octal) MODE\n" … … 389 460 struct vbsf_mount_opts opts = 390 461 { 462 -1, /* ttl */ 463 -1, /* msDirCacheTTL */ 464 -1, /* msInodeTTL */ 465 0, /* cMaxIoPages */ 466 0, /* cbDirBuf */ 467 kVbsfCacheMode_Default, 391 468 0, /* uid */ 392 469 0, /* gid */ 393 -1, /* ttl */394 470 ~0U, /* dmode */ 395 471 ~0U, /* fmode*/ … … 404 480 "\0", /* nls_name */ 405 481 NULL, /* convertcp */ 406 0, /* cMaxIoPages */407 482 }; 408 483 AssertCompile(sizeof(uid_t) == sizeof(int)); … … 415 490 mntinf.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2; 416 491 mntinf.length = sizeof(mntinf); 417 mntinf. tag[0] = '\0';492 mntinf.szTag[0] = '\0'; 418 493 419 494 if (getuid()) … … 486 561 flags |= MS_REMOUNT; 487 562 563 mntinf.ttl = opts.ttl; 564 mntinf.msDirCacheTTL = opts.msDirCacheTTL; 565 mntinf.msInodeTTL = opts.msInodeTTL; 566 mntinf.cMaxIoPages = opts.cMaxIoPages; 567 mntinf.cbDirBuf = opts.cbDirBuf; 568 mntinf.enmCacheMode = opts.enmCacheMode; 569 488 570 mntinf.uid = opts.uid; 489 571 mntinf.gid = opts.gid; 490 mntinf.ttl = opts.ttl;491 572 mntinf.dmode = opts.dmode; 492 573 mntinf.fmode = opts.fmode; 493 574 mntinf.dmask = opts.dmask; 494 575 mntinf.fmask = opts.fmask; 495 mntinf.cMaxIoPages = opts.cMaxIoPages;496 576 497 577 /* -
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r77951 r77953 526 526 527 527 528 528 529 /********************************************************************************************************************************* 529 530 * Misc * … … 539 540 DECLINLINE(bool) vbsf_should_use_cached_read(struct file *file, struct address_space *mapping, struct vbsf_super_info *pSuperInfo) 540 541 { 542 if ( (file->f_flags & O_DIRECT) 543 || pSuperInfo->enmCacheMode == kVbsfCacheMode_None) 544 return false; 545 if ( pSuperInfo->enmCacheMode == kVbsfCacheMode_Read 546 || pSuperInfo->enmCacheMode == kVbsfCacheMode_ReadWrite) 547 return true; 548 Assert(pSuperInfo->enmCacheMode == kVbsfCacheMode_Strict); 541 549 return mapping 542 550 && mapping->nrpages > 0 543 && mapping_writably_mapped(mapping) 544 && !(file->f_flags & O_DIRECT) 545 && 1 /** @todo make this behaviour configurable at mount time (pSuperInfo) */; 551 && mapping_writably_mapped(mapping); 546 552 } 547 553 … … 549 555 550 556 /********************************************************************************************************************************* 551 * Pipe / splice stuff for 2.6.17 >= linux < 2.6.31 (where no fallbacks were available)*557 * Pipe / splice stuff mainly for 2.6.17 >= linux < 2.6.31 (where no fallbacks were available) * 552 558 *********************************************************************************************************************************/ 553 559 … … 580 586 LOCK_PIPE(pPipe); 581 587 } 588 582 589 583 590 /** Worker for vbsf_feed_pages_to_pipe that wakes up readers. */ … … 1901 1908 } 1902 1909 1910 /** @todo Implement the read-write caching mode. */ 1911 1903 1912 /* 1904 1913 * If there are active writable mappings, coordinate with any … … 2746 2755 return 0; 2747 2756 2757 /** @todo Implement the read-write caching mode. */ 2758 2748 2759 /* 2749 2760 * Now now we reject async I/O requests. -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r77951 r77953 499 499 if ( !fForced 500 500 && !sf_i->force_restat 501 && jiffies - sf_i->ts_up_to_date < pSuperInfo-> ttl)501 && jiffies - sf_i->ts_up_to_date < pSuperInfo->cJiffiesInodeTTL) 502 502 rc = 0; 503 503 else { … … 611 611 if ( !fForced 612 612 && !sf_i->force_restat 613 && jiffies - sf_i->ts_up_to_date < pSuperInfo-> ttl)613 && jiffies - sf_i->ts_up_to_date < pSuperInfo->cJiffiesInodeTTL) 614 614 err = 0; 615 615 else { … … 1084 1084 unsigned long const cJiffiesAge = jiffies - vbsf_dentry_get_update_jiffies(dentry); 1085 1085 struct vbsf_super_info *pSuperInfo = VBSF_GET_SUPER_INFO(dentry->d_sb); 1086 if (cJiffiesAge < pSuperInfo-> ttl) {1087 SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> 1\n", cJiffiesAge, pSuperInfo-> ttl));1086 if (cJiffiesAge < pSuperInfo->cJiffiesDirCacheTTL) { 1087 SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> 1\n", cJiffiesAge, pSuperInfo->cJiffiesDirCacheTTL)); 1088 1088 rc = 1; 1089 1089 } else if (!vbsf_inode_revalidate_worker(dentry, true /*fForced*/, false /*fInodeLocked*/)) { 1090 1090 vbsf_dentry_set_update_jiffies(dentry, jiffies); /** @todo get jiffies from inode. */ 1091 SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 1\n", cJiffiesAge, pSuperInfo-> ttl));1091 SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 1\n", cJiffiesAge, pSuperInfo->cJiffiesDirCacheTTL)); 1092 1092 rc = 1; 1093 1093 } else { 1094 SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 0\n", cJiffiesAge, pSuperInfo-> ttl));1094 SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 0\n", cJiffiesAge, pSuperInfo->cJiffiesDirCacheTTL)); 1095 1095 rc = 0; 1096 1096 } … … 1118 1118 unsigned long const cJiffiesAge = vbsf_dentry_get_update_jiffies(dentry) - jiffies; 1119 1119 struct vbsf_super_info *pSuperInfo = VBSF_GET_SUPER_INFO(dentry->d_sb); 1120 if (cJiffiesAge < pSuperInfo-> ttl) {1121 SFLOGFLOW(("vbsf_dentry_revalidate: negative: age: %lu vs. TTL %lu -> 1\n", cJiffiesAge, pSuperInfo-> ttl));1120 if (cJiffiesAge < pSuperInfo->cJiffiesDirCacheTTL) { 1121 SFLOGFLOW(("vbsf_dentry_revalidate: negative: age: %lu vs. TTL %lu -> 1\n", cJiffiesAge, pSuperInfo->cJiffiesDirCacheTTL)); 1122 1122 rc = 1; 1123 1123 } else { … … 1125 1125 have the caller kick it out. */ 1126 1126 /** @todo stat the direntry and see if it exists now. */ 1127 SFLOGFLOW(("vbsf_dentry_revalidate: negative: age: %lu vs. TTL %lu -> 0\n", cJiffiesAge, pSuperInfo-> ttl));1127 SFLOGFLOW(("vbsf_dentry_revalidate: negative: age: %lu vs. TTL %lu -> 0\n", cJiffiesAge, pSuperInfo->cJiffiesDirCacheTTL)); 1128 1128 rc = 0; 1129 1129 } -
trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.c
r77139 r77953 45 45 return 1; /* Could not update mount table (failed to create memstream). */ 46 46 47 if (opts->ttl != -1) 48 fprintf(m, "ttl=%d,", opts->ttl); 49 if (opts->msDirCacheTTL >= 0) 50 fprintf(m, "dcachettl=%d,", opts->msDirCacheTTL); 51 if (opts->msInodeTTL >= 0) 52 fprintf(m, "inodettl=%d,", opts->msInodeTTL); 53 if (opts->cMaxIoPages) 54 fprintf(m, "maxiopages=%u,", opts->cMaxIoPages); 55 if (opts->cbDirBuf) 56 fprintf(m, "dirbuf=%u,", opts->cbDirBuf); 57 switch (opts->enmCacheMode) 58 { 59 default: 60 case kVbsfCacheMode_Default: 61 break; 62 case kVbsfCacheMode_None: fprintf(m, "cache=none,"); break; 63 case kVbsfCacheMode_Strict: fprintf(m, "cache=strict,"); break; 64 case kVbsfCacheMode_Read: fprintf(m, "cache=read,"); break; 65 case kVbsfCacheMode_ReadWrite: fprintf(m, "cache=readwrite,"); break; 66 } 47 67 if (opts->uid) 48 68 fprintf(m, "uid=%d,", opts->uid); 49 69 if (opts->gid) 50 70 fprintf(m, "gid=%d,", opts->gid); 51 if (opts->ttl)52 fprintf(m, "ttl=%d,", opts->ttl);53 71 if (*opts->nls_name) 54 72 fprintf(m, "iocharset=%s,", opts->nls_name); … … 59 77 else 60 78 fprintf(m, "%s,", MNTOPT_RW); 61 if (opts->cMaxIoPages)62 fprintf(m, "maxiopages=%u,", opts->cMaxIoPages);63 79 64 80 fclose(m); -
trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h
r77526 r77953 44 44 #define VBSF_MOUNT_SIGNATURE_BYTE_2 '\375' 45 45 46 /** 47 * VBox Linux Shared Folders VFS caching mode. 48 */ 49 enum vbsf_cache_mode { 50 /** Use the kernel modules default caching mode (kVbsfCacheMode_Strict). */ 51 kVbsfCacheMode_Default = 0, 52 /** No caching, go to the host for everything. This will have some minor 53 * coherency issues for memory mapping with unsynced dirty pages. */ 54 kVbsfCacheMode_None, 55 /** No caching, except for files with writable memory mappings. 56 * (Note to future: if we do oplock like stuff, it goes in here.) */ 57 kVbsfCacheMode_Strict, 58 /** Use page cache for reads. 59 * This improves guest performance for read intensive jobs, like compiling 60 * building. The flip side is that the guest may not see host modification in a 61 * timely manner and possibly update files with out-of-date cache information, 62 * as there exists no protocol for the host to notify the guest about file 63 * modifications. */ 64 kVbsfCacheMode_Read, 65 /** Use page cache for both reads and writes as far as that's possible. 66 * This is good for guest performance, but the price is that the guest possibly 67 * ignoring host changes and the host not seeing guest changes in a timely 68 * manner. */ 69 kVbsfCacheMode_ReadWrite, 70 /** End of valid values (exclusive). */ 71 kVbsfCacheMode_End, 72 /** Make sure the enum is sizeof(int32_t). */ 73 kVbsfCacheMode_32BitHack = 0x7fffffff 74 }; 75 76 /** 77 * VBox Linux Shared Folders VFS mount options. 78 */ 46 79 struct vbsf_mount_info_new { 47 80 /** … … 52 85 * reject the old structure being passed. 53 86 */ 54 char nullchar; 55 char signature[3]; /**< signature */ 56 int length; /**< length of the whole structure */ 57 char name[MAX_HOST_NAME]; /**< share name */ 58 char nls_name[MAX_NLS_NAME];/**< name of an I/O charset */ 59 int uid; /**< user ID for all entries, default 0=root */ 60 int gid; /**< group ID for all entries, default 0=root */ 61 int ttl; /**< directory entry and inode time to live in milliseconds. 62 * -1 for kernel default, 0 to disable caching. */ 63 int dmode; /**< mode for directories if != 0xffffffff */ 64 int fmode; /**< mode for regular files if != 0xffffffff */ 65 int dmask; /**< umask applied to directories */ 66 int fmask; /**< umask applied to regular files */ 67 char tag[32]; /**< Mount tag for VBoxService automounter. @since 6.0 */ 68 uint32_t cMaxIoPages; /**< Max pages to read & write at a time. @since 6.0.6 */ 87 char nullchar; 88 /** Signature */ 89 char signature[3]; 90 /** Length of the whole structure */ 91 int length; 92 /** Share name */ 93 char name[MAX_HOST_NAME]; 94 /** Name of an I/O charset */ 95 char nls_name[MAX_NLS_NAME]; 96 /** User ID for all entries, default 0=root */ 97 int uid; 98 /** Group ID for all entries, default 0=root */ 99 int gid; 100 /** Directory entry and inode time to live in milliseconds. 101 * -1 for kernel default, 0 to disable caching. 102 * @sa vbsf_mount_info_new::msDirCacheTTL, vbsf_mount_info_new::msInodeTTL */ 103 int ttl; 104 /** Mode for directories if != -1. */ 105 int dmode; 106 /** Mode for regular files if != -1. */ 107 int fmode; 108 /** umask applied to directories */ 109 int dmask; 110 /** umask applied to regular files */ 111 int fmask; 112 /** Mount tag for VBoxService automounter. 113 * @since 6.0.0 */ 114 char szTag[32]; 115 /** Max pages to read & write at a time. 116 * @since 6.0.6 */ 117 uint32_t cMaxIoPages; 118 /** The directory content buffer size. Set to 0 for kernel module default. 119 * Larger value reduces the number of host calls on large directories. */ 120 uint32_t cbDirBuf; 121 /** The time to live for directory entries (in milliseconds). @a ttl is used 122 * if negative. 123 * @since 6.0.6 */ 124 int32_t msDirCacheTTL; 125 /** The time to live for inode information (in milliseconds). @a ttl is used 126 * if negative. 127 * @since 6.0.6 */ 128 int32_t msInodeTTL; 129 /** The cache and coherency mode. 130 * @since 6.0.6 */ 131 enum vbsf_cache_mode enmCacheMode; 69 132 }; 133 #ifdef AssertCompileSize 134 AssertCompileSize(struct vbsf_mount_info_new, 2*4 + MAX_HOST_NAME + MAX_NLS_NAME + 7*4 + 32 + 5*4); 135 #endif 70 136 137 /** 138 * For use with the vbsfmount_complete() helper. 139 */ 71 140 struct vbsf_mount_opts { 141 int ttl; 142 int32_t msDirCacheTTL; 143 int32_t msInodeTTL; 144 uint32_t cMaxIoPages; 145 uint32_t cbDirBuf; 146 enum vbsf_cache_mode enmCacheMode; 72 147 int uid; 73 148 int gid; 74 int ttl;75 149 int dmode; 76 150 int fmode; … … 85 159 char nls_name[MAX_NLS_NAME]; 86 160 char *convertcp; 87 uint32_t cMaxIoPages;88 161 }; 89 162 -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
r77951 r77953 58 58 59 59 /********************************************************************************************************************************* 60 * Defined Constants And Macros * 61 *********************************************************************************************************************************/ 62 #define VBSF_DEFAULT_MAX_IO_PAGES RT_MIN(_16K / sizeof(RTGCPHYS64) /* => 8MB buffer */, VMMDEV_MAX_HGCM_DATA_SIZE >> PAGE_SHIFT) 63 #define VBSF_DEFAULT_DIR_BUF_SIZE _64K 64 65 66 /********************************************************************************************************************************* 60 67 * Global Variables * 61 68 *********************************************************************************************************************************/ … … 87 94 static void vbsf_super_info_copy_remount_options(struct vbsf_super_info *pSuperInfo, struct vbsf_mount_info_new *info) 88 95 { 89 pSuperInfo->ttl_msec = info->ttl;90 if (info->ttl > 0)91 pSuperInfo->ttl = msecs_to_jiffies(info->ttl);92 else if (info->ttl == 0 || info->ttl != -1)93 pSuperInfo->ttl = pSuperInfo->ttl_msec = 0;94 else95 pSuperInfo->ttl = msecs_to_jiffies(VBSF_DEFAULT_TTL_MS);96 97 96 pSuperInfo->uid = info->uid; 98 97 pSuperInfo->gid = info->gid; 99 98 100 if ((unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, tag)) {99 if ((unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, szTag)) { 101 100 /* new fields */ 102 101 pSuperInfo->dmode = info->dmode; … … 110 109 111 110 if ((unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, cMaxIoPages)) { 112 AssertCompile(sizeof(pSuperInfo-> tag) >= sizeof(info->tag));113 memcpy(pSuperInfo-> tag, info->tag, sizeof(info->tag));114 pSuperInfo-> tag[sizeof(pSuperInfo->tag) - 1] = '\0';111 AssertCompile(sizeof(pSuperInfo->szTag) >= sizeof(info->szTag)); 112 memcpy(pSuperInfo->szTag, info->szTag, sizeof(info->szTag)); 113 pSuperInfo->szTag[sizeof(pSuperInfo->szTag) - 1] = '\0'; 115 114 } else { 116 pSuperInfo-> tag[0] = '\0';115 pSuperInfo->szTag[0] = '\0'; 117 116 } 118 117 … … 124 123 too hard as we'd have to retry with smaller requests when this 125 124 happens, which isn't too efficient. */ 126 pSuperInfo->cMaxIoPages = RT_MIN(_16K / sizeof(RTGCPHYS64) /* => 8MB buffer */, 127 VMMDEV_MAX_HGCM_DATA_SIZE >> PAGE_SHIFT); 125 pSuperInfo->cMaxIoPages = VBSF_DEFAULT_MAX_IO_PAGES; 128 126 if ( (unsigned)info->length >= sizeof(struct vbsf_mount_info_new) 129 127 && info->cMaxIoPages > 0) { … … 135 133 } 136 134 137 pSuperInfo->cbDirBuf = _64K; /** @todo make configurable. */ 135 pSuperInfo->cbDirBuf = VBSF_DEFAULT_DIR_BUF_SIZE; 136 if ( (unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, cbDirBuf) 137 && info->cbDirBuf > 0) { 138 if (info->cbDirBuf <= _16M) 139 pSuperInfo->cbDirBuf = RT_ALIGN_32(info->cbDirBuf, PAGE_SIZE); 140 else 141 printk(KERN_WARNING "vboxsf: max directory buffer size (%#x) is out of range, using default (%#x) instead.\n", 142 info->cMaxIoPages, pSuperInfo->cMaxIoPages); 143 } 144 145 /* 146 * TTLs. 147 */ 148 pSuperInfo->msTTL = info->ttl; 149 if (info->ttl > 0) 150 pSuperInfo->cJiffiesDirCacheTTL = msecs_to_jiffies(info->ttl); 151 else if (info->ttl == 0 || info->ttl != -1) 152 pSuperInfo->cJiffiesDirCacheTTL = pSuperInfo->msTTL = 0; 153 else 154 pSuperInfo->cJiffiesDirCacheTTL = msecs_to_jiffies(VBSF_DEFAULT_TTL_MS); 155 pSuperInfo->cJiffiesInodeTTL = pSuperInfo->cJiffiesDirCacheTTL; 156 157 pSuperInfo->msDirCacheTTL = -1; 158 if ( (unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, msDirCacheTTL) 159 && info->msDirCacheTTL >= 0) { 160 if (info->msDirCacheTTL > 0) { 161 pSuperInfo->msDirCacheTTL = info->msDirCacheTTL; 162 pSuperInfo->cJiffiesDirCacheTTL = msecs_to_jiffies(info->msDirCacheTTL); 163 } else { 164 pSuperInfo->msDirCacheTTL = 0; 165 pSuperInfo->cJiffiesDirCacheTTL = 0; 166 } 167 } 168 169 pSuperInfo->msInodeTTL = -1; 170 if ( (unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, msInodeTTL) 171 && info->msInodeTTL >= 0) { 172 if (info->msInodeTTL > 0) { 173 pSuperInfo->msInodeTTL = info->msInodeTTL; 174 pSuperInfo->cJiffiesInodeTTL = msecs_to_jiffies(info->msInodeTTL); 175 } else { 176 pSuperInfo->msInodeTTL = 0; 177 pSuperInfo->cJiffiesInodeTTL = 0; 178 } 179 } 180 181 /* 182 * Caching. 183 */ 184 pSuperInfo->enmCacheMode = kVbsfCacheMode_Strict; 185 if ((unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, enmCacheMode)) { 186 switch (info->enmCacheMode) { 187 case kVbsfCacheMode_Default: 188 case kVbsfCacheMode_Strict: 189 break; 190 case kVbsfCacheMode_None: 191 case kVbsfCacheMode_Read: 192 case kVbsfCacheMode_ReadWrite: 193 pSuperInfo->enmCacheMode = info->enmCacheMode; 194 break; 195 default: 196 printk(KERN_WARNING "vboxsf: cache mode (%#x) is out of range, using default instead.\n", info->enmCacheMode); 197 break; 198 } 199 } 138 200 } 139 201 … … 698 760 * 699 761 * This is needed by the VBoxService automounter in order for it to pick up 700 * the the ' tag' option value it sets on its mount.762 * the the 'szTag' option value it sets on its mount. 701 763 */ 702 764 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) … … 713 775 struct vbsf_super_info *pSuperInfo = VBSF_GET_SUPER_INFO(sb); 714 776 if (pSuperInfo) { 715 seq_printf(m, ",uid=%u,gid=%u,ttl=%d,maxiopages=%u,iocharset=%s", 716 pSuperInfo->uid, pSuperInfo->gid, pSuperInfo->ttl_msec, pSuperInfo->cMaxIoPages, 717 pSuperInfo->nls ? pSuperInfo->nls->charset : "utf8"); 777 /* Performance related options: */ 778 if (pSuperInfo->msTTL != -1) 779 seq_printf(m, ",ttl=%d", pSuperInfo->msTTL); 780 if (pSuperInfo->msDirCacheTTL >= 0) 781 seq_printf(m, ",dcachettl=%d", pSuperInfo->msDirCacheTTL); 782 if (pSuperInfo->msInodeTTL >= 0) 783 seq_printf(m, ",inodettl=%d", pSuperInfo->msInodeTTL); 784 if (pSuperInfo->cMaxIoPages != VBSF_DEFAULT_MAX_IO_PAGES) 785 seq_printf(m, ",maxiopages=%u", pSuperInfo->cMaxIoPages); 786 if (pSuperInfo->cbDirBuf != VBSF_DEFAULT_DIR_BUF_SIZE) 787 seq_printf(m, ",dirbuf=%u", pSuperInfo->cbDirBuf); 788 switch (pSuperInfo->enmCacheMode) { 789 default: AssertFailed(); 790 case kVbsfCacheMode_Strict: 791 break; 792 case kVbsfCacheMode_None: seq_puts(m, ",cache=none"); break; 793 case kVbsfCacheMode_Read: seq_puts(m, ",cache=read"); break; 794 case kVbsfCacheMode_ReadWrite: seq_puts(m, ",cache=readwrite"); break; 795 } 796 797 /* Attributes and NLS: */ 798 seq_printf(m, ",iocharset=%s", pSuperInfo->nls ? pSuperInfo->nls->charset : "utf8"); 799 seq_printf(m, ",uid=%u,gid=%u", pSuperInfo->uid, pSuperInfo->gid); 718 800 if (pSuperInfo->dmode != ~0) 719 801 seq_printf(m, ",dmode=0%o", pSuperInfo->dmode); … … 724 806 if (pSuperInfo->fmask != 0) 725 807 seq_printf(m, ",fmask=0%o", pSuperInfo->fmask); 726 if (pSuperInfo->tag[0] != '\0') { 808 809 /* Misc: */ 810 if (pSuperInfo->szTag[0] != '\0') { 727 811 seq_puts(m, ",tag="); 728 seq_escape(m, pSuperInfo-> tag, " \t\n\\");812 seq_escape(m, pSuperInfo->szTag, " \t\n\\"); 729 813 } 730 814 } -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
r77951 r77953 130 130 /** Set if the NLS table is UTF-8. */ 131 131 bool fNlsIsUtf8; 132 /** time-to-live value for direntry and inode info in jiffies.133 * Zero == disabled. */134 unsigned long ttl;135 /** The mount option value for /proc/mounts. */136 int ttl_msec;137 132 int uid; 138 133 int gid; … … 143 138 /** Maximum number of pages to allow in an I/O buffer with the host. 144 139 * This applies to read and write operations. */ 145 uint32_t cMaxIoPages;140 uint32_t cMaxIoPages; 146 141 /** The default directory buffer size. */ 147 uint32_t cbDirBuf; 142 uint32_t cbDirBuf; 143 /** The time to live for directory entries in jiffies, zero if disabled. */ 144 uint32_t cJiffiesDirCacheTTL; 145 /** The time to live for inode information in jiffies, zero if disabled. */ 146 uint32_t cJiffiesInodeTTL; 147 /** The cache and coherency mode. */ 148 enum vbsf_cache_mode enmCacheMode; 148 149 /** Mount tag for VBoxService automounter. @since 6.0 */ 149 char tag[32];150 char szTag[32]; 150 151 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) 151 152 /** The backing device info structure. */ 152 153 struct backing_dev_info bdi; 153 154 #endif 155 /** The mount option value for /proc/mounts. */ 156 int32_t msTTL; 157 /** The time to live for directory entries in milliseconds, for /proc/mounts. */ 158 int32_t msDirCacheTTL; 159 /** The time to live for inode information in milliseconds, for /proc/mounts. */ 160 int32_t msInodeTTL; 154 161 }; 155 162 … … 335 342 * Sets the update-jiffies value for a dentry. 336 343 * 337 * This is used together with vbsf_super_info:: ttl to reduce re-validation of338 * dentry structures while walking.344 * This is used together with vbsf_super_info::cJiffiesDirCacheTTL to reduce 345 * re-validation of dentry structures while walking. 339 346 * 340 347 * This used to be living in d_time, but since 4.9.0 that seems to have become
Note:
See TracChangeset
for help on using the changeset viewer.