mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
Writeback error handling fixes for v4.14
-----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJZrTy3AAoJEAAOaEEZVoIVaucP/ApBAj2S5wzvlV1u6l8E6ae7 ZeEEZfcWwzRYlKjZAkTWqj9XvGpDGO5gLq4wsZK2edFAq++/MJF8ZVtN4tdZ1kUZ DUvRodtVOrT08Kp9wZXGT7JOFrf6U/6gMcR6p0MuWnHndeKYvlpcFi9NPT4EC9/z Zm9V7gtlPdSOha7eaSjUS0+vLERkxqXLBW3Av9QUOBP/lbI3lqIroGKeHDYnVdya 2P/k5EcRRJMyJP6TqyYxmmJl+UWjJFMLvnlUDBslHnD/u3mIUhw3JLHYBjn5dZRE Xjq56IDPoXDUvzlBhtn/Uqyx+/wtwsNsylpmKv6K5G1JfdeuSsPVsCey+A1cqV64 LpE5896wf9TmnmI9LNyh6vDn925xPSGBiF45UEp5f9aO7jXeY0MaEZ8g+ENqFIDK v4gtZdS9FhYHV+/l4qEwYMKrqSbwKEs1r1FT+f4wnABby1ojfdA57ZPlp5PV2Vjp szTp88Zkb7cMvZwEnWwxWofcJNmgS7uNahvnQF3IJ4ITsioEkuyYR3K4ZQMaaaV9 wCp6G0FhXZaK3OI7o9WiDwaO2elp9Hxc8bnqKpiBbHZkY0NLh7/++5VxpeNbTHFy AGijQiiKGNNyYqNj93wq9jpVdMNjB0pXrHRxfav8v7MtQ+WfbEoAENF4T7hN7iXn UuF6eSWEC5O1UCRUk1A+ =LLY3 -----END PGP SIGNATURE----- Merge tag 'wberr-v4.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux Pull writeback error handling updates from Jeff Layton: "This pile continues the work from last cycle on better tracking writeback errors. In v4.13 we added some basic errseq_t infrastructure and converted a few filesystems to use it. This set continues refining that infrastructure, adds documentation, and converts most of the other filesystems to use it. The main exception at this point is the NFS client" * tag 'wberr-v4.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux: ecryptfs: convert to file_write_and_wait in ->fsync mm: remove optimizations based on i_size in mapping writeback waits fs: convert a pile of fsync routines to errseq_t based reporting gfs2: convert to errseq_t based writeback error reporting for fsync fs: convert sync_file_range to use errseq_t based error-tracking mm: add file_fdatawait_range and file_write_and_wait fuse: convert to errseq_t based error tracking for fsync mm: consolidate dax / non-dax checks for writeback Documentation: add some docs for errseq_t errseq: rename __errseq_set to errseq_set
This commit is contained in:
commit
ec3604c7a5
31 changed files with 241 additions and 89 deletions
64
mm/filemap.c
64
mm/filemap.c
|
|
@ -475,6 +475,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
|
||||
|
|
@ -489,45 +512,22 @@ EXPORT_SYMBOL(filemap_fdatawait_range);
|
|||
*/
|
||||
int filemap_fdatawait_keep_errors(struct address_space *mapping)
|
||||
{
|
||||
loff_t i_size = i_size_read(mapping->host);
|
||||
|
||||
if (i_size == 0)
|
||||
return 0;
|
||||
|
||||
__filemap_fdatawait_range(mapping, 0, i_size - 1);
|
||||
__filemap_fdatawait_range(mapping, 0, LLONG_MAX);
|
||||
return filemap_check_and_keep_errors(mapping);
|
||||
}
|
||||
EXPORT_SYMBOL(filemap_fdatawait_keep_errors);
|
||||
|
||||
/**
|
||||
* filemap_fdatawait - wait for all under-writeback pages to complete
|
||||
* @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. 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)
|
||||
static bool mapping_needs_writeback(struct address_space *mapping)
|
||||
{
|
||||
loff_t i_size = i_size_read(mapping->host);
|
||||
|
||||
if (i_size == 0)
|
||||
return 0;
|
||||
|
||||
return filemap_fdatawait_range(mapping, 0, i_size - 1);
|
||||
return (!dax_mapping(mapping) && mapping->nrpages) ||
|
||||
(dax_mapping(mapping) && mapping->nrexceptional);
|
||||
}
|
||||
EXPORT_SYMBOL(filemap_fdatawait);
|
||||
|
||||
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
|
||||
|
|
@ -566,8 +566,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() */
|
||||
|
|
@ -589,7 +588,7 @@ EXPORT_SYMBOL(filemap_write_and_wait_range);
|
|||
|
||||
void __filemap_set_wb_err(struct address_space *mapping, int err)
|
||||
{
|
||||
errseq_t eseq = __errseq_set(&mapping->wb_err, err);
|
||||
errseq_t eseq = errseq_set(&mapping->wb_err, err);
|
||||
|
||||
trace_filemap_set_wb_err(mapping, eseq);
|
||||
}
|
||||
|
|
@ -656,8 +655,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() */
|
||||
|
|
|
|||
Loading…
Reference in a new issue