Merge tag 'for-5.15-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
[linux-2.6-microblaze.git] / mm / filemap.c
index 0fad083..920e8dc 100644 (file)
@@ -379,6 +379,32 @@ static int filemap_check_and_keep_errors(struct address_space *mapping)
        return 0;
 }
 
+/**
+ * filemap_fdatawrite_wbc - start writeback on mapping dirty pages in range
+ * @mapping:   address space structure to write
+ * @wbc:       the writeback_control controlling the writeout
+ *
+ * Call writepages on the mapping using the provided wbc to control the
+ * writeout.
+ *
+ * Return: %0 on success, negative error code otherwise.
+ */
+int filemap_fdatawrite_wbc(struct address_space *mapping,
+                          struct writeback_control *wbc)
+{
+       int ret;
+
+       if (!mapping_can_writeback(mapping) ||
+           !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
+               return 0;
+
+       wbc_attach_fdatawrite_inode(wbc, mapping->host);
+       ret = do_writepages(mapping, wbc);
+       wbc_detach_inode(wbc);
+       return ret;
+}
+EXPORT_SYMBOL(filemap_fdatawrite_wbc);
+
 /**
  * __filemap_fdatawrite_range - start writeback on mapping dirty pages in range
  * @mapping:   address space structure to write
@@ -399,7 +425,6 @@ static int filemap_check_and_keep_errors(struct address_space *mapping)
 int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
                                loff_t end, int sync_mode)
 {
-       int ret;
        struct writeback_control wbc = {
                .sync_mode = sync_mode,
                .nr_to_write = LONG_MAX,
@@ -407,14 +432,7 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
                .range_end = end,
        };
 
-       if (!mapping_can_writeback(mapping) ||
-           !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
-               return 0;
-
-       wbc_attach_fdatawrite_inode(&wbc, mapping->host);
-       ret = do_writepages(mapping, &wbc);
-       wbc_detach_inode(&wbc);
-       return ret;
+       return filemap_fdatawrite_wbc(mapping, &wbc);
 }
 
 static inline int __filemap_fdatawrite(struct address_space *mapping,