linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Dark Sylinc <dark_sylinc@yahoo.com.ar>
Cc: linux-ide@vger.kernel.org, hmh@debian.org
Subject: Re: SATA Shutdown issue confuses (sda)
Date: Wed, 28 Nov 2007 12:07:17 +0900	[thread overview]
Message-ID: <474CDB65.9050700@gmail.com> (raw)
In-Reply-To: <318018.27274.qm@web56310.mail.re3.yahoo.com>

[cc'ing Henrique.]

Hello,

Dark Sylinc wrote:
> 1) Like Scott James Remnant, Ubuntu's Development
> Manager
> (http://www.mail-archive.com/linux-ide@vger.kernel.org/msg06595.html)
> said, in Debian (actually he referred to Ubuntu, but
> looking at the code they make the same thing) shutdown
> iterates through all /dev/hd* files and shuts them
> down. So, if I'm right, sda (the node file for my
> friend's PC) is leaved untouch. Why is the warning
> appearing then? It is supposed that SATA drives not
> using the /dev/hd* convention shouldn't be stopped by
> shutdown.

Don't have any debian around but apparently it's issuing spin down for
/dev/sdX's too.

> 2) The kernel Flushes cache and puts in stand-by-now
> since 2.6.22 This can cause (if it was already
> stopped) the disk to spin up and then down. So....
> anyway the disk should spun down propperly before
> power down, it might be done twice, but none of them
> would be an emergency shut down. I think I'm missing
> something... or otherwise there is no problem at all

Well, double spin-down doesn't sound too good and as introducing double
spin down would be a kernel regression kernel doesn't issue spin-down if
it's already spun down.  This is usually okay but some rare drives spin
up on FLUSH_CACHE even if the cache is empty which leads to emergency
spin down.  The warning message is for such cases.

> 3) What's the proposed solution after all??? Shutdown
> should flush cache AND stop the SATA? or shutdown
> shouldn't do anything?
> You seem to be in favor of "not doing anything" but
> I'm also concerned that Kernel's prior to 2.6.22 would
> be negative affected by this solution.

Shutdown doesn't need to do anything for later kernels.  For older ones,
it should continue to issue FLUSH_CACHE and STANDBYNOW1.  The presence
of manage_start_stop sysfs node can be used to tell which action to take.

> 4) What everyone in forums is asking... are they SATA
> drives being forced from long time ago, and they have
> just found out by using the new kernel? That remains
> unclear.

I don't really get the question here.  Can you please elaborate?

> 5) At least on my friend's SATA, the "clack" sounds
> like 2 or 3 seconds before power downs, but it sounds
> slightly (and really slightly) different to the
> Window's shutdown "clack". Does this means that his
> drive is safe? Or is it possible for software to power
> down just the HDD without stopping the heads???

Sure way to tell is to look at emergency unload count int the output of
'smartctl -a'.  Basically, it should identical to 'hdparm -y'.

> 5b)I've compiled the kernel without the "Asynchronous
> SCSI scanning" flag (SCSI_SCAN_ASYNC). Does it have
> something to do that the kernel seems to be waiting
> for the SCSI to stop before powering down?

Nope.

> 6) If I'm not mistaken, in hdddown.c (debian's
> sysvinit code
> http://packages.debian.org/etch/sysvinit) in line 67
> we should change
> static int do_standby_idedisk(char *device)
> {
> #ifndef WIN_STANDBYNOW1
> #define WIN_STANDBYNOW1 0xE0
> #endif
> #ifndef WIN_STANDBYNOW2
> #define WIN_STANDBYNOW2 0x94
> #endif
> 	unsigned char args1[4] = {WIN_STANDBYNOW1,0,0,0};
> 	unsigned char args2[4] = {WIN_STANDBYNOW2,0,0,0};
> 	int fd;
> 
> 	if ((fd = open(device, O_RDWR)) < 0)
> 		return -1;
> 
> 	if (ioctl(fd, HDIO_DRIVE_CMD, &args1) &&
> 	    ioctl(fd, HDIO_DRIVE_CMD, &args2))
> 		return -1;
> 
> 	return 0;
> }
> 
> By:
> 
> static int do_standby_idedisk(char *device)
> {
> #ifndef WIN_STANDBYNOW1
> #define WIN_STANDBYNOW1 0xE0
> #endif
> #ifndef WIN_STANDBYNOW2
> #define WIN_STANDBYNOW2 0x94
> #endif
> #ifndef WIN_FLUSHCACHE
> #define WIN_FLUSHCACHE 0xE7
> #endif
> 	unsigned char args0[4] = {WIN_FLUSHCACHE,0,0,0};
> 	unsigned char args1[4] = {WIN_STANDBYNOW1,0,0,0};
> 	unsigned char args2[4] = {WIN_STANDBYNOW2,0,0,0};
> 	int fd;
> 
> 	if ((fd = open(device, O_RDWR)) < 0)
> 		return -1;
> 
> 	if (ioctl(fd, HDIO_DRIVE_CMD, &args0) &&
> 	    ioctl(fd, HDIO_DRIVE_CMD, &args1) &&
> 	    ioctl(fd, HDIO_DRIVE_CMD, &args2))
> 		return -1;
> 
> 	return 0;
> }

Opcode 0x94 is retired now and it's probably not too good a idea to
issue it to modern disks.  0xE0 should be good enough and yes you
definitely need to issue FLUSH before spinning down the disk.

The code needs to be a tad bit more complex.  It needs to check
manage_start_stop presence and skip any action if it's there.

> PS: I'm not a distro mantainer. But I'm concerned
> about my friend's SATA, and if we can get to a
> solution, I would be glad to report the patch to the
> Debian Community

ISTR this was resolved somehow and somebody was about to write how to
deal with this for debian.  Henrique, do you recall anything?  Did I
drop the ball again?

Thanks.

-- 
tejun

  reply	other threads:[~2007-11-28  3:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 20:08 SATA Shutdown issue confuses (sda) Dark Sylinc
2007-11-28  3:07 ` Tejun Heo [this message]
2007-11-28 20:02   ` Dark Sylinc
2007-11-29  1:04     ` Tejun Heo
2007-11-29  2:17       ` Dark Sylinc
2007-11-29  2:23         ` Tejun Heo
2007-11-29  3:49           ` Dark Sylinc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=474CDB65.9050700@gmail.com \
    --to=htejun@gmail.com \
    --cc=dark_sylinc@yahoo.com.ar \
    --cc=hmh@debian.org \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).