summaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2017-07-28 07:24:43 -0400
committerJeff Layton <jlayton@redhat.com>2017-07-31 19:12:26 -0400
commita823e4589e68996436d16db4ede9a43b646332f9 (patch)
tree2961b2c0bd94da25551564b52ff5501918b96fb5 /mm/filemap.c
parent7e51fe1dd180e525c9cb9dc613c524c83c130867 (diff)
downloadlinux-a823e4589e68996436d16db4ede9a43b646332f9.tar.bz2
mm: add file_fdatawait_range and file_write_and_wait
Necessary now for gfs2_fsync and sync_file_range, but there will eventually be other callers. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 72e46e6f0d9a..394bb5e96f87 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -476,6 +476,29 @@ int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte,
EXPORT_SYMBOL(filemap_fdatawait_range);
/**
+ * file_fdatawait_range - wait for writeback to complete
+ * @file: file pointing to 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 address space that file
+ * refers to, in the given range and wait for all of them. Check error
+ * status of the address space vs. the file->f_wb_err cursor and return it.
+ *
+ * Since the error status of the file is advanced by this function,
+ * callers are responsible for checking the return value and handling and/or
+ * reporting the error.
+ */
+int file_fdatawait_range(struct file *file, loff_t start_byte, loff_t end_byte)
+{
+ struct address_space *mapping = file->f_mapping;
+
+ __filemap_fdatawait_range(mapping, start_byte, end_byte);
+ return file_check_and_advance_wb_err(file);
+}
+EXPORT_SYMBOL(file_fdatawait_range);
+
+/**
* filemap_fdatawait_keep_errors - wait for writeback without clearing errors
* @mapping: address space structure to wait for
*