Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress bar meaningless on Linux machines with lots of write cache #14

Open
baconwaifu opened this issue Sep 2, 2020 · 0 comments
Open
Labels

Comments

@baconwaifu
Copy link

The progress bar for inject_{cd,dvd} is meaningless on linux systems with large write caches, due to the progress bar only counting what's been commited to writeback, rather than what's actually been written to disk. this leads to a quick "progress" meter, and then the program deadlocking for 5 minutes while it actually gets written out to disk.

A solution is the O_DSYNC flag, which causes write to block until the data hits disk, thus allowing the progress bar to be much more accurate (and not cause the program to lock up for 5 minutes when it calls sync() near the end...)
Simply patching osal_open_device_for_writing to always use O_DSYNC on unix(-likes) appears to work fine, since writing to files either A: goes through a different open call, or B: is being written to a drive that's significantly faster than the source, meaning that it doesn't affect performance noticeably.

Patch:

--- a/osal_unix.c
+++ b/osal_unix.c
@@ -96,7 +96,7 @@ int /* OSAL_OK, OSAL_ERR */
 osal_open_device_for_writing (const char *device_name,
                              osal_handle_t *handle)
 {
-  handle->desc = open (device_name, O_RDWR | O_LARGEFILE, S_IRUSR | S_IWUSR);
+  handle->desc = open (device_name, O_RDWR | O_LARGEFILE | O_DSYNC, S_IRUSR | S_IWUSR);
   return (handle->desc == -1 ? OSAL_ERR : OSAL_OK);
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants