|
Tomas Bzatek |
10280e |
From 28c39786927ad683f56c031d80a5c06f5b5b9aea Mon Sep 17 00:00:00 2001
|
|
Tomas Bzatek |
10280e |
From: Marius Vollmer <mvollmer@redhat.com>
|
|
Tomas Bzatek |
10280e |
Date: Tue, 5 Apr 2022 11:23:23 +0300
|
|
Tomas Bzatek |
10280e |
Subject: [PATCH] lvm2: Only install results of most recently started udpates
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
Fixes #966
|
|
Tomas Bzatek |
10280e |
---
|
|
Tomas Bzatek |
10280e |
modules/lvm2/udiskslinuxmodulelvm2.c | 13 ++++++++++++-
|
|
Tomas Bzatek |
10280e |
modules/lvm2/udiskslinuxvolumegroupobject.c | 12 ++++++++++++
|
|
Tomas Bzatek |
10280e |
2 files changed, 24 insertions(+), 1 deletion(-)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
diff --git a/modules/lvm2/udiskslinuxmodulelvm2.c b/modules/lvm2/udiskslinuxmodulelvm2.c
|
|
Tomas Bzatek |
10280e |
index 8e1ea13aec..77ecf94a6d 100644
|
|
Tomas Bzatek |
10280e |
--- a/modules/lvm2/udiskslinuxmodulelvm2.c
|
|
Tomas Bzatek |
10280e |
+++ b/modules/lvm2/udiskslinuxmodulelvm2.c
|
|
Tomas Bzatek |
10280e |
@@ -59,6 +59,8 @@ struct _UDisksLinuxModuleLVM2 {
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
gint delayed_update_id;
|
|
Tomas Bzatek |
10280e |
gboolean coldplug_done;
|
|
Tomas Bzatek |
10280e |
+
|
|
Tomas Bzatek |
10280e |
+ guint32 update_epoch;
|
|
Tomas Bzatek |
10280e |
};
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
typedef struct _UDisksLinuxModuleLVM2Class UDisksLinuxModuleLVM2Class;
|
|
Tomas Bzatek |
10280e |
@@ -86,6 +88,7 @@ udisks_linux_module_lvm2_constructed (GObject *object)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
module->name_to_volume_group = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_object_unref);
|
|
Tomas Bzatek |
10280e |
module->coldplug_done = FALSE;
|
|
Tomas Bzatek |
10280e |
+ module->update_epoch = 0;
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
if (G_OBJECT_CLASS (udisks_linux_module_lvm2_parent_class)->constructed)
|
|
Tomas Bzatek |
10280e |
G_OBJECT_CLASS (udisks_linux_module_lvm2_parent_class)->constructed (object);
|
|
Tomas Bzatek |
10280e |
@@ -221,6 +224,12 @@ lvm_update_vgs (GObject *source_obj,
|
|
Tomas Bzatek |
10280e |
gpointer key, value;
|
|
Tomas Bzatek |
10280e |
const gchar *vg_name;
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
+ if (GPOINTER_TO_UINT (user_data) != module->update_epoch)
|
|
Tomas Bzatek |
10280e |
+ {
|
|
Tomas Bzatek |
10280e |
+ vgs_pvs_data_free (data);
|
|
Tomas Bzatek |
10280e |
+ return;
|
|
Tomas Bzatek |
10280e |
+ }
|
|
Tomas Bzatek |
10280e |
+
|
|
Tomas Bzatek |
10280e |
if (! data)
|
|
Tomas Bzatek |
10280e |
{
|
|
Tomas Bzatek |
10280e |
if (error)
|
|
Tomas Bzatek |
10280e |
@@ -303,11 +312,13 @@ lvm_update (UDisksLinuxModuleLVM2 *module)
|
|
Tomas Bzatek |
10280e |
{
|
|
Tomas Bzatek |
10280e |
GTask *task;
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
+ module->update_epoch++;
|
|
Tomas Bzatek |
10280e |
+
|
|
Tomas Bzatek |
10280e |
/* the callback (lvm_update_vgs) is called in the default main loop (context) */
|
|
Tomas Bzatek |
10280e |
task = g_task_new (module,
|
|
Tomas Bzatek |
10280e |
NULL /* cancellable */,
|
|
Tomas Bzatek |
10280e |
lvm_update_vgs,
|
|
Tomas Bzatek |
10280e |
- NULL /* callback_data */);
|
|
Tomas Bzatek |
10280e |
+ GUINT_TO_POINTER (module->update_epoch));
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
/* holds a reference to 'task' until it is finished */
|
|
Tomas Bzatek |
10280e |
g_task_run_in_thread (task, (GTaskThreadFunc) vgs_task_func);
|
|
Tomas Bzatek |
10280e |
diff --git a/modules/lvm2/udiskslinuxvolumegroupobject.c b/modules/lvm2/udiskslinuxvolumegroupobject.c
|
|
Tomas Bzatek |
10280e |
index ce941cb250..ead08de7b1 100644
|
|
Tomas Bzatek |
10280e |
--- a/modules/lvm2/udiskslinuxvolumegroupobject.c
|
|
Tomas Bzatek |
10280e |
+++ b/modules/lvm2/udiskslinuxvolumegroupobject.c
|
|
Tomas Bzatek |
10280e |
@@ -66,6 +66,7 @@ struct _UDisksLinuxVolumeGroupObject
|
|
Tomas Bzatek |
10280e |
gchar *name;
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
GHashTable *logical_volumes;
|
|
Tomas Bzatek |
10280e |
+ guint32 update_epoch;
|
|
Tomas Bzatek |
10280e |
guint32 poll_epoch;
|
|
Tomas Bzatek |
10280e |
guint poll_timeout_id;
|
|
Tomas Bzatek |
10280e |
gboolean poll_requested;
|
|
Tomas Bzatek |
10280e |
@@ -99,6 +100,7 @@ static void crypttab_changed (UDisksCrypttabMonitor *monitor,
|
|
Tomas Bzatek |
10280e |
typedef struct {
|
|
Tomas Bzatek |
10280e |
BDLVMVGdata *vg_info;
|
|
Tomas Bzatek |
10280e |
GSList *vg_pvs;
|
|
Tomas Bzatek |
10280e |
+ guint32 epoch;
|
|
Tomas Bzatek |
10280e |
} VGUpdateData;
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
static void
|
|
Tomas Bzatek |
10280e |
@@ -183,6 +185,7 @@ udisks_linux_volume_group_object_set_property (GObject *__object,
|
|
Tomas Bzatek |
10280e |
static void
|
|
Tomas Bzatek |
10280e |
udisks_linux_volume_group_object_init (UDisksLinuxVolumeGroupObject *object)
|
|
Tomas Bzatek |
10280e |
{
|
|
Tomas Bzatek |
10280e |
+ object->update_epoch = 0;
|
|
Tomas Bzatek |
10280e |
object->poll_epoch = 0;
|
|
Tomas Bzatek |
10280e |
object->poll_timeout_id = 0;
|
|
Tomas Bzatek |
10280e |
object->poll_requested = FALSE;
|
|
Tomas Bzatek |
10280e |
@@ -575,6 +578,12 @@ update_vg (GObject *source_obj,
|
|
Tomas Bzatek |
10280e |
BDLVMVGdata *vg_info = data->vg_info;
|
|
Tomas Bzatek |
10280e |
GSList *vg_pvs = data->vg_pvs;
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
+ if (data->epoch != object->update_epoch)
|
|
Tomas Bzatek |
10280e |
+ {
|
|
Tomas Bzatek |
10280e |
+ lv_list_free (lvs);
|
|
Tomas Bzatek |
10280e |
+ return;
|
|
Tomas Bzatek |
10280e |
+ }
|
|
Tomas Bzatek |
10280e |
+
|
|
Tomas Bzatek |
10280e |
/* free the data container (but not 'vg_info' and 'vg_pvs') */
|
|
Tomas Bzatek |
10280e |
g_free (data);
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -711,8 +720,11 @@ udisks_linux_volume_group_object_update (UDisksLinuxVolumeGroupObject *object, B
|
|
Tomas Bzatek |
10280e |
gchar *vg_name = g_strdup (vg_info->name);
|
|
Tomas Bzatek |
10280e |
GTask *task = NULL;
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
+ object->update_epoch++;
|
|
Tomas Bzatek |
10280e |
+
|
|
Tomas Bzatek |
10280e |
data->vg_info = vg_info;
|
|
Tomas Bzatek |
10280e |
data->vg_pvs = pvs;
|
|
Tomas Bzatek |
10280e |
+ data->epoch = object->update_epoch;
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
/* the callback (update_vg) is called in the default main loop (context) */
|
|
Tomas Bzatek |
10280e |
task = g_task_new (g_object_ref (object), NULL /* cancellable */, update_vg, data /* callback_data */);
|