Re: tree corrupted on disk quota full

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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.

			Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]