]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
dd(1) uses gettimeofday(2) to compute the throughput statistics. However,
authorAlan Somers <asomers@FreeBSD.org>
Tue, 6 May 2014 22:06:39 +0000 (22:06 +0000)
committerAlan Somers <asomers@FreeBSD.org>
Tue, 6 May 2014 22:06:39 +0000 (22:06 +0000)
commitd1d66eac15bffff6ed36d1d3e51b76048ae0b77b
treea78744ab8c4dbf1758a6ebb06f3b0f84ca6fd7a6
parent789a10b106e92158b84168600cd6fa9d733bb837
dd(1) uses gettimeofday(2) to compute the throughput statistics.  However,
gettimeofday returns the system clock, which may jump forward or back,
especially if NTP is in use.  If the time jumps backwards, then dd will see
negative elapsed time, round it up to 1usec, and print an absurdly fast
transfer rate.

The solution is to use clock_gettime(2) with CLOCK_MONOTONIC_PRECISE as the
clock_id.  That clock advances steadily, regardless of changes to the system
clock.

Reviewed by: delphij
MFC after: 3 days
Sponsored by: Spectra Logic
bin/dd/dd.c
bin/dd/misc.c