diff options
author | phk <phk@FreeBSD.org> | 1999-09-18 21:28:09 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-09-18 21:28:09 +0000 |
commit | 924236547e11eeafee3db1e24987bb763df57937 (patch) | |
tree | 4c738e149f9af9c8a45a83d0705a1d933c3bd46f /sys | |
parent | 240736f7b919c5b42784ffed6fc7ce29c600a18f (diff) | |
download | FreeBSD-src-924236547e11eeafee3db1e24987bb763df57937.zip FreeBSD-src-924236547e11eeafee3db1e24987bb763df57937.tar.gz |
Count "free" operations in their own new tranaction type.
WARNING: libdevstat, iostat, vmstat, systat etc etc will need a recompile.
Add devstat_end_transaction_buf() which pulls all the vital data out
of a struct buf which is ready for biodone().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_devstat.c | 26 | ||||
-rw-r--r-- | sys/sys/devicestat.h | 18 |
2 files changed, 40 insertions, 4 deletions
diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c index 448b869..699ec3e 100644 --- a/sys/kern/subr_devstat.c +++ b/sys/kern/subr_devstat.c @@ -33,6 +33,7 @@ #include <sys/systm.h> #include <sys/time.h> #include <sys/types.h> +#include <sys/buf.h> #include <sys/sysctl.h> #include <sys/devicestat.h> @@ -212,13 +213,17 @@ devstat_end_transaction(struct devstat *ds, u_int32_t bytes, } else if (flags == DEVSTAT_WRITE) { ds->bytes_written += bytes; ds->num_writes++; + } else if (flags == DEVSTAT_FREE) { + ds->bytes_freed += bytes; + ds->num_frees++; } else ds->num_other++; /* * Keep a count of the various tag types sent. */ - if (tag_type != DEVSTAT_TAG_NONE) + if ((ds->flags & DEVSTAT_NO_ORDERED_TAGS == 0) && + tag_type != DEVSTAT_TAG_NONE) ds->tag_types[tag_type]++; /* @@ -238,6 +243,25 @@ devstat_end_transaction(struct devstat *ds, u_int32_t bytes, ds->unit_number, ds->busy_count); } +void +devstat_end_transaction_buf(struct devstat *ds, struct buf *bp) +{ + devstat_trans_flags flg; + + if (bp->b_flags & B_FREEBUF) + flg = DEVSTAT_FREE; + else if (bp->b_flags & B_READ) + flg = DEVSTAT_READ; + else + flg = DEVSTAT_WRITE; + + devstat_end_transaction(ds, + bp->b_bcount - bp->b_resid, + (bp->b_flags & B_ORDERED) ? + DEVSTAT_TAG_ORDERED : DEVSTAT_TAG_SIMPLE, + flg); +} + /* * This is the sysctl handler for the devstat package. The data pushed out * on the kern.devstat.all sysctl variable consists of the current devstat diff --git a/sys/sys/devicestat.h b/sys/sys/devicestat.h index 8887744..3846935 100644 --- a/sys/sys/devicestat.h +++ b/sys/sys/devicestat.h @@ -62,7 +62,8 @@ typedef enum { typedef enum { DEVSTAT_NO_DATA = 0x00, DEVSTAT_READ = 0x01, - DEVSTAT_WRITE = 0x02 + DEVSTAT_WRITE = 0x02, + DEVSTAT_FREE = 0x03 } devstat_trans_flags; typedef enum { @@ -130,12 +131,16 @@ struct devstat { */ char device_name[DEVSTAT_NAME_LEN]; int unit_number; + u_int64_t bytes_read; /* + * Total bytes read + * from a device. + */ u_int64_t bytes_written; /* * Total bytes written * to a device. */ - u_int64_t bytes_read; /* - * Total bytes read + u_int64_t bytes_freed; /* + * Total bytes freed * from a device. */ u_int64_t num_reads; /* @@ -148,6 +153,11 @@ struct devstat { * write requests to * the device. */ + u_int64_t num_frees; /* + * Total number of + * free requests to + * the device. + */ u_int64_t num_other; /* * Total number of * transactions that @@ -199,6 +209,7 @@ struct devstat { }; #ifdef KERNEL +struct buf; void devstat_add_entry(struct devstat *ds, const char *dev_name, int unit_number, u_int32_t block_size, devstat_support_flags flags, @@ -209,6 +220,7 @@ void devstat_start_transaction(struct devstat *ds); void devstat_end_transaction(struct devstat *ds, u_int32_t bytes, devstat_tag_type tag_type, devstat_trans_flags flags); +void devstat_end_transaction_buf(struct devstat *ds, struct buf *); #endif #endif /* _DEVICESTAT_H */ |