VirtualBox

Ignore:
Timestamp:
Mar 4, 2019 4:19:23 PM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Reviewing revalidate and d_revalidate locking. bugref:9172

Location:
trunk/src/VBox/Additions/linux/sharedfolders
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/sharedfolders/dirops.c

    r77549 r77559  
    11151115    .unlink = vbsf_inode_unlink,
    11161116    .rename = vbsf_inode_rename,
    1117 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
    1118     .revalidate = vbsf_inode_revalidate
    1119 #else
     1117#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18)
    11201118    .getattr = vbsf_inode_getattr,
    11211119    .setattr = vbsf_inode_setattr,
     1120#else
     1121    .revalidate = vbsf_inode_revalidate
     1122#endif
     1123#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    11221124    .symlink = vbsf_ino_symlink
    11231125#endif
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r77549 r77559  
    12581258        case SEEK_END: {
    12591259            struct vbsf_reg_info *sf_r = file->private_data;
    1260             int rc = vbsf_inode_revalidate_with_handle(VBSF_GET_F_DENTRY(file), sf_r->Handle.hHost, true /*fForce*/,
    1261                                  false /*fInodeLocked*/);
     1260            int rc = vbsf_inode_revalidate_with_handle(VBSF_GET_F_DENTRY(file), sf_r->Handle.hHost,
     1261                                                       true /*fForce*/, false /*fInodeLocked*/);
    12621262            if (rc == 0)
    12631263                break;
     
    13591359
    13601360struct inode_operations vbsf_reg_iops = {
    1361 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
    1362     .revalidate = vbsf_inode_revalidate
    1363 #else
     1361#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18)
    13641362    .getattr = vbsf_inode_getattr,
    13651363    .setattr = vbsf_inode_setattr
     1364#else
     1365    .revalidate = vbsf_inode_revalidate
    13661366#endif
    13671367};
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r77549 r77559  
    244244 * Update the inode with new object info from the host.
    245245 *
    246  * Called by sf_inode_revalidate() and sf_inode_revalidate_with_handle(), the
    247  * inode is probably locked...
    248  *
    249  * @todo sort out the inode locking situation.
     246 * Called by sf_inode_revalidate() and sf_inode_revalidate_with_handle().
    250247 */
    251248void vbsf_update_inode(struct inode *pInode, struct vbsf_inode_info *pInodeInfo, PSHFLFSOBJINFO pObjInfo,
     
    370367 * @sa sf_inode_revalidate()
    371368 */
    372 int vbsf_inode_revalidate_worker(struct dentry *dentry, bool fForced)
     369int vbsf_inode_revalidate_worker(struct dentry *dentry, bool fForced, bool fInodeLocked)
    373370{
    374371    int rc;
     
    403400                         * Reset the TTL and copy the info over into the inode structure.
    404401                         */
    405                         vbsf_update_inode(pInode, sf_i, &pReq->ObjInfo, sf_g, true /*fInodeLocked??*/);
     402                        vbsf_update_inode(pInode, sf_i, &pReq->ObjInfo, sf_g, fInodeLocked);
    406403                    } else if (rc == VERR_INVALID_HANDLE) {
    407404                        rc = -ENOENT; /* Restore.*/
     
    431428                             * Reset the TTL and copy the info over into the inode structure.
    432429                             */
    433                             vbsf_update_inode(pInode, sf_i, &pReq->CreateParms.Info, sf_g, true /*fInodeLocked??*/);
     430                            vbsf_update_inode(pInode, sf_i, &pReq->CreateParms.Info, sf_g, fInodeLocked);
    434431                            rc = 0;
    435432                        } else {
     
    456453
    457454
    458 /**
    459  * Revalidate an inode.
     455#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 18)
     456/**
     457 * Revalidate an inode for 2.4.
    460458 *
    461  * This is called directly as inode-op on 2.4, indirectly as dir-op
    462  * vbsf_dentry_revalidate() on 2.4/2.6.  The job is to find out whether
    463  * dentry/inode is still valid.  The test fails if @a dentry does not have an
    464  * inode or vbsf_stat() is unsuccessful, otherwise we return success and update
    465  * inode attributes.
     459 * This is called in the stat(), lstat() and readlink() code paths.  In the stat
     460 * cases the caller will use the result afterwards to produce the stat data.
     461 *
     462 * @note 2.4.x has a getattr() inode operation too, but it is not used.
    466463 */
    467464int vbsf_inode_revalidate(struct dentry *dentry)
    468465{
    469     return vbsf_inode_revalidate_worker(dentry, false /*fForced*/);
    470 }
     466    /*
     467     * We pretend the inode is locked here, as 2.4.x does not have inode level locking.
     468     */
     469    return vbsf_inode_revalidate_worker(dentry, false /*fForced*/, true /*fInodeLocked*/);
     470}
     471#endif /* < 2.5.18 */
    471472
    472473
     
    525526   has inode at all) from these new attributes we derive [kstat] via
    526527   [generic_fillattr] */
    527 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     528#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18)
    528529
    529530# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     
    551552    switch (flags & AT_STATX_SYNC_TYPE) {
    552553        default:
    553             rc = vbsf_inode_revalidate_worker(dentry, false /*fForced*/);
     554            rc = vbsf_inode_revalidate_worker(dentry, false /*fForced*/, false /*fInodeLocked*/);
    554555            break;
    555556
    556557        case AT_STATX_FORCE_SYNC:
    557             rc = vbsf_inode_revalidate_worker(dentry, true /*fForced*/);
     558            rc = vbsf_inode_revalidate_worker(dentry, true /*fForced*/, false /*fInodeLocked*/);
    558559            break;
    559560
     
    563564    }
    564565# else
    565     rc = vbsf_inode_revalidate_worker(dentry, false /*fForced*/);
     566    rc = vbsf_inode_revalidate_worker(dentry, false /*fForced*/, false /*fInodeLocked*/);
    566567# endif
    567568    if (rc == 0) {
     
    717718     * dentry and all its parent entries are valid and could touch their timestamps
    718719     * extending their TTL (CIFS does that). */
    719     return vbsf_inode_revalidate_worker(dentry, true /*fForced*/);
     720    return vbsf_inode_revalidate_worker(dentry, true /*fForced*/, true /*fInodeLocked*/);
    720721
    721722 fail1:
     
    729730}
    730731
    731 #endif /* >= 2.6.0 */
     732#endif /* >= 2.5.18 */
    732733
    733734static int vbsf_make_path(const char *caller, struct vbsf_inode_info *sf_i,
     
    869870 * cache is still valid.  The actual validation is job is handled by
    870871 * vbsf_inode_revalidate_worker().
     872 *
     873 * @note Caller holds no relevant locks, just a dentry reference.
    871874 */
    872875#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
     
    922925                SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> 1\n", cJiffiesAge, sf_g->ttl));
    923926                rc = 1;
    924             } else if (!vbsf_inode_revalidate_worker(dentry, true /*fForced*/)) {
     927            } else if (!vbsf_inode_revalidate_worker(dentry, true /*fForced*/, false /*fInodeLocked*/)) {
    925928                vbsf_dentry_set_update_jiffies(dentry, jiffies); /** @todo get jiffies from inode. */
    926929                SFLOGFLOW(("vbsf_dentry_revalidate: age: %lu vs. TTL %lu -> reval -> 1\n", cJiffiesAge, sf_g->ttl));
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r77549 r77559  
    213213extern void vbsf_update_inode(struct inode *pInode, struct vbsf_inode_info *pInodeInfo, PSHFLFSOBJINFO pObjInfo,
    214214                              struct vbsf_super_info *sf_g, bool fInodeLocked);
    215 extern int  vbsf_inode_revalidate(struct dentry *dentry);
    216 extern int  vbsf_inode_revalidate_worker(struct dentry *dentry, bool fForced);
     215extern int  vbsf_inode_revalidate_worker(struct dentry *dentry, bool fForced, bool fInodeLocked);
    217216extern int  vbsf_inode_revalidate_with_handle(struct dentry *dentry, SHFLHANDLE hHostFile, bool fForced, bool fInodeLocked);
    218 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     217#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18)
    219218# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
    220219extern int  vbsf_inode_getattr(const struct path *path, struct kstat *kstat, u32 request_mask, unsigned int query_flags);
     
    223222# endif
    224223extern int  vbsf_inode_setattr(struct dentry *dentry, struct iattr *iattr);
    225 #endif
     224#else  /* < 2.5.44 */
     225extern int  vbsf_inode_revalidate(struct dentry *dentry);
     226#endif /* < 2.5.44 */
    226227
    227228
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