VirtualBox

Changeset 77953 in vbox for trunk


Ignore:
Timestamp:
Mar 29, 2019 5:07:16 PM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Added more mount options: dcachettl=MILLISECONDS, inodettl=MILLISECONDS, dirbuf=BYTES and cache={default/strict|none|read|readwrite}. The readwrite cache mode isn't fully implemented yet (works same as 'read'). bugref:9172

Location:
trunk/src/VBox/Additions
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp

    r77492 r77953  
    376376    struct vbsf_mount_opts Opts =
    377377    {
     378        -1,                    /* ttl */
     379        -1,                    /* msDirCacheTTL */
     380        -1,                    /* msInodeTTL */
     381        0,                     /* cMaxIoPages */
     382        0,                     /* cbDirBuf */
     383        kVbsfCacheMode_Default,
    378384        0,                     /* uid */
    379385        (int)grp_vboxsf->gr_gid, /* gid */
    380         -1,                    /* ttl */
    381386        0770,                  /* dmode, owner and group "vboxsf" have full access */
    382387        0770,                  /* fmode, owner and group "vboxsf" have full access */
     
    391396        "\0",                  /* nls_name */
    392397        NULL,                  /* convertcp */
    393         0,                     /* cMaxIoPages */
    394398    };
    395399
     
    439443        mntinf.fmask = Opts.fmask;
    440444        mntinf.cMaxIoPages = Opts.cMaxIoPages;
    441         mntinf.tag[0] = '\0';
     445        mntinf.szTag[0] = '\0';
    442446
    443447        strcpy(mntinf.name, pszShareName);
     
    14731477    MntInfo.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2;
    14741478    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;
    14761485    MntInfo.uid          = MntOpts.uid   = 0;
    14771486    MntInfo.gid          = MntOpts.gid   = gidMount;
     
    14801489    MntInfo.dmask        = MntOpts.dmask = 0000;
    14811490    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));
    14841492    rc = RTStrCopy(MntInfo.name, sizeof(MntInfo.name), pEntry->pszName);
    14851493    if (RT_FAILURE(rc))
  • trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c

    r77859 r77953  
    9494}
    9595
     96static unsigned
     97safe_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
    96113static void
    97114process_mount_opts(const char *s, struct vbsf_mount_opts *opts)
     
    106123        HO_GID,
    107124        HO_TTL,
     125        HO_DENTRY_TTL,
     126        HO_INODE_TTL,
     127        HO_MAX_IO_PAGES,
     128        HO_DIR_BUF,
     129        HO_CACHE,
    108130        HO_DMODE,
    109131        HO_FMODE,
     
    113135        HO_IOCHARSET,
    114136        HO_CONVERTCP,
    115         HO_MAX_IO_PAGES,
    116137        HO_NOEXEC,
    117138        HO_EXEC,
     
    136157        {"uid",         HO_UID,             1, "default file owner user id"},
    137158        {"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"},
    139165        {"iocharset",   HO_IOCHARSET,       1, "i/o charset (default utf8)"},
    140166        {"convertcp",   HO_CONVERTCP,       1, "convert share name from given charset to utf8"},
     
    144170        {"dmask",       HO_DMASK,           1, "umask of directories"},
    145171        {"fmask",       HO_FMASK,           1, "umask of regular files"},
    146         {"maxiopages",  HO_MAX_IO_PAGES,    1, "max buffer size for I/O with host"},
    147172        {"noexec",      HO_NOEXEC,          0, NULL}, /* don't document these options directly here */
    148173        {"exec",        HO_EXEC,            0, NULL}, /* as they are well known and described in the */
     
    238263                        opts->remount = 1;
    239264                        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;
    240297                    case HO_UID:
    241298                        /** @todo convert string to id. */
     
    246303                        opts->gid = safe_atoi(val, val_len, 10);
    247304                        break;
    248                     case HO_TTL:
    249                         opts->ttl = safe_atoi(val, val_len, 10);
    250                         break;
    251305                    case HO_DMODE:
    252306                        opts->dmode = safe_atoi(val, val_len, 8);
     
    263317                    case HO_FMASK:
    264318                        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);
    268319                        break;
    269320                    case HO_IOCHARSET:
     
    360411           "     ro                 mount read only\n"
    361412           "     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");
    364435    printf("     dmode=MODE         override the mode of all directories to (octal) MODE\n"
    365436           "     fmode=MODE         override the mode of all regular files to (octal) MODE\n"
     
    389460    struct vbsf_mount_opts opts =
    390461    {
     462        -1,    /* ttl */
     463        -1,    /* msDirCacheTTL */
     464        -1,    /* msInodeTTL */
     465        0,     /* cMaxIoPages */
     466        0,     /* cbDirBuf */
     467        kVbsfCacheMode_Default,
    391468        0,     /* uid */
    392469        0,     /* gid */
    393         -1,    /* ttl */
    394470       ~0U,    /* dmode */
    395471       ~0U,    /* fmode*/
     
    404480        "\0",  /* nls_name */
    405481        NULL,  /* convertcp */
    406         0,     /* cMaxIoPages */
    407482    };
    408483    AssertCompile(sizeof(uid_t) == sizeof(int));
     
    415490    mntinf.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2;
    416491    mntinf.length       = sizeof(mntinf);
    417     mntinf.tag[0] = '\0';
     492    mntinf.szTag[0] = '\0';
    418493
    419494    if (getuid())
     
    486561        flags |= MS_REMOUNT;
    487562
     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
    488570    mntinf.uid   = opts.uid;
    489571    mntinf.gid   = opts.gid;
    490     mntinf.ttl   = opts.ttl;
    491572    mntinf.dmode = opts.dmode;
    492573    mntinf.fmode = opts.fmode;
    493574    mntinf.dmask = opts.dmask;
    494575    mntinf.fmask = opts.fmask;
    495     mntinf.cMaxIoPages = opts.cMaxIoPages;
    496576
    497577    /*
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r77951 r77953  
    526526
    527527
     528
    528529/*********************************************************************************************************************************
    529530*   Misc                                                                                                                         *
     
    539540DECLINLINE(bool) vbsf_should_use_cached_read(struct file *file, struct address_space *mapping, struct vbsf_super_info *pSuperInfo)
    540541{
     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);
    541549    return mapping
    542550        && 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);
    546552}
    547553
     
    549555
    550556/*********************************************************************************************************************************
    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)                                  *
    552558*********************************************************************************************************************************/
    553559
     
    580586    LOCK_PIPE(pPipe);
    581587}
     588
    582589
    583590/** Worker for vbsf_feed_pages_to_pipe that wakes up readers. */
     
    19011908    }
    19021909
     1910    /** @todo Implement the read-write caching mode. */
     1911
    19031912    /*
    19041913     * If there are active writable mappings, coordinate with any
     
    27462755        return 0;
    27472756
     2757    /** @todo Implement the read-write caching mode. */
     2758
    27482759    /*
    27492760     * Now now we reject async I/O requests.
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r77951 r77953  
    499499        if (   !fForced
    500500            && !sf_i->force_restat
    501             && jiffies - sf_i->ts_up_to_date < pSuperInfo->ttl)
     501            && jiffies - sf_i->ts_up_to_date < pSuperInfo->cJiffiesInodeTTL)
    502502            rc = 0;
    503503        else {
     
    611611        if (   !fForced
    612612            && !sf_i->force_restat
    613             && jiffies - sf_i->ts_up_to_date < pSuperInfo->ttl)
     613            && jiffies - sf_i->ts_up_to_date < pSuperInfo->cJiffiesInodeTTL)
    614614            err = 0;
    615615        else {
     
    10841084            unsigned long const     cJiffiesAge = jiffies - vbsf_dentry_get_update_jiffies(dentry);
    10851085            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));
    10881088                rc = 1;
    10891089            } else if (!vbsf_inode_revalidate_worker(dentry, true /*fForced*/, false /*fInodeLocked*/)) {
    10901090                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));
    10921092                rc = 1;
    10931093            } 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));
    10951095                rc = 0;
    10961096            }
     
    11181118                unsigned long const     cJiffiesAge = vbsf_dentry_get_update_jiffies(dentry) - jiffies;
    11191119                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));
    11221122                    rc = 1;
    11231123                } else {
     
    11251125                       have the caller kick it out. */
    11261126                    /** @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));
    11281128                    rc = 0;
    11291129                }
  • trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.c

    r77139 r77953  
    4545        return 1; /* Could not update mount table (failed to create memstream). */
    4646
     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    }
    4767    if (opts->uid)
    4868        fprintf(m, "uid=%d,", opts->uid);
    4969    if (opts->gid)
    5070        fprintf(m, "gid=%d,", opts->gid);
    51     if (opts->ttl)
    52         fprintf(m, "ttl=%d,", opts->ttl);
    5371    if (*opts->nls_name)
    5472        fprintf(m, "iocharset=%s,", opts->nls_name);
     
    5977    else
    6078        fprintf(m, "%s,", MNTOPT_RW);
    61     if (opts->cMaxIoPages)
    62         fprintf(m, "maxiopages=%u,", opts->cMaxIoPages);
    6379
    6480    fclose(m);
  • trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h

    r77526 r77953  
    4444#define VBSF_MOUNT_SIGNATURE_BYTE_2 '\375'
    4545
     46/**
     47 * VBox Linux Shared Folders VFS caching mode.
     48 */
     49enum 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 */
    4679struct vbsf_mount_info_new {
    4780    /**
     
    5285     * reject the old structure being passed.
    5386     */
    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;
    69132};
     133#ifdef AssertCompileSize
     134AssertCompileSize(struct vbsf_mount_info_new, 2*4 + MAX_HOST_NAME + MAX_NLS_NAME + 7*4 + 32 + 5*4);
     135#endif
    70136
     137/**
     138 * For use with the vbsfmount_complete() helper.
     139 */
    71140struct 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;
    72147    int uid;
    73148    int gid;
    74     int ttl;
    75149    int dmode;
    76150    int fmode;
     
    85159    char nls_name[MAX_NLS_NAME];
    86160    char *convertcp;
    87     uint32_t cMaxIoPages;
    88161};
    89162
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r77951 r77953  
    5858
    5959/*********************************************************************************************************************************
     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/*********************************************************************************************************************************
    6067*   Global Variables                                                                                                             *
    6168*********************************************************************************************************************************/
     
    8794static void vbsf_super_info_copy_remount_options(struct vbsf_super_info *pSuperInfo, struct vbsf_mount_info_new *info)
    8895{
    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     else
    95         pSuperInfo->ttl = msecs_to_jiffies(VBSF_DEFAULT_TTL_MS);
    96 
    9796    pSuperInfo->uid = info->uid;
    9897    pSuperInfo->gid = info->gid;
    9998
    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)) {
    101100        /* new fields */
    102101        pSuperInfo->dmode = info->dmode;
     
    110109
    111110    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';
    115114    } else {
    116         pSuperInfo->tag[0] = '\0';
     115        pSuperInfo->szTag[0] = '\0';
    117116    }
    118117
     
    124123       too hard as we'd have to retry with smaller requests when this
    125124       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;
    128126    if (   (unsigned)info->length >= sizeof(struct vbsf_mount_info_new)
    129127        && info->cMaxIoPages > 0) {
     
    135133    }
    136134
    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    }
    138200}
    139201
     
    698760 *
    699761 * 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.
    701763 */
    702764#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
     
    713775    struct vbsf_super_info *pSuperInfo = VBSF_GET_SUPER_INFO(sb);
    714776    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);
    718800        if (pSuperInfo->dmode != ~0)
    719801            seq_printf(m, ",dmode=0%o", pSuperInfo->dmode);
     
    724806        if (pSuperInfo->fmask != 0)
    725807            seq_printf(m, ",fmask=0%o", pSuperInfo->fmask);
    726         if (pSuperInfo->tag[0] != '\0') {
     808
     809        /* Misc: */
     810        if (pSuperInfo->szTag[0] != '\0') {
    727811            seq_puts(m, ",tag=");
    728             seq_escape(m, pSuperInfo->tag, " \t\n\\");
     812            seq_escape(m, pSuperInfo->szTag, " \t\n\\");
    729813        }
    730814    }
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r77951 r77953  
    130130    /** Set if the NLS table is UTF-8. */
    131131    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;
    137132    int uid;
    138133    int gid;
     
    143138    /** Maximum number of pages to allow in an I/O buffer with the host.
    144139     * This applies to read and write operations.  */
    145     uint32_t cMaxIoPages;
     140    uint32_t                cMaxIoPages;
    146141    /** 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;
    148149    /** Mount tag for VBoxService automounter.  @since 6.0 */
    149     char tag[32];
     150    char                    szTag[32];
    150151#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
    151152    /** The backing device info structure. */
    152153    struct backing_dev_info bdi;
    153154#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;
    154161};
    155162
     
    335342 * Sets the update-jiffies value for a dentry.
    336343 *
    337  * This is used together with vbsf_super_info::ttl to reduce re-validation of
    338  * dentry structures while walking.
     344 * This is used together with vbsf_super_info::cJiffiesDirCacheTTL to reduce
     345 * re-validation of dentry structures while walking.
    339346 *
    340347 * 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.

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