Bogus rsync "Success" message when out of disk space
John Van Essen
vanes002 at umn.edu
Mon Apr 28 05:40:39 EST 2003
JW,
(Ya know, I've been on this list for over a year and I still have
no idea what your first name is. Anyway...)
I moved my comment above the loop.
Here's the (final) patch. If you want to change the comment before
applying it, feel free to do so.
--- fileio.c.orig Fri Jan 25 15:07:34 2002
+++ fileio.c Sun Apr 27 12:29:17 2003
@@ -69,25 +69,28 @@
return len;
}
int write_file(int f,char *buf,size_t len)
{
int ret = 0;
- if (!sparse_files) {
- return write(f,buf,len);
- }
-
+ /* Normal writes are in this loop, too, so that retries
+ of partial writes will eventually set errno. */
while (len>0) {
- int len1 = MIN(len, SPARSE_WRITE_SIZE);
- int r1 = write_sparse(f, buf, len1);
+ int r1;
+ if (sparse_files) {
+ int len1 = MIN(len, SPARSE_WRITE_SIZE);
+ r1 = write_sparse(f, buf, len1);
+ } else {
+ r1 = write(f, buf, len);
+ }
if (r1 <= 0) {
if (ret > 0) return ret;
return r1;
}
len -= r1;
buf += r1;
ret += r1;
}
return ret;
--
John Van Essen <vanes002 at umn.edu>
On Sat, 26 Apr 2003, jw schultz <jw at pegasys.ws> wrote:
>On Sat, Apr 26, 2003 at 03:09:29PM -0500, John Van Essen wrote:
>> Patches welcome, eh, Paul?
>>
>> Upon further (belated) investigation, there are 2 affected places
>> in receiver.c with this error message. Both call write_file().
>> And write_file is called only in those two places. So that is the
>> appropriate location to patch. Especially since the obvious fix is
>> to use the rewrite code already there for the sparse file writes.
>
>This looks correct to me. On partial write we need to
>retry. The callers to write_file only test for
>completeness.
>
>I'd drop the added comments or put a generic
>"loop until all is written or error" at the top of the loop.
>The inline comments make the code harder to read.
>
>> -------------------------------------8<-------------------------------------
>> --- fileio.c.orig Fri Jan 25 15:07:34 2002
>> +++ fileio.c Sat Apr 26 12:16:25 2003
>> @@ -69,25 +69,28 @@
>> return len;
>> }
>>
>>
>>
>> int write_file(int f,char *buf,size_t len)
>> {
>> int ret = 0;
>>
>> - if (!sparse_files) {
>> - return write(f,buf,len);
>> - }
>> -
>> while (len>0) {
>> - int len1 = MIN(len, SPARSE_WRITE_SIZE);
>> - int r1 = write_sparse(f, buf, len1);
>> + int r1;
>> + if (sparse_files) {
>> + int len1 = MIN(len, SPARSE_WRITE_SIZE);
>> + r1 = write_sparse(f, buf, len1);
>> + } else {
>> + /* Normal writes are in this loop, too, so that */
>> + /* retries of partial writes will set errno. */
>> + r1 = write(f, buf, len);
>> + }
>> if (r1 <= 0) {
>> if (ret > 0) return ret;
>> return r1;
>> }
>> len -= r1;
>> buf += r1;
>> ret += r1;
>> }
>> return ret;
>> -------------------------------------8<-------------------------------------
>>
>> Test of unpatched rsync (bogus error message):
>>
>> write failed on jvejunk2 : Success
>> rsync error: error in file IO (code 11) at receiver.c(243)
>> rsync: connection unexpectedly closed (200 bytes read so far)
>> rsync error: error in rsync protocol data stream (code 12) at io.c(165)
>>
>>
>> Test of patched rsync (correct error message):
>>
>> write failed on jvejunk2 : No space left on device
>> rsync error: error in file IO (code 11) at receiver.c(243)
>> rsync: connection unexpectedly closed (200 bytes read so far)
>> rsync error: error in rsync protocol data stream (code 12) at io.c(165)
>>
>> --
>> John Van Essen <vanes002 at umn.edu>
>--
>________________________________________________________________
> J.W. Schultz Pegasystems Technologies
> email address: jw at pegasys.ws
>
> Remember Cernan and Schmitt
More information about the rsync
mailing list