All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux] blk-cgroup: always terminate io.stat lines
@ 2022-01-10 10:37 ` Wolfgang Bumiller
  0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Bumiller @ 2022-01-10 10:37 UTC (permalink / raw)
  To: linux-block; +Cc: cgroups, Jens Axboe, Tejun Heo, Christoph Hellwig

With the removal of seq_get_buf in blkcg_print_one_stat, we
cannot make adding the newline conditional on there being
relevant stats because the name has already been written
unconditionally.
Otherwise we may end up with multiple device names in one
line which is confusing and doesn't follow the nested-keyed
file format.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fixes: 252c651a4c85 ("blk-cgroup: stop using seq_get_buf")
---
I also switched to `seq_puts` as suggested by `checkpatch.pl`

This seemed like the simplest approach, so I thought I'd
send a patch.

On my physical machine, creating a new thin lv and starting
a container on it created lines such as

    253:10 253:5 rbytes=0 wbytes=0 rios=0 wios=1 dbytes=0 dios=0
    ^~~~~~ ^~~~~

This *looks* like the devices might just happen to have the
same stats, but that's not the case (and doesn't follow the
documented format).

With this patch this becomes:

    253:10
    253:5 rbytes=0 wbytes=0 rios=0 wios=1 dbytes=0 dios=0

Let me know if you prefer a different solution. I'm not sure
a temporary buffer that can be discarded would be much
better than the previous seq_get_buf() version. Otherwise
we'd need to change the `pd_stat_fn` interface to collect
the data separately and do the formatting afterwards I
suppose?

 block/blk-cgroup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 663aabfeba18..e3e3e826dff7 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -937,8 +937,7 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)
 			has_stats = true;
 	}
 
-	if (has_stats)
-		seq_printf(s, "\n");
+	seq_puts(s, "\n");
 }
 
 static int blkcg_print_stat(struct seq_file *sf, void *v)
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-10 13:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 10:37 [PATCH linux] blk-cgroup: always terminate io.stat lines Wolfgang Bumiller
2022-01-10 10:37 ` Wolfgang Bumiller
2022-01-10 13:12 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.