After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 774192 - Says "You can now unplug" when only a partition is unmounted
Says "You can now unplug" when only a partition is unmounted
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: udisks2 volume monitor
unspecified
Other Linux
: Normal critical
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2016-11-10 10:46 UTC by Egmont Koblinger
Modified: 2016-11-21 09:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Output of "gvfs-mount -li" (5.51 KB, text/plain)
2016-11-10 11:35 UTC, Egmont Koblinger
  Details
Screenshot (22.65 KB, image/png)
2016-11-10 11:37 UTC, Egmont Koblinger
  Details
udisks2: Always use generic notification when unmounting (1.71 KB, patch)
2016-11-10 14:56 UTC, Ondrej Holy
none Details | Review
udisks2: Always use generic notification when unmounting (1.39 KB, patch)
2016-11-18 08:12 UTC, Ondrej Holy
committed Details | Review

Description Egmont Koblinger 2016-11-10 10:46:22 UTC
Connect an external hard drive with multiple partitions with file systems on them (e.g. /dev/sdb1 and sdb2). Several "Files" windows pop up, with all these volumes shown in the left hand bar, with an Eject button next to each.

Click on one of these Eject buttons. The corresponding file system is properly unmounted.

Plus, a desktop notification "You can now unplug [VolumeName]" is presented.

This is incorrect, I clearly cannot unplug the disk as long as other partitions of it are mounted, and there's obviously no way I could unplug a partition without unplugging the entire disk.

The notification with such wording should only be presented if it was the last file system of the given disk that I unmounted (ejected).
Comment 1 Egmont Koblinger 2016-11-10 11:04:36 UTC
I hope you don't mind me setting Severity: critical.

This is (as far as I know) the typical value for bugs that can cause data loss. In my opinion if the data loss is not directly caused by the program code, but rather by the program giving false information to the user and the user potentially following that instruction, it's no different at all.

Nautilus _must not_ tell me it's safe to remove something when in fact it's not.
Comment 2 Ondrej Holy 2016-11-10 11:32:38 UTC
Thanks for your bug report.

Hmm, this is a rather GVfs issue, however, I can't reproduce it with devices I have. Both partitions are unmounted if I click on the eject button, not only the one. Although I remember that I saw something like this for start-stop devices, but don't have any here for test...

Can you please provide output from "gvfs-mount -li" for that device and also output from "gvfs-mount --monitor", which is printed when you press eject button for the one partition?
Comment 3 Egmont Koblinger 2016-11-10 11:35:51 UTC
Created attachment 339470 [details]
Output of "gvfs-mount -li"
Comment 4 Egmont Koblinger 2016-11-10 11:37:56 UTC
Created attachment 339471 [details]
Screenshot

Note: all four of those volumes with an eject button reside on the same external hard disk.
Comment 5 Egmont Koblinger 2016-11-10 11:41:36 UTC
root# gvfs-mount --monitor
Monitoring events. Press Ctrl+C to quit.
... here I click on 50 GB's "eject" button ...
Volume changed:     '50 GB Volume'
Mount changed: '50 GB Volume'
Mount removed: '50 GB Volume'
... desktop notification: "You can now unplug 50GB Volume" ...

... and similarly for all the others ...
Comment 6 Egmont Koblinger 2016-11-10 11:45:08 UTC
Thanks for looking at this issue :)

This is a plain simple spinning HDD taken out from my old laptop that died a few days ago :D, put in an external case and connected via USB to my brand new computer (running a brand new Yakkety installation).
Comment 7 Ondrej Holy 2016-11-10 11:55:20 UTC
Thanks for the logs, thanks to them I found device with the same properties. This is a bug in GVfs, although I wonder why Nautilus sometimes unmount all of the partitions and sometimes only the one...

Carlos, can you please point me to the relevant code in Nautilus?
Comment 9 Ondrej Holy 2016-11-10 13:01:06 UTC
Thanks, I see it already. Nautilus calls g_mount_eject if eject is supported, otherwise it calls g_mount_unmount. GVfs unmounts just the one mount, when g_mount_unmount is called. However, g_mount_eject invokes g_drive_eject, that's why all the mounts are unmounted sometimes... is there any result from the discussion with designers about the sidebar regarding to drives?
Comment 10 Ondrej Holy 2016-11-10 14:56:10 UTC
This unmount notification have been added by Bug 676111 long time ago. We should obviously set generic_text = TRUE in such case in order to print "%s has been unmounted\n" instead, see:
https://git.gnome.org/browse/gvfs/tree/monitor/udisks2/gvfsudisks2utils.c#n818
Comment 11 Ondrej Holy 2016-11-10 14:56:40 UTC
Created attachment 339498 [details] [review]
udisks2: Always use generic notification when unmounting

"You can now unplug %s\n" is used for mounts with filesystem,
"%s has been unmounted\n" is used otherwise. It is confusing
to say "unplug" for drives with multiple mounts, or for drives,
which need to be ejected, or stopped. I think "unplug" should
be used only when ejecting, or stopping. It might lead to data
loss if	user unplug the	device after unmounting	one of several
mounts.

Actually, it makes sense to me to say "unplug" also if drive
isn't ejectable, nor stopable and this is only one/last
mounted volume, however, I don't think we want detect this
case, because it seems to me fairly uncommon. I see this case
only for my card reader, because all my flash drives are
ejectable, and all my portable disks are stopable.
Comment 12 Carlos Soriano 2016-11-10 15:28:09 UTC
(In reply to Ondrej Holy from comment #9)
> Thanks, I see it already. Nautilus calls g_mount_eject if eject is
> supported, otherwise it calls g_mount_unmount. GVfs unmounts just the one
> mount, when g_mount_unmount is called. However, g_mount_eject invokes
> g_drive_eject, that's why all the mounts are unmounted sometimes... is there
> any result from the discussion with designers about the sidebar regarding to
> drives?

I figured out that would be the problem too.
I pinged Allan today but he didn't have time. I will try next week.
Comment 13 Carlos Soriano 2016-11-10 15:33:20 UTC
(In reply to Ondrej Holy from comment #11)
> Created attachment 339498 [details] [review] [review]
> udisks2: Always use generic notification when unmounting
> 
> "You can now unplug %s\n" is used for mounts with filesystem,
> "%s has been unmounted\n" is used otherwise. It is confusing
> to say "unplug" for drives with multiple mounts, or for drives,
> which need to be ejected, or stopped. I think "unplug" should
> be used only when ejecting, or stopping. It might lead to data
> loss if	user unplug the	device after unmounting	one of several
> mounts.
> 
> Actually, it makes sense to me to say "unplug" also if drive
> isn't ejectable, nor stopable and this is only one/last
> mounted volume, however, I don't think we want detect this
> case, because it seems to me fairly uncommon. I see this case
> only for my card reader, because all my flash drives are
> ejectable, and all my portable disks are stopable.

why a drive would not be ejectable/stopped? Either the drive cannot be unpluged from the system and doesn't make sense to "eject" it or it can be, no?
Comment 14 Ondrej Holy 2016-11-11 08:09:23 UTC
I am not sure I understand what is your question. But see SAMSUNG HN-M750MBB drive in attachment 339470 [details]: can_eject=0, can_start=0, can_stop=0 (it is based on udisks2/udev). Only thing what you can do is unmount all the mounts, then you can unplug the device, although I am not sure it is safe, this is a question rather for udisks2/udev people...
Comment 15 Egmont Koblinger 2016-11-11 08:18:07 UTC
That's another great point. The disk keeps spinning even after I unmount all partitions. I recall there being a command which halts the disk, after which it's obviously safe to remove it. I don't know if it's safe to remove it without halting first, but after the kernel has written everything it wanted to.
Comment 16 Carlos Soriano 2016-11-11 08:49:00 UTC
My question is, if it's not ejectable, why it says "you can unplug now" or we display any notification at all?
If the disk/stick is supposed to be extracted, why has can_eject=0? That would be not our problem.
Comment 17 Carlos Soriano 2016-11-11 08:50:31 UTC
(In reply to Egmont Koblinger from comment #15)
> That's another great point. The disk keeps spinning even after I unmount all
> partitions. I recall there being a command which halts the disk, after which
> it's obviously safe to remove it. I don't know if it's safe to remove it
> without halting first, but after the kernel has written everything it wanted
> to.

It's not, but the drive should be ejectable if it's supposed to be ejectable. If not it's a udisk/kernel/firmware bug, not ours.

Or I'm missing something obvious :)
Comment 18 Ondrej Holy 2016-11-18 08:02:48 UTC
(In reply to Carlos Soriano from comment #16)
> My question is, if it's not ejectable, why it says "you can unplug now" or
> we display any notification at all?

You are right, it doesn't make sense either for this case. I will reword the commit message and push...

> If the disk/stick is supposed to be extracted, why has can_eject=0? That
> would be not our problem.

That's problem lower in the stack (i.e. udisks/udev/kernel).
Comment 19 Ondrej Holy 2016-11-18 08:12:55 UTC
Created attachment 340223 [details] [review]
udisks2: Always use generic notification when unmounting

"You can now unplug %s\n" is used for mounts with filesystem,
"%s has been unmounted\n" is used otherwise when unmounting.
It is confusing to say "unplug" for drives with multiple mounts,
or for drives, which need to be ejected, or stopped. I think
"unplug" should be used only when ejecting, or stopping. It might
lead to data loss if user unplug the device after unmounting one
of several mounts.
Comment 20 Ondrej Holy 2016-11-18 08:13:20 UTC
Attachment 340223 [details] pushed as f760443 - udisks2: Always use generic notification when unmounting
Comment 21 Ondrej Holy 2016-11-18 08:15:00 UTC
Pushed also in gnome-3-22 branch...
Comment 22 Carlos Soriano 2016-11-21 09:56:08 UTC
Thanks Ondrej!