[sheepdog] [PATCH v2 1/4] sheep: add preliminary stat function
Liu Yuan
namei.unix at gmail.com
Mon Aug 26 08:51:53 CEST 2013
Add a new struct sd_stat to monitor the activities of the sheep daemon, which
are read by the dog. Currently it is very crude and monitors only request.
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
include/internal_proto.h | 13 +++++++++++++
sheep/request.c | 33 +++++++++++++++++++++++++++++++++
sheep/sheep_priv.h | 1 +
3 files changed, 47 insertions(+)
diff --git a/include/internal_proto.h b/include/internal_proto.h
index 2c24a52..adb9646 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -215,4 +215,17 @@ struct object_cache_info {
uint8_t directio;
};
+struct sd_stat {
+ struct s_request{
+ uint64_t gway_active_nr; /* nr of running request */
+ uint64_t peer_active_nr;
+ uint64_t gway_total_nr; /* Total nr of requests received */
+ uint64_t peer_total_nr;
+ uint64_t gway_total_rx; /* Data in */
+ uint64_t gway_total_tx; /* Data out */
+ uint64_t peer_total_rx;
+ uint64_t peer_total_tx;
+ } r;
+};
+
#endif /* __INTERNAL_PROTO_H__ */
diff --git a/sheep/request.c b/sheep/request.c
index a79f648..24ae59d 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -315,6 +315,35 @@ static void queue_local_request(struct request *req)
queue_work(sys->io_wqueue, &req->work);
}
+main_fn static inline void stat_request_begin(struct request *req)
+{
+ struct sd_req *hdr = &req->rq;
+
+ if (is_peer_op(req->op)) {
+ sys->stat.r.peer_total_nr++;
+ sys->stat.r.peer_active_nr++;
+ if (hdr->flags & SD_FLAG_CMD_WRITE)
+ sys->stat.r.peer_total_rx += hdr->data_length;
+ else
+ sys->stat.r.peer_total_tx += hdr->data_length;
+ } else if(is_gateway_op(req->op)) {
+ sys->stat.r.gway_total_nr++;
+ sys->stat.r.gway_active_nr++;
+ if (hdr->flags & SD_FLAG_CMD_WRITE)
+ sys->stat.r.gway_total_rx += hdr->data_length;
+ else
+ sys->stat.r.gway_total_tx += hdr->data_length;
+ }
+}
+
+main_fn static inline void stat_request_end(struct request *req)
+{
+ if (is_peer_op(req->op))
+ sys->stat.r.peer_active_nr--;
+ else if(is_gateway_op(req->op))
+ sys->stat.r.gway_active_nr--;
+}
+
static void queue_request(struct request *req)
{
struct sd_req *hdr = &req->rq;
@@ -384,6 +413,7 @@ static void queue_request(struct request *req)
rsp->result = SD_RES_SYSTEM_ERROR;
goto done;
}
+ stat_request_begin(req);
return;
done:
@@ -396,6 +426,7 @@ static void requeue_request(struct request *req)
put_vnode_info(req->vinfo);
req->vinfo = NULL;
}
+ stat_request_end(req);
queue_request(req);
}
@@ -504,6 +535,8 @@ main_fn void put_request(struct request *req)
if (refcount_dec(&req->refcnt) > 0)
return;
+ stat_request_end(req);
+
if (req->local)
eventfd_xwrite(req->local_req_efd, 1);
else {
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 35c067e..1cd22a4 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -153,6 +153,7 @@ struct system_info {
bool backend_dio;
/* upgrade data layout before starting service if necessary*/
bool upgrade;
+ struct sd_stat stat;
};
struct siocb {
--
1.7.9.5
More information about the sheepdog
mailing list