Subject: changes to dkdevice
To: None <tech-kern@NetBSD.ORG>
From: Jason Thorpe <>
List: tech-kern
Date: 11/07/1995 12:16:26
[ Sorry for the Cc:, Charles, but we've discussed this before, and I'd
  like your comments on this ASAP. ]

Hi folks...

Some other projects at the Real Job have been preempted by the need to 
have working disk statistics gathering on the i386 (specifically, for 
gathering some ccd performance data).  Making this work in the general 
case is going to require a fair number of changes to some kernel data 
structures, and I'd like to have a little discussion on the issue before 
I dive into implementation.

My idea is this:

	* First of all, remove the `struct device' member from
	  `struct dkdevice'.  There are two reasons for this;
	  a) a `disk' device might also be a pseudo-device, and thus
	  not require the `struct device' information, and b) all of
	  the disk drivers that currently use `struct dkdevice' also
	  use `struct device', and thus the instance of `struct device'
	  in `struct dkdevice' is redundant, and not used.

	* Add the following members to `struct dkdevice':
	  (Sorry for all the ??, but some of these statistics aren't
	   documented terribly well...I hope to change that.)

		char	*dk_name;	/* external name of the device */
		int	dk_busy;	/* indicates drive busy */
		long	dk_seek;	/* XXX number of seeks (?) */
		long	dk_time;	/* busy time */
		long	dk_wds;		/* XXX (??) */
		long	dk_wpms;	/* XXX transfer rate (??) */
		long	dk_xfer;	/* number of transfers */

	  Of course, this implies killing the corresponding instances
	  of the arrays in dkstat.h

	* Replace the dk_next member of `struct dkdevice' with
	  a TAILQ entry.

	* Keep a global list of disks currently attached to the
	  system.  This list of `struct dkdevice's will replace
	  the arrays of longs currently (not) used for disk
	  statistics gathering.  The global dk_ndrive will keep
	  a running total of the number of members in the list.
	  The global dk_busy will be obsoleted by the dk_busy member
	  of `struct dkdevice', and thus the system will not suffer
	  from the limitation of sizeof(int) as far as the number of
	  attached disks goes.

	* Implement two new functions for kern/subr_disk.c:

		disk_attach __P((struct dkdevice *));
			called by the individual disk drivers when
			the disk is attached.  Links the disk's
			`struct dkdevice' into the global list.

		disk_detach __P((struct dkdevice *));
			called by the individual disk drivers when
			the disk is detached.  Removes that disk's
			`struct dkdevice' from the global list.
	* Teach the one remaining config.old port (blush) how to use
	  the dkdevice stuff as opposed to the 4.3/4.4-like mechanism
	  it currently uses.

	* Fix iostat (and whichever other utilities access this information)
	  about the New World Order.  This will also require one to
	  rebuild ccdconfig(8), because the size of `struct ccd_softc' will
	  change (due to it's inclusion of a `struct dkdevice').

I need to start implementing something pretty soon, so if you have
comments and/or suggestions, speak up.  :-)

Jason R. Thorpe                             
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939