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

Re: tree corrupted on disk quota full

From
Andy Whitcroft <apw@shadowen.org>
Date
Jan 11, 2007, 22:10 UTC
Message-ID
<45A6B5E4.3050007@shadowen.org>
In-Reply-To
<Pine.LNX.4.64.0701111353030.3594@woody.osdl.org>
Linus Torvalds wrote:
Show 39 quoted lines
> 
> On Thu, 11 Jan 2007, Andy Whitcroft wrote:
>> The call was intended to replace a common idiom:
>>
>> if (xwrite(fd, buf, size) != size)
>> 	error
> 
> I really don't agree.
> 
> You should use "write_or_die()" for this idiom.
> 
> There really is two cases:
>  - the complex and robust one: "we will keep writing even in the presense 
>    of partial writes".
> 
>    This is "xwrite()". 
> 
>  - the simple case: "write everything", anything else is an error. This is 
>    "write_or_die()", or "write_in_full()".
> 
> And I claim, that for the "write_in_full()" case, if you EVER get anything 
> but the full length back, that's an error.
> 
> And it should be treated as such. There is NO POINT in write_in_full() 
> ever returning a partial result. It's unrecoverable by design - and if it 
> wasn't, you wouldn't use "write_in_full()" in the first place, you'd just 
> use "xwrite()".
> 
> And returning a partial result in that case is just a recipe for disaster. 
> I already pointed to one real bug due to this: write_buffer() was (and 
> currently is) simply buggy. And it's buggy EXACTLY becaue 
> "write_in_full()" was doing the wrong thing, and just made it easy to 
> write buggy code - it was no easier to use than xwrite(), and thus there 
> was no point to it. Might as well have just used xwrite() in the first 
> place.
> 
> So I repeat: either you use "xwrite()" (and handle the partial case), or 
> you use "write_in_full()" (and the partial case is an *ERROR*). There is 
> no sane middle ground in between those cases.

Things should be safe in general with the code as it is as we are checking the write length. But it is clear that converting to an error would simplify and clean up the code. Should have done that the first time.

If its not done in the morning, I'll fix it up.
-apw
Previous: Linus TorvaldsNext: Linus Torvalds
Message 15 of 24 in “tree corrupted on disk quota full”
  1. Michael S. TsirkinJan 11, 2007
  2. Andreas EricssonJan 11, 2007
  3. Andy WhitcroftJan 11, 2007
  4. Michael S. TsirkinJan 11, 2007
  5. Andreas EricssonJan 11, 2007
  6. Linus TorvaldsJan 11, 2007
  7. Linus TorvaldsJan 11, 2007
  8. Linus TorvaldsJan 11, 2007
  9. Junio C HamanoJan 11, 2007
  10. Andy WhitcroftJan 11, 2007
  11. Junio C HamanoJan 11, 2007
  12. Better error messages for corrupt databasesLinus Torvalds, Jan 11, 2007
  13. Shawn O. PearceJan 12, 2007
  14. Linus TorvaldsJan 11, 2007
  15. Andy WhitcroftJan 11, 2007
  16. Linus TorvaldsJan 11, 2007
  17. Michael S. TsirkinJan 11, 2007
  18. Linus TorvaldsJan 11, 2007
  19. Michael S. TsirkinJan 11, 2007
  20. Linus TorvaldsJan 11, 2007
  21. Michael S. TsirkinJan 11, 2007
  22. Linus TorvaldsJan 12, 2007
  23. Shawn O. PearceJan 12, 2007
  24. Junio C HamanoJan 13, 2007

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.