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

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

From
Junio C Hamano <junkio@cox.net>
Date
Oct 5, 2006, 06:15 UTC
Message-ID
<7vodsrguej.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0610041954480.3952@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> Yes, there should be a fflush() there before the fsync.

While I have your attention... The code that follows the committing of packed-refs file by calling rename() to move the lock file to its final name prunes already packed refs, and we should really make sure the effect of rename() survives before starting to remove loose refs from the filesystem.

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.

If the write-out of metainfo is ordered enough that if we rename the packed-refs lock file to its final destination and then we unlink loose refs, it might be reasonably safe to assume that rename(2)'s effect has already hit the disk when the effect of unlink(2) does, of the machine crashes in the meantime, as long as none of the later unlink hits the disk before rename does it is Ok.

Previous: Linus TorvaldsNext: Linus Torvalds
Message 3 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.