]> git.ipfire.org Git - thirdparty/git.git/commit
reftable: honor core.fsync
authorJohn Cai <johncai86@gmail.com>
Tue, 23 Jan 2024 18:51:10 +0000 (18:51 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Jan 2024 21:45:27 +0000 (13:45 -0800)
commit1df18a1c9a50b58afb19ef218f6517f347606800
tree47bc5abcc5b82f4d2ef70c2be9c01351dd46a2d8
parente02ecfcc534e2021aae29077a958dd11c3897e4c
reftable: honor core.fsync

While the reffiles backend honors configured fsync settings, the
reftable backend does not. Address this by fsyncing reftable files using
the write-or-die api's fsync_component() in two places: when we
add additional entries into the table, and when we close the reftable
writer.

This commits adds a flush function pointer as a new member of
reftable_writer because we are not sure that the first argument to the
*write function pointer always contains a file descriptor. In the case of
strbuf_add_void, the first argument is a buffer. This way, we can pass
in a corresponding flush function that knows how to flush depending on
which writer is being used.

This patch does not contain tests as they will need to wait for another
patch to start to exercise the reftable backend. At that point, the
tests will be added to observe that fsyncs are happening when the
reftable is in use.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/merged_test.c
reftable/readwrite_test.c
reftable/refname_test.c
reftable/reftable-writer.h
reftable/stack.c
reftable/test_framework.c
reftable/test_framework.h
reftable/writer.c
reftable/writer.h