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

Re: [PATCH] pack-refs: use lockfile as everybody else does.

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 5, 2006, 14:51 UTC
Message-ID
<Pine.LNX.4.64.0610050747590.3952@g5.osdl.org>
In-Reply-To
<7vodsrguej.fsf@assigned-by-dhcp.cox.net>
On Wed, 4 Oct 2006, Junio C Hamano wrote:
Show 6 quoted lines
> 
> How would one ensure the effect of rename(2) hits the disk
> platter before proceeding to do something else?  We seem to do
> sync(1) in git-repack.sh for similar reasons, and I wonder if we
> should do a sync(2) there.  I doubt it would be worth it though;
> the function can return before the actual writing is done.

sync() is supposed to wait until the data is on the disk, anything else is likely to be a bad implementation (even if POSIX may not _guarantee_ it).

Also, most filesystems (for various reasons, not the least of which is "speed of fsck") will journal metadata, but not file contents. Which means that if a crash happens and one of the loose refs has already been removed, then (thanks to journaling) that means that on most filesystems the rename would already have been guaranteed to hit the disk - even regardless of any sync().

So in practice, it's much more important to guarantee the file contents (the fsync) part, because the OS already tends to guarantee metadata ordering.

			Linus
Previous: Junio C Hamano
Message 4 of 4 in “pack-refs: use lockfile as everybody else does.”
  1. pack-refs: use lockfile as everybody else does.Junio C Hamano, Oct 3, 2006
  2. Linus TorvaldsOct 5, 2006
  3. Junio C HamanoOct 5, 2006
  4. Linus TorvaldsOct 5, 2006

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.