From 6c0a2b972225bf7b42a01401a3b0d4287abc2e72 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Fri, 4 Apr 1997 22:12:55 +0000 Subject: [PATCH] Implement dkstats for worm devices so they show up in iostat et al. I got tired of not seeing my worm stats show up during a burn. :) [Joerg, I just stapled in 1MB/sec for a bogus xfer rate and left seek = 1, as suggested - I'm not going to dynamically calculate the xfer rate from a known device spectable, OK? :-)] Reviewed by: joerg --- sys/scsi/worm.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sys/scsi/worm.c b/sys/scsi/worm.c index 82a8fa2de4f8..84e7f5694350 100644 --- a/sys/scsi/worm.c +++ b/sys/scsi/worm.c @@ -43,7 +43,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: worm.c,v 1.34 1997/03/23 06:33:55 bde Exp $ + * $Id: worm.c,v 1.35 1997/03/24 11:25:04 bde Exp $ */ #include "opt_bounce.h" @@ -66,6 +66,7 @@ #include #include #include +#include /* #include */ /* XXX a CD-R includes all CD functionality */ struct worm_quirks @@ -90,6 +91,7 @@ struct worm_quirks struct scsi_data { struct buf_queue_head buf_queue; + int dkunit; /* disk stats unit number */ u_int32_t n_blks; /* Number of blocks (0 for bogus) */ u_int32_t blk_size; /* Size of each blocks */ #ifdef DEVFS @@ -203,6 +205,18 @@ struct worm_quirks worm_quirks[] = { {0} }; +static inline void +worm_registerdev(int unit) +{ + if (dk_ndrive < DK_NDRIVE) { + sprintf(dk_names[dk_ndrive], "worm%d", unit); + dk_wpms[dk_ndrive] = (1*1024*1024/2); /* 1MB/sec XXX - fake! */ + SCSI_DATA(&worm_switch, unit)->dkunit = dk_ndrive++; + } else { + SCSI_DATA(&worm_switch, unit)->dkunit = -1; + } +} + static errval worm_size(struct scsi_link *sc_link, int flags) { @@ -239,6 +253,7 @@ worm_size(struct scsi_link *sc_link, int flags) static errval wormattach(struct scsi_link *sc_link) { + u_int32_t unit = sc_link->dev_unit; #ifdef DEVFS int mynor; #endif @@ -258,6 +273,7 @@ wormattach(struct scsi_link *sc_link) devfs_add_devswf(&worm_cdevsw, mynor | SCSI_CONTROL_MASK, DV_CHR, 0, 0, 0600, "rworm%d.ctl", mynor); #endif + worm_registerdev(unit); return 0; } @@ -351,6 +367,11 @@ wormstart(unit, flags) 100000, bp, flags | SCSI_NOSLEEP) == SUCCESSFULLY_QUEUED) { + if (worm->dkunit >= 0) { /* Cloned from od.c, possibly with same mistakes. :) */ + dk_xfer[worm->dkunit]++; + dk_seek[worm->dkunit] = 1; /* single track */ + dk_wds[worm->dkunit] += bp->b_bcount >> 6; + } if ((bp->b_flags & B_READ) == B_WRITE) worm->worm_flags |= WORMFL_WRITTEN; } else {