[PATCH] dd: call fsync() only once before exiting if conv=fsync is specified
Ari Sundholm
ari at tuxera.com
Tue Mar 14 17:22:03 UTC 2017
Hi!
On 03/14/2017 06:44 PM, Rostislav Skudnov wrote:
> Signed-off-by: Rostislav Skudnov <rostislav at tuxera.com>
It would probably be useful to tell why this change was made: it makes
the behavior consistent with coreutils dd and fixes performance problems
caused by calling fsync() over and over again.
> ---
> coreutils/dd.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/coreutils/dd.c b/coreutils/dd.c
> index 5e68087..d89c0ae 100644
> --- a/coreutils/dd.c
> +++ b/coreutils/dd.c
> @@ -532,17 +532,17 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
> if (write_and_stats(ibuf, n, obs, outfile))
> goto out_status;
> }
> -
> - if (G.flags & FLAG_FSYNC) {
> - if (fsync(ofd) < 0)
> - goto die_outfile;
> - }
> }
>
> if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
> if (write_and_stats(obuf, oc, obs, outfile))
> goto out_status;
> }
> +
> + if (G.flags & FLAG_FSYNC) {
> + if (fsync(ofd) < 0)
> + goto die_outfile;
> + }
> if (close(ifd) < 0) {
> die_infile:
> bb_simple_perror_msg_and_die(infile);
>
Maybe a blank line between the closing brace and the next if statement
to make the look more consistent?
Best regards,
Ari Sundholm
ari at tuxera.com
More information about the busybox
mailing list