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

Re: [PATCH] write_sha1_buffer

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 16, 2005, 02:55 UTC
Message-ID
<Pine.LNX.4.58.0504151942130.7211@ppc970.osdl.org>
In-Reply-To
<118833cc05041517502fa52a89@mail.gmail.com>
On Fri, 15 Apr 2005, Morten Welinder wrote:
>
> This write will failing sooner or later when someone's disk fills up. 
> That'll leave someone with a truncated file.

Yes. On the other hand, we could try to do this even better, ie make the classic write loop that handles EAGAIN.

No POSIX filesystem is supposed to return EAGAIN, but there are tons of "POSIX enough" filesystems. Notably NFS when mounted with "intr" (which some people think is wrong, but it tends to be better than the alternatives if your network is flaky enough).

But yes, even just a "write failed" is good enough, except you should also make sure that you remove the corrupt file. Sure, fsck will catch it, but if you don't do an fsck, somebody else might decide not to write the file out simply because "it's already there".

(This is also why we should write to a temp-file and then do an atomic "rename()").

		Linus
Previous: Morten WelinderNext: Linus Torvalds
Message 2 of 3 in “write_sha1_buffer”
  1. write_sha1_bufferMorten Welinder, Apr 16, 2005
  2. Linus TorvaldsApr 16, 2005
  3. Linus TorvaldsApr 16, 2005

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.