VirtualBox

Changeset 77443 in vbox for trunk/src


Ignore:
Timestamp:
Feb 22, 2019 9:47:06 PM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf,FsPerf: RTFileWrite vs mmap coherency test and fixes. bugref:9172

File:
1 edited

Legend:

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

    r77439 r77443  
    474474        struct sf_glob_info *sf_g = GET_GLOB_INFO(inode->i_sb);
    475475        struct sf_reg_info *sf_r = file->private_data;
    476 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2)
    477         struct address_space *mapping = file->f_mapping;
    478 #else
    479476        struct address_space *mapping = inode->i_mapping;
    480 #endif
    481477
    482478        TRACE();
     
    531527        }
    532528
    533 # if 0 /* Turns out this is slightly slower than locking the pages even for 4KB reads (4.19/amd64). */
     529#if 0 /* Turns out this is slightly slower than locking the pages even for 4KB reads (4.19/amd64). */
    534530        /*
    535531         * For medium sized requests try use a bounce buffer.
     
    559555                }
    560556        }
     557#endif
     558
     559        return sf_reg_read_fallback(file, buf, size, off, sf_g, sf_r);
     560}
     561
     562
     563/**
     564 * Wrapper around invalidate_mapping_pages() for page cache invalidation so that
     565 * the changes written via sf_reg_write are made visible to mmap users.
     566 */
     567DECLINLINE(void) sf_reg_write_invalidate_mapping_range(struct address_space *mapping, loff_t offStart, loff_t offEnd)
     568{
     569        /*
     570         * Only bother with this if the mapping has any pages in it.
     571         *
     572         * Note! According to the docs, the last parameter, end, is inclusive (we
     573         *       would have named it 'last' to indicate this).
     574         *
     575         * Note! The pre-2.6.12 function might not do enough to sure consistency
     576         *       when any of the pages in the range is already mapped.
     577         */
     578# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12)
     579        if (mapping)
     580                invalidate_inode_pages2_range(mapping, offStart >> PAGE_SHIFT, (offEnd - 1) >> PAGE_SHIFT);
     581# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 60)
     582        if (mapping && mapping->nrpages > 0)
     583                invalidate_mapping_pages(mapping, offStart >> PAGE_SHIFT, (offEnd - 1) >> PAGE_SHIFT);
     584# else
     585        /** @todo ... */
     586        RT_NOREF(mapping, offStart, offEnd);
    561587# endif
    562 
    563         return sf_reg_read_fallback(file, buf, size, off, sf_g, sf_r);
    564588}
    565589
     
    640664                                if (offFile > i_size_read(inode))
    641665                                        i_size_write(inode, offFile);
     666                                sf_reg_write_invalidate_mapping_range(inode->i_mapping, offFile - cbActual, offFile);
    642667
    643668                                /*
     
    689714                            loff_t * off)
    690715{
    691         loff_t pos;
    692         struct inode *inode = GET_F_DENTRY(file)->d_inode;
     716        struct inode         *inode = GET_F_DENTRY(file)->d_inode;
    693717        struct sf_inode_info *sf_i = GET_INODE_INFO(inode);
    694         struct sf_glob_info *sf_g = GET_GLOB_INFO(inode->i_sb);
    695         struct sf_reg_info *sf_r = file->private_data;
     718        struct sf_glob_info  *sf_g = GET_GLOB_INFO(inode->i_sb);
     719        struct sf_reg_info   *sf_r = file->private_data;
     720        struct address_space *mapping = inode->i_mapping;
     721        loff_t                pos;
    696722
    697723        TRACE();
     
    717743                        *off = pos;
    718744                return 0;
     745        }
     746
     747        /*
     748         * If there are active writable mappings, coordinate with any
     749         * pending writes via those.
     750         */
     751        if (   mapping
     752            && mapping->nrpages > 0
     753            && mapping_writably_mapped(mapping)) {
     754#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
     755                int err = filemap_fdatawait_range(mapping, pos, pos + size - 1);
     756                if (err)
     757                        return err;
     758#else
     759                /** @todo ...   */
     760#endif
    719761        }
    720762
     
    738780                                        if (pos > i_size_read(inode))
    739781                                                i_size_write(inode, pos);
     782                                        sf_reg_write_invalidate_mapping_range(mapping, pos - cbRet, pos);
    740783                                } else
    741784                                        cbRet = -EPROTO;
     
    751794        }
    752795
    753 # if 0 /* Turns out this is slightly slower than locking the pages even for 4KB reads (4.19/amd64). */
     796#if 0 /* Turns out this is slightly slower than locking the pages even for 4KB reads (4.19/amd64). */
    754797        /*
    755798         * For medium sized requests try use a bounce buffer.
     
    771814                                                if (pos > i_size_read(inode))
    772815                                                        i_size_write(inode, pos);
     816                                                sf_reg_write_invalidate_mapping_range(mapping, pos - cbRet, pos);
    773817                                        } else
    774818                                                cbRet = -EPROTO;
     
    785829                }
    786830        }
    787 # endif
     831#endif
    788832
    789833        return sf_reg_write_fallback(file, buf, size, off, pos, inode, sf_i, sf_g, sf_r);
     
    12161260{
    12171261        TRACE();
     1262#if 0
     1263        printk("sf_write_begin: pos=%#llx len=%#x flags=%#x\n", pos, len, flags);
     1264        RTLogBackdoorPrintf("sf_write_begin: pos=%#llx len=%#x flags=%#x\n", pos, len, flags);
     1265#endif
    12181266/** @todo rig up a FsPerf testcase for this code! */
    12191267
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