* Cleanup after batch-mode fsync_object_files. */
| 543 | * Cleanup after batch-mode fsync_object_files. |
| 544 | */ |
| 545 | static 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. */ |
| 578 | static void close_loose_object(struct odb_source_loose *loose, |
no test coverage detected