VirtualBox

Ignore:
Timestamp:
Apr 1, 2019 11:12:02 AM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Update inode info in vbsf_reg_open since we got accurate info from the host, allowing us to catch host mtime changes and timely invalidate the page cache. Get correct file position on O_APPEND from the host. bugref:9172

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

Legend:

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

    r77975 r77976  
    18631863
    18641864                cbRet   += cbActual;
    1865                 offFile += cbActual;
    18661865                buf      = (uint8_t *)buf + cbActual;
    18671866                size    -= cbActual;
     1867
     1868                offFile += cbActual;
     1869                if ((file->f_flags & O_APPEND) && (g_fSfFeatures & SHFL_FEATURE_WRITE_UPDATES_OFFSET))
     1870                    offFile = pReq->Parms.off64Write.u.value64;
    18681871                if (offFile > i_size_read(inode))
    18691872                    i_size_write(inode, offFile);
     1873
    18701874                sf_i->force_restat = 1; /* mtime (and size) may have changed */
    18711875
     
    19371941
    19381942    pos = *off;
    1939     /** @todo This should be handled by the host, it returning the new file
    1940      *        offset when appending.  We may have an outdated i_size value here! */
    19411943    if (file->f_flags & O_APPEND)
    19421944        pos = i_size_read(inode);
     
    19881990                                                   NULL /*papSrcPages*/, 0 /*offSrcPage0*/, 0 /*cSrcPages*/);
    19891991                    pos += cbRet;
     1992                    if ((file->f_flags & O_APPEND) && (g_fSfFeatures & SHFL_FEATURE_WRITE_UPDATES_OFFSET))
     1993                        pos = pReq->Parms.off64Write.u.value64;
    19901994                    *off = pos;
    19911995                    if (pos > i_size_read(inode))
     
    26302634 */
    26312635static ssize_t vbsf_reg_write_iter_locking(struct kiocb *kio, struct iov_iter *iter, size_t cbToWrite, loff_t offFile,
    2632                                            struct vbsf_super_info *pSuperInfo, struct vbsf_reg_info *sf_r,
    2633                                            struct inode *inode, struct vbsf_inode_info *sf_i, struct address_space *mapping)
     2636                                           struct vbsf_super_info *pSuperInfo, struct vbsf_reg_info *sf_r, struct inode *inode,
     2637                                           struct vbsf_inode_info *sf_i, struct address_space *mapping, bool fAppend)
    26342638{
    26352639    /*
     
    26972701
    26982702                cbRet      += cbActual;
     2703                cbToWrite  -= cbActual;
     2704
    26992705                offFile    += cbActual;
     2706                if (fAppend && (g_fSfFeatures & SHFL_FEATURE_WRITE_UPDATES_OFFSET))
     2707                    offFile = pReq->Parms.off64Write.u.value64;
    27002708                kio->ki_pos = offFile;
    2701                 cbToWrite  -= cbActual;
    27022709                if (offFile > i_size_read(inode))
    27032710                    i_size_write(inode, offFile);
     2711
    27042712                sf_i->force_restat = 1; /* mtime (and size) may have changed */
    27052713
     
    27802788    loff_t                  offFile    = kio->ki_pos;
    27812789# endif
     2790# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
     2791    bool const              fAppend    = RT_BOOL(kio->ki_flags & IOCB_APPEND);
     2792# else
     2793    bool const              fAppend    = RT_BOOL(kio->ki_filp->f_flags & O_APPEND);
     2794# endif
     2795
    27822796
    27832797    SFLOGFLOW(("vbsf_reg_write_iter: inode=%p file=%p size=%#zx off=%#llx type=%#x\n",
     
    27862800
    27872801    /*
    2788      * Enforce APPEND flag.
     2802     * Enforce APPEND flag (more later).
    27892803     */
    2790     /** @todo This should be handled by the host, it returning the new file
    2791      *        offset when appending.  We may have an outdated i_size value here! */
    2792 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
    2793     if (kio->ki_flags & IOCB_APPEND)
    2794 # else
    2795     if (kio->ki_filp->f_flags & O_APPEND)
    2796 # endif
     2804    if (fAppend)
    27972805        kio->ki_pos = offFile = i_size_read(inode);
    27982806
     
    28482856                        vbsf_reg_write_sync_page_cache(mapping, offFile, (uint32_t)cbRet, pReq->abData,
    28492857                                                       NULL /*papSrcPages*/, 0 /*offSrcPage0*/, 0 /*cSrcPages*/);
    2850                         kio->ki_pos = offFile += cbRet;
     2858
     2859                        offFile += cbRet;
     2860                        if (fAppend && (g_fSfFeatures & SHFL_FEATURE_WRITE_UPDATES_OFFSET))
     2861                            offFile = pReq->Parms.off64Write.u.value64;
     2862                        kio->ki_pos = offFile;
    28512863                        if (offFile > i_size_read(inode))
    28522864                            i_size_write(inode, offFile);
     2865
    28532866# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
    28542867                        if ((size_t)cbRet < cbToWrite)
     
    28712884     * Otherwise do the page locking thing.
    28722885     */
    2873     return vbsf_reg_write_iter_locking(kio, iter, cbToWrite, offFile, pSuperInfo, sf_r, inode, sf_i, mapping);
     2886    return vbsf_reg_write_iter_locking(kio, iter, cbToWrite, offFile, pSuperInfo, sf_r, inode, sf_i, mapping, fAppend);
    28742887}
    28752888
     
    30333046    if (pReq->CreateParms.Handle != SHFL_HANDLE_NIL) {
    30343047        vbsf_dentry_chain_increase_ttl(dentry);
     3048        vbsf_update_inode(inode, sf_i, &pReq->CreateParms.Info, pSuperInfo, false /*fInodeLocked*/, 0 /*fSetAttrs*/);
    30353049        rc_linux = 0;
    30363050    } else {
    30373051        switch (pReq->CreateParms.Result) {
    30383052            case SHFL_PATH_NOT_FOUND:
     3053                vbsf_dentry_invalidate_ttl(dentry);
    30393054                rc_linux = -ENOENT;
    30403055                break;
    30413056            case SHFL_FILE_NOT_FOUND:
     3057                vbsf_dentry_invalidate_ttl(dentry);
    30423058                /** @todo sf_dentry_increase_parent_ttl(file->f_dentry); if we can trust it.  */
    30433059                rc_linux = -ENOENT;
     
    30453061            case SHFL_FILE_EXISTS:
    30463062                vbsf_dentry_chain_increase_ttl(dentry);
     3063                vbsf_update_inode(inode, sf_i, &pReq->CreateParms.Info, pSuperInfo, false /*fInodeLocked*/, 0 /*fSetAttrs*/);
    30473064                rc_linux = -EEXIST;
    30483065                break;
     
    30543071    }
    30553072
    3056 /** @todo update the inode here, pReq carries the latest stats!  Very helpful
    3057  *        for detecting host side changes. */
    3058 
    3059     sf_i->force_restat = 1; /** @todo Why?!? */
    30603073    sf_r->Handle.hHost = pReq->CreateParms.Handle;
    30613074    file->private_data = sf_r;
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r77960 r77976  
    7171/** Last valid shared folders function number. */
    7272uint32_t     g_uSfLastFunction = SHFL_FN_SET_FILE_SIZE;
    73 /** Shared folders features. */
     73/** Shared folders features (SHFL_FEATURE_XXX). */
    7474uint64_t     g_fSfFeatures = 0;
    7575
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