Bug 195044

Summary: async behaviour during file copy to a removable device is confusing.
Product: [Unmaintained] kio Reporter: Davide Bettio <davide.bettio>
Component: generalAssignee: David Faure <faure>
Status: RESOLVED NOT A BUG    
Severity: critical CC: adawit, andreas_nordal_4, bjoern, chalkerx, christopher.m.braeuer, hakan, jramirez.uy, kikoloche, lumania, mail, nate, phlogi1, sylvain.gueniot, vortex
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Davide Bettio 2009-06-03 00:18:15 UTC
Version:            (using Devel)
Compiler:          gcc 4.1.2 gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.3)
OS:                Linux
Installed from:    Compiled sources

async behaviour during file copy to a removable device is confusing: according to the notifier the copy has ended but the file is still being written on the device.
Comment 1 Davide Bettio 2009-06-03 00:18:54 UTC
This bug may lead some users to data loss.
Comment 2 Davide Bettio 2009-06-03 00:21:39 UTC
I've changed priority to critical because data loss is a critical bug.
Comment 3 George Kiagiadakis 2009-06-03 11:26:27 UTC
This is a kernel behavior, not a behavior of kio_file. You can use the -o sync option in mount to mount the device in synchronous mode, although that will be quite slow. This cannot lead to data loss since you are *not* supposed to unplug the device before you properly unmount it. Unmount takes care to write the remaining data on the device and does not return until everything is written properly.
Comment 4 Davide Bettio 2009-06-03 15:22:19 UTC
We can open the new file (during a copy job) with O_SYNC.

>This cannot lead to data loss since you are *not* supposed to
>unplug the device before you properly unmount it.

Are users supposed to wait 3/4 minutes before their usb devices get unmounted?
Comment 5 Benjamin Schmitz 2009-08-16 23:52:41 UTC
Wouldn't it be possible (and actually pretty easy) to simply issue a sync (like with the command-line tool 'sync') before displaying the copy job as "completed" when writing to a removable device. That way the user could be sure that the file has been written once the copy job completes.

Of course you should properly unmount a device before unplugging but I think it would be more rational to only show a copy job as "completed" when the data was actually written - at least on a removable device.

Especially switchers from Microsoft Windows or novices are not used to unmounting a device before unplugging. Even experienced users can easily forget to unmount a USB stick before unplugging. This couldn't happen as easily if there was still a copy job visible on your desktop.
Comment 6 Cyrill Helg 2009-09-03 20:21:57 UTC
I think this is a related bug: https://bugs.kde.org/show_bug.cgi?id=192598
Comment 7 Dario Andres 2009-09-04 17:26:57 UTC
*** Bug 188978 has been marked as a duplicate of this bug. ***
Comment 8 Patrick 2009-11-15 21:43:25 UTC
I have the impression this is highly improved with 4.3. I just made a copy and the progress bar freezes at the end of the copy of each file and the copy won't be marked as done before it actually is.
Comment 9 Björn Ruberg 2009-12-01 23:35:07 UTC
Well, not for me. Just copied a 200 MB file to usb - and had to wait approximatly 20 seconds for the unmount to complete although the job was finished.

Anyway, why should a removable stick NOT beeing mounted synchronously? Normal usage is to copy files to or read files from it - there is no advantage of asynchronous mode there. It is something different when you have your system running from usb - then you want it to be asynchronous.

But I cannot see why someone who uses device manager to mount a stick needs asynchronous file transfer.
Comment 10 András Manţia 2010-01-22 21:23:17 UTC
FYI: http://lkml.indiana.edu/hypermail/linux/kernel/0505.1/1249.html

From my past experience (no recent numbers though), sync copying was much slower than async + unmount.
Comment 11 Davide Bettio 2010-01-22 21:37:17 UTC
Possible patch on review board: http://reviewboard.kde.org/r/2690
Comment 12 Hakan Bayindir 2010-05-26 19:55:58 UTC
Unmounting a removable device always guarantees that all files are completely written to the device AND you are not supposed to remove a device without unmounting it.

OTOH, Big files are always written out to the devices at the moment of copy request. Only small files wait in buffer and written instantly to the flash media upon unmount. 

I fail to see the issue here.
Comment 13 ichramm 2011-12-15 01:14:15 UTC
(In reply to comment #12)

>> I fail to see the issue here.

You have to be kidding me!

I had to teach my 4-years old son to wait unntil 'the light is off' (yeah, I had to say that), because on windows he has no problem umounting the pendrive after the copy dialog finished, but with KDE  is not the same:

When he says: "Dad! It's finished, look at the progress bar!".. I have to explain "No son, it is not finished yet, juist wait until the light turns off"..

I fail to see this is ok.

PD: I known this comment has more than a year old, but the bug is still alive and healthy!


> Unmounting a removable device always guarantees that all files are completely
> written to the device AND you are not supposed to remove a device without
> unmounting it.
> 
> OTOH, Big files are always written out to the devices at the moment of copy
> request. Only small files wait in buffer and written instantly to the flash
> media upon unmount. 
> 
> I fail to see the issue here.
Comment 14 Nikita Skovoroda 2012-01-19 18:07:02 UTC
Can this be fixed with:

1) A «busy» indicator near the usb drives in dolphin places / devices plasmoid?
2) Another, «syncing» progress bar when you press unmount?

Currently unmount does not give the right/any/understandable feedback while waiting for sync being completed.

The question is: is it possible to get the progress of the sync operation? Is it possible to tell if sync is being done at the current moment («busy» indicator)?
Comment 15 Nikita Skovoroda 2012-01-19 18:07:34 UTC
s/if sync is being done/if sync is being done or is planned/
Comment 16 Hakan Bayindir 2012-01-19 20:08:16 UTC
IMHO, with the increasing presence of the led-less flash drives and hard disks, a syncing indicator becomes extremely necessary. IIRC, Ubuntu is doing this for a long time (I remember "please wait I'm writing data to your disk" dialog) and it is very useful for everyone. 

Also while may not be directly relevant, I want to say that making a user worry less about operating a computer correctly greatly improves the user experience regardless of the level of the knowledge of the user (for example, I'm a developer yet want this indicator).
Comment 17 Andreas Nordal 2012-01-25 00:52:51 UTC
Don't forget the "flush" mount option. It should reduce the asyncness, maybe to an acceptible level?

Bug 273792 wants to mount with flush by default.
Comment 18 Hakan Bayindir 2012-10-03 21:03:09 UTC
KDE now has a "please wait" notification in the USB widget (via a spinning disk in the place of the eject button during sync) and dolphin doesn't change mounted symbol until sync completes. 

Also don't forget that, 99.95% of the USB flash drives eject properly after unmount so, your device is safe to remove when it disappears from USB widget / dolphin. The proposed patch is not required anymore. Nevertheless, the patch runs afoul of the many optimizations and concepts of the Linux storage subsystem.

IMHO, the solution addresses the problem from the wrong aspect.
Comment 19 Dawit Alemayehu 2012-10-18 04:57:04 UTC
*** Bug 274141 has been marked as a duplicate of this bug. ***
Comment 20 Dawit Alemayehu 2013-06-16 18:26:23 UTC
*** Bug 187511 has been marked as a duplicate of this bug. ***
Comment 21 Dawit Alemayehu 2013-06-21 22:43:11 UTC
*** Bug 274747 has been marked as a duplicate of this bug. ***
Comment 22 Nate Graham 2018-04-25 21:38:17 UTC
Is this still relevant or applicable with KDE Frameworks 5.45 and Plasma 5.12?
Comment 23 Nate Graham 2018-04-25 21:38:42 UTC
Is this still relevant or applicable with KDE Frameworks 5.45 and Plasma 5.12?
Comment 24 Hakan Bayindir 2018-04-26 17:03:39 UTC
Currently KDE does not allow to unmount a drive while a foreground file transfer or a background sync is in progress as far as I observed.

I find this behavior adequate, however I think my opinion alone is not sufficient to close this bug.

From my point of view this bug can be closed.
Comment 25 Björn Ruberg 2018-05-01 07:30:23 UTC
Agreed. No risk of data loss anymore.
Comment 26 Nate Graham 2018-05-01 12:57:39 UTC
Great, thanks!