[gnome-disk-utility] Use new API to add UI for checking/repairing Linux MD RAID arrays
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-disk-utility] Use new API to add UI for checking/repairing Linux MD RAID arrays
- Date: Thu, 18 Jun 2009 16:05:38 -0400 (EDT)
commit 5bae92a791f8c6c6ce5c4becca3f2bfc27fefc1d
Author: David Zeuthen <davidz redhat com>
Date: Thu Jun 18 16:02:47 2009 -0400
Use new API to add UI for checking/repairing Linux MD RAID arrays
src/gdu/gdu-callbacks.h | 5 ++
src/gdu/gdu-device.c | 43 +++++++++++++
src/gdu/gdu-device.h | 7 ++
src/gdu/gdu-util.c | 4 +
src/palimpsest/gdu-section-linux-md-drive.c | 88 +++++++++++++++++++++++++--
5 files changed, 141 insertions(+), 6 deletions(-)
---
diff --git a/src/gdu/gdu-callbacks.h b/src/gdu/gdu-callbacks.h
index b8f5114..59f3217 100644
--- a/src/gdu/gdu-callbacks.h
+++ b/src/gdu/gdu-callbacks.h
@@ -96,6 +96,11 @@ typedef void (*GduDeviceLinuxMdStopCompletedFunc) (GduDevice *device,
GError *error,
gpointer user_data);
+typedef void (*GduDeviceLinuxMdCheckCompletedFunc) (GduDevice *device,
+ guint num_errors,
+ GError *error,
+ gpointer user_data);
+
typedef void (*GduDeviceLinuxMdAddComponentCompletedFunc) (GduDevice *device,
GError *error,
gpointer user_data);
diff --git a/src/gdu/gdu-device.c b/src/gdu/gdu-device.c
index 9d6cf32..bed2471 100644
--- a/src/gdu/gdu-device.c
+++ b/src/gdu/gdu-device.c
@@ -2199,6 +2199,49 @@ gdu_device_op_linux_md_stop (GduDevice *device,
typedef struct {
GduDevice *device;
+ GduDeviceLinuxMdCheckCompletedFunc callback;
+ gpointer user_data;
+} LinuxMdCheckData;
+
+static void
+op_check_linux_md_array_cb (DBusGProxy *proxy, guint64 num_errors, GError *error, gpointer user_data)
+{
+ LinuxMdCheckData *data = user_data;
+ _gdu_error_fixup (error);
+ if (data->callback != NULL)
+ data->callback (data->device, num_errors, error, data->user_data);
+ g_object_unref (data->device);
+ g_free (data);
+}
+
+void
+gdu_device_op_linux_md_check (GduDevice *device,
+ gchar **options,
+ GduDeviceLinuxMdCheckCompletedFunc callback,
+ gpointer user_data)
+{
+ gchar *null_options[16];
+ LinuxMdCheckData *data;
+
+ data = g_new0 (LinuxMdCheckData, 1);
+ data->device = g_object_ref (device);
+ data->callback = callback;
+ data->user_data = user_data;
+
+ null_options[0] = NULL;
+ if (options == NULL)
+ options = null_options;
+
+ org_freedesktop_DeviceKit_Disks_Device_linux_md_check_async (device->priv->proxy,
+ (const char **) options,
+ op_check_linux_md_array_cb,
+ data);
+}
+
+/* -------------------------------------------------------------------------------- */
+
+typedef struct {
+ GduDevice *device;
GduDeviceLinuxMdAddComponentCompletedFunc callback;
gpointer user_data;
} LinuxMdAddComponentData;
diff --git a/src/gdu/gdu-device.h b/src/gdu/gdu-device.h
index 404aeb4..32cefd4 100644
--- a/src/gdu/gdu-device.h
+++ b/src/gdu/gdu-device.h
@@ -303,6 +303,13 @@ void gdu_device_op_linux_md_stop (GduDevice *device,
/* ---------------------------------------------------------------------------------------------------- */
+void gdu_device_op_linux_md_check (GduDevice *device,
+ gchar **options,
+ GduDeviceLinuxMdCheckCompletedFunc callback,
+ gpointer user_data);
+
+/* ---------------------------------------------------------------------------------------------------- */
+
void gdu_device_op_linux_md_add_component (GduDevice *device,
const char *component_objpath,
GduDeviceLinuxMdAddComponentCompletedFunc callback,
diff --git a/src/gdu/gdu-util.c b/src/gdu/gdu-util.c
index 707b753..8935df3 100644
--- a/src/gdu/gdu-util.c
+++ b/src/gdu/gdu-util.c
@@ -315,6 +315,10 @@ gdu_get_job_description (const char *job_id)
s = g_strdup (_("Stopping RAID Array"));
} else if (strcmp (job_id, "LinuxMdStart") == 0) {
s = g_strdup (_("Starting RAID Array"));
+ } else if (strcmp (job_id, "LinuxMdCheck") == 0) {
+ s = g_strdup (_("Checking RAID Array"));
+ } else if (strcmp (job_id, "LinuxMdRepair") == 0) {
+ s = g_strdup (_("Repairing RAID Array"));
} else if (strcmp (job_id, "DriveAtaSmartInitiateSelftest") == 0) {
s = g_strdup (_("Running S.M.A.R.T. Self Test"));
} else if (strcmp (job_id, "DriveEject") == 0) {
diff --git a/src/palimpsest/gdu-section-linux-md-drive.c b/src/palimpsest/gdu-section-linux-md-drive.c
index 4d0f943..3df571d 100644
--- a/src/palimpsest/gdu-section-linux-md-drive.c
+++ b/src/palimpsest/gdu-section-linux-md-drive.c
@@ -437,6 +437,70 @@ out:
}
static void
+on_check_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GduSectionLinuxMdDrive *section = GDU_SECTION_LINUX_MD_DRIVE (user_data);
+ GduPresentable *presentable;
+ GduDevice *device;
+
+ presentable = gdu_section_get_presentable (GDU_SECTION (section));
+ if (!GDU_IS_LINUX_MD_DRIVE (presentable)) {
+ g_warning ("%s: is not an linux_md drive", __FUNCTION__);
+ goto out;
+ }
+
+ device = gdu_presentable_get_device (presentable);
+ if (device == NULL) {
+ g_warning ("%s: linux_md drive not active", __FUNCTION__);
+ goto out;
+ }
+
+ gdu_device_op_linux_md_check (device,
+ NULL,
+ NULL,
+ NULL); /* TODO: report result back? */
+
+ out:
+ if (device != NULL)
+ g_object_unref (device);
+}
+
+static void
+on_repair_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GduSectionLinuxMdDrive *section = GDU_SECTION_LINUX_MD_DRIVE (user_data);
+ GduPresentable *presentable;
+ GduDevice *device;
+ gchar *options[2];
+
+ options[0] = "repair";
+ options[1] = NULL;
+
+ presentable = gdu_section_get_presentable (GDU_SECTION (section));
+ if (!GDU_IS_LINUX_MD_DRIVE (presentable)) {
+ g_warning ("%s: is not an linux_md drive", __FUNCTION__);
+ goto out;
+ }
+
+ device = gdu_presentable_get_device (presentable);
+ if (device == NULL) {
+ g_warning ("%s: linux_md drive not active", __FUNCTION__);
+ goto out;
+ }
+
+ gdu_device_op_linux_md_check (device,
+ options,
+ NULL,
+ NULL); /* TODO: report result back? */
+
+ out:
+ if (device != NULL)
+ g_object_unref (device);
+}
+
+static void
linux_md_buttons_update (GduSectionLinuxMdDrive *section)
{
GtkTreePath *path;
@@ -700,18 +764,18 @@ update (GduSectionLinuxMdDrive *section)
if (strcmp (sync_action, "reshape") == 0) {
g_string_append (str, ", ");
g_string_append (str, C_("RAID status", "Reshaping"));
- }
- else if (strcmp (sync_action, "resync") == 0) {
+ } else if (strcmp (sync_action, "resync") == 0) {
g_string_append (str, ", ");
g_string_append (str, C_("RAID status", "Resyncing"));
- }
- else if (strcmp (sync_action, "repair") == 0) {
+ } else if (strcmp (sync_action, "repair") == 0) {
g_string_append (str, ", ");
g_string_append (str, C_("RAID status", "Repairing"));
- }
- else if (strcmp (sync_action, "recover") == 0) {
+ } else if (strcmp (sync_action, "recover") == 0) {
g_string_append (str, ", ");
g_string_append (str, C_("RAID status", "Recovering"));
+ } else if (strcmp (sync_action, "check") == 0) {
+ g_string_append (str, ", ");
+ g_string_append (str, C_("RAID status", "Checking"));
}
sync_speed_str = gdu_util_get_speed_for_display (sync_speed);
@@ -1027,6 +1091,18 @@ gdu_section_linux_md_drive_init (GduSectionLinuxMdDrive *section)
gtk_widget_set_tooltip_text (button, _("Adds a new component to the running RAID array. Use this "
"when replacing a failed component or adding a hot spare."));
+ button = gtk_button_new_with_mnemonic (_("_Check"));
+ gtk_container_add (GTK_CONTAINER (button_box), button);
+ section->priv->add_button = button;
+ g_signal_connect (button, "clicked", G_CALLBACK (on_check_clicked), section);
+ gtk_widget_set_tooltip_text (button, _("Starts checking the RAID array for redundancy"));
+
+ button = gtk_button_new_with_mnemonic (_("_Repair"));
+ gtk_container_add (GTK_CONTAINER (button_box), button);
+ section->priv->add_button = button;
+ g_signal_connect (button, "clicked", G_CALLBACK (on_repair_clicked), section);
+ gtk_widget_set_tooltip_text (button, _("Starts repairing the RAID array"));
+
/* add renderers for tree view */
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("RAID Component"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]