Skip to contentSkip to conversation

sync.2: syncfs() now returns errors if writeback fails

PATCH Superseded Jeff Layton 3 participants 5 messages Jun 10, 2020 – Jun 25, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sync.2: syncfs() now returns errors if writeback fails

A patch has been merged for v5.8 that changes how syncfs() reports errors. Change the sync() manpage accordingly.

---
 man2/sync.2 | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
man2/sync.2 +23 -1
index 7198f3311b05..27e04cff5845 100644
@@ -86,11 +86,26 @@ to indicate the error.
 is always successful.
 .PP
 .BR syncfs ()
-can fail for at least the following reason:
+can fail for at least the following reasons:
 .TP
 .B EBADF
 .I fd
 is not a valid file descriptor.
+.TP
+.B EIO
+An error occurred during synchronization.
+This error may relate to data written to any file on the filesystem, or on
+metadata related to the filesytem itself.
+.TP
+.B ENOSPC
+Disk space was exhausted while synchronizing.
+.TP
+.BR ENOSPC ", " EDQUOT
+Data was written to a files on NFS or another filesystem which does not
+allocate space at the time of a
+.BR write (2)
+system call, and some previous write failed due to insufficient
+storage space.
 .SH VERSIONS
 .BR syncfs ()
 first appeared in Linux 2.6.39;
@@ -121,6 +136,13 @@ or
 .BR syncfs ()
 provide the same guarantees as fsync called on every file in
 the system or filesystem respectively.
+.PP
+In mainline kernel versions prior to 5.8,
+.\" commit 735e4ae5ba28c886d249ad04d3c8cc097dad6336
+.BR syncfs ()
+will only fail with EBADF when passed a bad file descriptor. In 5.8
+and later kernels, it will also report an error if one or more inodes failed
+to be written back since the last syncfs call.
 .SH BUGS
 Before version 1.3.20 Linux did not wait for I/O to complete
 before returning.
Signature · 1 line
2.26.2
#1 lore raw
Quoted 41 lines · Jeff Layton

A patch has been merged for v5.8 that changes how syncfs() reports errors. Change the sync() manpage accordingly.

---
 man2/sync.2 | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
man2/sync.2 +16 -1
index 7198f3311b05..27e04cff5845 100644
@@ -86,11 +86,26 @@ to indicate the error.
 is always successful.
 .PP
 .BR syncfs ()
-can fail for at least the following reason:
+can fail for at least the following reasons:
 .TP
 .B EBADF
 .I fd
 is not a valid file descriptor.
+.TP
+.B EIO
+An error occurred during synchronization.
+This error may relate to data written to any file on the filesystem, or on
+metadata related to the filesytem itself.
+.TP
+.B ENOSPC
+Disk space was exhausted while synchronizing.
+.TP
+.BR ENOSPC ", " EDQUOT
+Data was written to a files on NFS or another filesystem which does not
+allocate space at the time of a
+.BR write (2)
+system call, and some previous write failed due to insufficient
+storage space.
 .SH VERSIONS
 .BR syncfs ()
 first appeared in Linux 2.6.39;

man2/sync.2 or · line 145

Quoted 10 lines
man2/sync.2 +7 -0
@@ -121,6 +136,13 @@ or
 .BR syncfs ()
 provide the same guarantees as fsync called on every file in
 the system or filesystem respectively.
+.PP
+In mainline kernel versions prior to 5.8,
+.\" commit 735e4ae5ba28c886d249ad04d3c8cc097dad6336
+.BR syncfs ()
+will only fail with EBADF when passed a bad file descriptor. In 5.8
+and later kernels, it will also report an error if one or more inodes failed
+to be written back since the last syncfs call.

The sentence "In mainline kernel versions prior to 5.8, syncfs() will only fail with EBADF when passed a bad file descriptor" is ambiguous. It could mean that EBADF can now mean other things too.

Maybe write: "In mainline kernel versions prior to 5.8, syncfs() will only fail when passed a bad file descriptor (EBADF)."

- Eric

#2 lore raw
Quoted 57 lines · Eric Biggers
Quoted 41 lines · Jeff Layton

A patch has been merged for v5.8 that changes how syncfs() reports errors. Change the sync() manpage accordingly.

---
 man2/sync.2 | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
man2/sync.2 +16 -1
index 7198f3311b05..27e04cff5845 100644
@@ -86,11 +86,26 @@ to indicate the error.
 is always successful.
 .PP
 .BR syncfs ()
-can fail for at least the following reason:
+can fail for at least the following reasons:
 .TP
 .B EBADF
 .I fd
 is not a valid file descriptor.
+.TP
+.B EIO
+An error occurred during synchronization.
+This error may relate to data written to any file on the filesystem, or on
+metadata related to the filesytem itself.
+.TP
+.B ENOSPC
+Disk space was exhausted while synchronizing.
+.TP
+.BR ENOSPC ", " EDQUOT
+Data was written to a files on NFS or another filesystem which does not
+allocate space at the time of a
+.BR write (2)
+system call, and some previous write failed due to insufficient
+storage space.
 .SH VERSIONS
 .BR syncfs ()
 first appeared in Linux 2.6.39;

man2/sync.2 or · line 145

Quoted 10 lines
man2/sync.2 +7 -0
@@ -121,6 +136,13 @@ or
 .BR syncfs ()
 provide the same guarantees as fsync called on every file in
 the system or filesystem respectively.
+.PP
+In mainline kernel versions prior to 5.8,
+.\" commit 735e4ae5ba28c886d249ad04d3c8cc097dad6336
+.BR syncfs ()
+will only fail with EBADF when passed a bad file descriptor. In 5.8
+and later kernels, it will also report an error if one or more inodes failed
+to be written back since the last syncfs call.

The sentence "In mainline kernel versions prior to 5.8, syncfs() will only fail with EBADF when passed a bad file descriptor" is ambiguous. It could mean that EBADF can now mean other things too.

Quoted 4 lines

Maybe write: "In mainline kernel versions prior to 5.8, syncfs() will only fail when passed a bad file descriptor (EBADF)."

- Eric

Good point. Fixed in my tree using your verbiage. I'll send out a v2 patch once I give others a chance to comment.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>
#3 lore raw

Hi Jeff,

Any progress with v2 of this patch?

Thanks,

Michael

Quoted 68 lines · Jeff Layton
Quoted 57 lines · Eric Biggers
Quoted 41 lines · Jeff Layton

A patch has been merged for v5.8 that changes how syncfs() reports errors. Change the sync() manpage accordingly.

---
 man2/sync.2 | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
man2/sync.2 +16 -1
index 7198f3311b05..27e04cff5845 100644
@@ -86,11 +86,26 @@ to indicate the error.
 is always successful.
 .PP
 .BR syncfs ()
-can fail for at least the following reason:
+can fail for at least the following reasons:
 .TP
 .B EBADF
 .I fd
 is not a valid file descriptor.
+.TP
+.B EIO
+An error occurred during synchronization.
+This error may relate to data written to any file on the filesystem, or on
+metadata related to the filesytem itself.
+.TP
+.B ENOSPC
+Disk space was exhausted while synchronizing.
+.TP
+.BR ENOSPC ", " EDQUOT
+Data was written to a files on NFS or another filesystem which does not
+allocate space at the time of a
+.BR write (2)
+system call, and some previous write failed due to insufficient
+storage space.
 .SH VERSIONS
 .BR syncfs ()
 first appeared in Linux 2.6.39;

man2/sync.2 or · line 145

Quoted 10 lines
man2/sync.2 +7 -0
@@ -121,6 +136,13 @@ or
 .BR syncfs ()
 provide the same guarantees as fsync called on every file in
 the system or filesystem respectively.
+.PP
+In mainline kernel versions prior to 5.8,
+.\" commit 735e4ae5ba28c886d249ad04d3c8cc097dad6336
+.BR syncfs ()
+will only fail with EBADF when passed a bad file descriptor. In 5.8
+and later kernels, it will also report an error if one or more inodes failed
+to be written back since the last syncfs call.

The sentence "In mainline kernel versions prior to 5.8, syncfs() will only fail with EBADF when passed a bad file descriptor" is ambiguous. It could mean that EBADF can now mean other things too.

Quoted 4 lines

Maybe write: "In mainline kernel versions prior to 5.8, syncfs() will only fail when passed a bad file descriptor (EBADF)."

- Eric

Good point. Fixed in my tree using your verbiage. I'll send out a v2 patch once I give others a chance to comment.

Thanks!

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#4 lore raw
Quoted 8 lines · Michael Kerrisk (man-pages)

Hi Jeff,

Any progress with v2 of this patch?

Thanks,

Michael

Just sent it. Thanks for the reminder!

Quoted 72 lines · Jeff Layton
Quoted 68 lines · Eric Biggers
Quoted 57 lines · Jeff Layton
Quoted 41 lines

A patch has been merged for v5.8 that changes how syncfs() reports errors. Change the sync() manpage accordingly.

---
 man2/sync.2 | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
man2/sync.2 +16 -1
index 7198f3311b05..27e04cff5845 100644
@@ -86,11 +86,26 @@ to indicate the error.
 is always successful.
 .PP
 .BR syncfs ()
-can fail for at least the following reason:
+can fail for at least the following reasons:
 .TP
 .B EBADF
 .I fd
 is not a valid file descriptor.
+.TP
+.B EIO
+An error occurred during synchronization.
+This error may relate to data written to any file on the filesystem, or on
+metadata related to the filesytem itself.
+.TP
+.B ENOSPC
+Disk space was exhausted while synchronizing.
+.TP
+.BR ENOSPC ", " EDQUOT
+Data was written to a files on NFS or another filesystem which does not
+allocate space at the time of a
+.BR write (2)
+system call, and some previous write failed due to insufficient
+storage space.
 .SH VERSIONS
 .BR syncfs ()
 first appeared in Linux 2.6.39;

man2/sync.2 or · line 145

Quoted 10 lines
man2/sync.2 +7 -0
@@ -121,6 +136,13 @@ or
 .BR syncfs ()
 provide the same guarantees as fsync called on every file in
 the system or filesystem respectively.
+.PP
+In mainline kernel versions prior to 5.8,
+.\" commit 735e4ae5ba28c886d249ad04d3c8cc097dad6336
+.BR syncfs ()
+will only fail with EBADF when passed a bad file descriptor. In 5.8
+and later kernels, it will also report an error if one or more inodes failed
+to be written back since the last syncfs call.

The sentence "In mainline kernel versions prior to 5.8, syncfs() will only fail with EBADF when passed a bad file descriptor" is ambiguous. It could mean that EBADF can now mean other things too.

Quoted 4 lines

Maybe write: "In mainline kernel versions prior to 5.8, syncfs() will only fail when passed a bad file descriptor (EBADF)."

- Eric

Good point. Fixed in my tree using your verbiage. I'll send out a v2 patch once I give others a chance to comment.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>