VirtualBox

Changeset 77967 in vbox for trunk


Ignore:
Timestamp:
Mar 31, 2019 7:28:43 PM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Tried to figure out that fsync issue on 2.4.21-27.EL, but no luck. Various cleanups from what. bugref:9172

File:
1 edited

Legend:

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

    r77966 r77967  
    540540{
    541541# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 6)
    542     return !list_empty(mapping->i_mmap_shared);
     542    return !list_empty(&mapping->i_mmap_shared);
    543543# else
    544544    return mapping->i_mmap_shared != NULL;
     
    13011301        Assert((ssize_t)cPages >= 0);
    13021302        if (fSetDirty && !PageReserved(pPage))
    1303             SetPageDirty(pPage);
     1303            set_page_dirty(pPage);
    13041304        vbsf_put_page(pPage);
    13051305    }
     
    15811581                 * the error.  (Not sure if this is such a great idea...)
    15821582                 */
    1583                 if (cbRet > 0)
     1583                if (cbRet > 0) {
     1584                    SFLOGFLOW(("vbsf_reg_read: read at %#RX64 -> %Rrc; got cbRet=%#zx already\n", offFile, rc, cbRet));
    15841585                    *off = offFile;
    1585                 else
     1586                } else {
     1587                    SFLOGFLOW(("vbsf_reg_read: read at %#RX64 -> %Rrc\n", offFile, rc));
    15861588                    cbRet = -EPROTO;
     1589                }
    15871590                break;
    15881591            }
     
    18881891                     * the error.  (Not sure if this is such a great idea...)
    18891892                     */
    1890                     if (cbRet > 0)
     1893                    if (cbRet > 0) {
     1894                        SFLOGFLOW(("vbsf_reg_write: write at %#RX64 -> %Rrc; got cbRet=%#zx already\n", offFile, rc, cbRet));
    18911895                        *off = offFile;
    1892                     else
     1896                    } else {
     1897                        SFLOGFLOW(("vbsf_reg_write: write at %#RX64 -> %Rrc\n", offFile, rc));
    18931898                        cbRet = -EPROTO;
     1899                    }
    18941900                    break;
    18951901                }
     
    20582064        struct page *pPage = papPages[cPages];
    20592065        if (fSetDirty && !PageReserved(pPage))
    2060             SetPageDirty(pPage);
     2066            set_page_dirty(pPage);
    20612067        vbsf_put_page(pPage);
    20622068    }
     
    30733079    if (sf_r) {
    30743080        struct vbsf_super_info *pSuperInfo = VBSF_GET_SUPER_INFO(inode->i_sb);
     3081        struct address_space   *mapping    = inode->i_mapping;
    30753082        Assert(pSuperInfo);
    30763083
     3084        /* If we're closing the last handle for this inode, make sure the flush
     3085           the mapping or we'll end up in vbsf_writepage without a handle. */
     3086        if (   mapping
     3087            && mapping->nrpages > 0
     3088            /** @todo && last writable handle */ ) {
    30773089#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
    3078         /* See the smbfs source (file.c). mmap in particular can cause data to be
    3079          * written to the file after it is closed, which we can't cope with.  We
    3080          * copy and paste the body of filemap_write_and_wait() here as it was not
    3081          * defined before 2.6.6 and not exported until quite a bit later. */
    3082         /* filemap_write_and_wait(inode->i_mapping); */
    3083         if (inode->i_mapping->nrpages
    3084             && filemap_fdatawrite(inode->i_mapping) != -EIO)
    3085             filemap_fdatawait(inode->i_mapping);
    3086 #endif
     3090            if (filemap_fdatawrite(mapping) != -EIO)
     3091#else
     3092            if (   filemap_fdatasync(mapping) == 0
     3093                && fsync_inode_data_buffers(inode) == 0)
     3094#endif
     3095                filemap_fdatawait(inode->i_mapping);
     3096        }
    30873097
    30883098        /* Release sf_r, closing the handle if we're the last user. */
     
    31793189    }
    31803190#  else  /* < 2.5.12 */
    3181     rc  = fsync_inode_buffers(inode);
     3191    /** @todo
     3192     * Somethings is buggy here or in the 2.4.21-27.EL kernel I'm testing on.
     3193     *
     3194     * In theory we shouldn't need to do anything here, since msync will call
     3195     * writepage() on each dirty page and we write them out synchronously.  So, the
     3196     * problem is elsewhere...  Doesn't happen all the time either.  Sigh.
     3197     */
     3198    rc = fsync_inode_buffers(inode);
    31823199#   if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
    3183     rc |= fsync_inode_data_buffers(inode);
     3200    if (rc == 0 && datasync)
     3201        rc = fsync_inode_data_buffers(inode);
    31843202#   endif
    3185     /** @todo probably need to do more here... */
     3203
    31863204#  endif /* < 2.5.12 */
    31873205    return rc;
     
    36073625                    i_size_write(inode, offEndOfWrite);
    36083626
     3627                /* Update and unlock the page. */
    36093628                if (PageError(page))
    36103629                    ClearPageError(page);
    3611 
    3612                 err = 0;
    3613             } else {
    3614                 ClearPageUptodate(page);
    3615                 err = -EPROTO;
     3630                SetPageUptodate(page);
     3631                unlock_page(page);
     3632
     3633                vbsf_handle_release(pHandle, pSuperInfo, "vbsf_writepage");
     3634                return 0;
    36163635            }
     3636
     3637            /*
     3638             * We failed.
     3639             */
     3640            err = -EIO;
    36173641        } else
    36183642            err = -ENOMEM;
    36193643        vbsf_handle_release(pHandle, pSuperInfo, "vbsf_writepage");
    36203644    } else {
     3645        /** @todo we could re-open the file here and deal with this... */
    36213646        static uint64_t volatile s_cCalls = 0;
    36223647        if (s_cCalls++ < 16)
    36233648            printk("vbsf_writepage: no writable handle for %s..\n", sf_i->path->String.ach);
    3624         SetPageError(page);
    3625         err = -EPROTO;
    3626     }
     3649        err = -EIO;
     3650    }
     3651    SetPageError(page);
    36273652    unlock_page(page);
    36283653    return err;
     
    36463671               (unsigned long long)pos, len, flags);
    36473672        RTLogBackdoorPrintf("vboxsf: Unexpected call to vbsf_write_begin(pos=%#llx len=%#x flags=%#x)!  Please report.\n",
    3648                     (unsigned long long)pos, len, flags);
     3673                            (unsigned long long)pos, len, flags);
    36493674# ifdef WARN_ON
    36503675        WARN_ON(1);
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