Changeset 77966 in vbox for trunk/src/VBox
- Timestamp:
- Mar 31, 2019 1:57:12 AM (6 years ago)
- Location:
- trunk/src/VBox/Additions/linux/sharedfolders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r77961 r77966 76 76 #endif 77 77 78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 12) 79 # define PageUptodate(a_pPage) Page_Uptodate(a_pPage) 80 #endif 81 78 82 79 83 /********************************************************************************************************************************* … … 127 131 *********************************************************************************************************************************/ 128 132 DECLINLINE(void) vbsf_put_page(struct page *pPage); 129 DECLINLINE(void)vbsf_unlock_user_pages(struct page **papPages, size_t cPages, bool fSetDirty, bool fLockPgHack);133 static void vbsf_unlock_user_pages(struct page **papPages, size_t cPages, bool fSetDirty, bool fLockPgHack); 130 134 static void vbsf_reg_write_sync_page_cache(struct address_space *mapping, loff_t offFile, uint32_t cbRange, 131 135 uint8_t const *pbSrcBuf, struct page **papSrcPages, … … 530 534 * Misc * 531 535 *********************************************************************************************************************************/ 536 537 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 6) 538 /** Any writable mappings? */ 539 DECLINLINE(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. */ 552 DECLINLINE(bool) PageWriteback(struct page const *page) 553 { 554 return false; 555 } 556 #endif 557 532 558 533 559 /** … … 1273 1299 { 1274 1300 struct page *pPage = papPages[cPages]; 1301 Assert((ssize_t)cPages >= 0); 1275 1302 if (fSetDirty && !PageReserved(pPage)) 1276 1303 SetPageDirty(pPage); … … 1393 1420 # else 1394 1421 struct task_struct *pTask = current; 1395 s ize_t cPagesLocked;1422 ssize_t cPagesLocked; 1396 1423 down_read(&pTask->mm->mmap_sem); 1397 1424 cPagesLocked = get_user_pages(pTask, pTask->mm, uPtrFrom, cPages, fWrite, 1 /*force*/, papPages, NULL); … … 1521 1548 rc = VbglR0SfHostReqReadPgLst(pSuperInfo->map.root, pReq, sf_r->Handle.hHost, offFile, cbChunk, cPages); 1522 1549 1550 Assert(cPages <= cMaxPages); 1523 1551 vbsf_unlock_user_pages(papPages, cPages, true /*fSetDirty*/, fLockPgHack); 1524 1552 … … 1565 1593 if (pReq) 1566 1594 VbglR0PhysHeapFree(pReq); 1595 SFLOGFLOW(("vbsf_reg_read: returns %zd (%#zx), *off=%RX64 [lock]\n", cbRet, cbRet, *off)); 1567 1596 return cbRet; 1568 1597 } … … 1627 1656 cbRet = -EPROTO; 1628 1657 VbglR0PhysHeapFree(pReq); 1658 SFLOGFLOW(("vbsf_reg_read: returns %zd (%#zx), *off=%RX64 [embed]\n", cbRet, cbRet, *off)); 1629 1659 return cbRet; 1630 1660 } … … 1656 1686 VbglR0PhysHeapFree(pReq); 1657 1687 kfree(pvBounce); 1688 SFLOGFLOW(("vbsf_reg_read: returns %zd (%#zx), *off=%RX64 [bounce]\n", cbRet, cbRet, *off)); 1658 1689 return cbRet; 1659 1690 } … … 1825 1856 vbsf_reg_write_sync_page_cache(inode->i_mapping, offFile, cbActual, NULL /*pbKrnlBuf*/, 1826 1857 papPages, (uintptr_t)buf & PAGE_OFFSET_MASK, cPages); 1858 Assert(cPages <= cMaxPages); 1827 1859 vbsf_unlock_user_pages(papPages, cPages, false /*fSetDirty*/, fLockPgHack); 1828 1860 … … 1869 1901 if (pReq) 1870 1902 VbglR0PhysHeapFree(pReq); 1903 SFLOGFLOW(("vbsf_reg_write: returns %zd (%#zx), *off=%RX64 [lock]\n", cbRet, cbRet, *off)); 1871 1904 return cbRet; 1872 1905 } … … 1959 1992 1960 1993 VbglR0PhysHeapFree(pReq); 1994 SFLOGFLOW(("vbsf_reg_write: returns %zd (%#zx), *off=%RX64 [embed]\n", cbRet, cbRet, *off)); 1961 1995 return cbRet; 1962 1996 } … … 1993 2027 VbglR0PhysHeapFree(pReq); 1994 2028 kfree(pvBounce); 2029 SFLOGFLOW(("vbsf_reg_write: returns %zd (%#zx), *off=%RX64 [bounce]\n", cbRet, cbRet, *off)); 1995 2030 return cbRet; 1996 2031 } … … 1998 2033 } else { 1999 2034 kfree(pvBounce); 2035 SFLOGFLOW(("vbsf_reg_write: returns -EFAULT, *off=%RX64 [bounce]\n", *off)); 2000 2036 return -EFAULT; 2001 2037 } … … 3449 3485 3450 3486 /********************************************************************************************************************************* 3451 * Address Space Operations on Regular Files (for mmap )*3487 * Address Space Operations on Regular Files (for mmap, sendfile, direct I/O) * 3452 3488 *********************************************************************************************************************************/ 3453 3454 3455 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)3456 3489 3457 3490 /** … … 3527 3560 * fashion. 3528 3561 */ 3562 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 52) 3529 3563 static int vbsf_writepage(struct page *page, struct writeback_control *wbc) 3564 #else 3565 static int vbsf_writepage(struct page *page) 3566 #endif 3530 3567 { 3531 3568 struct address_space *mapping = page->mapping; … … 3536 3573 3537 3574 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)); 3539 3576 3540 3577 if (pHandle) { … … 3585 3622 if (s_cCalls++ < 16) 3586 3623 printk("vbsf_writepage: no writable handle for %s..\n", sf_i->path->String.ach); 3624 SetPageError(page); 3587 3625 err = -EPROTO; 3588 3626 } … … 3592 3630 3593 3631 3594 # 3632 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) 3595 3633 /** 3596 3634 * Called when writing thru the page cache (which we shouldn't be doing). … … 3609 3647 RTLogBackdoorPrintf("vboxsf: Unexpected call to vbsf_write_begin(pos=%#llx len=%#x flags=%#x)! Please report.\n", 3610 3648 (unsigned long long)pos, len, flags); 3611 # 3649 # ifdef WARN_ON 3612 3650 WARN_ON(1); 3613 # 3651 # endif 3614 3652 } 3615 3653 return simple_write_begin(file, mapping, pos, len, flags, pagep, fsdata); 3616 3654 } 3617 # 3618 3619 3620 # 3655 #endif /* KERNEL_VERSION >= 2.6.24 */ 3656 3657 3658 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10) 3621 3659 /** 3622 3660 * This is needed to make open accept O_DIRECT as well as dealing with direct 3623 3661 * I/O requests if we don't intercept them earlier. 3624 3662 */ 3625 # 3663 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) 3626 3664 static ssize_t vbsf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) 3627 # 3665 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) 3628 3666 static ssize_t vbsf_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset) 3629 # 3667 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) 3630 3668 static ssize_t vbsf_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t offset) 3631 # 3669 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 6) 3632 3670 static ssize_t vbsf_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t offset, unsigned long nr_segs) 3633 # 3671 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 55) 3634 3672 static int vbsf_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t offset, unsigned long nr_segs) 3635 # 3673 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41) 3636 3674 static int vbsf_direct_IO(int rw, struct file *file, const struct iovec *iov, loff_t offset, unsigned long nr_segs) 3637 # 3675 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 35) 3638 3676 static int vbsf_direct_IO(int rw, struct inode *inode, const struct iovec *iov, loff_t offset, unsigned long nr_segs) 3639 # 3677 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 26) 3640 3678 static 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. */ 3680 static int vbsf_direct_IO(int rw, struct file *file, struct kiobuf *buf, unsigned long whatever1, int whatever2) 3681 # else 3682 static int vbsf_direct_IO(int rw, struct inode *inode, struct kiobuf *buf, unsigned long whatever1, int whatever2) 3683 # endif 3644 3684 { 3645 3685 TRACE(); 3646 3686 return -EINVAL; 3647 3687 } 3648 # 3688 #endif 3649 3689 3650 3690 /** … … 3657 3697 .writepage = vbsf_writepage, 3658 3698 /** @todo Need .writepages if we want msync performance... */ 3659 # 3699 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 12) 3660 3700 .set_page_dirty = __set_page_dirty_buffers, 3661 # 3662 # 3701 #endif 3702 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) 3663 3703 .write_begin = vbsf_write_begin, 3664 3704 .write_end = simple_write_end, 3665 # else3705 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 45) 3666 3706 .prepare_write = simple_prepare_write, 3667 3707 .commit_write = simple_commit_write, 3668 # 3669 # 3708 #endif 3709 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10) 3670 3710 .direct_IO = vbsf_direct_IO, 3671 # 3711 #endif 3672 3712 }; 3673 3713 3674 #endif /* LINUX_VERSION_CODE >= 2.6.0 */ 3675 3714 -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r77964 r77966 307 307 sf_i->force_restat = 0; 308 308 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 # endif314 #endif315 309 if (RTFS_IS_DIRECTORY(pAttr->fMode)) { 316 310 inode->i_mode = sf_file_mode_to_linux(pAttr->fMode, pSuperInfo->dmode, pSuperInfo->dmask, S_IFDIR); … … 332 326 inode->i_op = &vbsf_reg_iops; 333 327 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 334 333 set_nlink(inode, 1); 335 334 } … … 815 814 */ 816 815 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) 818 820 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) 819 821 || (fAttrs & (ATTR_OPEN | ATTR_SIZE)) == (ATTR_OPEN | ATTR_SIZE)
Note:
See TracChangeset
for help on using the changeset viewer.