Skip to content

Commit 4bc1fd6

Browse files
avargitster
authored andcommitted
pack-objects: rename .idx files into place after .bitmap files
In preceding commits the race of renaming .idx files in place before .rev files and other auxiliary files was fixed in pack-write.c's finish_tmp_packfile(), builtin/repack.c's "struct exts", and builtin/index-pack.c's final(). As noted in the change to pack-write.c we left in place the issue of writing *.bitmap files after the *.idx, let's fix that issue. See 7cc8f97 (pack-objects: implement bitmap writing, 2013-12-21) for commentary at the time when *.bitmap was implemented about how those files are written out, nothing in that commit contradicts what's being done here. Note that this commit and preceding ones only close any race condition with *.idx files being written before their auxiliary files if we're optimistic about our lack of fsync()-ing in this are not tripping us over. See the thread at [1] for a rabbit hole of various discussions about filesystem races in the face of doing and not doing fsync() (and if doing fsync(), not doing it properly). We may want to fsync the containing directory once after renaming the *.idx file into place, but that is outside the scope of this series. 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2ec02dd commit 4bc1fd6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,6 @@ static void write_pack_file(void)
12501250
stage_tmp_packfiles(&tmpname, pack_tmp_name,
12511251
written_list, nr_written,
12521252
&pack_idx_opts, hash, &idx_tmp_name);
1253-
rename_tmp_packfile_idx(&tmpname, &idx_tmp_name);
12541253

12551254
if (write_bitmap_index) {
12561255
size_t tmpname_len = tmpname.len;
@@ -1267,6 +1266,8 @@ static void write_pack_file(void)
12671266
strbuf_setlen(&tmpname, tmpname_len);
12681267
}
12691268

1269+
rename_tmp_packfile_idx(&tmpname, &idx_tmp_name);
1270+
12701271
free(idx_tmp_name);
12711272
strbuf_release(&tmpname);
12721273
free(pack_tmp_name);

0 commit comments

Comments
 (0)