VirtualBox

Changeset 77492 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Feb 28, 2019 1:55:50 AM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Default dentry/stat TTL to 200 ms as on solaris. bugref:9172

  • Use the same stat/direntry TTL default value as we do on solaris (200 ms).
  • Changed the ttl=xxx mount option to be milliseconds rather than jiffies.
  • Force inode restat in sf_setattr() as a temp workaround for issue when TTL is non-zero (see older @todo in code).
  • Have separate dentry and inode update jiffies.
  • Reworked sf_dentry_revalidate and made it avoid restatting inodes more aggressively.
  • Extend TTL of parent dentry after successful opens and creation (does not extend to inodes, of course).
  • Stop using dentry::d_time like the rest of the file systems did around 4.9.0 (kernels back to 2.4.0 never seem to touch this from what I can tell, it was an file system internal field).
  • Since we only have one set of dentry ops, set super_block::s_d_op rather than calling d_set_d_op().
Location:
trunk/src/VBox/Additions
Files:
8 edited

Legend:

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

    r77138 r77492  
    378378        0,                     /* uid */
    379379        (int)grp_vboxsf->gr_gid, /* gid */
    380         0,                     /* ttl */
     380        -1,                    /* ttl */
    381381        0770,                  /* dmode, owner and group "vboxsf" have full access */
    382382        0770,                  /* fmode, owner and group "vboxsf" have full access */
     
    14731473    MntInfo.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2;
    14741474    MntInfo.length       = sizeof(MntInfo);
     1475    MntInfo.ttl          = MntOpts.uid   = -1;
    14751476    MntInfo.uid          = MntOpts.uid   = 0;
    14761477    MntInfo.gid          = MntOpts.gid   = gidMount;
  • trunk/src/VBox/Additions/linux/sharedfolders/dirops.c

    r77458 r77492  
    414414                goto fail0;
    415415
     416        /** @todo call host directly and avoid unnecessary copying here. */
    416417        err = sf_stat(__func__, sf_g, path, &fsinfo, 1);
    417418        if (err) {
     
    449450                }
    450451
     452                sf_new_i->path = path;
    451453                SET_INODE_INFO(inode, sf_new_i);
    452                 sf_init_inode(sf_g, inode, &fsinfo);
    453                 sf_new_i->path = path;
     454                sf_init_inode(inode, sf_new_i, &fsinfo, sf_g);
    454455
    455456#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
    456457                unlock_new_inode(inode);
    457458#endif
    458         }
    459 
    460         sf_i->force_restat = 0;
    461         dentry->d_time = jiffies;
     459                sf_dentry_chain_increase_parent_ttl(dentry);
     460        }
     461
     462        //sf_i->force_restat = 0; /** @todo r=bird: This looks like confusion. */
     463
     464        sf_dentry_set_update_jiffies(dentry, jiffies);
    462465#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
    463         d_set_d_op(dentry, &sf_dentry_ops);
     466        Assert(dentry->d_op == &sf_dentry_ops); /* (taken from the superblock) */
    464467#else
    465468        dentry->d_op = &sf_dentry_ops;
     
    522525        }
    523526
    524         sf_init_inode(sf_g, inode, info);
     527        sf_init_inode(inode, sf_new_i, info, sf_g);
    525528
    526529        sf_new_i->path = path;
     
    528531        sf_new_i->force_restat = 1;
    529532        sf_new_i->force_reread = 0;
     533        sf_new_i->ts_up_to_date = jiffies - INT_MAX / 2;
    530534#ifdef VBOX_STRICT
    531535        sf_new_i->u32Magic = SF_INODE_INFO_MAGIC;
     
    622626        }
    623627
     628        sf_dentry_chain_increase_parent_ttl(dentry);
     629
    624630        err = sf_instantiate(parent, dentry, path, &pCreateParms->Info,
    625631                             fDirectory ? SHFL_HANDLE_NIL : pCreateParms->Handle);
     
    642648        }
    643649
    644         sf_i->force_restat = 1;
     650        sf_i->force_restat = 1; /**< @todo r=bird: Why?!? */
    645651        VbglR0PhysHeapFree(pReq);
    646652        return 0;
     
    681687#endif
    682688{
     689/** @todo @a nd (struct nameidata) contains intent with partial open flags for
     690 *        2.6.0-3.5.999.  In 3.6.0 atomic_open was introduced and stuff
     691 *        changed (investigate)... */
    683692        TRACE();
    684693        return sf_create_aux(parent, dentry, mode, 0 /*fDirectory*/);
     
    716725        int rc, err;
    717726        struct sf_glob_info *sf_g = GET_GLOB_INFO(parent->i_sb);
    718         struct sf_inode_info *sf_i = GET_INODE_INFO(parent);
     727        struct sf_inode_info *sf_parent_i = GET_INODE_INFO(parent);
    719728        SHFLSTRING *path;
    720729
     
    722731        BUG_ON(!sf_g);
    723732
    724         err = sf_path_from_dentry(__func__, sf_g, sf_i, dentry, &path);
     733        err = sf_path_from_dentry(__func__, sf_g, sf_parent_i, dentry, &path);
    725734        if (!err) {
    726735                VBOXSFREMOVEREQ *pReq = (VBOXSFREMOVEREQ *)VbglR0PhysHeapAlloc(RT_UOFFSETOF(VBOXSFREMOVEREQ, StrPath.String)
     
    733742
    734743                        rc = VbglR0SfHostReqRemove(sf_g->map.root, pReq, fFlags);
     744
     745                        if (dentry->d_inode) {
     746                                struct sf_inode_info *sf_i = GET_INODE_INFO(dentry->d_inode);
     747                                sf_i->force_restat = 1;
     748                                sf_i->force_reread = 1;
     749                        }
     750
    735751                        if (RT_SUCCESS(rc)) {
    736752                                /* directory access/change time changed */
    737                                 sf_i->force_restat = 1;
     753                                sf_parent_i->force_restat = 1;
    738754                                /* directory content changed */
    739                                 sf_i->force_reread = 1;
     755                                sf_parent_i->force_reread = 1;
    740756
    741757                                err = 0;
     758                        } else if (rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND) {
     759                                LogFunc(("(%d): VbglR0SfRemove(%s) failed rc=%Rrc; calling d_drop on %p\n",
     760                                         fDirectory, path->String.utf8, rc, dentry));
     761                                d_drop(dentry);
    742762                        } else {
    743                                 LogFunc(("(%d): VbglR0SfRemove(%s) failed rc=%Rrc\n",
    744                                          fDirectory, path->String.utf8, rc));
     763                                LogFunc(("(%d): VbglR0SfRemove(%s) failed rc=%Rrc\n", fDirectory, path->String.utf8, rc));
    745764                                err = -RTErrConvertToErrno(rc);
    746765                        }
  • trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c

    r77139 r77492  
    387387        0,     /* uid */
    388388        0,     /* gid */
    389         0,     /* ttl */
     389        -1,    /* ttl */
    390390       ~0U,    /* dmode */
    391391       ~0U,    /* fmode*/
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r77458 r77492  
    973973        struct sf_inode_info *sf_i = GET_INODE_INFO(inode);
    974974        struct sf_reg_info *sf_r;
     975#if   LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
     976        struct dentry *dentry = file_dentry(file);
     977#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     978        struct dentry *dentry = file->f_path.dentry;
     979#else
     980        struct dentry *dentry = file->f_dentry;
     981#endif
    975982        VBOXSFCREATEREQ *pReq;
    976983        SHFLCREATEPARMS *pCreateParms;  /* temp glue */
     
    10821089        }
    10831090
    1084         if (pCreateParms->Handle == SHFL_HANDLE_NIL) {
     1091        if (pCreateParms->Handle != SHFL_HANDLE_NIL) {
     1092                sf_dentry_chain_increase_ttl(dentry);
     1093                rc_linux = 0;
     1094        } else {
    10851095                switch (pCreateParms->Result) {
    10861096                case SHFL_PATH_NOT_FOUND:
     1097                        rc_linux = -ENOENT;
     1098                        break;
    10871099                case SHFL_FILE_NOT_FOUND:
     1100                        /** @todo sf_dentry_increase_parent_ttl(file->f_dentry); if we can trust it.  */
    10881101                        rc_linux = -ENOENT;
    10891102                        break;
    10901103                case SHFL_FILE_EXISTS:
     1104                        sf_dentry_chain_increase_ttl(dentry);
    10911105                        rc_linux = -EEXIST;
    10921106                        break;
    10931107                default:
     1108                        sf_dentry_chain_increase_parent_ttl(dentry);
     1109                        rc_linux = 0;
    10941110                        break;
    10951111                }
    10961112        }
    10971113
    1098         sf_i->force_restat = 1;
     1114        sf_i->force_restat = 1; /** @todo Why?!? */
    10991115        sf_r->Handle.hHost = pCreateParms->Handle;
    11001116        file->private_data = sf_r;
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r77461 r77492  
    8787
    8888/* set [inode] attributes based on [info], uid/gid based on [sf_g] */
    89 void sf_init_inode(struct sf_glob_info *sf_g, struct inode *inode,
    90                    PSHFLFSOBJINFO info)
    91 {
    92         PSHFLFSOBJATTR attr;
     89void sf_init_inode(struct inode *inode, struct sf_inode_info *sf_i, PSHFLFSOBJINFO info, struct sf_glob_info *sf_g)
     90{
     91        PCSHFLFSOBJATTR attr = &info->Attr;
    9392        int mode;
    9493
    9594        TRACE();
    9695
    97         attr = &info->Attr;
     96        sf_i->ts_up_to_date = jiffies;
     97        sf_i->force_restat  = 0;
    9898
    9999#define mode_set(r) attr->fMode & (RTFS_UNIX_##r) ? (S_##r) : 0;
     
    185185 * Update the inode with new object info from the host.
    186186 */
    187 void sf_update_inode(struct inode *pInode, PSHFLFSOBJINFO pObjInfo, struct sf_glob_info *sf_g)
     187void sf_update_inode(struct inode *pInode, struct sf_inode_info *pInfoInfo, PSHFLFSOBJINFO pObjInfo, struct sf_glob_info *sf_g)
    188188{
    189189        /** @todo  make lock/rcu safe.  */
    190         sf_init_inode(sf_g, pInode, pObjInfo);
     190        sf_init_inode(pInode, pInfoInfo, pObjInfo, sf_g);
    191191}
    192192
     
    256256                 */
    257257                if (   !sf_i->force_restat
    258                     && jiffies - dentry->d_time < sf_g->ttl)
     258                    && jiffies - sf_i->ts_up_to_date < sf_g->ttl)
    259259                        rc = 0;
    260260                else {
     
    274274                                                 * Reset the TTL and copy the info over into the inode structure.
    275275                                                 */
    276                                                 dentry->d_time = jiffies;
    277                                                 sf_update_inode(pInode, &pReq->ObjInfo, sf_g);
     276                                                sf_update_inode(pInode, sf_i, &pReq->ObjInfo, sf_g);
    278277                                        } else if (rc == VERR_INVALID_HANDLE) {
    279278                                                rc = -ENOENT; /* Restore.*/
     
    303302                                                         * Reset the TTL and copy the info over into the inode structure.
    304303                                                         */
    305                                                         dentry->d_time = jiffies;
    306                                                         sf_update_inode(pInode, &pReq->CreateParms.Info, sf_g);
     304                                                        sf_update_inode(pInode, sf_i, &pReq->CreateParms.Info, sf_g);
    307305                                                        rc = 0;
    308306                                                } else {
     
    350348                if (   !fForced
    351349                    && !sf_i->force_restat
    352                     && jiffies - dentry->d_time < sf_g->ttl)
     350                    && jiffies - sf_i->ts_up_to_date <= sf_g->ttl)
    353351                        err = 0;
    354352                else {
     
    364362                                         * Reset the TTL and copy the info over into the inode structure.
    365363                                         */
    366                                         dentry->d_time = jiffies;
    367                                         sf_update_inode(pInode, &pReq->ObjInfo, sf_g);
     364                                        sf_update_inode(pInode, sf_i, &pReq->ObjInfo, sf_g);
    368365                                } else {
    369366                                        LogFunc(("VbglR0SfHostReqQueryObjInfo failed on %#RX64: %Rrc\n", hHostFile, err));
     
    376373        }
    377374        return err;
    378 }
    379 
    380 /* this is called during name resolution/lookup to check if the
    381    [dentry] in the cache is still valid. the job is handled by
    382    [sf_inode_revalidate] */
    383 static int
    384 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
    385 sf_dentry_revalidate(struct dentry *dentry, unsigned flags)
    386 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    387 sf_dentry_revalidate(struct dentry *dentry, struct nameidata *nd)
    388 #else
    389 sf_dentry_revalidate(struct dentry *dentry, int flags)
    390 #endif
    391 {
    392         TRACE();
    393 
    394 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
    395         if (flags & LOOKUP_RCU)
    396                 return -ECHILD;
    397 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
    398         /* see Documentation/filesystems/vfs.txt */
    399         if (nd && nd->flags & LOOKUP_RCU)
    400                 return -ECHILD;
    401 #endif
    402 
    403         if (sf_inode_revalidate(dentry))
    404                 return 0;
    405 
    406         return 1;
    407375}
    408376
     
    585553         * dentry and all its parent entries are valid and could touch their timestamps
    586554         * extending their TTL (CIFS does that). */
     555        sf_i->force_restat = 1; /* temp fix */
    587556        return sf_inode_revalidate(dentry);
    588557
     
    1001970}
    1002971
     972
     973/* this is called during name resolution/lookup to check if the
     974   [dentry] in the cache is still valid. the job is handled by
     975   [sf_inode_revalidate] */
     976static int
     977#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
     978sf_dentry_revalidate(struct dentry *dentry, unsigned flags)
     979#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     980sf_dentry_revalidate(struct dentry *dentry, struct nameidata *nd)
     981#else
     982sf_dentry_revalidate(struct dentry *dentry, int flags)
     983#endif
     984{
     985#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
     986        int const flags = nd ? nd->flags : 0;
     987#endif
     988
     989        int rc;
     990
     991        Assert(dentry);
     992        SFLOGFLOW(("sf_dentry_revalidate: %p %#x %s\n", dentry, flags, dentry->d_inode ? GET_INODE_INFO(dentry->d_inode)->path->String.ach : "<negative>"));
     993
     994        /*
     995         * See Documentation/filesystems/vfs.txt why we skip LOOKUP_RCU.
     996         *
     997         * Also recommended: https://lwn.net/Articles/649115/
     998         *                   https://lwn.net/Articles/649729/
     999         *                   https://lwn.net/Articles/650786/
     1000         *
     1001         */
     1002#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
     1003        if (flags & LOOKUP_RCU) {
     1004                rc = -ECHILD;
     1005                SFLOGFLOW(("sf_dentry_revalidate: RCU -> -ECHILD\n"));
     1006        } else
     1007#endif
     1008        {
     1009                /*
     1010                 * Do we have an inode or not?  If not it's probably a negative cache
     1011                 * entry, otherwise most likely a positive one.
     1012                 */
     1013                struct inode *pInode = dentry->d_inode;
     1014                if (pInode) {
     1015                        /*
     1016                         * Positive entry.
     1017                         *
     1018                         * Note! We're more aggressive here than other remote file systems,
     1019                         *       current (4.19) CIFS will for instance revalidate the inode
     1020                         *       and ignore the dentry timestamp for positive entries.
     1021                         */
     1022                        //struct sf_inode_info *sf_i = GET_INODE_INFO(pInode);
     1023                        unsigned long const  cJiffiesAge = sf_dentry_get_update_jiffies(dentry) - jiffies;
     1024                        struct sf_glob_info *sf_g        = GET_GLOB_INFO(dentry->d_sb);
     1025                        if (cJiffiesAge <= sf_g->ttl) {
     1026                                SFLOGFLOW(("sf_dentry_revalidate: age: %lu vs. TTL %lu -> 1\n", cJiffiesAge, sf_g->ttl));
     1027                                rc = 1;
     1028                        } else if (!sf_inode_revalidate(dentry /** @todo force */)) {
     1029                                sf_dentry_set_update_jiffies(dentry, jiffies); /** @todo get jiffies from inode. */
     1030                                SFLOGFLOW(("sf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 1\n", cJiffiesAge, sf_g->ttl));
     1031                                rc = 1;
     1032                        } else {
     1033                                SFLOGFLOW(("sf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 0\n", cJiffiesAge, sf_g->ttl));
     1034                                rc = 0;
     1035                        }
     1036                } else {
     1037                        /*
     1038                         * Negative entry.
     1039                         *
     1040                         * Invalidate dentries for open and renames here as we'll revalidate
     1041                         * these when taking the actual action (also good for case preservation
     1042                         * if we do case-insensitive mounts against windows + mac hosts at some
     1043                         * later point).
     1044                         */
     1045#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     1046                        if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
     1047#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75)
     1048                        if (flags & LOOKUP_CREATE)
     1049#else
     1050                        if (0)
     1051#endif
     1052                        {
     1053                                SFLOGFLOW(("sf_dentry_revalidate: negative: create or rename target -> 0\n"));
     1054                                rc = 0;
     1055                        } else {
     1056                                /* Can we skip revalidation based on TTL? */
     1057                                unsigned long const  cJiffiesAge = sf_dentry_get_update_jiffies(dentry) - jiffies;
     1058                                struct sf_glob_info *sf_g        = GET_GLOB_INFO(dentry->d_sb);
     1059                                if (cJiffiesAge < sf_g->ttl) {
     1060                                        SFLOGFLOW(("sf_dentry_revalidate: negative: age: %lu vs. TTL %lu -> 1\n", cJiffiesAge, sf_g->ttl));
     1061                                        rc = 1;
     1062                                } else {
     1063                                        /* We could revalidate it here, but we could instead just
     1064                                           have the caller kick it out. */
     1065                                        /** @todo stat the direntry and see if it exists now. */
     1066                                        SFLOGFLOW(("sf_dentry_revalidate: negative: age: %lu vs. TTL %lu -> 0\n", cJiffiesAge, sf_g->ttl));
     1067                                        rc = 0;
     1068                                }
     1069                        }
     1070                }
     1071        }
     1072        return rc;
     1073}
     1074
     1075#ifdef SFLOG_ENABLED
     1076
     1077/** For logging purposes only. */
     1078static int sf_dentry_delete(const struct dentry *pDirEntry)
     1079{
     1080        SFLOGFLOW(("sf_dentry_delete: %p\n", pDirEntry));
     1081        return 0;
     1082}
     1083
     1084static int sf_dentry_init(struct dentry *pDirEntry)
     1085{
     1086        SFLOGFLOW(("sf_dentry_init: %p\n", pDirEntry));
     1087        return 0;
     1088}
     1089
     1090#endif /* SFLOG_ENABLED */
     1091
     1092
    10031093struct dentry_operations sf_dentry_ops = {
    1004         .d_revalidate = sf_dentry_revalidate
     1094        .d_revalidate = sf_dentry_revalidate,
     1095#ifdef SFLOG_ENABLED
     1096        .d_delete = sf_dentry_delete,
     1097        .d_init = sf_dentry_init,
     1098#endif
    10051099};
    10061100
  • trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h

    r77138 r77492  
    3838#define MAX_HOST_NAME  256
    3939#define MAX_NLS_NAME    32
     40#define VBSF_DEFAULT_TTL_MS     200
    4041
    4142#define VBSF_MOUNT_SIGNATURE_BYTE_0 '\377'
     
    5859        int uid;                /**< user ID for all entries, default 0=root */
    5960        int gid;                /**< group ID for all entries, default 0=root */
    60         int ttl;                /**< time to live */
     61        int ttl;                /**< directory entry and inode time to live in milliseconds.
     62                                 * -1 for kernel default, 0 to disable caching.  */
    6163        int dmode;              /**< mode for directories if != 0xffffffff */
    6264        int fmode;              /**< mode for regular files if != 0xffffffff */
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r77458 r77492  
    7575static void sf_glob_copy_remount_options(struct sf_glob_info *sf_g, struct vbsf_mount_info_new *info)
    7676{
    77         sf_g->ttl = info->ttl;
     77        sf_g->ttl_msec = info->ttl;
     78        if (info->ttl > 0)
     79                sf_g->ttl = msecs_to_jiffies(info->ttl);
     80        else if (info->ttl == 0 || info->ttl != -1)
     81                sf_g->ttl = sf_g->ttl_msec = 0;
     82        else
     83                sf_g->ttl = msecs_to_jiffies(VBSF_DEFAULT_TTL_MS);
     84
    7885        sf_g->uid = info->uid;
    7986        sf_g->gid = info->gid;
     
    310317        sb->s_blocksize = 1024;
    311318#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 3)
    312         /* Required for seek/sendfile.
    313          *
    314          * Must by less than or equal to INT64_MAX despite the fact that the
    315          * declaration of this variable is unsigned long long. See determination
    316          * of 'loff_t max' in fs/read_write.c / do_sendfile(). I don't know the
    317          * correct limit but MAX_LFS_FILESIZE (8TB-1 on 32-bit boxes) takes the
    318          * page cache into account and is the suggested limit. */
     319        /* Required for seek/sendfile (see 'loff_t max' in fs/read_write.c / do_sendfile()). */
    319320# if defined MAX_LFS_FILESIZE
    320321        sb->s_maxbytes = MAX_LFS_FILESIZE;
     322# elif BITS_PER_LONG == 32
     323        sb->s_maxbytes = (loff_t)ULONG_MAX << PAGE_SHIFT;
    321324# else
    322         sb->s_maxbytes = 0x7fffffffffffffffULL;
     325        sb->s_maxbytes = INT64_MAX;
    323326# endif
    324327#endif
    325328        sb->s_op = &sf_super_ops;
     329#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
     330        sb->s_d_op = &sf_dentry_ops;
     331#endif
    326332
    327333#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
     
    345351        }
    346352
    347         sf_init_inode(sf_g, iroot, &fsinfo);
     353        sf_init_inode(iroot, sf_i, &fsinfo, sf_g);
    348354        SET_INODE_INFO(iroot, sf_i);
    349355
     
    519525        err = sf_stat(__func__, sf_g, sf_i->path, &fsinfo, 0);
    520526        BUG_ON(err != 0);
    521         sf_init_inode(sf_g, iroot, &fsinfo);
     527        sf_init_inode(iroot, sf_i, &fsinfo, sf_g);
    522528        /*unlock_new_inode(iroot); */
    523529        return 0;
     
    541547        struct sf_glob_info *sf_g = GET_GLOB_INFO(sb);
    542548        if (sf_g) {
    543                 seq_printf(m, ",uid=%u,gid=%u,ttl=%u,dmode=0%o,fmode=0%o,dmask=0%o,fmask=0%o,maxiopages=%u",
    544                            sf_g->uid, sf_g->gid, sf_g->ttl, sf_g->dmode, sf_g->fmode, sf_g->dmask,
     549                seq_printf(m, ",uid=%u,gid=%u,ttl=%d,dmode=0%o,fmode=0%o,dmask=0%o,fmask=0%o,maxiopages=%u",
     550                           sf_g->uid, sf_g->gid, sf_g->ttl_msec, sf_g->dmode, sf_g->fmode, sf_g->dmask,
    545551                           sf_g->fmask, sf_g->cMaxIoPages);
    546552                if (sf_g->tag[0] != '\0') {
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r77458 r77492  
    6060        VBGLSFMAP map;
    6161        struct nls_table *nls;
    62         int ttl;
     62        /** time-to-live value for direntry and inode info in jiffies.
     63         * Zero == disabled. */
     64        unsigned long ttl;
     65        /** The mount option value for /proc/mounts. */
     66        int ttl_msec;
    6367        int uid;
    6468        int gid;
     
    120124        /** directory content changed, update the whole directory on next sf_getdent */
    121125        int force_reread;
     126        /** The timestamp (jiffies) where the inode info was last updated. */
     127        unsigned long ts_up_to_date;
    122128
    123129        /** handle valid if a file was created with sf_create_aux until it will
     
    149155
    150156/**
    151  * VBox specific infor fore a regular file.
     157 * VBox specific information for a regular file.
    152158 */
    153159struct sf_reg_info {
     
    155161        struct sf_handle        Handle;
    156162};
     163
     164/**
     165 * Sets the update-jiffies value for a dentry.
     166 *
     167 * This is used together with sf_glob_info::ttl to reduce re-validation of
     168 * dentry structures while walking.
     169 *
     170 * This used to be living in d_time, but since 4.9.0 that seems to have become
     171 * unfashionable and d_fsdata is now used to for this purpose.  We do this all
     172 * the way back, since d_time seems only to have been used by the file system
     173 * specific code (at least going back to 2.4.0).
     174 */
     175DECLINLINE(void) sf_dentry_set_update_jiffies(struct dentry *pDirEntry, unsigned long uToSet)
     176{
     177    pDirEntry->d_fsdata = (void *)uToSet;
     178}
     179
     180/**
     181 * Get the update-jiffies value for a dentry.
     182 */
     183DECLINLINE(unsigned long) sf_dentry_get_update_jiffies(struct dentry *pDirEntry)
     184{
     185    return (unsigned long)pDirEntry->d_fsdata;
     186}
     187
     188/**
     189 * Increase the time-to-live of @a pDirEntry and all ancestors.
     190 * @param   pDirEntry           The directory entry cache entry which ancestors
     191 *                              we should increase the TTL for.
     192 */
     193DECLINLINE(void) sf_dentry_chain_increase_ttl(struct dentry *pDirEntry)
     194{
     195#ifdef VBOX_STRICT
     196        struct super_block * const pSuper = pDirEntry->d_sb;
     197#endif
     198        unsigned long const        uToSet = jiffies;
     199        do {
     200                Assert(pDirEntry->d_sb == pSuper);
     201                sf_dentry_set_update_jiffies(pDirEntry, uToSet);
     202                pDirEntry = pDirEntry->d_parent;
     203        } while (!IS_ROOT(pDirEntry));
     204}
     205
     206/**
     207 * Increase the time-to-live of all ancestors.
     208 * @param   pDirEntry           The directory entry cache entry which ancestors
     209 *                              we should increase the TTL for.
     210 */
     211DECLINLINE(void) sf_dentry_chain_increase_parent_ttl(struct dentry *pDirEntry)
     212{
     213        Assert(!pDirEntry->d_parent || pDirEntry->d_parent->d_sb == pDirEntry->d_sb);
     214        pDirEntry = pDirEntry->d_parent;
     215        if (pDirEntry)
     216            sf_dentry_chain_increase_ttl(pDirEntry);
     217}
     218
    157219
    158220/* globals */
     
    199261}
    200262
    201 extern void sf_init_inode(struct sf_glob_info *sf_g, struct inode *inode,
    202                           PSHFLFSOBJINFO info);
     263extern void sf_init_inode(struct inode *inode, struct sf_inode_info *sf_i, PSHFLFSOBJINFO info, struct sf_glob_info *sf_g);
    203264extern int sf_stat(const char *caller, struct sf_glob_info *sf_g,
    204265                   SHFLSTRING * path, PSHFLFSOBJINFO result, int ok_to_fail);
     
    246307# define TRACE()          LogFunc(("tracepoint\n"))
    247308# define SFLOGFLOW(aArgs) Log(aArgs)
     309# ifdef LOG_ENABLED
     310#  define SFLOG_ENABLED   1
     311# endif
    248312#else
    249313# define TRACE()          RTLogBackdoorPrintf("%s: tracepoint\n", __FUNCTION__)
    250314# define SFLOGFLOW(aArgs) RTLogBackdoorPrintf aArgs
     315# define SFLOG_ENABLED    1
    251316#endif
    252317
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