diff options
author | Tejun Heo <tj@kernel.org> | 2019-06-13 15:30:38 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-07-26 09:11:11 +0200 |
commit | d483ea783a93f5cd59c93aa0314fde7267a0968f (patch) | |
tree | e40b3b44db91e908230e169d1200aa225c7a0e41 /block | |
parent | c600458bb020e592ad29bf2449957e0a43f026b2 (diff) | |
download | linux-stable-d483ea783a93f5cd59c93aa0314fde7267a0968f.tar.gz linux-stable-d483ea783a93f5cd59c93aa0314fde7267a0968f.tar.bz2 linux-stable-d483ea783a93f5cd59c93aa0314fde7267a0968f.zip |
blkcg: update blkcg_print_stat() to handle larger outputs
commit f539da82f2158916e154d206054e0efd5df7ab61 upstream.
Depending on the number of devices, blkcg stats can go over the
default seqfile buf size. seqfile normally retries with a larger
buffer but since the ->pd_stat() addition, blkcg_print_stat() doesn't
tell seqfile that overflow has happened and the output gets printed
truncated. Fix it by calling seq_commit() w/ -1 on possible
overflows.
Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 903d23f0a354 ("blk-cgroup: allow controllers to output their own stats")
Cc: stable@vger.kernel.org # v4.19+
Cc: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-cgroup.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 1f7127b03490..e4715b35d42c 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1006,8 +1006,12 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) } next: if (has_stats) { - off += scnprintf(buf+off, size-off, "\n"); - seq_commit(sf, off); + if (off < size - 1) { + off += scnprintf(buf+off, size-off, "\n"); + seq_commit(sf, off); + } else { + seq_commit(sf, -1); + } } } |