From f17d5ee7d1972953bc1a0ac5bc6af4687fc3cbba Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 9 Apr 2014 15:22:20 +0000 Subject: [PATCH] Bug fix: A final fsync(2) was performed with stdio drives, even if not desired --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/libburn.h | 5 ++++- libburn/options.c | 4 +++- libburn/write.c | 19 +++++++++++++------ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index d3cd59c..8942be3 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2014.04.06.111004" +#define Cdrskin_timestamP "2014.04.07.180808" diff --git a/libburn/libburn.h b/libburn/libburn.h index 8535fce..bebdd36 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -3225,7 +3225,10 @@ void burn_write_opts_set_obs_pad(struct burn_write_opts *opts, int pad); from being clogged with lots of pending data for slow devices. @param opts The write opts to change @param rythm Number of 2KB output blocks after which fsync(2) is - performed. -1 means no fsync(), 0 means default, + performed. + -1 means no fsync() + 0 means default + 1 means fsync() only at end, @since 1.3.8 (noop before 1.3.8) elsewise the value must be >= 32. Default is currently 8192 = 16 MB. @since 0.7.4 diff --git a/libburn/options.c b/libburn/options.c index f29b214..ca88ea9 100644 --- a/libburn/options.c +++ b/libburn/options.c @@ -522,9 +522,11 @@ void burn_write_opts_set_obs_pad(struct burn_write_opts *opts, int pad) void burn_write_opts_set_stdio_fsync(struct burn_write_opts *opts, int rythm) { if (rythm == -1) - opts->stdio_fsync_size = 0; + opts->stdio_fsync_size = -1; /* never */ else if (rythm == 0) opts->stdio_fsync_size = Libburn_stdio_fsync_limiT; + else if (rythm == 1) + opts->stdio_fsync_size = 0; /* only at end of writing */ else if (rythm >= 32) opts->stdio_fsync_size = rythm; } diff --git a/libburn/write.c b/libburn/write.c index 79753a3..4095dfa 100644 --- a/libburn/write.c +++ b/libburn/write.c @@ -2665,7 +2665,7 @@ int burn_stdio_mmc_dummy_write(struct burn_drive *d, int start, */ int burn_stdio_sync_cache(int fd, struct burn_drive *d, int flag) { - int ret; + int ret, do_fsync; char *msg = NULL; if (fd < 0) { @@ -2678,11 +2678,18 @@ int burn_stdio_sync_cache(int fd, struct burn_drive *d, int flag) return 0; } d->needs_sync_cache = 0; - if (!(flag & 1)) - libdax_msgs_submit(libdax_messenger, -1, 0x00000002, - LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO, - "syncing cache (stdio fsync)", 0, 0); - ret = fsync(fd); + do_fsync = 0; + if (d->write_opts != NULL) + do_fsync = (d->write_opts->stdio_fsync_size >= 0); + if (do_fsync) { + if (!(flag & 1)) + libdax_msgs_submit(libdax_messenger, -1, 0x00000002, + LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO, + "syncing cache (stdio fsync)", 0, 0); + ret = fsync(fd); + } else { + ret = 0; + } if (ret != 0 && errno == EIO) { BURN_ALLOC_MEM(msg, char, 160);