Subject: Re: optimistic dd bandwidth calculation
To: Johan Danielsson <joda@pdc.kth.se>
From: Greg A. Woods <woods@weird.com>
List: tech-userlevel
Date: 07/18/2002 13:33:14
[ On , July 18, 2002 at 16:45:56 (+0200), Johan Danielsson wrote: ]
> Subject: optimistic dd bandwidth calculation
>
> 
> Does this look correct (this is in dd_close)?
> 
> --- dd.c        2002/01/10 03:25:12     1.26
> +++ dd.c        2002/07/18 14:44:46
> @ -360,6 +360,8 @
>         }
>         if (out.dbcnt)
>                 dd_out(1);
> +       if(fsync(out.fd) < 0)
> +               err(1, "%s", out.name);
>  }
>  
>  void
> 

No, absolutely not.  I almost never want dd to always hang while waiting
for fsync() before it finishes!

If you always wish the stats to be accurate w.r.t. low-level I/O rates,
(and/or have some desire to make sure that your data is safely committed
to storage before dd exits), it may make sense to add an "fsync" option,
perhaps to the already overloaded "conv=" parameter.  I've thought of
doing this several times, but have never got around to it.

If you add such an option then it may make sense to call fsync(out.fd)
in the SIGINFO handler when it's set too, i.e. before reporting the
stats, and given the way the code's written that would be the only call
necessary (since summary(), the SIGINFO handler, is called at exit()
time because it's been registered with atexit()).

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>