object-file: rename files transaction fsync function
When writing an object to a "files" ODB transaction, a full hardware flush is not initially performed during the fsync in `fsync_loose_object_transaction()` and instead delayed until the transaction is later committed. To be more consistent with other "files" ODB transaction helpers, rename the function to `odb_transaction_files_fsync()` accordingly. The conditional in the helper is also slightly restructured to improve clarity to readers. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Justin Tobler committed
Jul 10, 2026 at 11:37 UTC
9c182bb59bf0eb7fc3deecec65b4d5efe47df28c
1 file changed
+10
-6
object-file.c
+10
-6
@@ -518,12 +518,17 @@ static void odb_transaction_files_prepare(struct odb_transaction *base)
518
tmp_objdir_replace_primary_odb(transaction->objdir, 0);
519
}
520
521
-static void fsync_loose_object_transaction(struct odb_transaction *base,
522
- int fd, const char *filename)
521
+static void odb_transaction_files_fsync(struct odb_transaction *base,
522
+ int fd, const char *filename)
523
{
524
struct odb_transaction_files *transaction =
525
container_of_or_null(base, struct odb_transaction_files, base);
526
527
+ if (!transaction || !transaction->objdir) {
528
+ fsync_or_die(fd, filename);
529
+ return;
530
+ }
531
+
532
/*
533
* If we have an active ODB transaction, we issue a call that
534
* cleans the filesystem page cache but avoids a hardware flush
@@ -531,8 +536,7 @@ static void fsync_loose_object_transaction(struct odb_transaction *base,
536
* before renaming the objects to their final names as part of
537
* flush_batch_fsync.
538
*/
534
- if (!transaction || !transaction->objdir ||
535
- git_fsync(fd, FSYNC_WRITEOUT_ONLY) < 0) {
539
+ if (git_fsync(fd, FSYNC_WRITEOUT_ONLY) < 0) {
540
if (errno == ENOSYS)
541
warning(_("core.fsyncMethod = batch is unsupported on this platform"));
542
fsync_or_die(fd, filename);
@@ -553,7 +557,7 @@ static void flush_loose_object_transaction(struct odb_transaction_files *transac
557
/*
558
* Issue a full hardware flush against a temporary file to ensure
559
* that all objects are durable before any renames occur. The code in
556
- * fsync_loose_object_transaction has already issued a writeout
560
+ * odb_transaction_files_fsync has already issued a writeout
561
* request, but it has not flushed any writeback cache in the storage
562
* hardware or any filesystem logs. This fsync call acts as a barrier
563
* to ensure that the data in each new object file is durable before
@@ -582,7 +586,7 @@ static void close_loose_object(struct odb_source_loose *loose,
586
goto out;
587
588
if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))
585
- fsync_loose_object_transaction(loose->base.odb->transaction, fd, filename);
589
+ odb_transaction_files_fsync(loose->base.odb->transaction, fd, filename);
590
else if (fsync_object_files > 0)
591
fsync_or_die(fd, filename);
592
else