1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Mon, 10 Jan 2022 16:34:57 +0100
4 Subject: [PATCH] blk-cgroup: always terminate io.stat lines
6 With the removal of seq_get_buf in blkcg_print_one_stat, we
7 cannot make adding the newline conditional on there being
8 relevant stats because the name was already written out
10 Otherwise we may end up with multiple device names in one
11 line which is confusing and doesn't follow the nested-keyed
14 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
15 Fixes: 252c651a4c85 ("blk-cgroup: stop using seq_get_buf")
16 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 block/blk-cgroup.c | 9 ++-------
19 block/blk-iocost.c | 5 ++---
20 block/blk-iolatency.c | 6 ++----
21 include/linux/blk-cgroup.h | 2 +-
22 4 files changed, 7 insertions(+), 15 deletions(-)
24 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
25 index 0eec59e4df65..38c62a44905a 100644
26 --- a/block/blk-cgroup.c
27 +++ b/block/blk-cgroup.c
28 @@ -887,7 +887,6 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)
30 struct blkg_iostat_set *bis = &blkg->iostat;
31 u64 rbytes, wbytes, rios, wios, dbytes, dios;
32 - bool has_stats = false;
36 @@ -913,14 +912,12 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)
37 } while (u64_stats_fetch_retry(&bis->sync, seq));
39 if (rbytes || wbytes || rios || wios) {
41 seq_printf(s, "rbytes=%llu wbytes=%llu rios=%llu wios=%llu dbytes=%llu dios=%llu",
42 rbytes, wbytes, rios, wios,
46 if (blkcg_debug_stats && atomic_read(&blkg->use_delay)) {
48 seq_printf(s, " use_delay=%d delay_nsec=%llu",
49 atomic_read(&blkg->use_delay),
50 atomic64_read(&blkg->delay_nsec));
51 @@ -932,12 +929,10 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)
52 if (!blkg->pd[i] || !pol->pd_stat_fn)
55 - if (pol->pd_stat_fn(blkg->pd[i], s))
57 + pol->pd_stat_fn(blkg->pd[i], s);
61 - seq_printf(s, "\n");
65 static int blkcg_print_stat(struct seq_file *sf, void *v)
66 diff --git a/block/blk-iocost.c b/block/blk-iocost.c
67 index eb7b0d6bd11f..381c28f9561e 100644
68 --- a/block/blk-iocost.c
69 +++ b/block/blk-iocost.c
70 @@ -2995,13 +2995,13 @@ static void ioc_pd_free(struct blkg_policy_data *pd)
74 -static bool ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)
75 +static void ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)
77 struct ioc_gq *iocg = pd_to_iocg(pd);
78 struct ioc *ioc = iocg->ioc;
84 if (iocg->level == 0) {
85 unsigned vp10k = DIV64_U64_ROUND_CLOSEST(
86 @@ -3017,7 +3017,6 @@ static bool ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)
87 iocg->last_stat.wait_us,
88 iocg->last_stat.indebt_us,
89 iocg->last_stat.indelay_us);
93 static u64 ioc_weight_prfill(struct seq_file *sf, struct blkg_policy_data *pd,
94 diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
95 index c0545f9da549..9e0c83223e04 100644
96 --- a/block/blk-iolatency.c
97 +++ b/block/blk-iolatency.c
98 @@ -913,17 +913,16 @@ static bool iolatency_ssd_stat(struct iolatency_grp *iolat, struct seq_file *s)
99 (unsigned long long)stat.ps.missed,
100 (unsigned long long)stat.ps.total,
101 iolat->rq_depth.max_depth);
105 -static bool iolatency_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)
106 +static void iolatency_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)
108 struct iolatency_grp *iolat = pd_to_lat(pd);
109 unsigned long long avg_lat;
110 unsigned long long cur_win;
112 if (!blkcg_debug_stats)
117 return iolatency_ssd_stat(iolat, s);
118 @@ -936,7 +935,6 @@ static bool iolatency_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)
120 seq_printf(s, " depth=%u avg_lat=%llu win=%llu",
121 iolat->rq_depth.max_depth, avg_lat, cur_win);
125 static struct blkg_policy_data *iolatency_pd_alloc(gfp_t gfp,
126 diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
127 index b4de2010fba5..132e05ed6935 100644
128 --- a/include/linux/blk-cgroup.h
129 +++ b/include/linux/blk-cgroup.h
130 @@ -152,7 +152,7 @@ typedef void (blkcg_pol_online_pd_fn)(struct blkg_policy_data *pd);
131 typedef void (blkcg_pol_offline_pd_fn)(struct blkg_policy_data *pd);
132 typedef void (blkcg_pol_free_pd_fn)(struct blkg_policy_data *pd);
133 typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkg_policy_data *pd);
134 -typedef bool (blkcg_pol_stat_pd_fn)(struct blkg_policy_data *pd,
135 +typedef void (blkcg_pol_stat_pd_fn)(struct blkg_policy_data *pd,
138 struct blkcg_policy {