Re: tree corrupted on disk quota full
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Jan 11, 2007, 22:32 UTC
- Message-ID
- <Pine.LNX.4.64.0701111428420.3594@woody.osdl.org>
- In-Reply-To
- <45A6B5E4.3050007@shadowen.org>
On Thu, 11 Jan 2007, Andy Whitcroft wrote:
Show 7 quoted lines
> > > 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.
NO WE ARE NOT.
I already pointed you to write_buffer(). It used to do the right thing. It doesn't any more. And it doesn't, exactly because you converted it away from a loop that did it right, to doing "write_in_full()" and NOT checking the return value properly.
The thing is, if you support partial writes (ie xwrite()), you need to do it in a loop, and then the correct thing to check for is "zero or error".
Once you don't do a loop (ie "write_in_full()" - the whole _point_ is to not do the loop, after all), you need to either expand that check to "zero or error or partial" (which just makes the code _more_ complex), or you need to make "write_in_full()" just return an error for the partial case.
Which is why I'm harping on this issue: either we use "xwrite()", or we fix "write_in_full()" to return errors on partials. Because the "middle ground", where write_in_full() emulates the partial case of "xwrite()" is actually MORE complex than "xwrite()" itself.
Linus