Resuming after suspend, wrong settings from /etc/hdparm.conf are applied

Bug #1248012 reported by Ivan Lucchese on 2013-11-05
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
hdparm (Ubuntu)
Medium
Brian Murray

Bug Description

I have a new installation of Ubuntu 13.10 amd64 with hdparm 9.43-1ubuntu2.
I have 3 harddisks and I want 1 and only 1 of these disks to spindown after a minute on inactivity.

My /etc/hdparm.conf looks like this:

*************************************************
/dev/disk/by-id/ata-Maxtor_6Y080L0_Y29Q6WSC {
 spindown_time = 12
}
*************************************************

Resuming after a suspend, in pm-suspend.log I found:

*************************************************
Running hook /usr/lib/pm-utils/sleep.d/95hdparm-apm resume suspend:

/dev/sda:
 setting Advanced Power Management level to 0xfe (254)
 APM_level = 254

/dev/sdb:
 setting Advanced Power Management level to 0xfe (254)
 APM_level = 254

/dev/sda:
 setting standby to 12 (1 minutes)

/dev/sdb:
 setting standby to 12 (1 minutes)

/usr/lib/pm-utils/sleep.d/95hdparm-apm resume suspend: success.
***************************************************

Notice that /dev/disk/by-id/ata-Maxtor_6Y080L0_Y29Q6WSC was a link to /dev/sda.
After a reboot, /dev/disk/by-id/ata-Maxtor_6Y080L0_Y29Q6WSC was a link to /dev/sdc and in pm-suspend.log I found:

***************************************************
Running hook /usr/lib/pm-utils/sleep.d/95hdparm-apm resume suspend:

/dev/sda:
 setting Advanced Power Management level to 0xfe (254)
 APM_level = 254

/dev/sdc:
 setting Advanced Power Management level to 0xfe (254)
 APM_level = 254

/dev/sda:
 setting Advanced Power Management level to 0xfe (254)
 APM_level = 254

/dev/sdc:
 setting standby to 12 (1 minutes)
/usr/lib/pm-utils/sleep.d/95hdparm-apm resume suspend: success.
***************************************************

So in the 1st instance the spindown setting was applied also to a second disk ( the 3rd disk does not support AdvancedPM so it doesn't appear in the log and, BTW, this is another bug now reported in bug #1225169 ). In the 2nd instance, -B254 was applied a second time to /dev/sda.
IMHO, the problem lies in the variable apm_opt used in /usr/lib/pm-utils/power.d/95hdparm-apm both in resume_hdparm_apm() and resume_hdparm_spindown(). This variable is not initialized at the beginning of each "for" cycle. So when resume_hdparm_apm() is called apm_opt gets the first -B parameter found in /etc/hdparm.conf (or the default -B254) and it is not changed till another -B option is found. Then resume_hdparm_spindown() is called but apm_opt does not change till an -S value is found and so on.
So a possible solution is to initialize apm_opt at the beginning of each "for" cycle: a patch is attached.

Now in pm-suspend.log I correctly find:
***************************************************
Running hook /usr/lib/pm-utils/sleep.d/95hdparm-apm resume suspend:

/dev/sda:
 setting Advanced Power Management level to 0xfe (254)
 APM_level = 254

/dev/sdc:
 setting Advanced Power Management level to 0xfe (254)
 APM_level = 254

/dev/sdc:
 setting standby to 12 (1 minutes)
/usr/lib/pm-utils/sleep.d/95hdparm-apm resume suspend: success.
***************************************************

Ivan Lucchese (ivan-lucchese) wrote :

The attachment "hdparm.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in hdparm (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Brian Murray (brian-murray) wrote :

Thanks for the patch, Ivan! I've uploaded it to Trusty the development release of Ubuntu. It'd be great if you could forward it to debian, since they would also benefit from the patch.

Changed in hdparm (Ubuntu):
status: Triaged → In Progress
assignee: nobody → Brian Murray (brian-murray)
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package hdparm - 9.43-1ubuntu3

---------------
hdparm (9.43-1ubuntu3) trusty; urgency=low

  * debian/95hdparm-apm: reset apm_opt variable thanks to Ivan Lucchese for
    the patch (LP: #1248012)
 -- Brian Murray <email address hidden> Fri, 15 Nov 2013 13:46:16 -0800

Changed in hdparm (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers