From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 28 17:26:13 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FA82106566C for ; Thu, 28 Jan 2010 17:26:13 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay008.isp.belgacom.be (mailrelay008.isp.belgacom.be [195.238.6.174]) by mx1.freebsd.org (Postfix) with ESMTP id 004638FC0C for ; Thu, 28 Jan 2010 17:26:12 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap0EAIZWYUtQyBlC/2dsb2JhbACBNNhghDwEhX4 Received: from 66.25-200-80.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([80.200.25.66]) by relay.skynet.be with ESMTP; 28 Jan 2010 18:26:11 +0100 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.14.3/8.14.3) with ESMTP id o0SHQAxF005219; Thu, 28 Jan 2010 18:26:11 +0100 (CET) (envelope-from tijl@coosemans.org) From: Tijl Coosemans To: freebsd-hackers@freebsd.org, Alexander Best Date: Thu, 28 Jan 2010 18:26:09 +0100 User-Agent: KMail/1.9.10 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201001281826.10472.tijl@coosemans.org> Cc: Subject: Re: Spin down HDD after disk sync or before power off X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2010 17:26:13 -0000 On Tuesday 26 January 2010 20:17:23 Alexander Best wrote: > because of kern/140752 i looked through a discussion back in 2009 > (http://lists.freebsd.org/pipermail/freebsd-hackers/2009-March/027879.html) > concerning freebsd's hdd spin down procedure. right now > ATA_FLUSHCACHE is being used although the hitachi hdd specs > referenced in the pr say that this will not cause proper load/unload > and thus an emergency unload will occur which reduces the life > expectancy of hdds dramatically (20.000 shutdowns vs. 600.000 > shutdowns). unfortunately the discussion back then didn't come up > with any sort of decision/patch. > > attached you'll find a very simple patch which issues > ATA_STANDBY_IMMEDIATE instead of ATA_FLUSHCACHE during hdd spin down. > > could somebody with hdd knowledge comment on this? this matter seems > quite important since there may be a chance that the current spin > down mechanism in freebsd damages hdds! > Index: sys/dev/ata/ata-disk.c > =================================================================== > --- sys/dev/ata/ata-disk.c (revision 202848) > +++ sys/dev/ata/ata-disk.c (working copy) > @@ -191,8 +191,9 @@ > { > struct ata_device *atadev = device_get_softc(dev); > > - if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE) > - ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0); > + if (atadev->param.support.command2 & ATA_SUPPORT_STANDBY) This is the wrong bit. ATA_SUPPORT_STANDBY indicates whether a drive can be powered up straight into standby mode. The ATA_STANDBY_IMMEDIATE command is part of the standard power management feature set, so this line should be: if (atadev->param.support.command1 & ATA_SUPPORT_POWERMGT) > + ata_controlcmd(dev, ATA_STANDBY_IMMEDIATE, 0, 0, 0); > + > return 0; > }