History

fs/sync.c: sync_file_range(2) may use WB_SYNC_ALL writeback

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.

Amir Goldstein committed 7 years ago

Commit c553ea41 parent 53269052 files · +18 −6Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/fs.h+3−0
@@ -320,6 +320,9 @@ struct fscrypt_key { · 319 unmodified lines
320320 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
321321 #define SYNC_FILE_RANGE_WRITE 2
322322 #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)
323326
324327 /*
325328 * Flags for preadv2/pwritev2: