|
@@ -331,23 +331,14 @@ int filemap_flush(struct address_space *mapping)
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(filemap_flush);
|
|
EXPORT_SYMBOL(filemap_flush);
|
|
|
|
|
|
-/**
|
|
|
|
- * filemap_fdatawait_range - 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.
|
|
|
|
- */
|
|
|
|
-int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte,
|
|
|
|
- loff_t end_byte)
|
|
|
|
|
|
+static int __filemap_fdatawait_range(struct address_space *mapping,
|
|
|
|
+ loff_t start_byte, loff_t end_byte)
|
|
{
|
|
{
|
|
pgoff_t index = start_byte >> PAGE_CACHE_SHIFT;
|
|
pgoff_t index = start_byte >> PAGE_CACHE_SHIFT;
|
|
pgoff_t end = end_byte >> PAGE_CACHE_SHIFT;
|
|
pgoff_t end = end_byte >> PAGE_CACHE_SHIFT;
|
|
struct pagevec pvec;
|
|
struct pagevec pvec;
|
|
int nr_pages;
|
|
int nr_pages;
|
|
- int ret2, ret = 0;
|
|
|
|
|
|
+ int ret = 0;
|
|
|
|
|
|
if (end_byte < start_byte)
|
|
if (end_byte < start_byte)
|
|
goto out;
|
|
goto out;
|
|
@@ -374,6 +365,29 @@ int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte,
|
|
cond_resched();
|
|
cond_resched();
|
|
}
|
|
}
|
|
out:
|
|
out:
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * filemap_fdatawait_range - 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. Check error status of
|
|
|
|
+ * the address space and return it.
|
|
|
|
+ *
|
|
|
|
+ * Since the error status of the address space is cleared by this function,
|
|
|
|
+ * callers are responsible for checking the return value and handling and/or
|
|
|
|
+ * reporting the error.
|
|
|
|
+ */
|
|
|
|
+int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte,
|
|
|
|
+ loff_t end_byte)
|
|
|
|
+{
|
|
|
|
+ int ret, ret2;
|
|
|
|
+
|
|
|
|
+ ret = __filemap_fdatawait_range(mapping, start_byte, end_byte);
|
|
ret2 = filemap_check_errors(mapping);
|
|
ret2 = filemap_check_errors(mapping);
|
|
if (!ret)
|
|
if (!ret)
|
|
ret = ret2;
|
|
ret = ret2;
|
|
@@ -382,12 +396,39 @@ out:
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(filemap_fdatawait_range);
|
|
EXPORT_SYMBOL(filemap_fdatawait_range);
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * filemap_fdatawait_keep_errors - wait for writeback without clearing errors
|
|
|
|
+ * @mapping: address space structure to wait for
|
|
|
|
+ *
|
|
|
|
+ * Walk the list of under-writeback pages of the given address space
|
|
|
|
+ * and wait for all of them. Unlike filemap_fdatawait(), 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)
|
|
|
|
+ */
|
|
|
|
+void filemap_fdatawait_keep_errors(struct address_space *mapping)
|
|
|
|
+{
|
|
|
|
+ loff_t i_size = i_size_read(mapping->host);
|
|
|
|
+
|
|
|
|
+ if (i_size == 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ __filemap_fdatawait_range(mapping, 0, i_size - 1);
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* filemap_fdatawait - wait for all under-writeback pages to complete
|
|
* filemap_fdatawait - wait for all under-writeback pages to complete
|
|
* @mapping: address space structure to wait for
|
|
* @mapping: address space structure to wait for
|
|
*
|
|
*
|
|
* Walk the list of under-writeback pages of the given address space
|
|
* Walk the list of under-writeback pages of the given address space
|
|
- * and wait for all of them.
|
|
|
|
|
|
+ * and wait for all of them. Check error status of the address space
|
|
|
|
+ * and return it.
|
|
|
|
+ *
|
|
|
|
+ * Since the error status of the address space is cleared by this function,
|
|
|
|
+ * callers are responsible for checking the return value and handling and/or
|
|
|
|
+ * reporting the error.
|
|
*/
|
|
*/
|
|
int filemap_fdatawait(struct address_space *mapping)
|
|
int filemap_fdatawait(struct address_space *mapping)
|
|
{
|
|
{
|