diff options
author | Tom Yan <tom.ty89@gmail.com> | 2016-02-29 16:57:49 +0100 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2016-02-29 16:57:49 +0100 |
commit | 7c7a43df1031ed593e541a6eb21b450dffba0579 (patch) | |
tree | f3740215210007b8493f966f44ea4e2be6805460 | |
parent | ce392b4e158cbe8051c54203966851ed859412f6 (diff) | |
download | udisks-7c7a43df1031ed593e541a6eb21b450dffba0579.tar.gz |
Bug 92488 - Add support for read look-ahead ATA settings
https://bugs.freedesktop.org/show_bug.cgi?id=92488
-rw-r--r-- | data/org.freedesktop.UDisks2.xml | 18 | ||||
-rw-r--r-- | doc/man/udisks.xml | 13 | ||||
-rw-r--r-- | doc/udisks2-sections.txt | 4 | ||||
-rw-r--r-- | src/udiskslinuxdrive.c | 11 | ||||
-rw-r--r-- | src/udiskslinuxdriveata.c | 48 |
5 files changed, 87 insertions, 7 deletions
diff --git a/data/org.freedesktop.UDisks2.xml b/data/org.freedesktop.UDisks2.xml index bd72795..20c073d 100644 --- a/data/org.freedesktop.UDisks2.xml +++ b/data/org.freedesktop.UDisks2.xml @@ -162,6 +162,12 @@ Whether the write-cache is enabled (See ATA command <quote>SET FEATURES</quote>, sub-commands 0x82 and 0x02). Since 2.1. </para></listitem> </varlistentry> + <varlistentry> + <term>ata-read-lookahead-enabled (type <literal>'b'</literal>)</term> + <listitem><para> + Whether the read look-ahead is enabled (See ATA command <quote>SET FEATURES</quote>, sub-commands 0x55 and 0xaa). Since 2.1.7. + </para></listitem> + </varlistentry> </variablelist> The contents of this property is read from the configuration file <filename>/etc/udisks2/IDENTIFIER.conf</filename> @@ -666,6 +672,18 @@ --> <property name="WriteCacheEnabled" type="b" access="read"/> + <!-- ReadLookaheadSupported: + @since: 2.1.7 + Whether the drive supports configuring the read look-ahead. + --> + <property name="ReadLookaheadSupported" type="b" access="read"/> + + <!-- ReadLookaheadEnabled: + @since: 2.1.7 + Whether the read look-ahead is enabled (or %FALSE if not supported). + --> + <property name="ReadLookaheadEnabled" type="b" access="read"/> + <!-- PmGetState: @options: Options (currently unused except for <link linkend="udisks-std-options">standard options</link>). diff --git a/doc/man/udisks.xml b/doc/man/udisks.xml index e13129c..218a424 100644 --- a/doc/man/udisks.xml +++ b/doc/man/udisks.xml @@ -168,6 +168,19 @@ </para> </listitem> </varlistentry> + <varlistentry> + <term><option>ReadLookaheadEnabled</option></term> + <listitem> + <para> + A boolean specifying whether to enable or disable the + Read Look-ahead. Valid values for this key are + <quote>true</quote> and <quote>false</quote>. This is + similar to the <option>-A</option> option in + <citerefentry><refentrytitle>hdparm</refentrytitle><manvolnum>8</manvolnum></citerefentry>. + This key was added in 2.1.7. + </para> + </listitem> + </varlistentry> </variablelist> </refsect2> </refsect1> diff --git a/doc/udisks2-sections.txt b/doc/udisks2-sections.txt index 6dfc4b4..314175a 100644 --- a/doc/udisks2-sections.txt +++ b/doc/udisks2-sections.txt @@ -757,6 +757,8 @@ udisks_drive_ata_get_pm_enabled udisks_drive_ata_get_pm_supported udisks_drive_ata_get_write_cache_enabled udisks_drive_ata_get_write_cache_supported +udisks_drive_ata_get_read_lookahead_enabled +udisks_drive_ata_get_read_lookahead_supported udisks_drive_ata_get_security_enhanced_erase_unit_minutes udisks_drive_ata_get_security_erase_unit_minutes udisks_drive_ata_get_security_frozen @@ -780,6 +782,8 @@ udisks_drive_ata_set_pm_enabled udisks_drive_ata_set_pm_supported udisks_drive_ata_set_write_cache_enabled udisks_drive_ata_set_write_cache_supported +udisks_drive_ata_set_read_lookahead_enabled +udisks_drive_ata_set_read_lookahead_supported udisks_drive_ata_set_security_enhanced_erase_unit_minutes udisks_drive_ata_set_security_erase_unit_minutes udisks_drive_ata_set_security_frozen diff --git a/src/udiskslinuxdrive.c b/src/udiskslinuxdrive.c index cc2695a..e1652df 100644 --- a/src/udiskslinuxdrive.c +++ b/src/udiskslinuxdrive.c @@ -216,11 +216,12 @@ typedef struct { const GVariantType *type; } VariantKeyfileMapping; -static const VariantKeyfileMapping drive_configuration_mapping[4] = { - {"ata-pm-standby", "ATA", "StandbyTimeout", G_VARIANT_TYPE_INT32}, - {"ata-apm-level", "ATA", "APMLevel", G_VARIANT_TYPE_INT32}, - {"ata-aam-level", "ATA", "AAMLevel", G_VARIANT_TYPE_INT32}, - {"ata-write-cache-enabled", "ATA", "WriteCacheEnabled", G_VARIANT_TYPE_BOOLEAN}, +static const VariantKeyfileMapping drive_configuration_mapping[5] = { + {"ata-pm-standby", "ATA", "StandbyTimeout", G_VARIANT_TYPE_INT32}, + {"ata-apm-level", "ATA", "APMLevel", G_VARIANT_TYPE_INT32}, + {"ata-aam-level", "ATA", "AAMLevel", G_VARIANT_TYPE_INT32}, + {"ata-write-cache-enabled", "ATA", "WriteCacheEnabled", G_VARIANT_TYPE_BOOLEAN}, + {"ata-read-lookahead-enabled", "ATA", "ReadLookaheadEnabled", G_VARIANT_TYPE_BOOLEAN}, }; /* ---------------------------------------------------------------------------------------------------- */ diff --git a/src/udiskslinuxdriveata.c b/src/udiskslinuxdriveata.c index 63a29f2..badb5ab 100644 --- a/src/udiskslinuxdriveata.c +++ b/src/udiskslinuxdriveata.c @@ -225,6 +225,8 @@ update_pm (UDisksLinuxDriveAta *drive, gboolean aam_enabled = FALSE; gboolean write_cache_supported = FALSE; gboolean write_cache_enabled = FALSE; + gboolean read_lookahead_supported = FALSE; + gboolean read_lookahead_enabled = FALSE; gint aam_vendor_recommended_value = 0; guint16 word_82 = 0; guint16 word_83 = 0; @@ -247,8 +249,10 @@ update_pm (UDisksLinuxDriveAta *drive, aam_enabled = word_86 & (1<<9); if (aam_supported) aam_vendor_recommended_value = (word_94 >> 8); - write_cache_supported = word_82 & (1<<5); - write_cache_enabled = word_85 & (1<<5); + write_cache_supported = word_82 & (1<<5); + write_cache_enabled = word_85 & (1<<5); + read_lookahead_supported = word_82 & (1<<6); + read_lookahead_enabled = word_85 & (1<<6); g_object_freeze_notify (G_OBJECT (drive)); udisks_drive_ata_set_pm_supported (UDISKS_DRIVE_ATA (drive), !!pm_supported); @@ -260,6 +264,8 @@ update_pm (UDisksLinuxDriveAta *drive, udisks_drive_ata_set_aam_vendor_recommended_value (UDISKS_DRIVE_ATA (drive), aam_vendor_recommended_value); udisks_drive_ata_set_write_cache_supported (UDISKS_DRIVE_ATA (drive), !!write_cache_supported); udisks_drive_ata_set_write_cache_enabled (UDISKS_DRIVE_ATA (drive), !!write_cache_enabled); + udisks_drive_ata_set_read_lookahead_supported (UDISKS_DRIVE_ATA (drive), !!read_lookahead_supported); + udisks_drive_ata_set_read_lookahead_enabled (UDISKS_DRIVE_ATA (drive), !!read_lookahead_enabled); g_object_thaw_notify (G_OBJECT (drive)); } @@ -1634,6 +1640,8 @@ typedef struct gint ata_aam_level; gboolean ata_write_cache_enabled; gboolean ata_write_cache_enabled_set; + gboolean ata_read_lookahead_enabled; + gboolean ata_read_lookahead_enabled_set; UDisksLinuxDriveAta *ata; UDisksLinuxDevice *device; GVariant *configuration; @@ -1792,6 +1800,35 @@ apply_configuration_thread_func (gpointer user_data) } } + if (data->ata_read_lookahead_enabled_set) + { + /* ATA8: 7.48 SET FEATURES - EFh, Non-Data + * 7.48.13 Enable/disable read look-ahead + */ + UDisksAtaCommandInput input = {.command = 0xef, .feature = 0x55}; + UDisksAtaCommandOutput output = {0}; + if (data->ata_read_lookahead_enabled) + input.feature = 0xaa; + if (!udisks_ata_send_command_sync (fd, + -1, + UDISKS_ATA_COMMAND_PROTOCOL_NONE, + &input, + &output, + &error)) + { + udisks_error ("Error sending ATA command SET FEATURES, sub-command 0x%02x to %s: %s (%s, %d)", + (guint) input.feature, device_file, + error->message, g_quark_to_string (error->domain), error->code); + g_clear_error (&error); + } + else + { + udisks_notice ("%s Read Look-ahead on %s [%s]", + data->ata_read_lookahead_enabled ? "Enabled" : "Disabled", + device_file, udisks_drive_get_id (data->drive)); + } + } + out: if (fd != -1) close (fd); @@ -1822,6 +1859,8 @@ udisks_linux_drive_ata_apply_configuration (UDisksLinuxDriveAta *drive, data->ata_aam_level = -1; data->ata_write_cache_enabled = FALSE; data->ata_write_cache_enabled_set = FALSE; + data->ata_read_lookahead_enabled = FALSE; + data->ata_read_lookahead_enabled_set = FALSE; data->ata = g_object_ref (drive); data->device = g_object_ref (device); data->configuration = g_variant_ref (configuration); @@ -1843,6 +1882,11 @@ udisks_linux_drive_ata_apply_configuration (UDisksLinuxDriveAta *drive, data->ata_write_cache_enabled_set = TRUE; has_conf = TRUE; } + if (g_variant_lookup (configuration, "ata-read-lookahead-enabled", "b", &data->ata_read_lookahead_enabled)) + { + data->ata_read_lookahead_enabled_set = TRUE; + has_conf = TRUE; + } /* don't do anything if none of the configuration is set */ if (!has_conf) |