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

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

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