summaryrefslogtreecommitdiff
path: root/csum-file.c
diff options
context:
space:
mode:
authorNeeraj Singh <neerajsi@microsoft.com>2022-03-10 22:43:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-03-10 23:10:22 (GMT)
commit020406eaa52e67440d9b78087ec2ce25532cb219 (patch)
tree1e1946931dc25e380e3cadce28ac08dab9019c1f /csum-file.c
parentabf38abec201cded6094801766d69e11a6c112b6 (diff)
downloadgit-020406eaa52e67440d9b78087ec2ce25532cb219.zip
git-020406eaa52e67440d9b78087ec2ce25532cb219.tar.gz
git-020406eaa52e67440d9b78087ec2ce25532cb219.tar.bz2
core.fsync: introduce granular fsync control infrastructure
This commit introduces the infrastructure for the core.fsync configuration knob. The repository components we want to sync are identified by flags so that we can turn on or off syncing for specific components. If core.fsyncObjectFiles is set and the core.fsync configuration also includes FSYNC_COMPONENT_LOOSE_OBJECT, we will fsync any loose objects. This picks the strictest data integrity behavior if core.fsync and core.fsyncObjectFiles are set to conflicting values. This change introduces the currently unused fsync_component helper, which will be used by a later patch that adds fsyncing to the refs backend. Actual configuration and documentation of the fsync components list are in other patches in the series to separate review of the underlying mechanism from the policy of how it's configured. Helped-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Neeraj Singh <neerajsi@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'csum-file.c')
-rw-r--r--csum-file.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/csum-file.c b/csum-file.c
index 26e8a6d..59ef339 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -58,7 +58,8 @@ static void free_hashfile(struct hashfile *f)
free(f);
}
-int finalize_hashfile(struct hashfile *f, unsigned char *result, unsigned int flags)
+int finalize_hashfile(struct hashfile *f, unsigned char *result,
+ enum fsync_component component, unsigned int flags)
{
int fd;
@@ -69,7 +70,7 @@ int finalize_hashfile(struct hashfile *f, unsigned char *result, unsigned int fl
if (flags & CSUM_HASH_IN_STREAM)
flush(f, f->buffer, the_hash_algo->rawsz);
if (flags & CSUM_FSYNC)
- fsync_or_die(f->fd, f->name);
+ fsync_component_or_die(component, f->fd, f->name);
if (flags & CSUM_CLOSE) {
if (close(f->fd))
die_errno("%s: sha1 file error on close", f->name);