[Devel] [PATCH RHEL7 COMMIT] ms/mm: add filemap_fdatawait_range_keep_errors()

Konstantin Khorenko khorenko at virtuozzo.com
Sat Oct 26 01:03:21 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-1062.1.2.vz7.114.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.1.2.vz7.114.10
------>
commit 7634b6c6cfc5040cbf55f657324a587a1fbe3a0d
Author: Ross Zwisler <zwisler at chromium.org>
Date:   Sat Oct 26 01:03:19 2019 +0300

    ms/mm: add filemap_fdatawait_range_keep_errors()
    
    In the spirit of filemap_fdatawait_range() and
    filemap_fdatawait_keep_errors(), introduce
    filemap_fdatawait_range_keep_errors() which both takes a range upon
    which to wait and does not clear errors from the address space.
    
    Signed-off-by: Ross Zwisler <zwisler at google.com>
    Signed-off-by: Theodore Ts'o <tytso at mit.edu>
    Reviewed-by: Jan Kara <jack at suse.cz>
    Cc: stable at vger.kernel.org
    
    (cherry picked from commit aa0bfcd939c30617385ffa28682c062d78050eba)
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 include/linux/fs.h |  2 ++
 mm/filemap.c       | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 0b074aa9d8c6..014a7056af31 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2969,6 +2969,8 @@ extern int filemap_flush(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);
+extern int filemap_fdatawait_range_keep_errors(struct address_space *mapping,
+		loff_t start_byte, loff_t end_byte);
 
 static inline int filemap_fdatawait(struct address_space *mapping)
 {
diff --git a/mm/filemap.c b/mm/filemap.c
index 7bcf912431ba..fd9abfec4b41 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -434,6 +434,28 @@ int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte,
 }
 EXPORT_SYMBOL(filemap_fdatawait_range);
 
+/**
+ * filemap_fdatawait_range_keep_errors - wait for writeback to complete
+ * @mapping:		address space structure to wait for
+ * @start_byte:		offset in bytes where the range starts
+ * @end_byte:		offset in bytes where the range ends (inclusive)
+ *
+ * Walk the list of under-writeback pages of the given address space in the
+ * given range and wait for all of them.  Unlike filemap_fdatawait_range(),
+ * this function does not clear error status of the address space.
+ *
+ * Use this function if callers don't handle errors themselves.  Expected
+ * call sites are system-wide / filesystem-wide data flushers: e.g. sync(2),
+ * fsfreeze(8)
+ */
+int filemap_fdatawait_range_keep_errors(struct address_space *mapping,
+		loff_t start_byte, loff_t end_byte)
+{
+	__filemap_fdatawait_range(mapping, start_byte, end_byte);
+	return filemap_check_and_keep_errors(mapping);
+}
+EXPORT_SYMBOL(filemap_fdatawait_range_keep_errors);
+
 /**
  * file_fdatawait_range - wait for writeback to complete
  * @file:		file pointing to address space structure to wait for



More information about the Devel mailing list