Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-19 Thread Bruce Cran
On Tue, 16 Nov 2010 20:40:00 +
Bruce Cran br...@cran.org.uk wrote:

 One problem with the code that's been committed is that the shutdown
 event handler doesn't get run during a suspend operation so an
 emergency unload still gets done when running acpiconf -s3.

Something else I noticed today: I've just got a new disk that supports
NCQ and found the kern.cam.ada.ada_send_ordered sysctl that appears to
enable/disable its use (?).   But the shutdown handler that spins
the disk down only gets initialized if ada_send_ordered is enabled. I
was wondering what the reason for this is?

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-19 Thread Alexander Motin
Bruce Cran wrote:
 On Tue, 16 Nov 2010 20:40:00 +
 Bruce Cran br...@cran.org.uk wrote:
 
 One problem with the code that's been committed is that the shutdown
 event handler doesn't get run during a suspend operation so an
 emergency unload still gets done when running acpiconf -s3.
 
 Something else I noticed today: I've just got a new disk that supports
 NCQ and found the kern.cam.ada.ada_send_ordered sysctl that appears to
 enable/disable its use (?).  

ada_send_ordered controls periodical non-queued commands insertion to
avoid possible infinite commands starvation and timeouts as result. NCQ
can't be disabled now.

 But the shutdown handler that spins
 the disk down only gets initialized if ada_send_ordered is enabled. I
 was wondering what the reason for this is?

Interesting question. That code came as-is from da driver and I can't
explain it. I have feeling that it's wrong.

-- 
Alexander Motin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-17 Thread Alexander Best
On Wed Nov 17 10, Alexander Best wrote:
 On Wed Nov 17 10, Alexander Motin wrote:
  Alexander Best wrote:
   On Wed Nov 17 10, Alexander Motin wrote:
   Alexander Best wrote:
   On Tue Nov 16 10, Bruce Cran wrote:
   On Fri, 22 Oct 2010 10:03:09 +
   Alexander Best arun...@freebsd.org wrote:
  
   so how about olivers patch? it will only apply to ata devices so it's
   garanteed not to break any other CAM devices (i'm thinking about the
   aac controller issue). you could revert your previous shutdown work
   and plug olivers patch into CAM. you might want to replace the
   combination of flush/standby immediate with sleep.
   One problem with the code that's been committed is that the shutdown
   event handler doesn't get run during a suspend operation so an
   emergency unload still gets done when running acpiconf -s3.
   unfortunately i don't think a can help you on that one. acpi never 
   worked for
   me! even 'acpiconf -s1' will hopelessly crash my system. :(
   It is not necessary to have fully working suspend to work on this.
   Bounce mode should be enough. If bounce is also not working for you - it
   definitely should be the first thing to fix.
   
   bounce mode? sorry i'm lost.
  
  sysctl debug.acpi.suspend_bounce=1
  
  It will make system to wake up back immediately after suspending all
  devices, instead of transition to requested S-state.
 
 thanks. i'll investigate a little bit regarding this issue. under single user
 mode 'acpiconf -s 1' works with and without bounce mode set.
 
 under multi user mode however both modes fail. i've made sure kldstat reports
 the same modules loaded both under single and multi user mode so it seems no
 module (i suspected nvidia.ko or rtc.ko) is causing the acpi issue in multi
 user mode. maybe HAL is causing problems. i'll check that out.

alexander leidinger informd me that the cause for this might be the fact that
the kernel modules might be loaded in single user mode, but they're not being
accessed.

since i read somewhere that snd_hda might be causing problems with acpi i
stopped the musicpd daemon and unloaded snd_hda ans sound. doing 'acpiconf -s1'
didn't stall the system (i set debug.acpi.suspend_bounce=1) and my system came
backup again. so snd_hda/sound are defanetly causing problems for acpi.

however they are not the only modules causing problems. after the system came
back the following message was printed repeatedlyy to the console:

swap_pager: indefinite wait buffer ...

although my usb keyboard was working i couldn't perform certain actions:

1) switching to a differnt tty worked, but i couldn't log in (input was simply
   ignored)
2) i could enter chars on ttyv0, but ctrl+alt+del didn't do anything so i had
   to do a hard reset.

cheers.
alex

 
 cheers.
 alex
 
  
  -- 
  Alexander Motin
 
 -- 
 a13x

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-17 Thread Mark Felder
On Wed, 17 Nov 2010 09:37:00 -0600, Alexander Best arun...@freebsd.org  
wrote:


1) switching to a differnt tty worked, but i couldn't log in (input was  
simply

   ignored)


I don't mean to derail this thread if this is completely unrelated, but  
we've been having issues with FreeBSD 8.0 and 8.1 dying on our ESX 4.0  
cluster. The usual result is that the machine stops responding to all  
network activity and at the console you can switch ttys but it doesn't  
accept any input. We can't find any absolute hard evidence yet, but we  
think it might have to do with the preferred path changing to the SAN and  
FreeBSD freaking out. Could this possibly be boiling down to the same core  
issue?



Regards,


Mark
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-16 Thread Bruce Cran
On Fri, 22 Oct 2010 10:03:09 +
Alexander Best arun...@freebsd.org wrote:

 so how about olivers patch? it will only apply to ata devices so it's
 garanteed not to break any other CAM devices (i'm thinking about the
 aac controller issue). you could revert your previous shutdown work
 and plug olivers patch into CAM. you might want to replace the
 combination of flush/standby immediate with sleep.

One problem with the code that's been committed is that the shutdown
event handler doesn't get run during a suspend operation so an
emergency unload still gets done when running acpiconf -s3.

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-16 Thread Alexander Best
On Tue Nov 16 10, Bruce Cran wrote:
 On Fri, 22 Oct 2010 10:03:09 +
 Alexander Best arun...@freebsd.org wrote:
 
  so how about olivers patch? it will only apply to ata devices so it's
  garanteed not to break any other CAM devices (i'm thinking about the
  aac controller issue). you could revert your previous shutdown work
  and plug olivers patch into CAM. you might want to replace the
  combination of flush/standby immediate with sleep.
 
 One problem with the code that's been committed is that the shutdown
 event handler doesn't get run during a suspend operation so an
 emergency unload still gets done when running acpiconf -s3.

unfortunately i don't think a can help you on that one. acpi never worked for
me! even 'acpiconf -s1' will hopelessly crash my system. :(

cheers.
alex

 
 -- 
 Bruce Cran

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-16 Thread Alexander Motin
Alexander Best wrote:
 On Tue Nov 16 10, Bruce Cran wrote:
 On Fri, 22 Oct 2010 10:03:09 +
 Alexander Best arun...@freebsd.org wrote:

 so how about olivers patch? it will only apply to ata devices so it's
 garanteed not to break any other CAM devices (i'm thinking about the
 aac controller issue). you could revert your previous shutdown work
 and plug olivers patch into CAM. you might want to replace the
 combination of flush/standby immediate with sleep.
 One problem with the code that's been committed is that the shutdown
 event handler doesn't get run during a suspend operation so an
 emergency unload still gets done when running acpiconf -s3.
 
 unfortunately i don't think a can help you on that one. acpi never worked for
 me! even 'acpiconf -s1' will hopelessly crash my system. :(

It is not necessary to have fully working suspend to work on this.
Bounce mode should be enough. If bounce is also not working for you - it
definitely should be the first thing to fix.

From the other side ATM I see no good approach to this, as soon as CAM
devices are not present on NewBus to handle suspend events. Unless SIM
drivers will expose those events to CAM in some way.

-- 
Alexander Motin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-16 Thread Alexander Best
On Wed Nov 17 10, Alexander Motin wrote:
 Alexander Best wrote:
  On Tue Nov 16 10, Bruce Cran wrote:
  On Fri, 22 Oct 2010 10:03:09 +
  Alexander Best arun...@freebsd.org wrote:
 
  so how about olivers patch? it will only apply to ata devices so it's
  garanteed not to break any other CAM devices (i'm thinking about the
  aac controller issue). you could revert your previous shutdown work
  and plug olivers patch into CAM. you might want to replace the
  combination of flush/standby immediate with sleep.
  One problem with the code that's been committed is that the shutdown
  event handler doesn't get run during a suspend operation so an
  emergency unload still gets done when running acpiconf -s3.
  
  unfortunately i don't think a can help you on that one. acpi never worked 
  for
  me! even 'acpiconf -s1' will hopelessly crash my system. :(
 
 It is not necessary to have fully working suspend to work on this.
 Bounce mode should be enough. If bounce is also not working for you - it
 definitely should be the first thing to fix.

bounce mode? sorry i'm lost.

 
 From the other side ATM I see no good approach to this, as soon as CAM
 devices are not present on NewBus to handle suspend events. Unless SIM
 drivers will expose those events to CAM in some way.
 
 -- 
 Alexander Motin

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-16 Thread Garrett Cooper
On Tue, Nov 16, 2010 at 3:50 PM, Alexander Best arun...@freebsd.org wrote:
 On Wed Nov 17 10, Alexander Motin wrote:
 Alexander Best wrote:
  On Tue Nov 16 10, Bruce Cran wrote:
  On Fri, 22 Oct 2010 10:03:09 +
  Alexander Best arun...@freebsd.org wrote:
 
  so how about olivers patch? it will only apply to ata devices so it's
  garanteed not to break any other CAM devices (i'm thinking about the
  aac controller issue). you could revert your previous shutdown work
  and plug olivers patch into CAM. you might want to replace the
  combination of flush/standby immediate with sleep.
  One problem with the code that's been committed is that the shutdown
  event handler doesn't get run during a suspend operation so an
  emergency unload still gets done when running acpiconf -s3.
 
  unfortunately i don't think a can help you on that one. acpi never worked 
  for
  me! even 'acpiconf -s1' will hopelessly crash my system. :(

 It is not necessary to have fully working suspend to work on this.
 Bounce mode should be enough. If bounce is also not working for you - it
 definitely should be the first thing to fix.

 bounce mode? sorry i'm lost.

$ sysctl debug.acpi.suspend_bounce
debug.acpi.suspend_bounce: 0
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-16 Thread Alexander Motin
Alexander Best wrote:
 On Wed Nov 17 10, Alexander Motin wrote:
 Alexander Best wrote:
 On Tue Nov 16 10, Bruce Cran wrote:
 On Fri, 22 Oct 2010 10:03:09 +
 Alexander Best arun...@freebsd.org wrote:

 so how about olivers patch? it will only apply to ata devices so it's
 garanteed not to break any other CAM devices (i'm thinking about the
 aac controller issue). you could revert your previous shutdown work
 and plug olivers patch into CAM. you might want to replace the
 combination of flush/standby immediate with sleep.
 One problem with the code that's been committed is that the shutdown
 event handler doesn't get run during a suspend operation so an
 emergency unload still gets done when running acpiconf -s3.
 unfortunately i don't think a can help you on that one. acpi never worked 
 for
 me! even 'acpiconf -s1' will hopelessly crash my system. :(
 It is not necessary to have fully working suspend to work on this.
 Bounce mode should be enough. If bounce is also not working for you - it
 definitely should be the first thing to fix.
 
 bounce mode? sorry i'm lost.

sysctl debug.acpi.suspend_bounce=1

It will make system to wake up back immediately after suspending all
devices, instead of transition to requested S-state.

-- 
Alexander Motin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-11-16 Thread Alexander Best
On Wed Nov 17 10, Alexander Motin wrote:
 Alexander Best wrote:
  On Wed Nov 17 10, Alexander Motin wrote:
  Alexander Best wrote:
  On Tue Nov 16 10, Bruce Cran wrote:
  On Fri, 22 Oct 2010 10:03:09 +
  Alexander Best arun...@freebsd.org wrote:
 
  so how about olivers patch? it will only apply to ata devices so it's
  garanteed not to break any other CAM devices (i'm thinking about the
  aac controller issue). you could revert your previous shutdown work
  and plug olivers patch into CAM. you might want to replace the
  combination of flush/standby immediate with sleep.
  One problem with the code that's been committed is that the shutdown
  event handler doesn't get run during a suspend operation so an
  emergency unload still gets done when running acpiconf -s3.
  unfortunately i don't think a can help you on that one. acpi never worked 
  for
  me! even 'acpiconf -s1' will hopelessly crash my system. :(
  It is not necessary to have fully working suspend to work on this.
  Bounce mode should be enough. If bounce is also not working for you - it
  definitely should be the first thing to fix.
  
  bounce mode? sorry i'm lost.
 
 sysctl debug.acpi.suspend_bounce=1
 
 It will make system to wake up back immediately after suspending all
 devices, instead of transition to requested S-state.

thanks. i'll investigate a little bit regarding this issue. under single user
mode 'acpiconf -s 1' works with and without bounce mode set.

under multi user mode however both modes fail. i've made sure kldstat reports
the same modules loaded both under single and multi user mode so it seems no
module (i suspected nvidia.ko or rtc.ko) is causing the acpi issue in multi
user mode. maybe HAL is causing problems. i'll check that out.

cheers.
alex

 
 -- 
 Alexander Motin

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-27 Thread Alexander Best
On Thu Oct 21 10, Alexander Best wrote:
 On Thu Oct 21 10, Bruce Cran wrote:
  On Thu, 21 Oct 2010 14:33:49 +0200
  Dag-Erling Smørgrav d...@des.no wrote:
  
   The problem with setting a short idle timeout is that, on a typical
   laptop or desktop system, you end up spinning the disk down and back
   up several hundred times a day, which increases power consumption, I/O
   latency and wear.
  
  Do we think our users are silly enough to set a short timeout of just a
  few minutes?  I'd think most would use a setting of 20-30 minutes at
  a minimum. I never did understand why there were so many warnings;
  after all, some laptops even come with a default APM scheme in their
  HDDs that powers the disk down after 7 seconds!
 
 personally i still think something like the attached patch would be nice to
 have. there's a chance users might type the following:
 
 'atacontrol spindown device 10'
 
 thinking the timeout value is measured in minutes. although this gets 
 mentioned
 in atacontrol(4) it might still be worth reminding the user that he/she is
 performing actions which could damage the hardware.

i just stumbled upon PR 144770, where a somebody seems to have mistaken the
spindown value for minutes instead of seconds. so i really think we should have
this warning in atacontrol!

+1 from brucec, if i understood him correctly.

another possibility would be of course changing the spindown value from seconds
to minutes. imo this seems very reasonable, because measuring spindown time in
seconds is too fine grained and not intuitive. just like specifying the
'shutdown -p XX' delay in microseconds would not be useful. ;)

cheers.
alex

 
 cheers.
 alex
 
  
  -- 
  Bruce Cran
 
 -- 
 a13x

 diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c
 index 4354ddf..75a131a 100644
 --- a/sbin/atacontrol/atacontrol.c
 +++ b/sbin/atacontrol/atacontrol.c
 @@ -317,6 +317,10 @@ ata_spindown(int fd, const char *dev, const char *arg)
  
   if (arg != NULL) {
   tmo = strtoul(arg, NULL, 0);
 + if (tmo  600)
 + warnx(setting spindown timeout below 10 minutes is \
 +   not recommended (see EXAMPLES section of \
 +   atacontrol(8))\n);
   if (ioctl(fd, IOCATASSPINDOWN, tmo)  0)
   err(1, ioctl(IOCATASSPINDOWN));
   } else {


-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-27 Thread Garrett Cooper
On Wed, Oct 27, 2010 at 5:41 AM, Alexander Best arun...@freebsd.org wrote:
 On Thu Oct 21 10, Alexander Best wrote:
 On Thu Oct 21 10, Bruce Cran wrote:
  On Thu, 21 Oct 2010 14:33:49 +0200
  Dag-Erling Smørgrav d...@des.no wrote:
 
   The problem with setting a short idle timeout is that, on a typical
   laptop or desktop system, you end up spinning the disk down and back
   up several hundred times a day, which increases power consumption, I/O
   latency and wear.
 
  Do we think our users are silly enough to set a short timeout of just a
  few minutes?  I'd think most would use a setting of 20-30 minutes at
  a minimum. I never did understand why there were so many warnings;
  after all, some laptops even come with a default APM scheme in their
  HDDs that powers the disk down after 7 seconds!

 personally i still think something like the attached patch would be nice to
 have. there's a chance users might type the following:

 'atacontrol spindown device 10'

 thinking the timeout value is measured in minutes. although this gets 
 mentioned
 in atacontrol(4) it might still be worth reminding the user that he/she is
 performing actions which could damage the hardware.

 i just stumbled upon PR 144770, where a somebody seems to have mistaken the
 spindown value for minutes instead of seconds. so i really think we should 
 have
 this warning in atacontrol!

 +1 from brucec, if i understood him correctly.

 another possibility would be of course changing the spindown value from 
 seconds
 to minutes. imo this seems very reasonable, because measuring spindown time in
 seconds is too fine grained and not intuitive. just like specifying the
 'shutdown -p XX' delay in microseconds would not be useful. ;)

 cheers.
 alex


 cheers.
 alex

 
  --
  Bruce Cran

 --
 a13x

 diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c
 index 4354ddf..75a131a 100644
 --- a/sbin/atacontrol/atacontrol.c
 +++ b/sbin/atacontrol/atacontrol.c
 @@ -317,6 +317,10 @@ ata_spindown(int fd, const char *dev, const char *arg)

       if (arg != NULL) {
               tmo = strtoul(arg, NULL, 0);
 +             if (tmo  600)
 +                     warnx(setting spindown timeout below 10 minutes is \
 +                           not recommended (see EXAMPLES section of \
 +                           atacontrol(8))\n);
               if (ioctl(fd, IOCATASSPINDOWN, tmo)  0)
                       err(1, ioctl(IOCATASSPINDOWN));
       } else {

Why not just be consistent with other interfaces and provide
suffixes for the values to parse out integral times (i.e. 1 [second],
1m, 2h)? As long as the value is behavior is properly documented in
the manpage (and potentially as examples in the usage message), that
should be enough.
Thanks,
-Garrett
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-27 Thread Alexander Best
On Wed Oct 27 10, Garrett Cooper wrote:
 On Wed, Oct 27, 2010 at 5:41 AM, Alexander Best arun...@freebsd.org wrote:
  On Thu Oct 21 10, Alexander Best wrote:
  On Thu Oct 21 10, Bruce Cran wrote:
   On Thu, 21 Oct 2010 14:33:49 +0200
   Dag-Erling Smørgrav d...@des.no wrote:
  
The problem with setting a short idle timeout is that, on a typical
laptop or desktop system, you end up spinning the disk down and back
up several hundred times a day, which increases power consumption, I/O
latency and wear.
  
   Do we think our users are silly enough to set a short timeout of just a
   few minutes?  I'd think most would use a setting of 20-30 minutes at
   a minimum. I never did understand why there were so many warnings;
   after all, some laptops even come with a default APM scheme in their
   HDDs that powers the disk down after 7 seconds!
 
  personally i still think something like the attached patch would be nice to
  have. there's a chance users might type the following:
 
  'atacontrol spindown device 10'
 
  thinking the timeout value is measured in minutes. although this gets 
  mentioned
  in atacontrol(4) it might still be worth reminding the user that he/she is
  performing actions which could damage the hardware.
 
  i just stumbled upon PR 144770, where a somebody seems to have mistaken the
  spindown value for minutes instead of seconds. so i really think we should 
  have
  this warning in atacontrol!
 
  +1 from brucec, if i understood him correctly.
 
  another possibility would be of course changing the spindown value from 
  seconds
  to minutes. imo this seems very reasonable, because measuring spindown time 
  in
  seconds is too fine grained and not intuitive. just like specifying the
  'shutdown -p XX' delay in microseconds would not be useful. ;)
 
  cheers.
  alex
 
 
  cheers.
  alex
 
  
   --
   Bruce Cran
 
  --
  a13x
 
  diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c
  index 4354ddf..75a131a 100644
  --- a/sbin/atacontrol/atacontrol.c
  +++ b/sbin/atacontrol/atacontrol.c
  @@ -317,6 +317,10 @@ ata_spindown(int fd, const char *dev, const char *arg)
 
        if (arg != NULL) {
                tmo = strtoul(arg, NULL, 0);
  +             if (tmo  600)
  +                     warnx(setting spindown timeout below 10 minutes is \
  +                           not recommended (see EXAMPLES section of \
  +                           atacontrol(8))\n);
                if (ioctl(fd, IOCATASSPINDOWN, tmo)  0)
                        err(1, ioctl(IOCATASSPINDOWN));
        } else {
 
 Why not just be consistent with other interfaces and provide
 suffixes for the values to parse out integral times (i.e. 1 [second],
 1m, 2h)? As long as the value is behavior is properly documented in
 the manpage (and potentially as examples in the usage message), that
 should be enough.

that would increase usability, since users don't have to specify large values
in seconds, if they e.g. want the spindown to happen after 24 hours (24*60*60).
but this will not solve the real issue: specifying 'atacontrol spindown 1s'
WILL damage your hardware! imo users should be reminded about this even if this
is already mentioned in the manual.

also: will current scripts which set 'atacontrol spindown 600' e.g. continue to
work after implementing the use of suffixes?

 Thanks,
 -Garrett

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-27 Thread Garrett Cooper
On Wed, Oct 27, 2010 at 5:54 AM, Alexander Best arun...@freebsd.org wrote:
 On Wed Oct 27 10, Garrett Cooper wrote:
 On Wed, Oct 27, 2010 at 5:41 AM, Alexander Best arun...@freebsd.org wrote:
  On Thu Oct 21 10, Alexander Best wrote:
  On Thu Oct 21 10, Bruce Cran wrote:
   On Thu, 21 Oct 2010 14:33:49 +0200
   Dag-Erling Smørgrav d...@des.no wrote:
  
The problem with setting a short idle timeout is that, on a typical
laptop or desktop system, you end up spinning the disk down and back
up several hundred times a day, which increases power consumption, I/O
latency and wear.
  
   Do we think our users are silly enough to set a short timeout of just a
   few minutes?  I'd think most would use a setting of 20-30 minutes at
   a minimum. I never did understand why there were so many warnings;
   after all, some laptops even come with a default APM scheme in their
   HDDs that powers the disk down after 7 seconds!
 
  personally i still think something like the attached patch would be nice 
  to
  have. there's a chance users might type the following:
 
  'atacontrol spindown device 10'
 
  thinking the timeout value is measured in minutes. although this gets 
  mentioned
  in atacontrol(4) it might still be worth reminding the user that he/she is
  performing actions which could damage the hardware.
 
  i just stumbled upon PR 144770, where a somebody seems to have mistaken the
  spindown value for minutes instead of seconds. so i really think we should 
  have
  this warning in atacontrol!
 
  +1 from brucec, if i understood him correctly.
 
  another possibility would be of course changing the spindown value from 
  seconds
  to minutes. imo this seems very reasonable, because measuring spindown 
  time in
  seconds is too fine grained and not intuitive. just like specifying the
  'shutdown -p XX' delay in microseconds would not be useful. ;)
 
  cheers.
  alex
 
 
  cheers.
  alex
 
  
   --
   Bruce Cran
 
  --
  a13x
 
  diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c
  index 4354ddf..75a131a 100644
  --- a/sbin/atacontrol/atacontrol.c
  +++ b/sbin/atacontrol/atacontrol.c
  @@ -317,6 +317,10 @@ ata_spindown(int fd, const char *dev, const char 
  *arg)
 
        if (arg != NULL) {
                tmo = strtoul(arg, NULL, 0);
  +             if (tmo  600)
  +                     warnx(setting spindown timeout below 10 minutes is 
  \
  +                           not recommended (see EXAMPLES section of \
  +                           atacontrol(8))\n);
                if (ioctl(fd, IOCATASSPINDOWN, tmo)  0)
                        err(1, ioctl(IOCATASSPINDOWN));
        } else {

     Why not just be consistent with other interfaces and provide
 suffixes for the values to parse out integral times (i.e. 1 [second],
 1m, 2h)? As long as the value is behavior is properly documented in
 the manpage (and potentially as examples in the usage message), that
 should be enough.

 that would increase usability, since users don't have to specify large values
 in seconds, if they e.g. want the spindown to happen after 24 hours 
 (24*60*60).
 but this will not solve the real issue: specifying 'atacontrol spindown 1s'
 WILL damage your hardware! imo users should be reminded about this even if 
 this
 is already mentioned in the manual.

Maybe something similar to kern.geom.debugflags should be
implemented for this feature as a safety belt for people doing
something stupid?

 also: will current scripts which set 'atacontrol spindown 600' e.g. continue 
 to
 work after implementing the use of suffixes?

Yeah... why not :)?
Thanks!
-Garrett
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-27 Thread Oliver Fromme

Alexander Best wrote:
  i just stumbled upon PR 144770, where a somebody seems to have mistaken the
  spindown value for minutes instead of seconds. so i really think we should 
  have
  this warning in atacontrol!
  
  +1 from brucec, if i understood him correctly.
  
  another possibility would be of course changing the spindown value from 
  seconds
  to minutes. imo this seems very reasonable, because measuring spindown time 
  in
  seconds is too fine grained and not intuitive. just like specifying the
  'shutdown -p XX' delay in microseconds would not be useful. ;)

No, please don't.  Changing the meaning of the value from
seconds to minutes will break people's existing setups.

I'm also against printing a warning for values less than 600.
If I want to set the value to 300, I don't want to be slapped
with a useless warning.

Also note that 300 (and even much less) might be perfectly
reasonable, depending on the kind of device!  As a rule of
thumb, the smaller a drive, the better it is optimized for
many spin up/down cycles.  For example, I've got a portable
HDD mp3 player that contains a 1.8 disk.  When playing an
mp3 file, it spins up every 20 seconds or so, reads 500 KB,
then spins down again.

In my opinion, this is purely a documentation issue.
If it is well-documented that the spindown value is given
in seconds, then that should be sufficient.

Supporting values like 5m or 1h would be fine, as long
as a value without a letter still means seconds.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

Python is an experiment in how much freedom programmers need.
Too much freedom and nobody can read another's code; too little
and expressiveness is endangered.
-- Guido van Rossum
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-27 Thread Oliver Fromme

Alexander Best wrote:
  but this will not solve the real issue: specifying 'atacontrol
  spindown 1s' WILL damage your hardware!

You're making assumptions.  I can very well imagine scenarios
where 1s might make sense and will not damage the hardware,
for example when there is no file system mounted from the
disk in question.

For several years I ran a BBS machine that ran off a memory
disk.  Every 24 hours it made a backup of its current state
by writing a tar file to the raw device of a physical disk
(there were no file systems mounted from that disk).
Having a spindown time of 1s in such a context certainly
wouldn't hurt.

Best regards
   Oliver

PS:  Please allow me to copy a few things from my collection
of quotes which fit very well here:

UNIX was not designed to stop you from doing stupid things,
because that would also stop you from doing clever things.
-- Doug Gwyn

If you aim the gun at your foot and pull the trigger, it's
UNIX's job to ensure reliable delivery of the bullet to
where you aimed the gun (in this case, Mr. Foot).
-- Terry Lambert

Unix gives you just enough rope to hang yourself --
and then a couple of more feet, just to be sure.
-- Eric Allman

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

I suggested holding a Python Object Oriented Programming Seminar,
but the acronym was unpopular.
-- Joseph Strout
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-27 Thread Alexander Motin
Alexander Best wrote:
 On Wed Oct 27 10, Garrett Cooper wrote:
 Why not just be consistent with other interfaces and provide
 suffixes for the values to parse out integral times (i.e. 1 [second],
 1m, 2h)? As long as the value is behavior is properly documented in
 the manpage (and potentially as examples in the usage message), that
 should be enough.
 
 that would increase usability, since users don't have to specify large values
 in seconds, if they e.g. want the spindown to happen after 24 hours 
 (24*60*60).

Largest value that could be set more or less precisely for ATA disks is
5.5hours. Absolute maximum is 12 hours. So 24h interval is just
inapplicable.

 but this will not solve the real issue: specifying 'atacontrol spindown 1s'
 WILL damage your hardware! imo users should be reminded about this even if 
 this
 is already mentioned in the manual.

I would say WILL depends on hardware. And it's reasonability also
depends on situation.

-- 
Alexander Motin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-27 Thread Bruce Cran
On Wed, 27 Oct 2010 15:04:39 +0200 (CEST)
Oliver Fromme o...@lurza.secnetix.de wrote:

 I'm also against printing a warning for values less than 600.
 If I want to set the value to 300, I don't want to be slapped
 with a useless warning.

Having just checked Windows and seen that it lets you specify a timeout
down to 1 minute with no warnings, I don't think we want to make it
more difficult for people to do the same thing on FreeBSD.  I don't
know if atacontrol already does this, but maybe we could have a log
entry, for example:

 atacontrol /dev/ad0 spindown 60
spin-down timer set to 60 seconds.

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-24 Thread Alexander Motin
Alexander Best wrote:
 On Thu Oct 21 10, Dag-Erling Smørgrav wrote:
 Alexander Best arun...@freebsd.org writes:
 no need to get upset. you asked where i found the information regarding the
 wear impact of spinning down disks and i gave you the answer.
 I am upset by your claim that doing spin downs upon reboot might be
 even worse than not doing spindowns upon shutdown, because you should
 know better, and following your advice could damage people's hardware.
 
 well...since currently hdds don't spindown during shutdown the current 
 behavior
 is in fact damaging hardware. i don't quite understand why this hasn't been
 fixed yet. the patch is available and known to work. it won't cause any
 problems with SCSI devices like mav's current implementation, since the
 spindown code is limited to ATA devices.
 
 instead of talking and talking somebody should drop the changes into HEAD!

Comparing two ways implementing spindown, I've recalled that both of
them using xpt_polled_action() method, which depends on working
controller polling operation. So they could be almost equaly not good.
But the method present in HEAD now is more universal. Looking on fact
that need of spindown is not so obvious for SCSI devices (in SAN
environments), we can just make kern.cam.power_down tunable a bitmask of
supported protocols for now. Patch is attached.

But there is still question that stops me from going one way or another
now. Where all this this things should be done properly: in peripheral
driver, as proposed (then it have to be duplicated in da and ada drivers
and possibly some others), or at the transport level, as present,
independent from drivers? I am not sure, but have feeling that tape
drives (for example) may also benefit from head parking before powering
down.

-- 
Alexander Motin
--- cam_xpt.c.prev  2010-09-22 07:52:38.0 +0300
+++ cam_xpt.c   2010-10-24 18:50:13.0 +0300
@@ -153,7 +153,7 @@ static struct xpt_softc xsoftc;
 TUNABLE_INT(kern.cam.boot_delay, xsoftc.boot_delay);
 SYSCTL_INT(_kern_cam, OID_AUTO, boot_delay, CTLFLAG_RDTUN,
xsoftc.boot_delay, 0, Bus registration wait time);
-static int xpt_power_down = 0;
+static int xpt_power_down = 1;
 TUNABLE_INT(kern.cam.power_down, xpt_power_down);
 SYSCTL_INT(_kern_cam, OID_AUTO, power_down, CTLFLAG_RW,
xpt_power_down, 0, Power down devices on shutdown);
@@ -4646,11 +4646,16 @@ xpt_shutdown_dev(struct cam_ed *device, 
return (1);
 
if (device-protocol == PROTO_ATA) {
+   if ((xpt_power_down  1) == 0)
+   return (1);
/* Only power down device if it supports power management. */
if ((device-ident_data.support.command1 
ATA_SUPPORT_POWERMGT) == 0)
return (1);
-   } else if (device-protocol != PROTO_SCSI)
+   } else if (device-protocol == PROTO_SCSI) {
+   if ((xpt_power_down  2) == 0)
+   return (1);
+   } else
return (1);
 
xpt_compile_path(path,
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org

Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-24 Thread Bruce Cran
On Sun, 24 Oct 2010 19:47:57 +0300
Alexander Motin m...@freebsd.org wrote:

 Comparing two ways implementing spindown, I've recalled that both of
 them using xpt_polled_action() method, which depends on working
 controller polling operation. So they could be almost equaly not good.
 But the method present in HEAD now is more universal. Looking on fact
 that need of spindown is not so obvious for SCSI devices (in SAN
 environments), we can just make kern.cam.power_down tunable a bitmask
 of supported protocols for now. Patch is attached.

I've just committed the patch to move the functionality into ada(4).
Should it be reverted?

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-24 Thread Oliver Fromme

Bruce Cran wrote:
  I've just committed the patch to move the functionality into ada(4).
  Should it be reverted?

It seems to me that ATA and SCSI devices are sufficiently
different (from the code's point of view) that it makes
sense to separate the functionality in the ada and da
drivers.  In other words, I think the commit is good.
I'm biased, though.

By the way, I also think it's better to issue a standby
immediate command, not a sleep command.  The former
is reversible, i.e. the drive can spin up if required
(for whatever reason), while the latter may require a
hardware reset, according to the documentation.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

Python tricks is a tough one, cuz the language is so clean. E.g.,
C makes an art of confusing pointers with arrays and strings, which
leads to lotsa neat pointer tricks; APL mistakes everything for an
array, leading to neat one-liners; and Perl confuses everything
period, making each line a joyous adventure wink.
-- Tim Peters
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-24 Thread Alexander Motin
Bruce Cran wrote:
 On Sun, 24 Oct 2010 19:47:57 +0300
 Alexander Motin m...@freebsd.org wrote:
 
 Comparing two ways implementing spindown, I've recalled that both of
 them using xpt_polled_action() method, which depends on working
 controller polling operation. So they could be almost equaly not good.
 But the method present in HEAD now is more universal. Looking on fact
 that need of spindown is not so obvious for SCSI devices (in SAN
 environments), we can just make kern.cam.power_down tunable a bitmask
 of supported protocols for now. Patch is attached.
 
 I've just committed the patch to move the functionality into ada(4).
 Should it be reverted?

Both solutions are possible. I don't have strong enough position to
hurry now, when it is already done. It would be nice to hear opinion of
SCSI people whether this functionality needed/safe there.

-- 
Alexander Motin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-24 Thread Tijl Coosemans
On Sunday 24 October 2010 18:47:57 Alexander Motin wrote:
 I am not sure, but have feeling that tape drives (for example) may
 also benefit from head parking before powering down.

USB hard disks would benefit as well I think. Although, ideally it
should happen after unmounting the last file system.


signature.asc
Description: This is a digitally signed message part.


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-24 Thread Alexander Motin
Tijl Coosemans wrote:
 On Sunday 24 October 2010 18:47:57 Alexander Motin wrote:
 I am not sure, but have feeling that tape drives (for example) may
 also benefit from head parking before powering down.
 
 USB hard disks would benefit as well I think. Although, ideally it
 should happen after unmounting the last file system.

Depending on unmount would be excessively aggressive. Far from every
device close will be followed by unplugging. Same time nobody denies to
run `camcontrol stop daX` before unplugging.

USB disks are still da. It would be more interesting to know if this
practice applicable to other kinds of SCSI devices.

-- 
Alexander Motin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-23 Thread Alexander Best
On Thu Oct 21 10, Dag-Erling Smørgrav wrote:
 Alexander Best arun...@freebsd.org writes:
  no need to get upset. you asked where i found the information regarding the
  wear impact of spinning down disks and i gave you the answer.
 
 I am upset by your claim that doing spin downs upon reboot might be
 even worse than not doing spindowns upon shutdown, because you should
 know better, and following your advice could damage people's hardware.

well...since currently hdds don't spindown during shutdown the current behavior
is in fact damaging hardware. i don't quite understand why this hasn't been
fixed yet. the patch is available and known to work. it won't cause any
problems with SCSI devices like mav's current implementation, since the
spindown code is limited to ATA devices.

instead of talking and talking somebody should drop the changes into HEAD!

cheers.
alex

 
 DES
 -- 
 Dag-Erling Smørgrav - d...@des.no

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-22 Thread Alexander Motin
Alexander Best wrote:
 the current implementation (kern.cam.power_down) uses a singe sleep
 operation, whereas the patch by oliver uses flush and standby immediate.

Sleep is just more aggressive. It puts device into deeper sleep state. I
don't think it is important from wearing point of view.

 unfortunately almost nobody was aware of mav's work at the time of the
 discussion. would have been nice to have a note in cam(4) explaining the
 purpose of kern.cam.power_down. that way a lot of double work could have been
 avoided.

That code was expected to handle spindown on shutdown in unified fashion
for ATA and SCSI devices without dependency from peripheral driver (even
without one), just using different commands for each protocol. It works,
but in current implementation it is unreliable. The problem is that it
uses polled operation mode, not supported by some controllers or
unreliable on some (e.g. atapicam). So the code is disabled now by
default. I haven't yet decided it's future: it should be either reworked
or reverted.

As positive side -- as soon as CAM is not using NewBus at the moment,
CAM registers own shutdown handlers. That allows CAM to receive the
howto argument, which allows to separate cases of reboot and shutdown
cases just by:
if ((howto  RB_POWEROFF) == 0)

 is the ATA(4) subsystem still being actively worked on or will it die out 
 after
 officially switching to ATA_CAM? the question is, if it is worth implementing
 hdd spin down for ATA(4)?

I don't think it will be really critical. Next months I am going to work
on ataraid(4) replacement, which was main declared show stopper for the
switch. I hope to trash legacy code some time after switching to ATA_CAM
to clear number of odd things (like almost not working port multipliers
support or duplicate drivers), required by it.

-- 
Alexander Motin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-22 Thread Alexander Best
On Fri Oct 22 10, Alexander Motin wrote:
 Alexander Best wrote:
  the current implementation (kern.cam.power_down) uses a singe sleep
  operation, whereas the patch by oliver uses flush and standby immediate.
 
 Sleep is just more aggressive. It puts device into deeper sleep state. I
 don't think it is important from wearing point of view.
 
  unfortunately almost nobody was aware of mav's work at the time of the
  discussion. would have been nice to have a note in cam(4) explaining the
  purpose of kern.cam.power_down. that way a lot of double work could have 
  been
  avoided.
 
 That code was expected to handle spindown on shutdown in unified fashion
 for ATA and SCSI devices without dependency from peripheral driver (even
 without one), just using different commands for each protocol. It works,
 but in current implementation it is unreliable. The problem is that it
 uses polled operation mode, not supported by some controllers or
 unreliable on some (e.g. atapicam). So the code is disabled now by
 default. I haven't yet decided it's future: it should be either reworked
 or reverted.

so how about olivers patch? it will only apply to ata devices so it's
garanteed not to break any other CAM devices (i'm thinking about the aac
controller issue). you could revert your previous shutdown work and plug
olivers patch into CAM. you might want to replace the combination of
flush/standby immediate with sleep.

cheers.
alex

 
 As positive side -- as soon as CAM is not using NewBus at the moment,
 CAM registers own shutdown handlers. That allows CAM to receive the
 howto argument, which allows to separate cases of reboot and shutdown
 cases just by:
   if ((howto  RB_POWEROFF) == 0)
 
  is the ATA(4) subsystem still being actively worked on or will it die out 
  after
  officially switching to ATA_CAM? the question is, if it is worth 
  implementing
  hdd spin down for ATA(4)?
 
 I don't think it will be really critical. Next months I am going to work
 on ataraid(4) replacement, which was main declared show stopper for the
 switch. I hope to trash legacy code some time after switching to ATA_CAM
 to clear number of odd things (like almost not working port multipliers
 support or duplicate drivers), required by it.
 
 -- 
 Alexander Motin

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-22 Thread Tijl Coosemans
On Friday 22 October 2010 00:32:54 Paul Wootton wrote:
 Actually, the green series does spin all the way down, well at least
 the drive I have does.
 Here is the output from one of my drives, that I do not think has
 long left to live.
 
 === START OF INFORMATION SECTION ===
 Model Family: Western Digital Caviar Green family
 Device Model: WDC WD5000AADS-00M2B0
 Serial Number:WD-WMAV51882791
 Firmware Version: 01.00A01
 User Capacity:500,107,862,016 bytes
 Device is:In smartctl database [for details use: -P show]
 ATA Version is:   8
 ATA Standard is:  Exact ATA specification draft version not indicated
 Local Time is:Thu Oct 21 23:31:35 2010 BST
 SMART support is: Available - device has SMART capability.
 SMART support is: Enabled
 
 SMART Attributes Data Structure revision number: 16
 Vendor Specific SMART Attributes with Thresholds:
 ID# ATTRIBUTE_NAME  FLAG VALUE WORST THRESH TYPE  
 UPDATED  WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f   200   200   051Pre-fail  
 Always   -   0
3 Spin_Up_Time0x0027   111   104   021Pre-fail  
 Always   -   7425
4 Start_Stop_Count0x0032   100   100   000Old_age   
 Always   -   98
5 Reallocated_Sector_Ct   0x0033   200   200   140Pre-fail  
 Always   -   0
7 Seek_Error_Rate 0x002e   100   253   000Old_age   
 Always   -   0
9 Power_On_Hours  0x0032   093   093   000Old_age   
 Always   -   5295
   10 Spin_Retry_Count0x0032   100   253   000Old_age   
 Always   -   0
   11 Calibration_Retry_Count 0x0032   100   253   000Old_age   
 Always   -   0
   12 Power_Cycle_Count   0x0032   100   100   000Old_age   
 Always   -   96
 192 Power-Off_Retract_Count 0x0032   200   200   000Old_age   
 Always   -   95
 193 Load_Cycle_Count0x0032   001   001   000Old_age   
 Always   -   781014
 194 Temperature_Celsius 0x0022   120   102   000Old_age   
 Always   -   27
 196 Reallocated_Event_Count 0x0032   200   200   000Old_age   
 Always   -   0
 197 Current_Pending_Sector  0x0032   200   200   000Old_age   
 Always   -   0
 198 Offline_Uncorrectable   0x0030   200   200   000Old_age   
 Offline  -   0
 199 UDMA_CRC_Error_Count0x0032   200   200   000Old_age   
 Always   -   0
 200 Multi_Zone_Error_Rate   0x0008   200   200   000Old_age   
 Offline  -   0
 
 
 The datasheet for these drive 
 http://www.wdc.com/wdproducts/library/SpecSheet/ENG/2879-701229.pdfhttp://www.wdc.com/wdproducts/library/SpecSheet/ENG/2879-701229.pdf
  
 says
 Reliability/Data Integrity
 Load/unload cycles (3) 300,000
 Limited Warranty (years) (4)
 (3) Controlled unload at ambient condition
 (4) The term of the limited warranty my vary by region
 
 Also 
 http://wdc.custhelp.com/cgi-bin/wdc.cfg/php/enduser/std_adp.php?p_faqid=5357
 (drive has been validated to 1 million load/unload cycles without issue)
 
 Im already at 781014 load cycles, yet the drive is only about 7 months 
 old. Doing the math, I am getting a load/unload cycle about every 24.5 
 seconds
 Another 2 months and I will be knocking on for 1 million load/unload 
 cycles
 
 As DES has already said, for most people the extra load/unload cycles 
 when rebooting a computer will not be an issue at all and is far more 
 desirable than an emergency park when powering down

FreeBSD frequently accesses hard disks (log files, flushing dirty
memory pages every 30s,...) and laptop drives tend to have aggressive
power saving settings by default. That's why your load cycle is so high.

To deal with this you should consider installing sysutils/ataidle and
adding these lines to /etc/rc.conf:

ataidle_enable=YES
ataidle_devices=ad0
ataidle_ad0=-P 0

An alternative is to use atacontrol(8).

If you don't mind the spin down when rebooting you can solve the
emergency park at shutdown with a simple patch like this:

--- sys/dev/ata/ata-disk.c
+++ sys/dev/ata/ata-disk.c
@@ -193,6 +193,8 @@
 
 if (atadev-param.support.command2  ATA_SUPPORT_FLUSHCACHE)
 ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
+if (atadev-param.support.command1  ATA_SUPPORT_POWERMGT)
+ata_controlcmd(dev, ATA_STANDBY_IMMEDIATE, 0, 0, 0);
 return 0;
 }
 


signature.asc
Description: This is a digitally signed message part.


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-22 Thread Bruce Cran
On Fri, 22 Oct 2010 12:07:36 +0200
Tijl Coosemans t...@coosemans.org wrote:

 FreeBSD frequently accesses hard disks (log files, flushing dirty
 memory pages every 30s,...) and laptop drives tend to have aggressive
 power saving settings by default. That's why your load cycle is so
 high.

I'm not sure the APM value updates the idle3 timer inside the
drive: it may be necessary to run WD's wdidle3.exe tool to change the
power management timer.  And yes, people are rather annoyed that it's
necessary to have a copy of DOS to update the drive!

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Dag-Erling Smørgrav
Alexander Best arun...@freebsd.org writes:
 since there seems no way to distinguish between these two states in ATA(4) 
 it's
 probably better to leave it as it is, since doing spin downs upon reboot might
 be even worse than not doing spindowns upon shutdown.

No.  Where did you get that idea?  To repeat what I've said before -
several times - in this thread, a modern disk drive can handle hundreds
of thousands of controlled unloads but only a few hundred emergency
unloads. Given the choice between never spin down and always spin
down, the safe alternative is always spin down.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Alexander Best
On Thu Oct 21 10, Dag-Erling Smørgrav wrote:
 Alexander Best arun...@freebsd.org writes:
  since there seems no way to distinguish between these two states in ATA(4) 
  it's
  probably better to leave it as it is, since doing spin downs upon reboot 
  might
  be even worse than not doing spindowns upon shutdown.
 
 No.  Where did you get that idea?  To repeat what I've said before -
 several times - in this thread, a modern disk drive can handle hundreds
 of thousands of controlled unloads but only a few hundred emergency
 unloads. Given the choice between never spin down and always spin
 down, the safe alternative is always spin down.

atacontrol(8) says that:

You should not set a spindown timeout on a disk with / or syslog logging
 on it as the disk will be worn out spinning down and up all the time.

this seems to indicate that spinning down a disk has quite an impact.

while chatting with bruce cran regarding this matter we discovered that mav@
already implemented this feature back in february, but disabled it by default
due to issues with the aac controller.

the current implementation (kern.cam.power_down) uses a singe sleep
operation, whereas the patch by oliver uses flush and standby immediate.

unfortunately almost nobody was aware of mav's work at the time of the
discussion. would have been nice to have a note in cam(4) explaining the
purpose of kern.cam.power_down. that way a lot of double work could have been
avoided.

is the ATA(4) subsystem still being actively worked on or will it die out after
officially switching to ATA_CAM? the question is, if it is worth implementing
hdd spin down for ATA(4)?

cheers.
alex

 
 DES
 -- 
 Dag-Erling Smørgrav - d...@des.no

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Dag-Erling Smørgrav
Alexander Best arun...@freebsd.org writes:
 Dag-Erling Smørgrav d...@des.no writes:
  No.  Where did you get that idea?  To repeat what I've said before -
  several times - in this thread, a modern disk drive can handle hundreds
  of thousands of controlled unloads but only a few hundred emergency
  unloads. Given the choice between never spin down and always spin
  down, the safe alternative is always spin down.
 atacontrol(8) says that:

 You should not set a spindown timeout on a disk with / or syslog logging
  on it as the disk will be worn out spinning down and up all the time.

 this seems to indicate that spinning down a disk has quite an impact.

The problem with setting a short idle timeout is that, on a typical
laptop or desktop system, you end up spinning the disk down and back up
several hundred times a day, which increases power consumption, I/O
latency and wear.

However, a single emergency unload (what happens when the disk loses
power without first unloading the head) shortens the disk's life
expectancy as much as hundreds or thousands of controlled unloads.

Unless you think our users commonly reboot their computers hundreds or
thousands of times between each time they cycle the power, the safe
alternative is to *always* spin down during shutdown.

I truly hope this is the *last* time I have to repeat this.  It's really
not that hard to understand.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Bruce Cran
On Thu, 21 Oct 2010 14:33:49 +0200
Dag-Erling Smørgrav d...@des.no wrote:

 The problem with setting a short idle timeout is that, on a typical
 laptop or desktop system, you end up spinning the disk down and back
 up several hundred times a day, which increases power consumption, I/O
 latency and wear.

Do we think our users are silly enough to set a short timeout of just a
few minutes?  I'd think most would use a setting of 20-30 minutes at
a minimum. I never did understand why there were so many warnings;
after all, some laptops even come with a default APM scheme in their
HDDs that powers the disk down after 7 seconds!

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Alexander Best
On Thu Oct 21 10, Dag-Erling Smørgrav wrote:
 Alexander Best arun...@freebsd.org writes:
  Dag-Erling Smørgrav d...@des.no writes:
   No.  Where did you get that idea?  To repeat what I've said before -
   several times - in this thread, a modern disk drive can handle hundreds
   of thousands of controlled unloads but only a few hundred emergency
   unloads. Given the choice between never spin down and always spin
   down, the safe alternative is always spin down.
  atacontrol(8) says that:
 
  You should not set a spindown timeout on a disk with / or syslog 
  logging
   on it as the disk will be worn out spinning down and up all the time.
 
  this seems to indicate that spinning down a disk has quite an impact.
 
 The problem with setting a short idle timeout is that, on a typical
 laptop or desktop system, you end up spinning the disk down and back up
 several hundred times a day, which increases power consumption, I/O
 latency and wear.
 
 However, a single emergency unload (what happens when the disk loses
 power without first unloading the head) shortens the disk's life
 expectancy as much as hundreds or thousands of controlled unloads.
 
 Unless you think our users commonly reboot their computers hundreds or
 thousands of times between each time they cycle the power, the safe
 alternative is to *always* spin down during shutdown.
 
 I truly hope this is the *last* time I have to repeat this.  It's really
 not that hard to understand.

no need to get upset. you asked where i found the information regarding the
wear impact of spinning down disks and i gave you the answer.

i totally agree with you on this issue. yet again: is it worth changing this
for the ata(4) sub system which will probably become obsolete in one or two
years? the ata(4) subsytem exists since FreeBSD 4.0. why introduce this change
now that it's going to die soon?

also as i pointed out in my earlier post, spinning down disks already caused
problems with the aac controller. since not a lot of testing went into the spin
down code one can expect more controller related issues to arise.

cheers.
alex

 
 DES
 -- 
 Dag-Erling Smørgrav - d...@des.no

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Alexander Best
On Thu Oct 21 10, Bruce Cran wrote:
 On Thu, 21 Oct 2010 14:33:49 +0200
 Dag-Erling Smørgrav d...@des.no wrote:
 
  The problem with setting a short idle timeout is that, on a typical
  laptop or desktop system, you end up spinning the disk down and back
  up several hundred times a day, which increases power consumption, I/O
  latency and wear.
 
 Do we think our users are silly enough to set a short timeout of just a
 few minutes?  I'd think most would use a setting of 20-30 minutes at
 a minimum. I never did understand why there were so many warnings;
 after all, some laptops even come with a default APM scheme in their
 HDDs that powers the disk down after 7 seconds!

personally i still think something like the attached patch would be nice to
have. there's a chance users might type the following:

'atacontrol spindown device 10'

thinking the timeout value is measured in minutes. although this gets mentioned
in atacontrol(4) it might still be worth reminding the user that he/she is
performing actions which could damage the hardware.

cheers.
alex

 
 -- 
 Bruce Cran

-- 
a13x
diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c
index 4354ddf..75a131a 100644
--- a/sbin/atacontrol/atacontrol.c
+++ b/sbin/atacontrol/atacontrol.c
@@ -317,6 +317,10 @@ ata_spindown(int fd, const char *dev, const char *arg)
 
if (arg != NULL) {
tmo = strtoul(arg, NULL, 0);
+   if (tmo  600)
+   warnx(setting spindown timeout below 10 minutes is \
+ not recommended (see EXAMPLES section of \
+ atacontrol(8))\n);
if (ioctl(fd, IOCATASSPINDOWN, tmo)  0)
err(1, ioctl(IOCATASSPINDOWN));
} else {
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org

Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Bruce Cran
On Thu, 21 Oct 2010 13:41:14 +
Alexander Best arun...@freebsd.org wrote:

 personally i still think something like the attached patch would be
 nice to have. there's a chance users might type the following:
 
 'atacontrol spindown device 10'
 
 thinking the timeout value is measured in minutes. 

I agree - users coming from ataidle(8) will expect the timeout to be in
minutes too.

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread RW
On Thu, 21 Oct 2010 12:21:10 +
Alexander Best arun...@freebsd.org wrote:

 
 atacontrol(8) says that:
 
 You should not set a spindown timeout on a disk with / or syslog
 logging on it as the disk will be worn out spinning down and up all
 the time.
 
 this seems to indicate that spinning down a disk has quite an impact.

That's mostly likely a hang-over from older disk technologies when the
heads touched the surface on spinning down.  
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Dag-Erling Smørgrav
Bruce Cran br...@cran.org.uk writes:
 Do we think our users are silly enough to set a short timeout of just a
 few minutes?  I'd think most would use a setting of 20-30 minutes at
 a minimum. I never did understand why there were so many warnings;
 after all, some laptops even come with a default APM scheme in their
 HDDs that powers the disk down after 7 seconds!

Really?  That would make the system close to unusable, and the disk's
life expectancy would be reduced to a few months; a disk that performs
two load / unload cycles per minute on average will need replacing after
three to six months.  Remember, there was a huge flap a couple of years
when Ubuntu shipped with a default timeout of 90 seconds, which is more
than ten times more than what you suggest.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Dag-Erling Smørgrav
Alexander Best arun...@freebsd.org writes:
 no need to get upset. you asked where i found the information regarding the
 wear impact of spinning down disks and i gave you the answer.

I am upset by your claim that doing spin downs upon reboot might be
even worse than not doing spindowns upon shutdown, because you should
know better, and following your advice could damage people's hardware.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Dag-Erling Smørgrav
RW rwmailli...@googlemail.com writes:
 Alexander Best arun...@freebsd.org wrote:
  this seems to indicate that spinning down a disk has quite an impact.
 That's mostly likely a hang-over from older disk technologies when the
 heads touched the surface on spinning down.  

They still do, although these days the landing zone has a special
surface designed to minimize friction on the head and prevent it from
sticking to the surface.  In addition, in an emergency unload (when
power is lost while the disk is still spinning) the heads retract in a
violent and uncontrolled manner, which can lead to mechanical damage to
the arms.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Bruce Cran
On Thu, 21 Oct 2010 16:35:06 +0200
Dag-Erling Smørgrav d...@des.no wrote:

 Really?  That would make the system close to unusable, and the disk's
 life expectancy would be reduced to a few months; a disk that performs
 two load / unload cycles per minute on average will need replacing
 after three to six months.  Remember, there was a huge flap a couple
 of years when Ubuntu shipped with a default timeout of 90 seconds,
 which is more than ten times more than what you suggest.

The Ubuntu issue was what I was thinking of - I got that mixed up with
the aggressive power management of the WD EARS drives.

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Dag-Erling Smørgrav
Bruce Cran br...@cran.org.uk writes:
 The Ubuntu issue was what I was thinking of - I got that mixed up with
 the aggressive power management of the WD EARS drives.

The entire Green series, actually, which includes models such as the
EADS, AARS etc., but there's more to them than that - the central
feature is their dynamically adjusted rotational speed, which allows
them to conserve power without spinning all the way down.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Erik Trulsson
On Thu, Oct 21, 2010 at 05:20:54PM +0200, Dag-Erling Smørgrav wrote:
 Bruce Cran br...@cran.org.uk writes:
  The Ubuntu issue was what I was thinking of - I got that mixed up with
  the aggressive power management of the WD EARS drives.
 
 The entire Green series, actually, which includes models such as the
 EADS, AARS etc., but there's more to them than that - the central
 feature is their dynamically adjusted rotational speed, which allows
 them to conserve power without spinning all the way down.

They do not have any dynamically adjusted rotational speed, despite
what Western Digitals marketing department would like you to believe.

Tests by various reliable review sites have shown that all the Green
models examined so far spin at 5400RPM with no variations.
(See e.g. http://www.silentpcreview.com/article786-page2.html
or  http://www.storagereview.com/1000.sr?page=0,0  )

There could be differences in rotational speed between different models
(but no such difference has been reported yet), but they all have a
fixed RPM.



-- 
Insert your favourite quote here.
Erik Trulsson
ertr1...@student.uu.se
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-21 Thread Paul Wootton

 On 10/21/10 15:20, Dag-Erling Smørgrav wrote:

Bruce Cranbr...@cran.org.uk  writes:

The Ubuntu issue was what I was thinking of - I got that mixed up with
the aggressive power management of the WD EARS drives.

The entire Green series, actually, which includes models such as the
EADS, AARS etc., but there's more to them than that - the central
feature is their dynamically adjusted rotational speed, which allows
them to conserve power without spinning all the way down.

DES


Actually, the green series does spin all the way down, well at least the 
drive I have does.
Here is the output from one of my drives, that I do not think has long 
left to live.


=== START OF INFORMATION SECTION ===
Model Family: Western Digital Caviar Green family
Device Model: WDC WD5000AADS-00M2B0
Serial Number:WD-WMAV51882791
Firmware Version: 01.00A01
User Capacity:500,107,862,016 bytes
Device is:In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:Thu Oct 21 23:31:35 2010 BST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME  FLAG VALUE WORST THRESH TYPE  
UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate 0x002f   200   200   051Pre-fail  
Always   -   0
  3 Spin_Up_Time0x0027   111   104   021Pre-fail  
Always   -   7425
  4 Start_Stop_Count0x0032   100   100   000Old_age   
Always   -   98
  5 Reallocated_Sector_Ct   0x0033   200   200   140Pre-fail  
Always   -   0
  7 Seek_Error_Rate 0x002e   100   253   000Old_age   
Always   -   0
  9 Power_On_Hours  0x0032   093   093   000Old_age   
Always   -   5295
 10 Spin_Retry_Count0x0032   100   253   000Old_age   
Always   -   0
 11 Calibration_Retry_Count 0x0032   100   253   000Old_age   
Always   -   0
 12 Power_Cycle_Count   0x0032   100   100   000Old_age   
Always   -   96
192 Power-Off_Retract_Count 0x0032   200   200   000Old_age   
Always   -   95
193 Load_Cycle_Count0x0032   001   001   000Old_age   
Always   -   781014
194 Temperature_Celsius 0x0022   120   102   000Old_age   
Always   -   27
196 Reallocated_Event_Count 0x0032   200   200   000Old_age   
Always   -   0
197 Current_Pending_Sector  0x0032   200   200   000Old_age   
Always   -   0
198 Offline_Uncorrectable   0x0030   200   200   000Old_age   
Offline  -   0
199 UDMA_CRC_Error_Count0x0032   200   200   000Old_age   
Always   -   0
200 Multi_Zone_Error_Rate   0x0008   200   200   000Old_age   
Offline  -   0



The datasheet for these drive 
http://www.wdc.com/wdproducts/library/SpecSheet/ENG/2879-701229.pdfhttp://www.wdc.com/wdproducts/library/SpecSheet/ENG/2879-701229.pdf 
says

Reliability/Data Integrity
Load/unload cycles (3) 300,000
Limited Warranty (years) (4)
(3) Controlled unload at ambient condition
(4) The term of the limited warranty my vary by region

Also 
http://wdc.custhelp.com/cgi-bin/wdc.cfg/php/enduser/std_adp.php?p_faqid=5357

(drive has been validated to 1 million load/unload cycles without issue)

Im already at 781014 load cycles, yet the drive is only about 7 months 
old. Doing the math, I am getting a load/unload cycle about every 24.5 
seconds
Another 2 months and I will be knocking on for 1 million load/unload 
cycles


As DES has already said, for most people the extra load/unload cycles 
when rebooting a computer will not be an issue at all and is far more 
desirable than an emergency park when powering down



Paul
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-10-18 Thread Alexander Best
On Thu Sep 16 10, Oliver Fromme wrote:
 
 Tijl Coosemans wrote:
   On Thursday 16 September 2010 16:10:22 Oliver Fromme wrote:
Tijl Coosemans wrote:
 I would just spin down the disk in case of a halt. An unwanted spin
 down is harmless compared to an emergency shutdown and usually the
 intention is to power off rather than reboot.

Is it?  When I intend to power-off, I use shutdown -p, not
shutdown -h.  Quite often (but not always) when I halt a
machine, I'm going to reboot to multi-user, not power off.
   
   Hmm, I suppose support for power off is ubiquitous nowadays. It used to
   be that halt meant: bring the system in a state where we can safely cut
   the power. In that case it makes sense to let halt spin down the disks.
   If you intend to reboot why not explicitly reboot rather than halt?
 
 For example, I use shutdown -h in order to swap disks that
 are not hot-swappable, or other kind of hardware work that
 can be done while the machine is switched on.
 
 Of course, in that particular case the disk which is about
 to be swapped out should be spun down, while the others
 should not.  But that's not a problem because I can use
 atacontrol(8) and camcontrol(8) to spin down a specific
 disk drive manually.
 
   Also, to go from single to multi user mode you can just exit(1) the
   shell.
 
 Yes, of course, that's a different matter.
 
 I've updated the patch for ada(4).  It includes a bug fix
 (command1 vs. command2) and uses the howto flags passed to
 the shutdown function.  Thanks again for pointing these out.

any chances of getting this one committed? although this only works for CAM(4)
and not ATA(4) it seems the patch is doing the right thing:
- only spindown the disk when the system shuts down
- don't spin down hdds, if the user reboots

since there seems no way to distinguish between these two states in ATA(4) it's
probably better to leave it as it is, since doing spin downs upon reboot might
be even worse than not doing spindowns upon shutdown.

cheers.
alex

ps: also: most of the ATA(4) users under HEAD seem to use options ATA_CAM. ;)

 
 Best regards
Oliver
 
 
 --- ata_da.c.orig 2010-05-23 18:16:33.0 +0200
 +++ ata_da.c  2010-09-16 17:21:10.0 +0200
 @@ -42,6 +42,7 @@
  #include sys/eventhandler.h
  #include sys/malloc.h
  #include sys/cons.h
 +#include sys/reboot.h
  #include geom/geom_disk.h
  #endif /* _KERNEL */
  
 @@ -79,7 +80,8 @@
   ADA_FLAG_CAN_TRIM   = 0x080,
   ADA_FLAG_OPEN   = 0x100,
   ADA_FLAG_SCTX_INIT  = 0x200,
 - ADA_FLAG_CAN_CFA= 0x400
 + ADA_FLAG_CAN_CFA= 0x400,
 + ADA_FLAG_CAN_POWERMGT   = 0x800
  } ada_flags;
  
  typedef enum {
 @@ -180,6 +182,10 @@
  #define  ADA_DEFAULT_SEND_ORDERED1
  #endif
  
 +#ifndef  ADA_DEFAULT_SPINDOWN_SHUTDOWN
 +#define  ADA_DEFAULT_SPINDOWN_SHUTDOWN   1
 +#endif
 +
  /*
   * Most platforms map firmware geometry to actual, but some don't.  If
   * not overridden, default to nothing.
 @@ -191,6 +197,7 @@
  static int ada_retry_count = ADA_DEFAULT_RETRY;
  static int ada_default_timeout = ADA_DEFAULT_TIMEOUT;
  static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED;
 +static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN;
  
  SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0,
  CAM Direct Access Disk driver);
 @@ -203,6 +210,9 @@
  SYSCTL_INT(_kern_cam_ada, OID_AUTO, ada_send_ordered, CTLFLAG_RW,
 ada_send_ordered, 0, Send Ordered Tags);
  TUNABLE_INT(kern.cam.ada.ada_send_ordered, ada_send_ordered);
 +SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW,
 +   ada_spindown_shutdown, 0, Spin down upon shutdown);
 +TUNABLE_INT(kern.cam.ada.spindown_shutdown, ada_spindown_shutdown);
  
  /*
   * ADA_ORDEREDTAG_INTERVAL determines how often, relative
 @@ -665,6 +675,8 @@
   softc-flags |= ADA_FLAG_CAN_48BIT;
   if (cgd-ident_data.support.command2  ATA_SUPPORT_FLUSHCACHE)
   softc-flags |= ADA_FLAG_CAN_FLUSHCACHE;
 + if (cgd-ident_data.support.command1  ATA_SUPPORT_POWERMGT)
 + softc-flags |= ADA_FLAG_CAN_POWERMGT;
   if (cgd-ident_data.satacapabilities  ATA_SUPPORT_NCQ 
   cgd-inq_flags  SID_CmdQue)
   softc-flags |= ADA_FLAG_CAN_NCQ;
 @@ -1222,6 +1234,58 @@
/*getcount_only*/0);
   cam_periph_unlock(periph);
   }
 +
 + if (ada_spindown_shutdown == 0 ||
 + (howto  (RB_HALT | RB_POWEROFF)) == 0)
 + return;
 +
 + DELAY(50);
 +
 + TAILQ_FOREACH(periph, adadriver.units, unit_links) {
 + union ccb ccb;
 +
 + /* If we paniced with lock held - not recurse here. */
 + if (cam_periph_owned(periph))
 + continue;
 + cam_periph_lock(periph);
 + softc = (struct ada_softc *)periph-softc;
 + /*
 +  * We only 

Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Dag-Erling Smørgrav
Garrett Cooper gcoo...@freebsd.org writes:
 Agreed. Spinning down at reboot isn't smart and seems like a good way
 to kill a disk quicker.

*not* spinning down at halt is far worse.  Most modern disks are rated
for hundreds of thousands of load-unload cycles, but far fewer emergency
unloads (which is what happens when the drive loses power while still
spinning).

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Oliver Fromme

Alexander Best wrote:
  On Wed Sep 15 10, Oliver Fromme wrote:
   Warren Block wbl...@wonkity.com wrote:
[...]
8. Alexander Motin has an updated CAM version of the ATA system which 
will eventually replace the existing one.  In -CURRENT, anyway.  He was 
kind enough to look at my event handler.  My understanding is that he is 
looking at implementing the head parking/standby mechanism in that new 
code.
   
   The patch below will work with the new CAM ATA driver
   (i.e. ada(4) disks).  It adds a sysctl, so you can switch
   the spin-down off if you're going to just reboot:
   # sysctl kern.cam.ada.spindown_shutdown=0
  
  i haven't tested your patch yet, but i don't think deciding whether to spin
  down the hdd should be decided merely from the sysctl value.

It was the most simple and least intrusive way to introduce
some means to switch it on and off.  Of course there might
be better ways to do it.  You're welcome to submit your own
patch.

  the hdd should spindown when a shutdown has been issued and not spindown,
  if a reboot has been issued.

Right.  That's why my shutdown wrapper script sets the sysctl
to 0 when the -r option is present (I've got that wrapper
script for ages, for different reasons).

Also, there are cases where it is completely impossible to
decide automatically whether the disks should be spun down
or not.  For example, if the admin issues a shutdown -h
(halt), there's no way for the OS to know in advance whether
the admin is going to switch the machine off or reboot to
multi-user.  So there must be a way for the user to forcibly
enable/disable the spindown feature.  I think a sysctl is
the most appropriate way to do that, isn't it?

Actually, my plan is to have a mask of two bits for the
sysctl (the default value would be 3):

 - bit 0: enable (1) or disable (0) spindown
 - bit 1: automatic (1) or manual (0) setting

With the default setting (i.e. bit 1 == 1), at shutdown time
some facility would look at the reboot(2) howto flags and
then set bit 0 to either 0 or 1.

There are several ways where to handle that.  For example,
init(8) could be modified to pass the howto value to
rc.shutdown (which could be useful for other purposes, too).
Then a standard rc.d script could handle the spindown sysctl.
The advantage of that solution would be maximum flexibility,
because the actual logic is implemented in an rc.d script.

  deciding whether freebsd reboots or shuts down cannot be done from a script,
  since users might use the reboot or halt commands in which case (if i'm not
  mistaken) all shutdown scripts get skipped.

Right, which is why it is a rather bad idea to use halt(8)
or reboot(8), except in an emergency.  Actually I think the
manpages and handbook should strongly discourage it, and
recommend to use shutdown(8) or init(8) instead, both of
which send a signal to PID 1 by default, so rc.shutdown is
executed properly.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

If Java had true garbage collection, most programs
would delete themselves upon execution.
-- Robert Sewell
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Tijl Coosemans
On Thursday 16 September 2010 10:41:07 Oliver Fromme wrote:
 Alexander Best wrote:
 On Wed Sep 15 10, Oliver Fromme wrote:
 The patch below will work with the new CAM ATA driver
 (i.e. ada(4) disks).  It adds a sysctl, so you can switch
 the spin-down off if you're going to just reboot:
 # sysctl kern.cam.ada.spindown_shutdown=0

 the hdd should spindown when a shutdown has been issued and not spindown,
 if a reboot has been issued.

 Right.  That's why my shutdown wrapper script sets the sysctl
 to 0 when the -r option is present (I've got that wrapper
 script for ages, for different reasons).
 
 Also, there are cases where it is completely impossible to
 decide automatically whether the disks should be spun down
 or not.  For example, if the admin issues a shutdown -h
 (halt), there's no way for the OS to know in advance whether
 the admin is going to switch the machine off or reboot to
 multi-user.  So there must be a way for the user to forcibly
 enable/disable the spindown feature.  I think a sysctl is
 the most appropriate way to do that, isn't it?

I would just spin down the disk in case of a halt. An unwanted spin
down is harmless compared to an emergency shutdown and usually the
intention is to power off rather than reboot.

Part of your patch modifies ada_shutdown. That function already gets
the reboot(2) howto flags passed to it, so you could test for
(howto  (RB_HALT | RB_POWEROFF)) != 0 before issuing the STANDBY
command. There's no need to make this more complicated with a sysctl
that can override this in my opinion.

Also command2 should be command1 in this line:

+   if (cgd-ident_data.support.command2  ATA_SUPPORT_POWERMGT)


signature.asc
Description: This is a digitally signed message part.


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Oliver Fromme

Tijl Coosemans wrote:
  On Thursday 16 September 2010 10:41:07 Oliver Fromme wrote:
   Also, there are cases where it is completely impossible to
   decide automatically whether the disks should be spun down
   or not.  For example, if the admin issues a shutdown -h
   (halt), there's no way for the OS to know in advance whether
   the admin is going to switch the machine off or reboot to
   multi-user.  So there must be a way for the user to forcibly
   enable/disable the spindown feature.  I think a sysctl is
   the most appropriate way to do that, isn't it?
  
  I would just spin down the disk in case of a halt. An unwanted spin
  down is harmless compared to an emergency shutdown and usually the
  intention is to power off rather than reboot.

Is it?  When I intend to power-off, I use shutdown -p, not
shutdown -h.  Quite often (but not always) when I halt a
machine, I'm going to reboot to multi-user, not power off.

In that case I certainly wouldn't want to spin the drives
down and have them spun up immediately afterwards.  I don't
think that weartear caused by that procedure is completely
insignificant (although it's certainly less of a problem
than emergency unloads).

For that reason I definitely want to have a way to disable
the spindown function manually.

  Part of your patch modifies ada_shutdown. That function already gets
  the reboot(2) howto flags passed to it, so you could test for
  (howto  (RB_HALT | RB_POWEROFF)) != 0 before issuing the STANDBY
  command.

Right, good point.  I didn't notice because the shutdown
function in ad(4) doesn't get the howto flag, so I assumed
(without checking) that ada(4) doesn't get it either.

  There's no need to make this more complicated with a sysctl
  that can override this in my opinion.

I'm afraid I have to disagree (see above).  Apart from that,
there's nothing complicated at all about a sysctl.

  Also command2 should be command1 in this line:
  
  +   if (cgd-ident_data.support.command2  ATA_SUPPORT_POWERMGT)

Oops ...  You're right.  Thanks for pointing that out.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

I made up the term 'object-oriented', and I can tell you
I didn't have C++ in mind.
-- Alan Kay, OOPSLA '97
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Warren Block

On Thu, 16 Sep 2010, Alexander Best wrote:


On Wed Sep 15 10, Oliver Fromme wrote:

Warren Block wbl...@wonkity.com wrote:
 [...]
 8. Alexander Motin has an updated CAM version of the ATA system which
 will eventually replace the existing one.  In -CURRENT, anyway.  He was
 kind enough to look at my event handler.  My understanding is that he is
 looking at implementing the head parking/standby mechanism in that new
 code.

The patch below will work with the new CAM ATA driver
(i.e. ada(4) disks).  It adds a sysctl, so you can switch
the spin-down off if you're going to just reboot:
# sysctl kern.cam.ada.spindown_shutdown=0


i haven't tested your patch yet, but i don't think deciding whether to spin
down the hdd should be decided merely from the sysctl value.

the hdd should spindown when a shutdown has been issued and not spindown,
if a reboot has been issued.


It's been a while, but the problem I found when comparing the NetBSD 
code was that there didn't appear to be a way to tell from within the 
FreeBSD driver whether it was a shutdown or reboot.

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Nathan Whitehorn
On 09/16/10 09:42, Warren Block wrote:
 On Thu, 16 Sep 2010, Alexander Best wrote:

 On Wed Sep 15 10, Oliver Fromme wrote:
 Warren Block wbl...@wonkity.com wrote:
  [...]
  8. Alexander Motin has an updated CAM version of the ATA system which
  will eventually replace the existing one.  In -CURRENT, anyway. 
 He was
  kind enough to look at my event handler.  My understanding is that
 he is
  looking at implementing the head parking/standby mechanism in that
 new
  code.

 The patch below will work with the new CAM ATA driver
 (i.e. ada(4) disks).  It adds a sysctl, so you can switch
 the spin-down off if you're going to just reboot:
 # sysctl kern.cam.ada.spindown_shutdown=0

 i haven't tested your patch yet, but i don't think deciding whether
 to spin
 down the hdd should be decided merely from the sysctl value.

 the hdd should spindown when a shutdown has been issued and not
 spindown,
 if a reboot has been issued.

 It's been a while, but the problem I found when comparing the NetBSD
 code was that there didn't appear to be a way to tell from within the
 FreeBSD driver whether it was a shutdown or reboot.

Register a shutdown event handler? The second argument can be tested
against RB_HALT to determine what is happening.
-Nathan
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Tijl Coosemans
On Thursday 16 September 2010 16:10:22 Oliver Fromme wrote:
 Tijl Coosemans wrote:
 I would just spin down the disk in case of a halt. An unwanted spin
 down is harmless compared to an emergency shutdown and usually the
 intention is to power off rather than reboot.
 
 Is it?  When I intend to power-off, I use shutdown -p, not
 shutdown -h.  Quite often (but not always) when I halt a
 machine, I'm going to reboot to multi-user, not power off.

Hmm, I suppose support for power off is ubiquitous nowadays. It used to
be that halt meant: bring the system in a state where we can safely cut
the power. In that case it makes sense to let halt spin down the disks.
If you intend to reboot why not explicitly reboot rather than halt?
Also, to go from single to multi user mode you can just exit(1) the
shell.

 In that case I certainly wouldn't want to spin the drives
 down and have them spun up immediately afterwards.  I don't
 think that weartear caused by that procedure is completely
 insignificant (although it's certainly less of a problem
 than emergency unloads).
 
 For that reason I definitely want to have a way to disable
 the spindown function manually.

Ok, I'm soft on the sysctl really, it wouldn't hurt anyone. Although,
if the intention is to just override the default behaviour at the time
of shutdown you might as well just add an option to halt(8). A don't
spin down disks option would fit in with the other options there.


signature.asc
Description: This is a digitally signed message part.


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Oliver Fromme

Tijl Coosemans wrote:
  On Thursday 16 September 2010 16:10:22 Oliver Fromme wrote:
   Tijl Coosemans wrote:
I would just spin down the disk in case of a halt. An unwanted spin
down is harmless compared to an emergency shutdown and usually the
intention is to power off rather than reboot.
   
   Is it?  When I intend to power-off, I use shutdown -p, not
   shutdown -h.  Quite often (but not always) when I halt a
   machine, I'm going to reboot to multi-user, not power off.
  
  Hmm, I suppose support for power off is ubiquitous nowadays. It used to
  be that halt meant: bring the system in a state where we can safely cut
  the power. In that case it makes sense to let halt spin down the disks.
  If you intend to reboot why not explicitly reboot rather than halt?

For example, I use shutdown -h in order to swap disks that
are not hot-swappable, or other kind of hardware work that
can be done while the machine is switched on.

Of course, in that particular case the disk which is about
to be swapped out should be spun down, while the others
should not.  But that's not a problem because I can use
atacontrol(8) and camcontrol(8) to spin down a specific
disk drive manually.

  Also, to go from single to multi user mode you can just exit(1) the
  shell.

Yes, of course, that's a different matter.

I've updated the patch for ada(4).  It includes a bug fix
(command1 vs. command2) and uses the howto flags passed to
the shutdown function.  Thanks again for pointing these out.

Best regards
   Oliver


--- ata_da.c.orig   2010-05-23 18:16:33.0 +0200
+++ ata_da.c2010-09-16 17:21:10.0 +0200
@@ -42,6 +42,7 @@
 #include sys/eventhandler.h
 #include sys/malloc.h
 #include sys/cons.h
+#include sys/reboot.h
 #include geom/geom_disk.h
 #endif /* _KERNEL */
 
@@ -79,7 +80,8 @@
ADA_FLAG_CAN_TRIM   = 0x080,
ADA_FLAG_OPEN   = 0x100,
ADA_FLAG_SCTX_INIT  = 0x200,
-   ADA_FLAG_CAN_CFA= 0x400
+   ADA_FLAG_CAN_CFA= 0x400,
+   ADA_FLAG_CAN_POWERMGT   = 0x800
 } ada_flags;
 
 typedef enum {
@@ -180,6 +182,10 @@
 #defineADA_DEFAULT_SEND_ORDERED1
 #endif
 
+#ifndefADA_DEFAULT_SPINDOWN_SHUTDOWN
+#defineADA_DEFAULT_SPINDOWN_SHUTDOWN   1
+#endif
+
 /*
  * Most platforms map firmware geometry to actual, but some don't.  If
  * not overridden, default to nothing.
@@ -191,6 +197,7 @@
 static int ada_retry_count = ADA_DEFAULT_RETRY;
 static int ada_default_timeout = ADA_DEFAULT_TIMEOUT;
 static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED;
+static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN;
 
 SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0,
 CAM Direct Access Disk driver);
@@ -203,6 +210,9 @@
 SYSCTL_INT(_kern_cam_ada, OID_AUTO, ada_send_ordered, CTLFLAG_RW,
ada_send_ordered, 0, Send Ordered Tags);
 TUNABLE_INT(kern.cam.ada.ada_send_ordered, ada_send_ordered);
+SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW,
+   ada_spindown_shutdown, 0, Spin down upon shutdown);
+TUNABLE_INT(kern.cam.ada.spindown_shutdown, ada_spindown_shutdown);
 
 /*
  * ADA_ORDEREDTAG_INTERVAL determines how often, relative
@@ -665,6 +675,8 @@
softc-flags |= ADA_FLAG_CAN_48BIT;
if (cgd-ident_data.support.command2  ATA_SUPPORT_FLUSHCACHE)
softc-flags |= ADA_FLAG_CAN_FLUSHCACHE;
+   if (cgd-ident_data.support.command1  ATA_SUPPORT_POWERMGT)
+   softc-flags |= ADA_FLAG_CAN_POWERMGT;
if (cgd-ident_data.satacapabilities  ATA_SUPPORT_NCQ 
cgd-inq_flags  SID_CmdQue)
softc-flags |= ADA_FLAG_CAN_NCQ;
@@ -1222,6 +1234,58 @@
 /*getcount_only*/0);
cam_periph_unlock(periph);
}
+
+   if (ada_spindown_shutdown == 0 ||
+   (howto  (RB_HALT | RB_POWEROFF)) == 0)
+   return;
+
+   DELAY(50);
+
+   TAILQ_FOREACH(periph, adadriver.units, unit_links) {
+   union ccb ccb;
+
+   /* If we paniced with lock held - not recurse here. */
+   if (cam_periph_owned(periph))
+   continue;
+   cam_periph_lock(periph);
+   softc = (struct ada_softc *)periph-softc;
+   /*
+* We only spin-down the drive if it is capable of it..
+*/
+   if ((softc-flags  ADA_FLAG_CAN_POWERMGT) == 0) {
+   cam_periph_unlock(periph);
+   continue;
+   }
+
+   /* XXX Hide this behind bootverbose? */
+   xpt_print(periph-path, spin-down\n);
+
+   xpt_setup_ccb(ccb.ccb_h, periph-path, CAM_PRIORITY_NORMAL);
+
+   ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
+   cam_fill_ataio(ccb.ataio,
+   1,
+   adadone,
+  

Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread RW
On Thu, 16 Sep 2010 09:17:52 +0200
Dag-Erling Smørgrav d...@des.no wrote:

 Garrett Cooper gcoo...@freebsd.org writes:
  Agreed. Spinning down at reboot isn't smart and seems like a good
  way to kill a disk quicker.
 
 *not* spinning down at halt is far worse.  Most modern disks are rated
 for hundreds of thousands of load-unload cycles, but far fewer
 emergency unloads (which is what happens when the drive loses power
 while still spinning).

As I understand it wear from spinning-down used to come from the head
actually scraping the disk surface as it lost lift, parking placed the
head on a disposable area, but modern drives take the head off the disk
altogether.

When Hitachi was specifying 300,000 unloads, they said that in testing
the drives were still working at 1,000,000, someone quoted 600,000 as
the current spec. At these levels you can be spinning the drives
down and up  ever few minutes for the normal lifetime of the drive.

Even on very old drives I doubt reboot are much of a problem, they're
rare on servers. On laptops and desktops they're rare compared to
shutdowns and suspends.  
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-16 Thread Warren Block

On Thu, 16 Sep 2010, Oliver Fromme wrote:


I've updated the patch for ada(4).  It includes a bug fix
(command1 vs. command2) and uses the howto flags passed to
the shutdown function.  Thanks again for pointing these out.


Works perfectly on a system here.  Thanks!
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-15 Thread Oliver Fromme
Warren Block wbl...@wonkity.com wrote:
  [...]
  8. Alexander Motin has an updated CAM version of the ATA system which 
  will eventually replace the existing one.  In -CURRENT, anyway.  He was 
  kind enough to look at my event handler.  My understanding is that he is 
  looking at implementing the head parking/standby mechanism in that new 
  code.

The patch below will work with the new CAM ATA driver
(i.e. ada(4) disks).  It adds a sysctl, so you can switch
the spin-down off if you're going to just reboot:
# sysctl kern.cam.ada.spindown_shutdown=0

This patch applies to stable/8, but I think it should
work with current, too (I haven't tried because I don't
have a machine running HEAD that has ada(4) disks).

Best regards
   Oliver


--- ata_da.c.orig   2010-05-23 18:16:33.0 +0200
+++ ata_da.c2010-09-15 22:48:03.0 +0200
@@ -79,7 +79,8 @@
ADA_FLAG_CAN_TRIM   = 0x080,
ADA_FLAG_OPEN   = 0x100,
ADA_FLAG_SCTX_INIT  = 0x200,
-   ADA_FLAG_CAN_CFA= 0x400
+   ADA_FLAG_CAN_CFA= 0x400,
+   ADA_FLAG_CAN_POWERMGT   = 0x800
 } ada_flags;
 
 typedef enum {
@@ -180,6 +181,10 @@
 #defineADA_DEFAULT_SEND_ORDERED1
 #endif
 
+#ifndefADA_DEFAULT_SPINDOWN_SHUTDOWN
+#defineADA_DEFAULT_SPINDOWN_SHUTDOWN   1
+#endif
+
 /*
  * Most platforms map firmware geometry to actual, but some don't.  If
  * not overridden, default to nothing.
@@ -191,6 +196,7 @@
 static int ada_retry_count = ADA_DEFAULT_RETRY;
 static int ada_default_timeout = ADA_DEFAULT_TIMEOUT;
 static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED;
+static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN;
 
 SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0,
 CAM Direct Access Disk driver);
@@ -203,6 +209,9 @@
 SYSCTL_INT(_kern_cam_ada, OID_AUTO, ada_send_ordered, CTLFLAG_RW,
ada_send_ordered, 0, Send Ordered Tags);
 TUNABLE_INT(kern.cam.ada.ada_send_ordered, ada_send_ordered);
+SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW,
+   ada_spindown_shutdown, 0, Spin down upon shutdown);
+TUNABLE_INT(kern.cam.ada.spindown_shutdown, ada_spindown_shutdown);
 
 /*
  * ADA_ORDEREDTAG_INTERVAL determines how often, relative
@@ -665,6 +674,8 @@
softc-flags |= ADA_FLAG_CAN_48BIT;
if (cgd-ident_data.support.command2  ATA_SUPPORT_FLUSHCACHE)
softc-flags |= ADA_FLAG_CAN_FLUSHCACHE;
+   if (cgd-ident_data.support.command2  ATA_SUPPORT_POWERMGT)
+   softc-flags |= ADA_FLAG_CAN_POWERMGT;
if (cgd-ident_data.satacapabilities  ATA_SUPPORT_NCQ 
cgd-inq_flags  SID_CmdQue)
softc-flags |= ADA_FLAG_CAN_NCQ;
@@ -1222,6 +1233,57 @@
 /*getcount_only*/0);
cam_periph_unlock(periph);
}
+
+   if (ada_spindown_shutdown == 0)
+   return;
+
+   DELAY(50);
+
+   TAILQ_FOREACH(periph, adadriver.units, unit_links) {
+   union ccb ccb;
+
+   /* If we paniced with lock held - not recurse here. */
+   if (cam_periph_owned(periph))
+   continue;
+   cam_periph_lock(periph);
+   softc = (struct ada_softc *)periph-softc;
+   /*
+* We only spin-down the drive if it is capable of it..
+*/
+   if ((softc-flags  ADA_FLAG_CAN_POWERMGT) == 0) {
+   cam_periph_unlock(periph);
+   continue;
+   }
+
+   /* XXX Hide this behind bootverbose? */
+   xpt_print(periph-path, spin-down\n);
+
+   xpt_setup_ccb(ccb.ccb_h, periph-path, CAM_PRIORITY_NORMAL);
+
+   ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
+   cam_fill_ataio(ccb.ataio,
+   1,
+   adadone,
+   CAM_DIR_NONE,
+   0,
+   NULL,
+   0,
+   ada_default_timeout*1000);
+
+   ata_28bit_cmd(ccb.ataio, ATA_STANDBY_IMMEDIATE, 0, 0, 0);
+   xpt_polled_action(ccb);
+
+   if ((ccb.ccb_h.status  CAM_STATUS_MASK) != CAM_REQ_CMP)
+   xpt_print(periph-path, Spin-down disk failed\n);
+
+   if ((ccb.ccb_h.status  CAM_DEV_QFRZN) != 0)
+   cam_release_devq(ccb.ccb_h.path,
+/*relsim_flags*/0,
+/*reduction*/0,
+/*timeout*/0,
+/*getcount_only*/0);
+   cam_periph_unlock(periph);
+   }
 }
 
 #endif /* _KERNEL */



-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: 

Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-15 Thread Alexander Best
On Wed Sep 15 10, Oliver Fromme wrote:
 Warren Block wbl...@wonkity.com wrote:
   [...]
   8. Alexander Motin has an updated CAM version of the ATA system which 
   will eventually replace the existing one.  In -CURRENT, anyway.  He was 
   kind enough to look at my event handler.  My understanding is that he is 
   looking at implementing the head parking/standby mechanism in that new 
   code.
 
 The patch below will work with the new CAM ATA driver
 (i.e. ada(4) disks).  It adds a sysctl, so you can switch
 the spin-down off if you're going to just reboot:
 # sysctl kern.cam.ada.spindown_shutdown=0

i haven't tested your patch yet, but i don't think deciding whether to spin
down the hdd should be decided merely from the sysctl value.

the hdd should spindown when a shutdown has been issued and not spindown,
if a reboot has been issued.

either people have the sysctl set to 1 in which case a reboot will cause a
spindown (which isn't healthy for the hdd)
...or people will set it to 0 in which case everything remains just the way it
is.

imo the sysctl should stay, but shuld have a different meaning. if it is set to
1 (which should be the default) a shutdown will issue a spindown; a reboot
won't.
if for some reason people want back the current behavior (no spindown even
during a shutdown) they need to set it to 0.

deciding whether freebsd reboots or shuts down cannot be done from a script,
since users might use the reboot or halt commands in which case (if i'm not
mistaken) all shutdown scripts get skipped.

cheers.
alex

 
 This patch applies to stable/8, but I think it should
 work with current, too (I haven't tried because I don't
 have a machine running HEAD that has ada(4) disks).
 
 Best regards
Oliver
 
 snip
 
 
 -- 
 Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
 Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
 secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
 chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart
 
 FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd
 
 Python is executable pseudocode.  Perl is executable line noise.

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Summary: Re: Spin down HDD after disk sync or before power off

2010-09-15 Thread Garrett Cooper
On Wed, Sep 15, 2010 at 5:49 PM, Alexander Best arun...@freebsd.org wrote:
 On Wed Sep 15 10, Oliver Fromme wrote:
 Warren Block wbl...@wonkity.com wrote:
   [...]
   8. Alexander Motin has an updated CAM version of the ATA system which
   will eventually replace the existing one.  In -CURRENT, anyway.  He was
   kind enough to look at my event handler.  My understanding is that he is
   looking at implementing the head parking/standby mechanism in that new
   code.

 The patch below will work with the new CAM ATA driver
 (i.e. ada(4) disks).  It adds a sysctl, so you can switch
 the spin-down off if you're going to just reboot:
 # sysctl kern.cam.ada.spindown_shutdown=0

 i haven't tested your patch yet, but i don't think deciding whether to spin
 down the hdd should be decided merely from the sysctl value.

 the hdd should spindown when a shutdown has been issued and not spindown,
 if a reboot has been issued.

 either people have the sysctl set to 1 in which case a reboot will cause a
 spindown (which isn't healthy for the hdd)
 ...or people will set it to 0 in which case everything remains just the way it
 is.

 imo the sysctl should stay, but shuld have a different meaning. if it is set 
 to
 1 (which should be the default) a shutdown will issue a spindown; a reboot
 won't.
 if for some reason people want back the current behavior (no spindown even
 during a shutdown) they need to set it to 0.

Agreed. Spinning down at reboot isn't smart and seems like a good way
to kill a disk quicker.

 deciding whether freebsd reboots or shuts down cannot be done from a script,
 since users might use the reboot or halt commands in which case (if i'm not
 mistaken) all shutdown scripts get skipped.

I'm not so sure of that statement, in particular because halt(8),
reboot(8), and shutdown(8) send SIGTERM to processes (unless you use
halt -q / reboot -q ... there might be some other scenarios I'm not
envisioning here).

Thanks,
-Garrett
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Summary: Re: Spin down HDD after disk sync or before power off

2010-03-05 Thread Warren Block
Just wanted to followup with a summary before all vestiges of what I 
learned evaporate from my memory.  My apologies for the lateness.


1. Existing FreeBSD ata-disk code does not explicitly park the hard 
drive heads on shutdown.  So the power loss causes an emergency park, 
which sounds bad and is bad for the heads.


2. There are a limited number of powerup/powerdown or maybe 
spinup/spindown cycles for a drive.  Not sure what causes the wear.


3. FreeBSD doesn't park heads at reboot, either, but that's good because 
of #2.


4. FreeBSD's suspend code does call STANDBY_IMMEDIATE to park heads.

5. I couldn't tell if the STANDBY_IMMEDIATE in a reboot actually spun 
the drive down.  It may be that the hardware reset happens so quickly 
after the standby that it doesn't matter.  Or maybe it brakes very 
quietly.  Possibly different brands do different things.  I can think of 
ways to check, like measuring motor current, but don't have the 
equipment to try that.


6. Ond?ej Majerech suggested checking NetBSD's method of spinning the 
drive down.  I did, and they have a direct way of telling the difference 
between reboot and shutdown, somewhat differently from FreeBSD.


7. I actually waded hip-deep through magic C code and made a powerdown 
event handler for ata-disk.c.  It compiled and even seemed to work, 
although I don't trust it.


8. Alexander Motin has an updated CAM version of the ATA system which 
will eventually replace the existing one.  In -CURRENT, anyway.  He was 
kind enough to look at my event handler.  My understanding is that he is 
looking at implementing the head parking/standby mechanism in that new 
code.


Conclusions:

If you rarely power down a system with FreeBSD, it may not matter, and 
reboots with the existing code should not be a problem.


If you power down a system from FreeBSD often, the patch in 
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=233916+0+archive/2010/freebsd-hackers/20100131.freebsd-hackers 
is still the lowest-impact version, although it calls STANDBY_IMMEDIATE 
for both reboot and shutdown.


I don't have evidence either way as to whether the standby followed by a 
reboot causes as much wear as a cold spinup/spindown cycle, or whether 
that is more of a problem than emergency head parks.


-Warren Block * Rapid City, South Dakota USA
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org