Bug fix: A final fsync(2) was performed with stdio drives, even if not desired

This commit is contained in:
Thomas Schmitt 2014-04-09 15:22:20 +00:00
parent d08658833a
commit f17d5ee7d1
4 changed files with 21 additions and 9 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2014.04.06.111004"
#define Cdrskin_timestamP "2014.04.07.180808"

View File

@ -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

View File

@ -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;
}

View File

@ -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);