|
|
Subscribe / Log in / New account

What about other filesystems?

What about other filesystems?

Posted Jan 17, 2021 4:41 UTC (Sun) by NYKevin (subscriber, #129325)
In reply to: What about other filesystems? by Wol
Parent article: Fast commits for ext4

It depends. Let's go through these:

- For fsync()'ing multiple files, the standard answer is "use a thread pool." This is also the standard answer to "I want asynchronous I/O like on Windows," so no surprise there.
- As the article mentions, they are discussing an "fsync multiple files" syscall, which will (probably) further alleviate this problem (if it actually happens).
- I'm not aware of any syscall called "fsfsync()," so I assume you meant syncfs(2). That function is not in POSIX, so all we have to go on is the note in that man page, which explicitly states that "sync() or syncfs() provide the same guarantees as fsync() called on every file in the system or filesystem respectively."
- POSIX says that sync(2) is not required to wait for the writes to complete before returning (unlike fsync()). As noted above, POSIX does not specify syncfs() at all.
- Arguably, a conforming implementation could implement sync() as a no-op, because POSIX says it causes outstanding data "to be scheduled for writing out" - but it was *already* scheduled for writing out.
- Therefore, if you want to be pedantically POSIX-correct, you should not use sync(2) at all, because it gets you exactly nothing according to the standard.
- Since syncfs() is already Linux-specific, you can rely on its Linux-specific guarantees, if you are in a position to call it in the first place.


to post comments

What about other filesystems?

Posted Jan 18, 2021 5:34 UTC (Mon) by joib (subscriber, #8541) [Link] (2 responses)

I believe io_uring supports fsync, so that would be a way to do an asynchronous fsync on somewhat modern Linux.

What about other filesystems?

Posted Jan 18, 2021 7:16 UTC (Mon) by NYKevin (subscriber, #129325) [Link]

Well, you can also use aio_fsync(3), but that's basically just a crappier version of "use a thread pool."

IMHO this is a broader issue with aio(7) and not a problem with fsync in particular.

What about other filesystems?

Posted Jan 18, 2021 10:45 UTC (Mon) by farnz (subscriber, #17727) [Link]

io_uring does provide the primitives needed; there's IORING_OP_FSYNC (with IORING_FSYNC_DATASYNC to weaken from fsync to fdatasync) and IORING_OP_SYNC_FILE_RANGE for flushing caches asynchronously, and the IOSQE_IO_DRAIN and IOSQE_IO_LINK flags to order io_uring operations with respect to each other so that you can issue the fsync after all the related writes have been done.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds