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 676111 - Add GMountOperation::show-unmount-progress signal
Add GMountOperation::show-unmount-progress signal
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 619665 676125
 
 
Reported: 2012-05-15 16:04 UTC by David Zeuthen (not reading bugmail)
Modified: 2012-07-16 12:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
mount-operation: add show-unmount-progress signal (4.02 KB, patch)
2012-07-10 19:53 UTC, Cosimo Cecchi
reviewed Details | Review
udisks2: plug a memory leak (1.41 KB, patch)
2012-07-10 19:54 UTC, Cosimo Cecchi
committed Details | Review
trivial: remove unused defines (1.21 KB, patch)
2012-07-10 19:54 UTC, Cosimo Cecchi
committed Details | Review
udisks2: simplify some code (901 bytes, patch)
2012-07-10 19:54 UTC, Cosimo Cecchi
committed Details | Review
monitor: handle show-unmount-progress signal (9.75 KB, patch)
2012-07-10 19:54 UTC, Cosimo Cecchi
committed Details | Review
udisks2: implement show-unmount-progress (17.55 KB, patch)
2012-07-10 19:54 UTC, Cosimo Cecchi
reviewed Details | Review
common: add support show-unmount-progress signal to GMountOperationDBus (7.80 KB, patch)
2012-07-10 19:54 UTC, Cosimo Cecchi
committed Details | Review
daemon: implement show-unmount-progress in GVfsJobUnmount (2.68 KB, patch)
2012-07-10 19:54 UTC, Cosimo Cecchi
none Details | Review
mount-operation: add show-unmount-progress signal (4.24 KB, patch)
2012-07-10 22:24 UTC, Cosimo Cecchi
committed Details | Review
udisks2: factor out a common function (5.95 KB, patch)
2012-07-10 22:27 UTC, Cosimo Cecchi
committed Details | Review
udisks2: split a helper function (1.33 KB, patch)
2012-07-10 22:27 UTC, Cosimo Cecchi
committed Details | Review
udisks2: implement show-unmount-progress (9.85 KB, patch)
2012-07-10 22:29 UTC, Cosimo Cecchi
reviewed Details | Review
udisks2: implement show-unmount-progress (10.40 KB, patch)
2012-07-11 20:19 UTC, Cosimo Cecchi
committed Details | Review
daemon: implement show-unmount-progress in GVfsJobUnmount (2.91 KB, patch)
2012-07-13 19:50 UTC, Cosimo Cecchi
committed Details | Review

Description David Zeuthen (not reading bugmail) 2012-05-15 16:04:44 UTC
The idea here is that if unmounting is slow because the OS kernel is transferring data from kernel buffers to stable storage (the writes done by the app have already completed), we want to convey this to the user so he doesn't unplug the device. This happens very frequently on Linux if you don't mount with the 'sync' option.

The various GMount implementations would emit this signal when unmounting and the time spent doing the operation exceeds, say, 1.5 seconds.

GMountOperation implementations, such as GtkMountOperation, would e.g. pop up a window telling the user to wait.

This is not a new idea, it's related to the existing ::show-processes signal

 http://developer.gnome.org/gio/unstable/GMountOperation.html#GMountOperation-show-processes

that is shown when there are open fd's on a device being unmounted.

The signal should include parameters about estimated amount of data and estimated time left. We'd initially set this to -1 (for unknown) and ignore it in e.g. GtkMountOperation but in the future we could possibly get this information from the kernel.

The signal would be allowed to be emitted several times (for updated parameters).

See https://bugzilla.redhat.com/show_bug.cgi?id=819492 for some background on why we want this.
Comment 1 David Zeuthen (not reading bugmail) 2012-05-15 17:07:11 UTC
Thinking more about it, I think GMountOperation::show-unmount-progress is more appropriate than GMountOperation::unmount-pending and more in line with the existing GMountOperation signals, see http://developer.gnome.org/gio/unstable/GMountOperation.html#GMountOperation.signals
Comment 2 Matthias Clasen 2012-07-06 00:48:45 UTC
Tomas, Cosimo - is one of you looking at implementing this API ?
Comment 3 Cosimo Cecchi 2012-07-09 13:57:28 UTC
I'm working on this.
Comment 4 Cosimo Cecchi 2012-07-10 19:53:59 UTC
Created attachment 218457 [details] [review]
mount-operation: add show-unmount-progress signal

---

GLib part
Comment 5 Cosimo Cecchi 2012-07-10 19:54:25 UTC
Created attachment 218458 [details] [review]
udisks2: plug a memory leak

We were not free-ing the UnmountMountsOp structure when there was an
error in one mount. Fix that and use g_list_free_full to make code more
concise.
Comment 6 Cosimo Cecchi 2012-07-10 19:54:29 UTC
Created attachment 218459 [details] [review]
trivial: remove unused defines
Comment 7 Cosimo Cecchi 2012-07-10 19:54:34 UTC
Created attachment 218460 [details] [review]
udisks2: simplify some code
Comment 8 Cosimo Cecchi 2012-07-10 19:54:39 UTC
Created attachment 218461 [details] [review]
monitor: handle show-unmount-progress signal
Comment 9 Cosimo Cecchi 2012-07-10 19:54:43 UTC
Created attachment 218462 [details] [review]
udisks2: implement show-unmount-progress
Comment 10 Cosimo Cecchi 2012-07-10 19:54:48 UTC
Created attachment 218463 [details] [review]
common: add support show-unmount-progress signal to GMountOperationDBus
Comment 11 Cosimo Cecchi 2012-07-10 19:54:52 UTC
Created attachment 218464 [details] [review]
daemon: implement show-unmount-progress in GVfsJobUnmount
Comment 12 David Zeuthen (not reading bugmail) 2012-07-10 20:09:08 UTC
Review of attachment 218457 [details] [review]:

LGTM, only some doc comments

::: gio/gmountoperation.c
@@ +393,3 @@
+   *     is completed
+   *
+   * @time_left: the estimated time left before the operation completes, or -1

I would say s/1.5 seconds/some time (typically 1.5 seconds)/

@@ +399,3 @@
+   * can take a considerable amount of time. This signal will be emitted several
+   * times as long as the unmount operation is outstanding, and then one
+   *     is completed

Suggest to use the word "may" instead of "will" since I believe the udisks2 impl will only emit it once (with bytes_left set to -1) and then one more time at the end (with bytes_left set to 0).
Comment 13 David Zeuthen (not reading bugmail) 2012-07-10 20:11:16 UTC
Review of attachment 218458 [details] [review]:

Looks good to me.
Comment 14 David Zeuthen (not reading bugmail) 2012-07-10 20:11:58 UTC
Review of attachment 218459 [details] [review]:

Yup.
Comment 15 David Zeuthen (not reading bugmail) 2012-07-10 20:12:52 UTC
Review of attachment 218460 [details] [review]:

OK, we can do that
Comment 16 David Zeuthen (not reading bugmail) 2012-07-10 20:16:06 UTC
Review of attachment 218461 [details] [review]:

Looks correct to me, it's mostly just copy-paste from the show-processes signal, right? Might be good to get Tomas' review on it as well since he touched that code last.
Comment 17 David Zeuthen (not reading bugmail) 2012-07-10 20:46:09 UTC
Review of attachment 218462 [details] [review]:

This looks a bit complicated and I'm wondering if it can be simplified somewhat... isn't the basic idea just that we want to attach extra data to the GMountOperation passed to the unmount() and eject() vfuncs?

If so, I think we should attach it using g_object_set_data_full() and not have the users worry about freeing it (including who frees it).

I don't think we need to expose the UnmountNotifyData struct either, I mean, we can just have gvfs_udisks2_unmount_notify_data_*() functions take a GMountOperation themselves and worry about getting/creating the UnmountNotifyData struct as needed.

With those changes, I think the changes to gvfsudisks2mount.c and gvfsudisks2drive.c will be very small, basically it will just be a _start() and _stop() in the beginning resp. end of the mount and eject implementations.

::: monitor/udisks2/gvfsudisks2utils.c
@@ +640,3 @@
+   * bytes left fields.
+   */
+

Not sure about the TODO item, I think if bytes_left or time_left is set then the dialog showing GMountOperation would convey the time...

@@ +650,3 @@
+  g_free (message);
+  g_free (name);
+unmount_notify_get_name (UnmountNotifyData *data)

Not sure it's appropriate to use that language for mounts that are not udisks - suggest to use very generic language for those instead, perhaps

 Unmount /mnt/path/to/mountpoint
 Please wait...

or similar. Thoughts?

@@ +737,3 @@
+  message = g_strdup_printf (_("You can now unplug %s\n"), name);
+  g_signal_emit_by_name (data->op, "show-unmount-progress",
+  data = g_slice_new0 (UnmountNotifyData);

Same here, this is not appropriate for non-udisks mounts... Probably say

 /mnt/path/to/mountpoint has been unmounted

or something?
Comment 18 Cosimo Cecchi 2012-07-10 22:24:40 UTC
Created attachment 218486 [details] [review]
mount-operation: add show-unmount-progress signal

---

Fixed documentation as for review comments
Comment 19 Cosimo Cecchi 2012-07-10 22:27:03 UTC
Created attachment 218487 [details] [review]
udisks2: factor out a common function

Factor out unmount_data_complete(), we'll use it later.
Comment 20 Cosimo Cecchi 2012-07-10 22:27:16 UTC
Created attachment 218488 [details] [review]
udisks2: split a helper function

We'll need to use this later.
Comment 21 Cosimo Cecchi 2012-07-10 22:29:37 UTC
Created attachment 218489 [details] [review]
udisks2: implement show-unmount-progress

---

Thanks for the review David, this approach really makes the code simpler.
Comment 22 Cosimo Cecchi 2012-07-10 22:42:33 UTC
(In reply to comment #17)
> ::: monitor/udisks2/gvfsudisks2utils.c
> @@ +640,3 @@
> +   * bytes left fields.
> +   */
> +
> 
> Not sure about the TODO item, I think if bytes_left or time_left is set then
> the dialog showing GMountOperation would convey the time...

The comment there is not about including those in the message string, but about reporting the values in the signal emission.

> Not sure it's appropriate to use that language for mounts that are not udisks -
> suggest to use very generic language for those instead, perhaps
> 
>  Unmount /mnt/path/to/mountpoint
>  Please wait...
> 
> or similar. Thoughts?

I didn't change this because I don't understand what you mean with "not udisks"...this code path is only hit for udisks mounts....
 
> Same here, this is not appropriate for non-udisks mounts... Probably say
> 
>  /mnt/path/to/mountpoint has been unmounted
> 
> or something?

...and I'd feel bad talking to the user in terms of mountpoints...the reason why the notification is useful in this case is to prevent accidental data loss due to an early physical unplug, and we already special case optical media.

In which scenarios would this wording not be appropriate with udisks objects?
Comment 23 David Zeuthen (not reading bugmail) 2012-07-11 14:28:39 UTC
Comment on attachment 218486 [details] [review]
mount-operation: add show-unmount-progress signal

Looks good to me, thanks
Comment 24 David Zeuthen (not reading bugmail) 2012-07-11 14:29:51 UTC
Review of attachment 218487 [details] [review]:

Sounds good to me.
Comment 25 David Zeuthen (not reading bugmail) 2012-07-11 14:31:14 UTC
Review of attachment 218488 [details] [review]:

Good idea
Comment 26 David Zeuthen (not reading bugmail) 2012-07-11 14:39:59 UTC
Review of attachment 218489 [details] [review]:

This is exactly what I had in mind, thanks! Except for the question about disconnecting signal handlers, this is good to go I think

::: monitor/udisks2/gvfsudisks2utils.c
@@ +723,3 @@
+  g_slice_free (UnmountNotifyData, data);
+}
+  message = g_strdup_printf (_("Writing data to %s\n"

Shouldn't we disconnect the signal handlers in unmount_notify_data_free()? For example, it's not entirely impossible you get another ::reply signal...
Comment 27 David Zeuthen (not reading bugmail) 2012-07-11 14:53:13 UTC
(In reply to comment #22)
> I didn't change this because I don't understand what you mean with "not
> udisks"...this code path is only hit for udisks mounts....

The way I read the patch from comment 21 (the latest patch) is that it shows the notification also if filesystem == NULL in which case we will just run the umount(8) command on the mount (e.g. it's a non-udisks mount).

> > Same here, this is not appropriate for non-udisks mounts... Probably say
> > 
> >  /mnt/path/to/mountpoint has been unmounted
> > 
> > or something?
> 
> ...and I'd feel bad talking to the user in terms of mountpoints...

OK, well, just use g_mount_get_name() then. It'll be set to the last path element of the mount point anyway (overridable with x-gvfs-name mount option). That's the name the user sees anyway.

> the reason
> why the notification is useful in this case is to prevent accidental data loss
> due to an early physical unplug, and we already special case optical media.

But exactly the same reasons (physical unplug of e.g. network cable, suspend, etc.) applies to any other kind of mount since _any_ filesystem mount will have some level of client-side buffering between the upper layers (~ filesystem) through the interconnect (USB, SATA for physical devices, IP / ethernet for network mounts) and to the platters / etc.

The mount could be

 - NFS
 - CIFS
 - Storage backed by GMail
 - any kind of FUSE-thing

Suppose for example the mount is for my GMail account and it's mounted at /home/davidz/GMailStorage. Let's say that I don't use the x-gvfs-name option so g_mount_get_name() returns "GMailStorage). I don't think it's appropriate to say

 Writing data to GMailStorage
 Don't unplug until finished
 [later] You can now unplug GMailStorage

I think it would be better to say

 Unmounting GMailStorage
 Please wait
 [later] GMailStorage has been unmounted
Comment 28 Cosimo Cecchi 2012-07-11 20:19:24 UTC
Created attachment 218587 [details] [review]
udisks2: implement show-unmount-progress

---

Use a different wording for mounts that don't have a filesystem object.
Comment 29 Cosimo Cecchi 2012-07-11 20:21:03 UTC
We discussed the signal stuff on IRC; I think this should cover the other comments about the strings we use.
Comment 30 David Zeuthen (not reading bugmail) 2012-07-11 21:01:58 UTC
Review of attachment 218587 [details] [review]:

Looks good to me, please commit (I'm assuming you've tested it with both usb sticks and NFS fstab mounts). Thanks!
Comment 31 Cosimo Cecchi 2012-07-11 23:59:03 UTC
Comment on attachment 218486 [details] [review]
mount-operation: add show-unmount-progress signal

Attachment 218486 [details] pushed as 44375ad - mount-operation: add show-unmount-progress signal
Comment 32 Cosimo Cecchi 2012-07-12 00:00:41 UTC
Attachment 218458 [details] pushed as 079c5ae - udisks2: plug a memory leak
Attachment 218459 [details] pushed as 9aec339 - trivial: remove unused defines
Attachment 218460 [details] pushed as 17f987f - udisks2: simplify some code
Attachment 218461 [details] pushed as 8c61a01 - monitor: handle show-unmount-progress signal
Attachment 218487 [details] pushed as 4fccf40 - udisks2: factor out a common function
Attachment 218488 [details] pushed as 8dcd2e3 - udisks2: split a helper function
Attachment 218587 [details] pushed as 174f304 - udisks2: implement show-unmount-progress
Comment 33 Cosimo Cecchi 2012-07-12 00:13:30 UTC
(In reply to comment #30)
> Review of attachment 218587 [details] [review]:
> 
> Looks good to me, please commit (I'm assuming you've tested it with both usb
> sticks and NFS fstab mounts). Thanks!

Thanks...I pushed a version with two other small corner case fixes discovered in testing with various scenarios.

Keeping this open for the remaining two patches for the daemon part.
Comment 34 Tomas Bzatek 2012-07-13 12:45:03 UTC
Review of attachment 218464 [details] [review]:

Firing notification for all GVfs backends is rather unusual but hey, why not, could be actually useful in some cases.

::: daemon/gvfsjobunmount.c
@@ +141,3 @@
+  g_debug ("gvfsjobunmount progress clear");
+
+  message = g_strdup_printf (_("Connection to %s closed"),

wording: GVfs backends are not always network services, suggesting using something neutral like "%s has been unmounted"

@@ +160,3 @@
+  /* TODO: report estimated bytes and time left */
+  g_mount_source_show_unmount_progress (op_job->mount_source,
+                                        _("Writing data"), -1, -1);

In the future, we could report umount/sync progress for some backends. For example, archiving backend might be doing archive close which may be essential to ensure archive integrity and could take quite a long time. We would have to call this handler multiple times then.

@@ +180,3 @@
     return;
 
+  unmount_progress_start (op_job);

You're calling unmount_progress_start() and unmount_progress_clear() only from within run(). However, some backends might be actually doing real unmount within try_unmount even if it should be used only for quick operations. And since there's 1.5 sec timeout, it shouldn't disrupt the UI if it returns quickly and then falls back into run().

Also, there are even more occurrences of try_unmount calls in the file for the force unmount functionality.
Comment 35 Tomas Bzatek 2012-07-13 12:54:51 UTC
Review of attachment 218463 [details] [review]:

Looks good to me, please commit, I'll update my gdbus-core branch afterwards (involving 75% rewrite anyway).

Please also bump GIO requirement for the new signal.
Comment 36 Cosimo Cecchi 2012-07-13 19:33:22 UTC
Comment on attachment 218463 [details] [review]
common: add support show-unmount-progress signal to GMountOperationDBus

Attachment 218463 [details] pushed as 69bdea2 - common: add support show-unmount-progress signal to GMountOperationDBus
Comment 37 Cosimo Cecchi 2012-07-13 19:50:07 UTC
(In reply to comment #34)

> ::: daemon/gvfsjobunmount.c
> @@ +141,3 @@
> +  g_debug ("gvfsjobunmount progress clear");
> +
> +  message = g_strdup_printf (_("Connection to %s closed"),
> 
> wording: GVfs backends are not always network services, suggesting using
> something neutral like "%s has been unmounted"

Okay, fixed now.

> @@ +160,3 @@
> +  /* TODO: report estimated bytes and time left */
> +  g_mount_source_show_unmount_progress (op_job->mount_source,
> +                                        _("Writing data"), -1, -1);
> 
> In the future, we could report umount/sync progress for some backends. For
> example, archiving backend might be doing archive close which may be essential
> to ensure archive integrity and could take quite a long time. We would have to
> call this handler multiple times then.

Sure, there shouldn't be any problem in calling this many times (and it's something that can't happen ATM as far as I see), but I tweaked a bit the code to make it more robust to this case.

> @@ +180,3 @@
>      return;
> 
> +  unmount_progress_start (op_job);
> 
> You're calling unmount_progress_start() and unmount_progress_clear() only from
> within run(). However, some backends might be actually doing real unmount
> within try_unmount even if it should be used only for quick operations. And
> since there's 1.5 sec timeout, it shouldn't disrupt the UI if it returns
> quickly and then falls back into run().
> 
> Also, there are even more occurrences of try_unmount calls in the file for the
> force unmount functionality.

Yeah....though my understanding of the code here was that try_unmount() is allowed to block though, since it shouldn't take a long time (if it did, the backend would have returned FALSE and then unmount() would have run in a thread), so there's little point in running the timeout if the code is going to block anyway.
I don't think this is really needed by any backend ATM, so I left it as it was in the next patch.
Comment 38 Cosimo Cecchi 2012-07-13 19:50:38 UTC
Created attachment 218755 [details] [review]
daemon: implement show-unmount-progress in GVfsJobUnmount

---

Address Tomas' review.
Comment 39 Tomas Bzatek 2012-07-16 11:38:10 UTC
Review of attachment 218755 [details] [review]:

(In reply to comment #37)
> Yeah....though my understanding of the code here was that try_unmount() is
> allowed to block though, since it shouldn't take a long time (if it did, the
> backend would have returned FALSE and then unmount() would have run in a
> thread), so there's little point in running the timeout if the code is going to
> block anyway.
> I don't think this is really needed by any backend ATM, so I left it as it was
> in the next patch.

That's right, it's not needed for the moment, it could only serve as a safety fallback for badly written backends. Okay then, leave it as is, time will tell if it's needed or not, it's a trivial change after all.

Patch looks good, please commit.
Comment 40 Cosimo Cecchi 2012-07-16 12:45:14 UTC
Attachment 218755 [details] pushed as 39a92eb - daemon: implement show-unmount-progress in GVfsJobUnmount

Thanks Tomas, closing this as FIXED.