[Devel] [PATCH 15/15] fs/fuse kio: add locked cs_get_avg_in_flight()

Pavel Butsykin pbutsykin at virtuozzo.com
Fri May 17 16:20:48 MSK 2019


This function is needed to display in_flight_avg metrics for cs statistics in
cs unlocked context.

Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
---
 fs/fuse/kio/pcs/fuse_stat.c |  2 +-
 fs/fuse/kio/pcs/pcs_cs.c    | 11 +++++++++++
 fs/fuse/kio/pcs/pcs_cs.h    |  1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/kio/pcs/fuse_stat.c b/fs/fuse/kio/pcs/fuse_stat.c
index edb124a00682..1cf14bcc0073 100644
--- a/fs/fuse/kio/pcs/fuse_stat.c
+++ b/fs/fuse/kio/pcs/fuse_stat.c
@@ -137,7 +137,7 @@ static int do_show_cs_stats(struct pcs_cs *cs, void *ctx)
 {
 	struct seq_file *m = ctx;
 	int rpc_state = cs->rpc ? cs->rpc->state : PCS_RPC_UNCONN;
-	unsigned int in_flight_avg = 0; /* TODO */
+	unsigned int in_flight_avg = cs_get_avg_in_flight_lock(cs);
 	struct pcs_perf_stat_cnt iolat, netlat;
 	struct pcs_perf_rate_cnt read_ops_rate, write_ops_rate, sync_ops_rate;
 
diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index b41284fe9205..2dc730107864 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -896,6 +896,17 @@ unsigned int cs_get_avg_in_flight(struct pcs_cs *cs)
 	return cs->in_flight_avg;
 }
 
+unsigned int cs_get_avg_in_flight_lock(struct pcs_cs *cs)
+{
+	unsigned int in_flight_avg;
+
+	spin_lock(&cs->lock);
+	in_flight_avg = cs_get_avg_in_flight(cs);
+	spin_unlock(&cs->lock);
+
+	return in_flight_avg;
+}
+
 void cs_increment_in_flight(struct pcs_cs *cs, unsigned int to_add)
 {
 	unsigned int avg;
diff --git a/fs/fuse/kio/pcs/pcs_cs.h b/fs/fuse/kio/pcs/pcs_cs.h
index f20b4f584861..533fb6ed2ae4 100644
--- a/fs/fuse/kio/pcs/pcs_cs.h
+++ b/fs/fuse/kio/pcs/pcs_cs.h
@@ -145,6 +145,7 @@ void cs_increment_in_flight(struct pcs_cs *cs, unsigned int to_add);
 void cs_decrement_in_flight(struct pcs_cs *cs, unsigned int to_dec);
 void cs_cwnd_use_or_lose(struct pcs_cs *cs);
 unsigned int cs_get_avg_in_flight(struct pcs_cs *cs);
+unsigned int cs_get_avg_in_flight_lock(struct pcs_cs *cs);
 
 void pcs_csset_init(struct pcs_cs_set *css);
 void pcs_csset_fini(struct pcs_cs_set *css);
-- 
2.15.1



More information about the Devel mailing list