Subject: Re: Stopping SCSI disks
To: Ken Hornstein <kenh@cmf.nrl.navy.mil>
From: Anders Dinsen <dinsen@danbbs.dk>
List: tech-kern
Date: 01/24/1999 23:06:38
I have crossposted this to tech-kern because I realize that this is
a kernel technicality...

Thanks for your answer, Ken!

On Fri, 22 Jan 1999, Ken Hornstein wrote:
> >On the i386 there's APM to stop the CPU and IDE disks and control
> >[...]
> 
> APM really has no concept of what the disks are doing.
> 
> The way IDE works is that you tell the drive, "Spin down after N seconds
> of no accesses".  The operating system doesn't know that the drive has
> been spun down.

Ah. Thanks for clearing this! I assume there's no such SCSI2 command?

> There should be enough accounting in the kernel to have NetBSD do it
> (which would also work for SCSI drives), but no one has yet written
> it.

I imagined that a solution would be to extend the sd driver with an
ioctl command that tells it to spin the drive down and set a flag that the
disk has been stopped. On the next access, the driver would know (from the
flag) that a start unit command should be sent first (and the flag should
be cleared). 

Another approach would be to try sending a start unit command if the
drive returns error on an io command and repeating the command once.

A userland daemon - doing essentially the same as iostat(8) - would
monitor the drives' activity and spin them down using this new command.
Any disk controlled by a driver supporting this ioctl could be spun down
using this daemon.

I have only a vauge idea about how to modifiy the sd driver (although I
have skimmed through the code on 1.3.2), and also don't know any SCSI
commands, so unfortunately I'm not the one that will write this... (except
maybe the daemon). 

I saw scsi-idle-2.0.36 announced on comp.os.linux.announce as a package
and kernel patch to do this under Linux, but according to the README it is
quite unstable (!). Anyway, I cannot see why we should suffer from that! 

--
Anders Dinsen 
dinsen@danbbs.dk
http://www.danbbs.dk/~dinsen