From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 6 13:40:11 2009 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 BED641065673 for ; Fri, 6 Mar 2009 13:40:11 +0000 (UTC) (envelope-from octavian.covalschi@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.230]) by mx1.freebsd.org (Postfix) with ESMTP id 8A9D58FC24 for ; Fri, 6 Mar 2009 13:40:11 +0000 (UTC) (envelope-from octavian.covalschi@gmail.com) Received: by rv-out-0506.google.com with SMTP id f6so496605rvb.43 for ; Fri, 06 Mar 2009 05:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=TOVd+oAZ7XHJjB8JqVcJBy5l4R56Z4842A/KNkw4Ot4=; b=E3r92Eu7pjA2P3rNLmryeEVoVMSWp0GL3ppNNxTfewLYDBJhM4ifJK4JoScOJ1hrXI dyu/q/ctA+TzoLHEAMUpW6gt4F0HLlYE9oyR1kcMjpkVjM5qbih/DMnSn05KpNel2EkA hECQoXGU8I2XsC/P2iJyQrqBvbYNYm4VqlORc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=hy1TbsVH0le3noZo1DsNqclz9Qyarvw07zvMXT7yICMx51+BRowh9A+u1XGYF2Xr82 w+MdgQDtwrHPR90L0dhUSiGCHszyXUyQFItz48p0+ZTxEdY7onkgy+Fyq3i9yPsiVRmX VVJkEi1NVw2AFEr9Vas9aTuR8YtRjhpIxJpmw= MIME-Version: 1.0 Received: by 10.143.29.17 with SMTP id g17mr1110380wfj.109.1236346811079; Fri, 06 Mar 2009 05:40:11 -0800 (PST) In-Reply-To: <49B04B19.5010100@gmx.net> References: <200903041938.n24Jcqdr060153@lurza.secnetix.de> <49AF1C1B.3050604@gmx.net> <49AF2CCA.2080706@gmx.net> <49B04563.3010002@gmx.net> <49B04B19.5010100@gmx.net> Date: Fri, 6 Mar 2009 07:40:11 -0600 Message-ID: From: Octavian Covalschi To: Daniel Thiele Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org 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: Fri, 06 Mar 2009 13:40:12 -0000 I played more with this, and got here so far: if (atadev->param.support.command1 & ATA_SUPPORT_STANDBY) { device_printf(dev, "Trying to spindown before poweroff.\n"); atadev->spindown = 1; ad_spindown((void *)dev); } else { device_printf(dev, "Cannot spindown before poweroff.\n"); } for some reason this check works on my laptop: if (atadev->param.support.command1 & ATA_SUPPORT_STANDBY) instead of if (atadev->param.support.command2 & ATA_SUPPORT_STANDBY) command1 vs command2 I'm using 7.1-STABLE... By the way, does anyone know why ad_shutdown is _not_ called at poweroff? Apparently it's called only at halt & reboot... Still looking... PS: I think last post didn't get to entire mail list, so trying to send it again. On Thu, Mar 5, 2009 at 3:58 PM, Daniel Thiele wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Octavian Covalschi wrote: > | I tried your patch 1st, but it didn't work for me for shutdown, although > I > | didn't try it with halt (I assumed they work the same). > | > | While I was looking into that, I've discovered "ad_spindown" function, > and > | tried to use it, and as I said, it works (for me at least), but only with > | halt. > | > > Hmm, here is what David Tolpin mentioned back in 2006 when he replied > (privately) to the fist fix I came up with: > > "Besides, I had to increase timeout in ata-queue for controlcmd " > > I am no kernel expert, so I am not quite sure how to incorporate his > suggestion, but may be this helps with your problem. > > I would be interested in your progress on this topic, for maybe some day > one of my machines will refuse to spin down the disk with the "simple" > patch, too. > > | > | On Thu, Mar 5, 2009 at 3:34 PM, Daniel Thiele wrote: > | > | Octavian Covalschi wrote: > | | OK. > | | > | | After several _kernel_ recompilations (by the end I found out that I > | can use > | | -DNO_KERNELCLEAN ) I've got some results. > | | > | | As i found out that ata-disk.c already has ad_spindown function, witch > I > | | tried to use, so after small changes I have: > | | > | | static void > | | ad_shutdown(device_t dev) > | | { > | | struct ata_device *atadev = device_get_softc(dev); > | | > | | if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE) > | | ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0); > | | > | | /* start */ > | | device_printf(dev, "Forced spindown\n"); > | | atadev->spindown = 1; > | | ad_spindown((void *)dev); > | | /* end */ > | | } > | | > | | But for some reason this works only with Halt or shutdown -h now, on > | | shutdown -p it even doesn't get inside ad_shutdown. > | | Well at least I have this :) > | | > | > | Does putting > | > | if (atadev->param.support.command2 & > (ATA_SUPPORT_APM|ATA_SUPPORT_STANDBY)) > | ~ ata_controlcmd(dev, ATA_STANDBY_IMMEDIATE, 0, 0, 0); > | > | directly into ad_shutdown() work? > | > | About your gmirror question: Unfortunately I never used gmirror together > | with the spindown-hack, but I (as a just layperson on this topic(!)) do > | not see any reason why this could cause a problem, since ad_shutdown() > | is most likely called after the disks got unmounted and after GEOM is > | done with them. > | > | Best regards, > | > | Daniel > |> > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.11 (FreeBSD) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkmwSxUACgkQCOZKcWNoXg5QBQCcDADmK8RrIduZCAY6IksuHSNm > disAnRUjx6SgGUPghw+/X9uf5oFFdEs/ > =xmQO > -----END PGP SIGNATURE----- >