[Devel] [PATCH RHEL7 COMMIT] ms/mm: consolidate dax / non-dax checks for writeback
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Jun 18 12:02:02 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 4b33fdb994d65e467880b1e7a9fbac91dc661019
Author: Vasily Averin <vvs at 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 at suse.cz>
Signed-off-by: Jeff Layton <jlayton at redhat.com>
https://pmc.acronis.com/browse/VSTOR-10912
(cherry picked from commit 9326c9b20dd813248280cca1e1d1c05e939dae15)
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
mm/filemap.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
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() */
More information about the Devel
mailing list