[gnome-disk-utility] Make it possible to configure the Write Cache on ATA hard disks
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Make it possible to configure the Write Cache on ATA hard disks
- Date: Fri, 7 Dec 2012 20:49:31 +0000 (UTC)
commit 1542a1c4078d88527efac97373a0fdf5c8b672dc
Author: David Zeuthen <zeuthen gmail com>
Date: Fri Dec 7 15:48:31 2012 -0500
Make it possible to configure the Write Cache on ATA hard disks
http://people.freedesktop.org/~david/gnome-disks-write-cache-setting.png
Signed-off-by: David Zeuthen <zeuthen gmail com>
data/ui/disk-settings-dialog.ui | 178 ++++++++++++++++++++++++++++++++++---
src/disks/gdudisksettingsdialog.c | 61 ++++++++++++-
2 files changed, 223 insertions(+), 16 deletions(-)
---
diff --git a/data/ui/disk-settings-dialog.ui b/data/ui/disk-settings-dialog.ui
index e1bd8c9..67cfff3 100644
--- a/data/ui/disk-settings-dialog.ui
+++ b/data/ui/disk-settings-dialog.ui
@@ -19,6 +19,7 @@
<property name="width_request">500</property>
<property name="height_request">300</property>
<property name="can_focus">False</property>
+ <property name="border_width">2</property>
<property name="title" translatable="yes">Drive Settings</property>
<property name="resizable">False</property>
<property name="modal">True</property>
@@ -50,9 +51,7 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">_Standby Timeout</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">standby-switch</property>
+ <property name="label" translatable="yes">Standby Timeout</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1"/>
@@ -69,6 +68,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Turn on to configure Standby Timeout at startup and when the disk is connected</property>
</object>
<packing>
<property name="expand">False</property>
@@ -156,7 +156,8 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Standby</property>
+ <property name="label" translatable="yes">_Standby</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="tab_fill">False</property>
@@ -178,9 +179,7 @@
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">_Advanced Power Management</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">apm-switch</property>
+ <property name="label" translatable="yes">Advanced Power Management</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1"/>
@@ -197,6 +196,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Turn on to configure APM at startup and when the disk is connected</property>
</object>
<packing>
<property name="expand">False</property>
@@ -305,7 +305,9 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">APM</property>
+ <property name="label" translatable="yes">A_PM</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">apm-box</property>
</object>
<packing>
<property name="position">1</property>
@@ -328,9 +330,7 @@
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Automatic Aco_ustic Management</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">aam-switch</property>
+ <property name="label" translatable="yes">Automatic Acoustic Management</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1"/>
@@ -347,6 +347,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Turn on to configure AAM at startup and when the disk is connected</property>
</object>
<packing>
<property name="expand">False</property>
@@ -374,7 +375,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
+ <property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="aam-vendor-recommended-label">
<property name="visible">True</property>
@@ -469,13 +470,164 @@
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">AAM</property>
+ <property name="label" translatable="yes">_AAM</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">aam-box</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox" id="write-cache-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox" id="box3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Write Cache</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="write-cache-switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Turn on to configure Write Cache setting at startup and when the disk is connected</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="write-cache-widgets-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">24</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkGrid" id="grid2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">S_etting</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">write-cache-comboboxtext</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="write-cache-comboboxtext">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="entry_text_column">0</property>
+ <property name="id_column">1</property>
+ <items>
+ <item translatable="yes">Enable Write Cache</item>
+ <item translatable="yes">Disable Write Cache</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="width_request">500</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Performance is increased by enabling write caching, but leaves the system susceptible to data loss in the event of a power failure</property>
+ <property name="wrap">True</property>
+ <attributes>
+ <attribute name="style" value="italic"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Write _Cache</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">write-cache-box</property>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">True</property>
diff --git a/src/disks/gdudisksettingsdialog.c b/src/disks/gdudisksettingsdialog.c
index d18ab1d..f2fb803 100644
--- a/src/disks/gdudisksettingsdialog.c
+++ b/src/disks/gdudisksettingsdialog.c
@@ -61,6 +61,12 @@ typedef struct
GtkWidget *aam_scale;
GtkAdjustment *aam_adjustment;
+ /* Write Cache */
+ GtkWidget *write_cache_box;
+ GtkWidget *write_cache_switch;
+ GtkWidget *write_cache_widgets_box;
+ GtkWidget *write_cache_comboboxtext;
+
} DialogData;
static const struct {
@@ -92,6 +98,12 @@ static const struct {
{G_STRUCT_OFFSET (DialogData, aam_scale), "aam-scale"},
{G_STRUCT_OFFSET (DialogData, aam_adjustment), "aam-adjustment"},
+ /* Write Cache */
+ {G_STRUCT_OFFSET (DialogData, write_cache_box), "write-cache-box"},
+ {G_STRUCT_OFFSET (DialogData, write_cache_switch), "write-cache-switch"},
+ {G_STRUCT_OFFSET (DialogData, write_cache_widgets_box), "write-cache-widgets-box"},
+ {G_STRUCT_OFFSET (DialogData, write_cache_comboboxtext), "write-cache-comboboxtext"},
+
{0, NULL}
};
@@ -158,7 +170,8 @@ compute_configuration (DialogData *data)
{
if (g_strcmp0 (key, "ata-pm-standby") == 0 ||
g_strcmp0 (key, "ata-apm-level") == 0 ||
- g_strcmp0 (key, "ata-aam-level") == 0)
+ g_strcmp0 (key, "ata-aam-level") == 0 ||
+ g_strcmp0 (key, "ata-write-cache-enabled") == 0)
{
/* handled by us, skip */
}
@@ -202,6 +215,18 @@ compute_configuration (DialogData *data)
}
}
+ /* AAM */
+ if (gtk_switch_get_active (GTK_SWITCH (data->write_cache_switch)))
+ {
+ if (udisks_drive_ata_get_write_cache_supported (data->ata))
+ {
+ gboolean enabled = FALSE;
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (data->write_cache_comboboxtext)) == 0)
+ enabled = TRUE;
+ g_variant_builder_add (&builder, "{sv}", "ata-write-cache-enabled", g_variant_new_boolean (enabled));
+ }
+ }
+
return g_variant_builder_end (&builder);
}
@@ -235,7 +260,6 @@ update_dialog (DialogData *data)
gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, changed);
/* update labels */
-
update_standby_label (data);
update_apm_label (data);
update_aam_label (data);
@@ -469,11 +493,15 @@ gdu_disk_settings_dialog_show (GduWindow *window,
gint standby_value = -1;
gint apm_value = -1;
gint aam_value = -1;
+ gboolean write_cache_enabled = FALSE;
+ gboolean write_cache_enabled_set = FALSE;
/* Power Management page */
g_variant_lookup (data->orig_drive_configuration, "ata-pm-standby", "i", &standby_value);
g_variant_lookup (data->orig_drive_configuration, "ata-apm-level", "i", &apm_value);
g_variant_lookup (data->orig_drive_configuration, "ata-aam-level", "i", &aam_value);
+ if (g_variant_lookup (data->orig_drive_configuration, "ata-write-cache-enabled", "b", &write_cache_enabled))
+ write_cache_enabled_set = TRUE;
/* Standby (default to 10 minutes -> 120) */
if (standby_value == -1)
@@ -515,6 +543,19 @@ gdu_disk_settings_dialog_show (GduWindow *window,
gtk_adjustment_set_value (data->aam_adjustment, aam_value);
gtk_switch_set_active (GTK_SWITCH (data->aam_switch), TRUE);
}
+
+ /* Write Cache (default to "Enabled") */
+ if (!write_cache_enabled_set)
+ {
+ gtk_combo_box_set_active (GTK_COMBO_BOX (data->write_cache_comboboxtext), 0);
+ gtk_switch_set_active (GTK_SWITCH (data->write_cache_switch), FALSE);
+ }
+ else
+ {
+ gtk_combo_box_set_active (GTK_COMBO_BOX (data->write_cache_comboboxtext),
+ write_cache_enabled ? 0 : 1);
+ gtk_switch_set_active (GTK_SWITCH (data->write_cache_switch), TRUE);
+ }
}
g_signal_connect (data->standby_switch,
@@ -523,6 +564,8 @@ gdu_disk_settings_dialog_show (GduWindow *window,
"notify::active", G_CALLBACK (on_property_changed), data);
g_signal_connect (data->aam_switch,
"notify::active", G_CALLBACK (on_property_changed), data);
+ g_signal_connect (data->write_cache_switch,
+ "notify::active", G_CALLBACK (on_property_changed), data);
g_signal_connect (data->standby_adjustment,
"notify::value", G_CALLBACK (on_property_changed), data);
@@ -530,6 +573,8 @@ gdu_disk_settings_dialog_show (GduWindow *window,
"notify::value", G_CALLBACK (on_property_changed), data);
g_signal_connect (data->aam_adjustment,
"notify::value", G_CALLBACK (on_property_changed), data);
+ g_signal_connect (data->write_cache_comboboxtext,
+ "notify::active", G_CALLBACK (on_property_changed), data);
g_object_bind_property (data->standby_switch,
"active",
@@ -549,6 +594,12 @@ gdu_disk_settings_dialog_show (GduWindow *window,
"sensitive",
G_BINDING_SYNC_CREATE);
+ g_object_bind_property (data->write_cache_switch,
+ "active",
+ data->write_cache_widgets_box,
+ "sensitive",
+ G_BINDING_SYNC_CREATE);
+
update_dialog (data);
while (TRUE)
@@ -603,6 +654,9 @@ disable_unused_widgets (DialogData *data)
if (!udisks_drive_ata_get_aam_supported (data->ata))
hide_forever (data->aam_box);
+
+ if (!udisks_drive_ata_get_write_cache_supported (data->ata))
+ hide_forever (data->write_cache_box);
}
gboolean
@@ -630,7 +684,8 @@ gdu_disk_settings_dialog_should_show (UDisksObject *object)
if ((udisks_drive_ata_get_pm_supported (ata) && !is_ssd) ||
udisks_drive_ata_get_apm_supported (ata) ||
- udisks_drive_ata_get_aam_supported (ata))
+ udisks_drive_ata_get_aam_supported (ata) ||
+ udisks_drive_ata_get_write_cache_supported (ata))
{
ret = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]