VirtualBox

Changeset 77966 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 31, 2019 1:57:12 AM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Some 2.4.21-xy.EL fixes - enabled mmap to get working O_DIRECT and sendfile (among other thing). bugref:9172

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

Legend:

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

    r77961 r77966  
    7676#endif
    7777
     78#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 12)
     79# define PageUptodate(a_pPage) Page_Uptodate(a_pPage)
     80#endif
     81
    7882
    7983/*********************************************************************************************************************************
     
    127131*********************************************************************************************************************************/
    128132DECLINLINE(void) vbsf_put_page(struct page *pPage);
    129 DECLINLINE(void) vbsf_unlock_user_pages(struct page **papPages, size_t cPages, bool fSetDirty, bool fLockPgHack);
     133static void vbsf_unlock_user_pages(struct page **papPages, size_t cPages, bool fSetDirty, bool fLockPgHack);
    130134static void vbsf_reg_write_sync_page_cache(struct address_space *mapping, loff_t offFile, uint32_t cbRange,
    131135                                           uint8_t const *pbSrcBuf, struct page **papSrcPages,
     
    530534*   Misc                                                                                                                         *
    531535*********************************************************************************************************************************/
     536
     537#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 6)
     538/** Any writable mappings? */
     539DECLINLINE(bool) mapping_writably_mapped(struct address_space const *mapping)
     540{
     541# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 6)
     542    return !list_empty(mapping->i_mmap_shared);
     543# else
     544    return mapping->i_mmap_shared != NULL;
     545# endif
     546}
     547#endif
     548
     549
     550#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 12)
     551/** Missing in 2.4.x, so just stub it for now. */
     552DECLINLINE(bool) PageWriteback(struct page const *page)
     553{
     554    return false;
     555}
     556#endif
     557
    532558
    533559/**
     
    12731299    {
    12741300        struct page *pPage = papPages[cPages];
     1301        Assert((ssize_t)cPages >= 0);
    12751302        if (fSetDirty && !PageReserved(pPage))
    12761303            SetPageDirty(pPage);
     
    13931420# else
    13941421    struct task_struct *pTask = current;
    1395     size_t cPagesLocked;
     1422    ssize_t cPagesLocked;
    13961423    down_read(&pTask->mm->mmap_sem);
    13971424    cPagesLocked = get_user_pages(pTask, pTask->mm, uPtrFrom, cPages, fWrite, 1 /*force*/, papPages, NULL);
     
    15211548            rc = VbglR0SfHostReqReadPgLst(pSuperInfo->map.root, pReq, sf_r->Handle.hHost, offFile, cbChunk, cPages);
    15221549
     1550            Assert(cPages <= cMaxPages);
    15231551            vbsf_unlock_user_pages(papPages, cPages, true /*fSetDirty*/, fLockPgHack);
    15241552
     
    15651593    if (pReq)
    15661594        VbglR0PhysHeapFree(pReq);
     1595    SFLOGFLOW(("vbsf_reg_read: returns %zd (%#zx), *off=%RX64 [lock]\n", cbRet, cbRet, *off));
    15671596    return cbRet;
    15681597}
     
    16271656                    cbRet = -EPROTO;
    16281657                VbglR0PhysHeapFree(pReq);
     1658                SFLOGFLOW(("vbsf_reg_read: returns %zd (%#zx), *off=%RX64 [embed]\n", cbRet, cbRet, *off));
    16291659                return cbRet;
    16301660            }
     
    16561686                VbglR0PhysHeapFree(pReq);
    16571687                kfree(pvBounce);
     1688                SFLOGFLOW(("vbsf_reg_read: returns %zd (%#zx), *off=%RX64 [bounce]\n", cbRet, cbRet, *off));
    16581689                return cbRet;
    16591690            }
     
    18251856                vbsf_reg_write_sync_page_cache(inode->i_mapping, offFile, cbActual, NULL /*pbKrnlBuf*/,
    18261857                                               papPages, (uintptr_t)buf & PAGE_OFFSET_MASK, cPages);
     1858                Assert(cPages <= cMaxPages);
    18271859                vbsf_unlock_user_pages(papPages, cPages, false /*fSetDirty*/, fLockPgHack);
    18281860
     
    18691901    if (pReq)
    18701902        VbglR0PhysHeapFree(pReq);
     1903    SFLOGFLOW(("vbsf_reg_write: returns %zd (%#zx), *off=%RX64 [lock]\n", cbRet, cbRet, *off));
    18711904    return cbRet;
    18721905}
     
    19591992
    19601993            VbglR0PhysHeapFree(pReq);
     1994            SFLOGFLOW(("vbsf_reg_write: returns %zd (%#zx), *off=%RX64 [embed]\n", cbRet, cbRet, *off));
    19611995            return cbRet;
    19621996        }
     
    19932027                    VbglR0PhysHeapFree(pReq);
    19942028                    kfree(pvBounce);
     2029                    SFLOGFLOW(("vbsf_reg_write: returns %zd (%#zx), *off=%RX64 [bounce]\n", cbRet, cbRet, *off));
    19952030                    return cbRet;
    19962031                }
     
    19982033            } else {
    19992034                kfree(pvBounce);
     2035                SFLOGFLOW(("vbsf_reg_write: returns -EFAULT, *off=%RX64 [bounce]\n", *off));
    20002036                return -EFAULT;
    20012037            }
     
    34493485
    34503486/*********************************************************************************************************************************
    3451 *   Address Space Operations on Regular Files (for mmap)                                                                         *
     3487*   Address Space Operations on Regular Files (for mmap, sendfile, direct I/O)                                                   *
    34523488*********************************************************************************************************************************/
    3453 
    3454 
    3455 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    34563489
    34573490/**
     
    35273560 * fashion.
    35283561 */
     3562#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 52)
    35293563static int vbsf_writepage(struct page *page, struct writeback_control *wbc)
     3564#else
     3565static int vbsf_writepage(struct page *page)
     3566#endif
    35303567{
    35313568    struct address_space   *mapping = page->mapping;
     
    35363573
    35373574    SFLOGFLOW(("vbsf_writepage: inode=%p page=%p off=%#llx pHandle=%p (%#llx)\n",
    3538                inode, page,(uint64_t)page->index << PAGE_SHIFT, pHandle, pHandle->hHost));
     3575               inode, page, (uint64_t)page->index << PAGE_SHIFT, pHandle, pHandle ? pHandle->hHost : 0));
    35393576
    35403577    if (pHandle) {
     
    35853622        if (s_cCalls++ < 16)
    35863623            printk("vbsf_writepage: no writable handle for %s..\n", sf_i->path->String.ach);
     3624        SetPageError(page);
    35873625        err = -EPROTO;
    35883626    }
     
    35923630
    35933631
    3594 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
     3632#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
    35953633/**
    35963634 * Called when writing thru the page cache (which we shouldn't be doing).
     
    36093647        RTLogBackdoorPrintf("vboxsf: Unexpected call to vbsf_write_begin(pos=%#llx len=%#x flags=%#x)!  Please report.\n",
    36103648                    (unsigned long long)pos, len, flags);
    3611 #  ifdef WARN_ON
     3649# ifdef WARN_ON
    36123650        WARN_ON(1);
    3613 #  endif
     3651# endif
    36143652    }
    36153653    return simple_write_begin(file, mapping, pos, len, flags, pagep, fsdata);
    36163654}
    3617 # endif /* KERNEL_VERSION >= 2.6.24 */
    3618 
    3619 
    3620 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
     3655#endif /* KERNEL_VERSION >= 2.6.24 */
     3656
     3657
     3658#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
    36213659/**
    36223660 * This is needed to make open accept O_DIRECT as well as dealing with direct
    36233661 * I/O requests if we don't intercept them earlier.
    36243662 */
    3625 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
     3663# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
    36263664static ssize_t vbsf_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
    3627 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
     3665# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
    36283666static ssize_t vbsf_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
    3629 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     3667# elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
    36303668static ssize_t vbsf_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
    3631 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 6)
     3669# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 6)
    36323670static ssize_t vbsf_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t offset, unsigned long nr_segs)
    3633 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 55)
     3671# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 55)
    36343672static int vbsf_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t offset, unsigned long nr_segs)
    3635 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
     3673# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
    36363674static int vbsf_direct_IO(int rw, struct file *file, const struct iovec *iov, loff_t offset, unsigned long nr_segs)
    3637 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 35)
     3675# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 35)
    36383676static int vbsf_direct_IO(int rw, struct inode *inode, const struct iovec *iov, loff_t offset, unsigned long nr_segs)
    3639 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 26)
     3677# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 26)
    36403678static int vbsf_direct_IO(int rw, struct inode *inode, char *buf, loff_t offset, size_t count)
    3641 #  else
    3642 static int vbsf_direct_IO(int rw, struct inode *inode, struct kiobuf *, unsigned long, int)
    3643 #  endif
     3679# elif LINUX_VERSION_CODE == KERNEL_VERSION(2, 4, 21) && defined(I_NEW) /* RHEL3 Frankenkernel.  */
     3680static int vbsf_direct_IO(int rw, struct file *file, struct kiobuf *buf, unsigned long whatever1, int whatever2)
     3681# else
     3682static int vbsf_direct_IO(int rw, struct inode *inode, struct kiobuf *buf, unsigned long whatever1, int whatever2)
     3683# endif
    36443684{
    36453685    TRACE();
    36463686    return -EINVAL;
    36473687}
    3648 # endif
     3688#endif
    36493689
    36503690/**
     
    36573697    .writepage      = vbsf_writepage,
    36583698    /** @todo Need .writepages if we want msync performance...  */
    3659 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 12)
     3699#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 12)
    36603700    .set_page_dirty = __set_page_dirty_buffers,
    3661 # endif
    3662 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
     3701#endif
     3702#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
    36633703    .write_begin    = vbsf_write_begin,
    36643704    .write_end      = simple_write_end,
    3665 # else
     3705#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 45)
    36663706    .prepare_write  = simple_prepare_write,
    36673707    .commit_write   = simple_commit_write,
    3668 # endif
    3669 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
     3708#endif
     3709#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
    36703710    .direct_IO      = vbsf_direct_IO,
    3671 # endif
     3711#endif
    36723712};
    36733713
    3674 #endif /* LINUX_VERSION_CODE >= 2.6.0 */
    3675 
     3714
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r77964 r77966  
    307307    sf_i->force_restat  = 0;
    308308
    309 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    310     inode->i_mapping->a_ops = &vbsf_reg_aops;
    311 # if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 19, 0)
    312     inode->i_mapping->backing_dev_info = &pSuperInfo->bdi; /* This is needed for mmap. */
    313 # endif
    314 #endif
    315309    if (RTFS_IS_DIRECTORY(pAttr->fMode)) {
    316310        inode->i_mode = sf_file_mode_to_linux(pAttr->fMode, pSuperInfo->dmode, pSuperInfo->dmask, S_IFDIR);
     
    332326        inode->i_op = &vbsf_reg_iops;
    333327        inode->i_fop = &vbsf_reg_fops;
     328        inode->i_mapping->a_ops = &vbsf_reg_aops;
     329#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 17) \
     330 && LINUX_VERSION_CODE <  KERNEL_VERSION(4, 0, 0)
     331        inode->i_mapping->backing_dev_info = &pSuperInfo->bdi; /* This is needed for mmap. */
     332#endif
    334333        set_nlink(inode, 1);
    335334    }
     
    815814         */
    816815        unsigned fAttrs = iattr->ia_valid;
    817         if (   (fAttrs & ~ATTR_FILE) == (ATTR_SIZE | ATTR_MTIME | ATTR_CTIME)
     816#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
     817        fAttrs &= ~ATTR_FILE;
     818#endif
     819        if (   fAttrs == (ATTR_SIZE | ATTR_MTIME | ATTR_CTIME)
    818820#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
    819821            || (fAttrs & (ATTR_OPEN | ATTR_SIZE)) == (ATTR_OPEN | ATTR_SIZE)
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