[RHEL7,COMMIT] ms/mm: consolidate dax / non-dax checks for writeback

Submitted by Konstantin Khorenko on June 18, 2018, 9:02 a.m.

Details

Message ID 201806180902.w5I922Je019536@finist_ce7.work
State New
Series "ms/mm: consolidate dax / non-dax checks for writeback"
Headers show

Commit Message

Konstantin Khorenko June 18, 2018, 9:02 a.m.
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 4b33fdb994d65e467880b1e7a9fbac91dc661019
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Mon Jun 18 12:02:01 2018 +0300

    ms/mm: consolidate dax / non-dax checks for writeback
    
    We have this complex conditional copied to several places. Turn it into
    a helper function.
    
    Reviewed-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Jeff Layton <jlayton@redhat.com>
    
    https://pmc.acronis.com/browse/VSTOR-10912
    (cherry picked from commit 9326c9b20dd813248280cca1e1d1c05e939dae15)
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 mm/filemap.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/filemap.c b/mm/filemap.c
index b9c5e2a3f949..4da330109568 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -493,12 +493,17 @@  int filemap_fdatawait(struct address_space *mapping)
 }
 EXPORT_SYMBOL(filemap_fdatawait);
 
+static bool mapping_needs_writeback(struct address_space *mapping)
+{
+	return (!dax_mapping(mapping) && mapping->nrpages) ||
+	    (dax_mapping(mapping) && mapping->nrexceptional);
+}
+
 int filemap_write_and_wait(struct address_space *mapping)
 {
 	int err = 0;
 
-	if ((!dax_mapping(mapping) && mapping->nrpages) ||
-	    (dax_mapping(mapping) && mapping->nrexceptional)) {
+	if (mapping_needs_writeback(mapping)) {
 		err = filemap_fdatawrite(mapping);
 		/*
 		 * Even if the above returned error, the pages may be
@@ -537,8 +542,7 @@  int filemap_write_and_wait_range(struct address_space *mapping,
 {
 	int err = 0;
 
-	if ((!dax_mapping(mapping) && mapping->nrpages) ||
-	    (dax_mapping(mapping) && mapping->nrexceptional)) {
+	if (mapping_needs_writeback(mapping)) {
 		err = __filemap_fdatawrite_range(mapping, lstart, lend,
 						 WB_SYNC_ALL);
 		/* See comment of filemap_write_and_wait() */
@@ -627,8 +631,7 @@  int file_write_and_wait_range(struct file *file, loff_t lstart, loff_t lend)
 	int err = 0, err2;
 	struct address_space *mapping = file->f_mapping;
 
-	if ((!dax_mapping(mapping) && mapping->nrpages) ||
-	    (dax_mapping(mapping) && mapping->nrexceptional)) {
+	if (mapping_needs_writeback(mapping)) {
 		err = __filemap_fdatawrite_range(mapping, lstart, lend,
 						 WB_SYNC_ALL);
 		/* See comment of filemap_write_and_wait() */