Spin down HDD after disk sync or before power off
Octavian Covalschi
octavian.covalschi at gmail.com
Fri Mar 6 05:40:12 PST 2009
I played more with this, and got here so far:
if (atadev->param.support.command1 & ATA_SUPPORT_STANDBY) {
device_printf(dev, "Trying to spindown before poweroff.\n");
atadev->spindown = 1;
ad_spindown((void *)dev);
} else {
device_printf(dev, "Cannot spindown before poweroff.\n");
}
for some reason this check works on my laptop:
if (atadev->param.support.command1 & ATA_SUPPORT_STANDBY)
instead of
if (atadev->param.support.command2 & ATA_SUPPORT_STANDBY)
command1 vs command2
I'm using 7.1-STABLE...
By the way, does anyone know why ad_shutdown is _not_ called at poweroff?
Apparently it's called only at halt & reboot...
Still looking...
PS: I think last post didn't get to entire mail list, so trying to send it
again.
On Thu, Mar 5, 2009 at 3:58 PM, Daniel Thiele <dthiele at gmx.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Octavian Covalschi wrote:
> | I tried your patch 1st, but it didn't work for me for shutdown, although
> I
> | didn't try it with halt (I assumed they work the same).
> |
> | While I was looking into that, I've discovered "ad_spindown" function,
> and
> | tried to use it, and as I said, it works (for me at least), but only with
> | halt.
> |
>
> Hmm, here is what David Tolpin mentioned back in 2006 when he replied
> (privately) to the fist fix I came up with:
>
> "Besides, I had to increase timeout in ata-queue for controlcmd "
>
> I am no kernel expert, so I am not quite sure how to incorporate his
> suggestion, but may be this helps with your problem.
>
> I would be interested in your progress on this topic, for maybe some day
> one of my machines will refuse to spin down the disk with the "simple"
> patch, too.
>
> |
> | On Thu, Mar 5, 2009 at 3:34 PM, Daniel Thiele <dthiele at gmx.net> wrote:
> |
> | Octavian Covalschi wrote:
> | | OK.
> | |
> | | After several _kernel_ recompilations (by the end I found out that I
> | can use
> | | -DNO_KERNELCLEAN ) I've got some results.
> | |
> | | As i found out that ata-disk.c already has ad_spindown function, witch
> I
> | | tried to use, so after small changes I have:
> | |
> | | static void
> | | ad_shutdown(device_t dev)
> | | {
> | | struct ata_device *atadev = device_get_softc(dev);
> | |
> | | if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
> | | ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
> | |
> | | /* start */
> | | device_printf(dev, "Forced spindown\n");
> | | atadev->spindown = 1;
> | | ad_spindown((void *)dev);
> | | /* end */
> | | }
> | |
> | | But for some reason this works only with Halt or shutdown -h now, on
> | | shutdown -p it even doesn't get inside ad_shutdown.
> | | Well at least I have this :)
> | |
> |
> | Does putting
> |
> | if (atadev->param.support.command2 &
> (ATA_SUPPORT_APM|ATA_SUPPORT_STANDBY))
> | ~ ata_controlcmd(dev, ATA_STANDBY_IMMEDIATE, 0, 0, 0);
> |
> | directly into ad_shutdown() work?
> |
> | About your gmirror question: Unfortunately I never used gmirror together
> | with the spindown-hack, but I (as a just layperson on this topic(!)) do
> | not see any reason why this could cause a problem, since ad_shutdown()
> | is most likely called after the disks got unmounted and after GEOM is
> | done with them.
> |
> | Best regards,
> |
> | Daniel
> |>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.11 (FreeBSD)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkmwSxUACgkQCOZKcWNoXg5QBQCcDADmK8RrIduZCAY6IksuHSNm
> disAnRUjx6SgGUPghw+/X9uf5oFFdEs/
> =xmQO
> -----END PGP SIGNATURE-----
>
More information about the freebsd-hackers
mailing list