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().
This commit is contained in:
Poul-Henning Kamp 1999-09-18 21:28:09 +00:00
parent d93b26d657
commit f80d57eec0
2 changed files with 40 additions and 4 deletions

View File

@ -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

View File

@ -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 */