Date: Thu, 16 Sep 2010 10:41:07 +0200 (CEST) From: Oliver Fromme <olli@lurza.secnetix.de> To: arundel@FreeBSD.ORG (Alexander Best) Cc: freebsd-hackers@FreeBSD.ORG, mav@FreeBSD.ORG Subject: Re: Summary: Re: Spin down HDD after disk sync or before power off Message-ID: <201009160841.o8G8f7Q2047725@lurza.secnetix.de> In-Reply-To: <20100916004902.GA46401@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Alexander Best wrote: > On Wed Sep 15 10, Oliver Fromme wrote: > > Warren Block <wblock@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009160841.o8G8f7Q2047725>