MCPcopy Create free account
hub / github.com/git/git / flush_loose_object_transaction

Function flush_loose_object_transaction

object-file.c:545–575  ·  view source on GitHub ↗

* Cleanup after batch-mode fsync_object_files. */

Source from the content-addressed store, hash-verified

543 * Cleanup after batch-mode fsync_object_files.
544 */
545static void flush_loose_object_transaction(struct odb_transaction_files *transaction)
546{
547 struct strbuf temp_path = STRBUF_INIT;
548 struct tempfile *temp;
549
550 if (!transaction->objdir)
551 return;
552
553 /*
554 * Issue a full hardware flush against a temporary file to ensure
555 * that all objects are durable before any renames occur. The code in
556 * fsync_loose_object_transaction has already issued a writeout
557 * request, but it has not flushed any writeback cache in the storage
558 * hardware or any filesystem logs. This fsync call acts as a barrier
559 * to ensure that the data in each new object file is durable before
560 * the final name is visible.
561 */
562 strbuf_addf(&temp_path, "%s/bulk_fsync_XXXXXX",
563 repo_get_object_directory(transaction->base.source->odb->repo));
564 temp = xmks_tempfile(temp_path.buf);
565 fsync_or_die(get_tempfile_fd(temp), get_tempfile_path(temp));
566 delete_tempfile(&temp);
567 strbuf_release(&temp_path);
568
569 /*
570 * Make the object files visible in the primary ODB after their data is
571 * fully durable.
572 */
573 tmp_objdir_migrate(transaction->objdir);
574 transaction->objdir = NULL;
575}
576
577/* Finalize a file on disk, and close it. */
578static void close_loose_object(struct odb_source_loose *loose,

Callers 1

Calls 9

strbuf_addfFunction · 0.85
xmks_tempfileFunction · 0.85
fsync_or_dieFunction · 0.85
get_tempfile_fdFunction · 0.85
get_tempfile_pathFunction · 0.85
delete_tempfileFunction · 0.85
strbuf_releaseFunction · 0.85
tmp_objdir_migrateFunction · 0.85

Tested by

no test coverage detected