New: man 2 fsync implies possibility to return early
A message that is not in the archive (sent off-list or not yet received): [email protected]/
[CC += LKML and a few kernel programmers]
Hi,
Quoted 28 lines · On 10/29/21 23:25, [email protected] wrote:
https://bugzilla.kernel.org/show_bug.cgi?id=214873
Bug ID: 214873
Summary: man 2 fsync implies possibility to return early
Product: Documentation
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: low
Priority: P1
Component: man-pages
Assignee: [email protected]
Reporter: [email protected]
Regression: NoThe manpage for the fsync system call (
https://man7.org/linux/man-pages/man2/fsync.2.html ) describes as flushing the related caches to a storage device so that the information can even be retrieved after a crash/reboot. But then it does make the statement "The call blocks until the device reports that the transfer has completed." which causes now some interpretation: What happens if the device reports early completion (e.g. via a bugged firmware) of the transfer while the kernel still sees unsent caches in its context? Doesfsync()indeed return then as the last referenced sentence implies or does it continue to send the caches the kernel sees to guarantee data integrity as good as possible as the previous documented part might imply?
Quoted 7 lines
I noticed this discrepancy when reporting a bug against dd (
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51345 ) that causes dd to return early when it is used with its fsync capability while the kernel still sees caches and consulting thefsync()manpage made it not clear if such a theoretical possibility from thefsync()system call would be intended or not so eventually this part could be slighty enhanced.
I don't know how fsync(2) works. Could some kernel fs programmer please check if the text matches the implementation, and if that issue reported should be reworded in the manual page?
Thanks,
Alex
Signature · 3 lines
Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/
Quoted 41 lines · Alejandro Colomar (man-pages)
[CC += LKML and a few kernel programmers]
Hi,
Quoted 28 lines · On 10/29/21 23:25, [email protected] wrote:
https://bugzilla.kernel.org/show_bug.cgi?id=214873
Bug ID: 214873
Summary: man 2 fsync implies possibility to return early
Product: Documentation
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: low
Priority: P1
Component: man-pages
Assignee: [email protected]
Reporter: [email protected]
Regression: NoThe manpage for the fsync system call (
https://man7.org/linux/man-pages/man2/fsync.2.html ) describes as flushing the related caches to a storage device so that the information can even be retrieved after a crash/reboot. But then it does make the statement "The call blocks until the device reports that the transfer has completed." which causes now some interpretation: What happens if the device reports early completion (e.g. via a bugged firmware) of the transfer while the kernel still sees unsent caches in its context? Doesfsync()indeed return then as the last referenced sentence implies or does it continue to send the caches the kernel sees to guarantee data integrity as good as possible as the previous documented part might imply?Quoted 7 lines
I noticed this discrepancy when reporting a bug against dd (
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51345 ) that causes dd to return early when it is used with its fsync capability while the kernel still sees caches and consulting thefsync()manpage made it not clear if such a theoretical possibility from thefsync()system call would be intended or not so eventually this part could be slighty enhanced.
Quoted 3 lines
I don't know how fsync(2) works. Could some kernel fs programmer please check if the text matches the implementation, and if that issue reported should be reworded in the manual page?
I don't know what the "see caches" mean in a few spots in the above text? In simplified terms, fsync will write out dirty data and then ensure that it is stable on media. The latter is your cache flush, if the underlying device is using some sort of writeback caching. When the flush is issued, there is no more dirty kernel cached data.
If the device doesn't honor a cache flush (eg "all writes previously acked are now stable"), then there's nothing the kernel can do about it. It would not even know. The only way to know is if a powercut comes in after a flush, and once power is restored, the media contains stale data.
There is no issue here. If your storage device is lying to you, buy better storage devices.
Signature · 1 line
Jens Axboe
A message that is not in the archive (sent off-list or not yet received): [email protected]/
Re: [Bug 214873] man 2 fsync implies possibility to return early
[Add CCs]
Hi Jens,
Quoted 9 lines · On 11/8/21 00:24, [email protected] wrote:
https://bugzilla.kernel.org/show_bug.cgi?id=214873
[email protected] changed:
What |Removed |Added
----------------------------------------------------------------------------Status|RESOLVED |REOPENED Resolution|INVALID |---
Quoted 9 lines
--- Comment #5 from [email protected] ---
This ticket was closed pretty fast after comment #2 so I could not write comment #4 before closing this ticket and now it seems due to it being closed it does not receive attention anymore. Thus I'm reopening this ticket so that comment #4 can be evaluated if this makes changes to the manpage valid.But if you think there is really nothing that needs to be changed feel free to close this ticket again as I then won't bother about it here anymore.
That comment (and the previous) was directed to you, but since you're not CCd in this bugzilla issue, you didn't receive it. Could you please have a look at it.
I also CCd the same other emails as in my previous email, since some of them may want to have a look at it too.
Thanks,
Alex
Signature · 3 lines
Alejandro Colomar Linux man-pages comaintainer; http://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/