forked fromtorvalds/linux
- Notifications
You must be signed in to change notification settings - Fork0
Commit735e4ae
vfs: track per-sb writeback errors and report them to syncfs
Patch series "vfs: have syncfs() return error when there are writebackerrors", v6.Currently, syncfs does not return errors when one of the inodes fails tobe written back. It will return errors based on the legacy AS_EIO andAS_ENOSPC flags when syncing out the block device fails, but that's notparticularly helpful for filesystems that aren't backed by a blockdev.It's also possible for a stray sync to lose those errors.The basic idea in this set is to track writeback errors at thesuperblock level, so that we can quickly and easily check whethersomething bad happened without having to fsync each file individually.syncfs is then changed to reliably report writeback errors after theyoccur, much in the same fashion as fsync does now.This patch (of 2):Usually we suggest that applications call fsync when they want to ensurethat all data written to the file has made it to the backing store, butthat can be inefficient when there are a lot of open files.Calling syncfs on the filesystem can be more efficient in somesituations, but the error reporting doesn't currently work the way mostpeople expect. If a single inode on a filesystem reports a writebackerror, syncfs won't necessarily return an error. syncfs only returns anerror if __sync_blockdev fails, and on some filesystems that's a no-op.It would be better if syncfs reported an error if there were anywriteback failures. Then applications could call syncfs to see if thereare any errors on any open files, and could then call fsync on all ofthe other descriptors to figure out which one failed.This patch adds a new errseq_t to struct super_block, and hasmapping_set_error also record writeback errors there.To report those errors, we also need to keep an errseq_t in struct fileto act as a cursor. This patch adds a dedicated field for that purpose,which slots nicely into 4 bytes of padding at the end of struct file onx86_64.An earlier version of this patch used an O_PATH file descriptor to cuethe kernel that the open file should track the superblock error and notthe inode's writeback error.I think that API is just too weird though. This is simpler and shouldmake syncfs error reporting "just work" even if someone is multiplexingfsync and syncfs on the same fds.Signed-off-by: Jeff Layton <jlayton@kernel.org>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Reviewed-by: Jan Kara <jack@suse.cz>Cc: Andres Freund <andres@anarazel.de>Cc: Matthew Wilcox <willy@infradead.org>Cc: Al Viro <viro@zeniv.linux.org.uk>Cc: Christoph Hellwig <hch@infradead.org>Cc: Dave Chinner <david@fromorbit.com>Cc: David Howells <dhowells@redhat.com>Link:http://lkml.kernel.org/r/20200428135155.19223-1-jlayton@kernel.orgLink:http://lkml.kernel.org/r/20200428135155.19223-2-jlayton@kernel.orgSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent78128fa commit735e4ae
6 files changed
+27
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
380 | 381 | | |
381 | 382 | | |
382 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
746 | | - | |
747 | | - | |
748 | 746 | | |
| 747 | + | |
749 | 748 | | |
750 | 749 | | |
751 | 750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
174 | 176 | | |
175 | | - | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
976 | 976 | | |
977 | 977 | | |
978 | 978 | | |
| 979 | + | |
979 | 980 | | |
980 | 981 | | |
981 | 982 | | |
| |||
1520 | 1521 | | |
1521 | 1522 | | |
1522 | 1523 | | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
1523 | 1527 | | |
1524 | 1528 | | |
1525 | 1529 | | |
| |||
2827 | 2831 | | |
2828 | 2832 | | |
2829 | 2833 | | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
2830 | 2846 | | |
2831 | 2847 | | |
2832 | 2848 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
0 commit comments
Comments
(0)