[Devel] [PATCH RHEL7 COMMIT] ms/mm: remove optimizations based on i_size in mapping writeback waits

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 18 12:02:04 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.3.2.vz7.61.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.3.2.vz7.61.3
------>
commit fa4c90db0b45d49dc2b1b5ee7f23a6f28c8ad474
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Mon Jun 18 12:02:04 2018 +0300

    ms/mm: remove optimizations based on i_size in mapping writeback waits
    
    Marcelo added this i_size based optimization with a patch in 2004
    (commitid is from the linux-history tree):
    
        commit 765dad09b4ac101a32d87af2bb793c3060497d3c
        Author: Marcelo Tosatti <marcelo.tosatti at cyclades.com>
        Date:   Tue Sep 7 17:51:17 2004 -0700
    
            small wait_on_page_writeback_range() optimization
    
            filemap_fdatawait() calls wait_on_page_writeback_range() with -1
            as "end" parameter.  This is not needed since we know the EOF
            from the inode.  Use that instead.
    
    There may be races here, particularly with clustered or network
    filesystems. It also seems like a bit of a layering violation since
    we're operating on an address_space here, not an inode.
    
    Finally, it's also questionable whether this optimization really helps
    on workloads that we care about. Should we be optimizing for writeback
    vs. truncate races in a codepath where we expect to wait anyway? It
    doesn't seem worth the risk.
    
    Remove this optimization from the filemap_fdatawait codepaths. This
    means that filemap_fdatawait becomes a trivial wrapper around
    filemap_fdatawait_range.
    
    Reviewed-by: Jan Kara <jack at suse.cz>
    Signed-off-by: Jeff Layton <jlayton at redhat.com>
    
    https://pmc.acronis.com/browse/VSTOR-10912
    (cherry picked from commit ffb959bbdf923b4f89a08a04aba2501b1b16d164)
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 include/linux/fs.h |  7 ++++++-
 mm/filemap.c       | 30 +-----------------------------
 2 files changed, 7 insertions(+), 30 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 340770ef3c86..11b1ba0e4a57 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2948,10 +2948,15 @@ extern int invalidate_inode_pages2_range(struct address_space *mapping,
 extern int write_inode_now(struct inode *, int);
 extern int filemap_fdatawrite(struct address_space *);
 extern int filemap_flush(struct address_space *);
-extern int filemap_fdatawait(struct address_space *);
 extern int filemap_fdatawait_keep_errors(struct address_space *mapping);
 extern int filemap_fdatawait_range(struct address_space *, loff_t lstart,
 				   loff_t lend);
+
+static inline int filemap_fdatawait(struct address_space *mapping)
+{
+	return filemap_fdatawait_range(mapping, 0, LLONG_MAX);
+}
+
 extern int filemap_write_and_wait(struct address_space *mapping);
 extern int filemap_write_and_wait_range(struct address_space *mapping,
 				        loff_t lstart, loff_t lend);
diff --git a/mm/filemap.c b/mm/filemap.c
index f4db0e7e40bd..e7218a56a368 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -483,39 +483,11 @@ EXPORT_SYMBOL(file_fdatawait_range);
  */
 int filemap_fdatawait_keep_errors(struct address_space *mapping)
 {
-	loff_t i_size = i_size_read(mapping->host);
-
-	if (i_size == 0)
-		return 0;
-
-	__filemap_fdatawait_range(mapping, 0, i_size - 1);
+	__filemap_fdatawait_range(mapping, 0, LLONG_MAX);
 	return filemap_check_and_keep_errors(mapping);
 }
 EXPORT_SYMBOL(filemap_fdatawait_keep_errors);
 
-/**
- * filemap_fdatawait - wait for all under-writeback pages to complete
- * @mapping: address space structure to wait for
- *
- * Walk the list of under-writeback pages of the given address space
- * and wait for all of them.  Check error status of the address space
- * and return it.
- *
- * Since the error status of the address space is cleared by this function,
- * callers are responsible for checking the return value and handling and/or
- * reporting the error.
- */
-int filemap_fdatawait(struct address_space *mapping)
-{
-	loff_t i_size = i_size_read(mapping->host);
-
-	if (i_size == 0)
-		return 0;
-
-	return filemap_fdatawait_range(mapping, 0, i_size - 1);
-}
-EXPORT_SYMBOL(filemap_fdatawait);
-
 static bool mapping_needs_writeback(struct address_space *mapping)
 {
 	return (!dax_mapping(mapping) && mapping->nrpages) ||


More information about the Devel mailing list