This idea ties together ideas
#8033 and
#7989 with some improvements.
Problems with USB Flash Unmounting: 1) When you pull the plug on a drive, the system does not detect it and take care of the forced unmount for you. User has to go to command line. 2) When you unplug a drive, even when the light isn't blinking, unflushed buffers can cause significant data loss for no apparent reason.
Solution:
1) the system should detect when the drive is unplugged and if it is still mounted, a forced unmount should occur. This will prevent the user from having to use the command line for an every day occurrence. Many newbies reboot the system to get rid of this error state.
2) There should be a timeout set that after X seconds of inactivity (I propose 5 seconds) the write buffer should be flushed.
3) A new .fslog (or similar) file should be installed in all usb flash drives upon connection. If its a journaled filesystem, then don't, but for fat32 and others, it should do this. It will have the following function:
a. for every flush of the write buffer due to the timeout in part (2), write an entry into the log at the end indicating all writes are complete. This can be called the "clean" state
b. when writing to the disk with an initially empty write buffer, check to see if the log indicates a clean or dirty state. If clean, change the state to dirty.
c. when mounting a flash drive the system should read the log file, detect whether it is dirty or clean, and do a fsck if dirty, warning the user to not unplug the drive when it is in use.
d. Due to (a) and (b), at maximum, a log write could only occur once after 5 seconds of inactivity if the buffer has data in it. So it would not reduce lifespan of the flash. And even if your worried about flushing after 5 seconds, it would only correspond to writes already on their way to the disk, negating any problem with limited writes and lifespan of the drive.
The log file will be of negligible size and only grow with one entry for file transfers that happen greater than 5 seconds apart. Lifespan of the drive will not be hurt because these log entries will be VERY small and will only happen when writing activity is already going to happen to the disk anyway. The log can be cleaned up upon mounting of the drive. Since there is already a daemon running in the background to auto mount a USB flash drive, this functionality should be added to said daemon.
Tags:
(none)
No attachments.