23d0127096cb ("fs/sync.c: make sync_file_range(2) use WB_SYNC_NONE writeback") claims that sync_file_range(2) syscall was "created for userspace to be able to issue background writeout and so waiting for in-flight IO is undesirable there" and changes the writeback (back) to WB_SYNC_NONE. This claim is only partially true. It is true for users that use the flag SYNC_FILE_RANGE_WRITE by itself, as does PostgreSQL, the user that was the reason for changing to WB_SYNC_NONE writeback. However, that claim is not true for users that use that flag combination SYNC_FILE_RANGE_{WAIT_BEFORE|WRITE|_WAIT_AFTER}. Those users explicitly requested to wait for in-flight IO as well as to writeback of dirty pages. Re-brand that flag combination as SYNC_FILE_RANGE_WRITE_AND_WAIT and use WB_SYNC_ALL writeback to perform the full range sync request.
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -320,6 +320,9 @@ struct fscrypt_key { · 319 unmodified lines | ||
| 320 | 320 | #define SYNC_FILE_RANGE_WAIT_BEFORE 1 |
| 321 | 321 | #define SYNC_FILE_RANGE_WRITE 2 |
| 322 | 322 | #define SYNC_FILE_RANGE_WAIT_AFTER 4 |
| 323 | +#define SYNC_FILE_RANGE_WRITE_AND_WAIT (SYNC_FILE_RANGE_WRITE | \ | |
| 324 | + SYNC_FILE_RANGE_WAIT_BEFORE | \ | |
| 325 | + SYNC_FILE_RANGE_WAIT_AFTER) | |
| 323 | 326 | |
| 324 | 327 | /* |
| 325 | 328 | * Flags for preadv2/pwritev2: |