Skip to content

Commit 333427a

Browse files
committed
btrfs: minimal conversion to errseq_t writeback error reporting on fsync
Just check and advance the errseq_t in the file before returning, and use an errseq_t based check for writeback errors. Other internal callers of filemap_* functions are left as-is. Signed-off-by: Jeff Layton <[email protected]>
1 parent 1b18027 commit 333427a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/btrfs/file.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
20112011
struct btrfs_root *root = BTRFS_I(inode)->root;
20122012
struct btrfs_trans_handle *trans;
20132013
struct btrfs_log_ctx ctx;
2014-
int ret = 0;
2014+
int ret = 0, err;
20152015
bool full_sync = 0;
20162016
u64 len;
20172017

@@ -2030,7 +2030,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
20302030
*/
20312031
ret = start_ordered_ops(inode, start, end);
20322032
if (ret)
2033-
return ret;
2033+
goto out;
20342034

20352035
inode_lock(inode);
20362036
atomic_inc(&root->log_batch);
@@ -2135,10 +2135,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
21352135
* An ordered extent might have started before and completed
21362136
* already with io errors, in which case the inode was not
21372137
* updated and we end up here. So check the inode's mapping
2138-
* flags for any errors that might have happened while doing
2139-
* writeback of file data.
2138+
* for any errors that might have happened since we last
2139+
* checked called fsync.
21402140
*/
2141-
ret = filemap_check_errors(inode->i_mapping);
2141+
ret = filemap_check_wb_err(inode->i_mapping, file->f_wb_err);
21422142
inode_unlock(inode);
21432143
goto out;
21442144
}
@@ -2227,6 +2227,9 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
22272227
ret = btrfs_end_transaction(trans);
22282228
}
22292229
out:
2230+
err = file_check_and_advance_wb_err(file);
2231+
if (!ret)
2232+
ret = err;
22302233
return ret > 0 ? -EIO : ret;
22312234
}
22322235

0 commit comments

Comments
 (0)