Bogus rsync "Success" message when out of disk space

jw schultz jw at pegasys.ws
Mon Apr 28 11:00:29 EST 2003


On Sun, Apr 27, 2003 at 02:40:39PM -0500, John Van Essen wrote:
> 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...)

To imply decete is not humourous.  The only amusement i've
found in people who disbelieve me when told my name is their
clumsy efforts to hide their curiosity and incapacity to
explain it.  It is like watching someone attempting to
confirm that someone else isn't wearing underpants.  If J.W.
(In email i leave out the punctuation) is good enough for
the DMV and the IRS it should be good enough for you.

> 
> I moved my comment above the loop.

You are still commenting on history but that can be fixed
during commit.  A simple "loop until write complete or errno set"
is clear and to the point.  If i check it in i'll probably
do a block comment for the function instead; that way it can
refer to caller expectations.

I'll allow a little time for dissent or assent.

> 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
> 
> -- 
> To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
> Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
> 

-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw at pegasys.ws

		Remember Cernan and Schmitt


More information about the rsync mailing list