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:
parent
d93b26d657
commit
f80d57eec0
@ -33,6 +33,7 @@
|
|||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/buf.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
#include <sys/devicestat.h>
|
#include <sys/devicestat.h>
|
||||||
@ -212,13 +213,17 @@ devstat_end_transaction(struct devstat *ds, u_int32_t bytes,
|
|||||||
} else if (flags == DEVSTAT_WRITE) {
|
} else if (flags == DEVSTAT_WRITE) {
|
||||||
ds->bytes_written += bytes;
|
ds->bytes_written += bytes;
|
||||||
ds->num_writes++;
|
ds->num_writes++;
|
||||||
|
} else if (flags == DEVSTAT_FREE) {
|
||||||
|
ds->bytes_freed += bytes;
|
||||||
|
ds->num_frees++;
|
||||||
} else
|
} else
|
||||||
ds->num_other++;
|
ds->num_other++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keep a count of the various tag types sent.
|
* 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]++;
|
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);
|
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
|
* 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
|
* on the kern.devstat.all sysctl variable consists of the current devstat
|
||||||
|
@ -62,7 +62,8 @@ typedef enum {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
DEVSTAT_NO_DATA = 0x00,
|
DEVSTAT_NO_DATA = 0x00,
|
||||||
DEVSTAT_READ = 0x01,
|
DEVSTAT_READ = 0x01,
|
||||||
DEVSTAT_WRITE = 0x02
|
DEVSTAT_WRITE = 0x02,
|
||||||
|
DEVSTAT_FREE = 0x03
|
||||||
} devstat_trans_flags;
|
} devstat_trans_flags;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -130,12 +131,16 @@ struct devstat {
|
|||||||
*/
|
*/
|
||||||
char device_name[DEVSTAT_NAME_LEN];
|
char device_name[DEVSTAT_NAME_LEN];
|
||||||
int unit_number;
|
int unit_number;
|
||||||
|
u_int64_t bytes_read; /*
|
||||||
|
* Total bytes read
|
||||||
|
* from a device.
|
||||||
|
*/
|
||||||
u_int64_t bytes_written; /*
|
u_int64_t bytes_written; /*
|
||||||
* Total bytes written
|
* Total bytes written
|
||||||
* to a device.
|
* to a device.
|
||||||
*/
|
*/
|
||||||
u_int64_t bytes_read; /*
|
u_int64_t bytes_freed; /*
|
||||||
* Total bytes read
|
* Total bytes freed
|
||||||
* from a device.
|
* from a device.
|
||||||
*/
|
*/
|
||||||
u_int64_t num_reads; /*
|
u_int64_t num_reads; /*
|
||||||
@ -148,6 +153,11 @@ struct devstat {
|
|||||||
* write requests to
|
* write requests to
|
||||||
* the device.
|
* the device.
|
||||||
*/
|
*/
|
||||||
|
u_int64_t num_frees; /*
|
||||||
|
* Total number of
|
||||||
|
* free requests to
|
||||||
|
* the device.
|
||||||
|
*/
|
||||||
u_int64_t num_other; /*
|
u_int64_t num_other; /*
|
||||||
* Total number of
|
* Total number of
|
||||||
* transactions that
|
* transactions that
|
||||||
@ -199,6 +209,7 @@ struct devstat {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef KERNEL
|
#ifdef KERNEL
|
||||||
|
struct buf;
|
||||||
void devstat_add_entry(struct devstat *ds, const char *dev_name,
|
void devstat_add_entry(struct devstat *ds, const char *dev_name,
|
||||||
int unit_number, u_int32_t block_size,
|
int unit_number, u_int32_t block_size,
|
||||||
devstat_support_flags flags,
|
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,
|
void devstat_end_transaction(struct devstat *ds, u_int32_t bytes,
|
||||||
devstat_tag_type tag_type,
|
devstat_tag_type tag_type,
|
||||||
devstat_trans_flags flags);
|
devstat_trans_flags flags);
|
||||||
|
void devstat_end_transaction_buf(struct devstat *ds, struct buf *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _DEVICESTAT_H */
|
#endif /* _DEVICESTAT_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user