summaryrefslogtreecommitdiff
path: root/block/blk-cgroup.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-08-10 17:26:23 +0200
committerJens Axboe <axboe@kernel.dk>2021-08-16 10:53:01 -0600
commit252c651a4c854b328445a536bd1892e999103fca (patch)
tree1b04a2a2de7f4a9383f71514ee6cf61550e08937 /block/blk-cgroup.c
parent49cb5168a7c6abf9835f9acdce6263bc2deefeb6 (diff)
blk-cgroup: stop using seq_get_buf
seq_get_buf is a crutch that undoes all the memory safety of the seq_file interface. Use the normal seq_printf interfaces instead. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20210810152623.1796144-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r--block/blk-cgroup.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 52aa0540ccaf..b8ec47dcce42 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -877,8 +877,6 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)
bool has_stats = false;
const char *dname;
unsigned seq;
- char *buf;
- size_t size = seq_get_buf(s, &buf), off = 0;
int i;
if (!blkg->online)
@@ -888,13 +886,7 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)
if (!dname)
return;
- /*
- * Hooray string manipulation, count is the size written NOT
- * INCLUDING THE \0, so size is now count+1 less than what we
- * had before, but we want to start writing the next bit from
- * the \0 so we only add count to buf.
- */
- off += scnprintf(buf+off, size-off, "%s ", dname);
+ seq_printf(s, "%s ", dname);
do {
seq = u64_stats_fetch_begin(&bis->sync);
@@ -909,40 +901,30 @@ static void blkcg_print_one_stat(struct blkcg_gq *blkg, struct seq_file *s)
if (rbytes || wbytes || rios || wios) {
has_stats = true;
- off += scnprintf(buf+off, size-off,
- "rbytes=%llu wbytes=%llu rios=%llu wios=%llu dbytes=%llu dios=%llu",
+ seq_printf(s, "rbytes=%llu wbytes=%llu rios=%llu wios=%llu dbytes=%llu dios=%llu",
rbytes, wbytes, rios, wios,
dbytes, dios);
}
if (blkcg_debug_stats && atomic_read(&blkg->use_delay)) {
has_stats = true;
- off += scnprintf(buf+off, size-off, " use_delay=%d delay_nsec=%llu",
+ seq_printf(s, " use_delay=%d delay_nsec=%llu",
atomic_read(&blkg->use_delay),
atomic64_read(&blkg->delay_nsec));
}
for (i = 0; i < BLKCG_MAX_POLS; i++) {
struct blkcg_policy *pol = blkcg_policy[i];
- size_t written;
if (!blkg->pd[i] || !pol->pd_stat_fn)
continue;
- written = pol->pd_stat_fn(blkg->pd[i], buf+off, size-off);
- if (written)
+ if (pol->pd_stat_fn(blkg->pd[i], s))
has_stats = true;
- off += written;
}
- if (has_stats) {
- if (off < size - 1) {
- off += scnprintf(buf+off, size-off, "\n");
- seq_commit(s, off);
- } else {
- seq_commit(s, -1);
- }
- }
+ if (has_stats)
+ seq_printf(s, "\n");
}
static int blkcg_print_stat(struct seq_file *sf, void *v)