git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Enable core.fsyncObjectFiles by default

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 24, 2015, 05:32 UTC
Message-ID
<xmqqegl1brjb.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150623232921.GB14324@thunk.org>
Theodore Ts'o <tytso@mit.edu> writes:
Show 6 quoted lines
> The main issue is that non-expert users might not realize that they
> really need to run "git fsck" after a crash; otherwise, what might
> happen is that although git is only appending, that you might have
> some zero-length (or partially written) git object or pack files, and
> while you might not notice at that moment, it might come and bite you
> later.

Regarding loose object files, given that we write to a temporary, optionally fsync, close and then move to the final name, would we still see partially written file if we omit the fsync, or would the corruption be limited to either empty or missing?

The reason I am wondering is because the codepath to create an object (i.e. "update-index --add", "hash-object -w", or "add") first checks if a packed or a loose object file _exists_ and if so bypasses writing the same thing anew, but the existence check for a loose object is to merely making sure that access(F_OK) (and optionally utime()) succeeds. If the potential breakage is limited to truncation to empty, then we could replace it with stat(2) and st.st_size check, as no loose object file can be empty.

Previous: Theodore Ts'oNext: Theodore Ts'o
Message 4 of 8 in “Enable core.fsyncObjectFiles by default”
  1. Enable core.fsyncObjectFiles by defaultStefan Beller, Jun 23, 2015
  2. Junio C HamanoJun 23, 2015
  3. Theodore Ts'oJun 23, 2015
  4. Junio C HamanoJun 24, 2015
  5. Theodore Ts'oJun 24, 2015
  6. Duy NguyenJun 24, 2015
  7. Jeff KingJun 24, 2015
  8. Junio C HamanoJun 24, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.