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 732565 - Attempting to format device during creating of encrypted partition fails
Attempting to format device during creating of encrypted partition fails
Status: RESOLVED FIXED
Product: gnome-disk-utility
Classification: Core
Component: general
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-disk-utility-maint
gnome-disk-utility-maint
Depends on:
Blocks:
 
 
Reported: 2014-07-01 17:34 UTC by Michael Catanzaro
Modified: 2017-08-21 19:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Disable action buttons during jobs (2.49 KB, patch)
2017-07-17 21:22 UTC, Kai Lüke
none Details | Review
Disable action buttons during jobs (10.13 KB, patch)
2017-07-17 23:52 UTC, Kai Lüke
none Details | Review
Disable action buttons during jobs (12.33 KB, patch)
2017-07-19 12:11 UTC, Kai Lüke
reviewed Details | Review
Disable action buttons during jobs (9.82 KB, patch)
2017-07-23 13:00 UTC, Kai Lüke
reviewed Details | Review
Disable action buttons during jobs (9.88 KB, patch)
2017-08-14 21:28 UTC, Kai Lüke
committed Details | Review
Delay sensitivity during job updates (3.72 KB, patch)
2017-08-14 21:32 UTC, Kai Lüke
none Details | Review
Delay sensitivity during job updates (4.46 KB, patch)
2017-08-15 20:56 UTC, Kai Lüke
none Details | Review
Delay sensitivity during job updates (16.09 KB, patch)
2017-08-16 17:00 UTC, Kai Lüke
committed Details | Review

Description Michael Catanzaro 2014-07-01 17:34:15 UTC
* Create a new encrypted partition
* This takes a little while, so become bored and decide you want to format the entire device instead

Expected behavior: unusable controls like Format are insensitive while a long-running operation is in progress

Actual behavior: I can click Format and get an unfriendly error message:

Error wiping device: Command-line `wipefs -a "/dev/sdb1"' exited with non-zero exit status 1: wipefs: error: /dev/sdb1: probing initialization failed: Device or resource busy
 (udisks-error-quark, 0)
Comment 1 Kai Lüke 2017-07-17 21:22:06 UTC
Created attachment 355784 [details] [review]
Disable action buttons during jobs

At least from the GNOME Disks side this prevents these error messages or even destructive actions.
Comment 2 Kai Lüke 2017-07-17 22:05:50 UTC
Maybe it's possible to cover even more corner cases, like e.g. looking at jobs of other volumes - I better try to get this done first.
Comment 3 Kai Lüke 2017-07-17 23:52:38 UTC
Created attachment 355795 [details] [review]
Disable action buttons during jobs
Comment 4 Ondrej Holy 2017-07-19 07:33:26 UTC
Review of attachment 355795 [details] [review]:

Looks good apart from some cosmetic issues :-)

::: src/disks/gduapplication.c
@@ +576,3 @@
+
+  jobs = udisks_client_get_jobs_for_object (client, object);
+  jobs = g_list_concat (jobs, gdu_application_get_local_jobs_for_object (application, object));

Wouldn't be better to add the object in objects_to_check?
objects_to_check = g_list_prepend (objects_to_check, g_object_ref (object));
So you can simplify the code then...

@@ +590,3 @@
+          UDisksEncrypted *encrypted_for_object;
+
+          block_for_object = udisks_object_peek_block (object_iter);

I would move this inside "if (encrypted_for_object != NULL)" statement...

@@ +609,3 @@
+          if (encrypted_for_object != NULL)
+            {
+              UDisksBlock *cleartext;

\n

::: src/disks/gduwindow.c
@@ +1879,3 @@
     }
 
+  if (!window->has_any_volume_job)

Wouldn't be better to do it as the following?
sensitive = !window->has_any_volume_job;
gtk_widget_set_sensitive (window->devtab_drive_generic_button, sensitive);
...
or set sensitivity for parent widget instead?

@@ +1888,3 @@
+  else
+    {
+      gtk_widget_set_sensitive (window->devtab_grid_toolbar, FALSE);

This is probably redundant, because it is rewritten later...

@@ +1893,3 @@
+      gtk_widget_set_sensitive (window->devtab_drive_power_off_button, FALSE);
+      gtk_widget_set_sensitive (window->devtab_drive_loop_detach_button, FALSE);
+    }

nitpick: I would add \n, but it is up to you...

@@ +1970,3 @@
                    GList     *jobs)
 {
+  window->has_drive_job = jobs != NULL;

window->has_drive_job = (jobs != NULL);

@@ +1978,3 @@
                     GList     *jobs)
 {
+  window->has_volume_job = window->has_volume_job || jobs != NULL;

window->has_volume_job = (window->has_volume_job || jobs != NULL);

@@ +2967,3 @@
       if (object != NULL)
         {
+          window->has_volume_job = gdu_application_has_running_job (window->application, object);

Not sure about, but isn't this redundant? Isn't enough to check this in update_volume_jobs?

::: src/libgdu/gduutils.h
@@ +73,3 @@
 gchar *gdu_utils_get_pretty_uri (GFile *file);
 
+GList *get_all_contained_objects (UDisksClient *client,

GList *gdu_utils_get_all_contained_objects (UDisksClient *client,
Comment 5 Kai Lüke 2017-07-19 12:11:51 UTC
Created attachment 355940 [details] [review]
Disable action buttons during jobs

Good, I changed the place where the variables are assigned and hope it helps for readability even if the overall architecture is not so flexible.
Comment 6 Ondrej Holy 2017-07-19 13:41:06 UTC
Review of attachment 355940 [details] [review]:

::: src/disks/gduwindow.c
@@ +1887,3 @@
+  gtk_widget_set_sensitive (window->devtab_drive_loop_detach_button, drive_sensitivity);
+
+  selected_volume_sensitivity = !window->has_volume_job && !window->has_drive_job;

selected_volume_sensitivity = (!window->has_volume_job && !window->has_drive_job);

@@ +1963,2 @@
 {
+  window->has_volume_job = FALSE; /* comes before update_volume_jobs */

Wouldn't be finally better to move all these logic in update_jobs (so you can remove window->has_*_job at all)?

Is necessary to have origin_object as a param? Can't be simply window->current_object used instead?
Comment 7 Kai Lüke 2017-07-23 13:00:15 UTC
Created attachment 356231 [details] [review]
Disable action buttons during jobs

Thanks, good hint!
If I would remove the variables the whole retrieval of drive jobs would have to be done again with code copy for the volume update case…
Comment 8 Ondrej Holy 2017-07-25 11:08:49 UTC
Review of attachment 356231 [details] [review]:

Looks good, just it pretty flickers during e.g. resizing... can't we add e.g. some dummy-job for the operations like resizing? or some short timeout before setting sensitivity to true?
Comment 9 Ondrej Holy 2017-07-25 13:36:27 UTC
Review of attachment 356231 [details] [review]:

Btw this still doesn't prevent e.g. creating of a new partition when resizing...
Comment 10 Kai Lüke 2017-08-14 21:28:35 UTC
Created attachment 357571 [details] [review]
Disable action buttons during jobs

(no change, just added the URL in the commit message)
Comment 11 Kai Lüke 2017-08-14 21:32:38 UTC
Created attachment 357572 [details] [review]
Delay sensitivity during job updates

The whole state of the job updates is rather complicated with all these chained calls. This is more like a hack, but other solutions are out of sight with the current architecture (also a change might not fullfill all promises).
Comment 12 Ondrej Holy 2017-08-15 13:16:15 UTC
Review of attachment 357572 [details] [review]:

Thanks! I do not see any flickering with this patch, great!

But the sensitivity should be changed immediately if somebody changes the drive for example.

::: src/disks/gduwindow.c
@@ +1957,3 @@
+        g_source_remove (window->delay_job_update_id);
+
+      window->delay_job_update_id = g_timeout_add (300, delayed_job_update, window);

Please add #define with value on the top file...
Comment 13 Kai Lüke 2017-08-15 20:56:51 UTC
Created attachment 357674 [details] [review]
Delay sensitivity during job updates

Yes, that wasn't working at all! Now it should be ok.
Comment 14 Ondrej Holy 2017-08-16 14:54:19 UTC
Review of attachment 357674 [details] [review]:

Looks ok for drives, but the same problem for volumes... :-(

It would be nice to get those patches in this release as well. It would be a nice addition not only for resize feature...!

::: src/disks/gduwindow.c
@@ +1925,3 @@
+  window->is_delayed_job_update = TRUE;
+  update_all (window);
+  window->is_delayed_job_update = FALSE;

nitpick: The flag is changed only for the function calls, so would be better to use function argument instead. (If you want to avoid changing update_all on all places, you can rename update_all to e.g. update_all_internal and create macro/function with name update_all which just calls update_all_internal with correct param).
Comment 15 Kai Lüke 2017-08-16 17:00:37 UTC
Created attachment 357742 [details] [review]
Delay sensitivity during job updates

Sorry for the bad patch, this effect slipped through while testing…
Yes, global state is not nice in general, so even if it was more a method of holding the patch small and not a real global state I've just made it a proper function argument :)
Comment 16 Ondrej Holy 2017-08-17 08:38:54 UTC
Review of attachment 357742 [details] [review]:

Looks ok and seems working correctly. Just the "changed" on GduVolumeGrid is emitted also on "changed" from UDisksClient (not only when a user changes the selection), so not sure it can't be a problem in some cases...
Comment 17 Kai Lüke 2017-08-17 12:06:11 UTC
(Shouldn't be a problem because it could only cause a flicker during the transtion from one to the next job but that behavior was not observed.)