Improve async/sync writing behaviour for removable devices

Bug #20717 reported by Celso Pinto
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux-source-2.6.15 (Ubuntu)
Invalid
Medium
Martin Pitt

Bug Description

I noticed that USB Storage devices are mounted without the sync option which
often may result in data loss when using those USB Flash devices (USB pens, USB
sticks, whatever) because the user may not be familiar with the unmount
procedure, which flushes the data into the USB device.

The best solution is to use the sync option while mounting the device, even if
this slows down copying or moving files into the USB device.

I understand that external USB hard-drives also fit into this category so
probably you should perform some kind of check to see if the device isn't an
hard-drive since in that case the sync option doesn't make much sense.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

This is handled by pmount, and if I recall correctly the FAT filesystem driver
doesn't support "sync".

Revision history for this message
Celso Pinto (cpinto) wrote :

Sorry for putting it in hotplug. I can assure you FAT supports the sync
operation because I use it.

Revision history for this message
Martin Pitt (pitti) wrote :

In the early days, "sync" was indeed the default, but we switched it to async;
please see:

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=309591;archive=yes

sync is the wrong mode for flash devices due to exaggerated flash wearout, and
it is a very inconvenient mode for hard disks since it slows down writing by the
factor 10 or even worse.

I won't change that back since the reasoning in #309591 was really sane.

About FAT and sync: the option works halfway. The write lag is much smaller than
in async mode, but after a completed write operation there are still unwritten
things in the cache.

Revision history for this message
Celso Pinto (cpinto) wrote :

Fair enough

Revision history for this message
Mumbo Jumbo (mumbojumbo) wrote :

To quote Alan Cox on this issue: "It sounds like your need to find a vendor who
makes decent keys." ;)

Perhaps the sync option in its current state shouldn't be used. However, I do
believe that the end user symptoms needs to be addressed. That is, something
should be done about:

"Why the *¤()/#&¤/%) isn't all my music transfered to my USB flash player?!?!"

Should a new bug be opened? And if so, against what? Should this be reopened and
the summary changed?

And NO, users aren't going to learn unmounting their drives prior to pulling
them out. NEVER! This is the floppy story all over again. :)

Revision history for this message
Marc DM (marcdm) wrote :

(In reply to comment #5)
> To quote Alan Cox on this issue: "It sounds like your need to find a vendor who
> makes decent keys." ;)
>
> Perhaps the sync option in its current state shouldn't be used. However, I do
> believe that the end user symptoms needs to be addressed.

> And NO, users aren't going to learn unmounting their drives prior to pulling
> them out. NEVER! This is the floppy story all over again. :)

Actually, couldn't we change the GUI description to "Write Data To Disk" instead
of "Unmount" when we notice that we've mounted a FAT/VFAT filesystem async?.

My Apologies if it's a stupid suggestion.

MarcDM (marcdm _at_ phronein _dot_ com)

Revision history for this message
Martin Pitt (pitti) wrote :

*** Bug 26635 has been marked as a duplicate of this bug. ***

Revision history for this message
Martin Pitt (pitti) wrote :

Since this keeps getting asked, I reopen this one as a reference bug

Revision history for this message
Ben Collins (ben-collins) wrote :

Closing, people can still find the bug. We should use the wiki for reference.
Who volunteers? :)

Revision history for this message
Chris Weiss (cweiss) wrote :

um, i understand the flash wear part, but for disk performance, the data still takes the same amount of time to actualy write to the disk, sync or not. it's just a matter of the user being told when the data is really and completely commited to disk.

I'd like to petition to reopen this bug, data loss (which just confused the hell out of me for 20 minutes with a 1GB flash disk) is a LOT bigger deal then wearing out the flash, in fact this async option just cause not only FAT corruption but also uneeded writes to the flash as I have to keep guessing when it was really done writting so I could unplug the dive.

your efforts to save my flash have now caused extra wear. I'll manage my own flash lifetime thank you, and I don't care about performance as much as knowing when the data is commited to disk. again, async has not helped performance (still takes as long as it takes) and has actualy hurt my flash lifetime. mission NOT accomplished.

Revision history for this message
Martin Pitt (pitti) wrote :

Wrt. performance, the difference between sync and async is a magnitude (factor 10 to 100, depending on the application).

I am aware that the unmounting behaviour should be greatly improved, and we already have an open bug about this (bug 32643), which will be fixed for Dapper.

Thanks,

Martin

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.