diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2014-04-20 22:18:05 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2014-04-20 22:18:05 +0000 |
commit | 2e725ccac7a39ac5fbf5b3722e91e0798a6c0d2b (patch) | |
tree | d2b295daff3303e442f8426cd7f1837f86607646 /usr.sbin/iscsid | |
parent | e79019706bc021dcb1a09a738f3ec5c25ecf12c2 (diff) |
Introduce some basic stats for the vscsi layer. Just counting the commands
and the bytes we push through vscsi(4).
Diffstat (limited to 'usr.sbin/iscsid')
-rw-r--r-- | usr.sbin/iscsid/iscsid.c | 6 | ||||
-rw-r--r-- | usr.sbin/iscsid/iscsid.h | 17 | ||||
-rw-r--r-- | usr.sbin/iscsid/vscsi.c | 35 |
3 files changed, 53 insertions, 5 deletions
diff --git a/usr.sbin/iscsid/iscsid.c b/usr.sbin/iscsid/iscsid.c index d2dc36a9871..08bcdfc35ff 100644 --- a/usr.sbin/iscsid/iscsid.c +++ b/usr.sbin/iscsid/iscsid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iscsid.c,v 1.11 2014/04/20 12:22:16 claudio Exp $ */ +/* $OpenBSD: iscsid.c,v 1.12 2014/04/20 22:18:04 claudio Exp $ */ /* * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> @@ -265,6 +265,10 @@ iscsid_ctrl_dispatch(void *ch, struct pdu *pdu) log_verbose(*valp); control_compose(ch, CTRL_SUCCESS, NULL, 0); break; + case CTRL_VSCSI_STATS: + control_compose(ch, CTRL_VSCSI_STATS, vscsi_stats(), + sizeof(struct vscsi_stats)); + break; default: log_warnx("unknown control message type %d", cmh->type); control_compose(ch, CTRL_FAILURE, NULL, 0); diff --git a/usr.sbin/iscsid/iscsid.h b/usr.sbin/iscsid/iscsid.h index 6dd9d4ce66e..1bc123d0646 100644 --- a/usr.sbin/iscsid/iscsid.h +++ b/usr.sbin/iscsid/iscsid.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iscsid.h,v 1.10 2014/04/07 19:55:46 claudio Exp $ */ +/* $OpenBSD: iscsid.h,v 1.11 2014/04/20 22:18:04 claudio Exp $ */ /* * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> @@ -53,6 +53,7 @@ struct ctrlmsghdr { #define CTRL_INITIATOR_CONFIG 4 #define CTRL_SESSION_CONFIG 5 #define CTRL_LOG_VERBOSE 6 +#define CTRL_VSCSI_STATS 7 TAILQ_HEAD(session_head, session); @@ -271,6 +272,19 @@ struct kvp { #define KVP_KEY_ALLOCED 0x01 #define KVP_VALUE_ALLOCED 0x02 +struct vscsi_stats { + u_int64_t bytes_rd; + u_int64_t bytes_wr; + u_int64_t cnt_read; + u_int64_t cnt_write; + u_int64_t cnt_i2t; + u_int64_t cnt_i2t_dir[3]; + u_int64_t cnt_t2i; + u_int64_t cnt_t2i_status[3]; + u_int32_t cnt_probe; + u_int32_t cnt_detach; +}; + extern const struct session_params iscsi_sess_defaults; extern const struct connection_params iscsi_conn_defaults; extern struct session_params initiator_sess_defaults; @@ -356,3 +370,4 @@ void vscsi_dispatch(int, short, void *); void vscsi_data(unsigned long, int, void *, size_t); void vscsi_status(int, int, void *, size_t); void vscsi_event(unsigned long, u_int, u_int); +struct vscsi_stats *vscsi_stats(void); diff --git a/usr.sbin/iscsid/vscsi.c b/usr.sbin/iscsid/vscsi.c index 26bcacc5f6c..0dfafc5f777 100644 --- a/usr.sbin/iscsid/vscsi.c +++ b/usr.sbin/iscsid/vscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vscsi.c,v 1.9 2014/04/19 18:31:33 claudio Exp $ */ +/* $OpenBSD: vscsi.c,v 1.10 2014/04/20 22:18:04 claudio Exp $ */ /* * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> @@ -17,6 +17,7 @@ */ #include <sys/types.h> +#include <sys/param.h> /* for nitems */ #include <sys/ioctl.h> #include <sys/queue.h> #include <sys/socket.h> @@ -35,8 +36,9 @@ #include "log.h" struct vscsi { - struct event ev; - int fd; + struct event ev; + int fd; + struct vscsi_stats stats; } v; struct scsi_task { @@ -82,6 +84,10 @@ vscsi_dispatch(int fd, short event, void *arg) if (ioctl(v.fd, VSCSI_I2T, &i2t) == -1) fatal("vscsi_dispatch"); + v.stats.cnt_i2t++; + if (i2t.direction < (int)nitems(v.stats.cnt_i2t_dir)) + v.stats.cnt_i2t_dir[i2t.direction]++; + s = initiator_t2s(i2t.target); if (s == NULL) fatalx("vscsi_dispatch: unknown target"); @@ -131,11 +137,19 @@ vscsi_dispatch(int fd, short event, void *arg) session_task_issue(s, &t->task); } +/* read / write data to vscsi */ void vscsi_data(unsigned long req, int tag, void *buf, size_t len) { struct vscsi_ioc_data data; + if (req == VSCSI_DATA_READ) { + v.stats.cnt_read++; + v.stats.bytes_rd += len; + } else if (req == VSCSI_DATA_WRITE) { + v.stats.cnt_write++; + v.stats.bytes_wr += len; + } data.tag = tag; data.data = buf; data.datalen = len; @@ -149,6 +163,10 @@ vscsi_status(int tag, int status, void *buf, size_t len) { struct vscsi_ioc_t2i t2i; + v.stats.cnt_t2i++; + if (status < (int)nitems(v.stats.cnt_t2i_status)) + v.stats.cnt_t2i_status[status]++; + bzero(&t2i, sizeof(t2i)); t2i.tag = tag; t2i.status = status; @@ -167,6 +185,11 @@ vscsi_event(unsigned long req, u_int target, u_int lun) { struct vscsi_ioc_devevent devev; + if (req == VSCSI_REQPROBE) + v.stats.cnt_probe++; + else if (req == VSCSI_REQDETACH) + v.stats.cnt_detach++; + devev.target = target; devev.lun = lun; @@ -303,3 +326,9 @@ vscsi_dataout(struct connection *c, struct scsi_task *t, u_int32_t ttt, } conn_task_issue(c, &t->task); } + +struct vscsi_stats * +vscsi_stats(void) +{ + return &v.stats; +} |