lxcfs/0014-fix-proc-diskstats-show-in-container.patch

129 lines
4.3 KiB
Diff
Raw Normal View History

From 6710b6d777e4e25b1ce78a4cb9736e7e65f15aa2 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Tue, 30 Nov 2021 15:26:26 +0800
Subject: [PATCH 14/17] fix-proc-diskstats-show-in-container
---
src/proc_fuse.c | 98 +++++++++++++++++++++++++++++--------------------
1 file changed, 59 insertions(+), 39 deletions(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 72f6de6..0d5ba89 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -792,7 +792,64 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
if (stats.read || stats.write || stats.read_merged || stats.write_merged ||
stats.read_sectors || stats.write_sectors || stats.read_ticks ||
stats.write_ticks || stats.ios_pgr || stats.total_ticks || stats.rq_ticks ||
- stats.discard_merged || stats.discard_sectors || stats.discard_ticks)
+ stats.discard_merged || stats.discard_sectors || stats.discard_ticks) {
+ if (need_record_diskstats(stats.major, stats.minor)) {
+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+ &stats.major,
+ &stats.minor,
+ tmp_dev_name,
+ &stats.read,
+ &stats.read_merged,
+ &stats.read_sectors,
+ &stats.read_ticks,
+ &stats.write,
+ &stats.write_merged,
+ &stats.write_sectors,
+ &stats.write_ticks,
+ &stats.ios_pgr,
+ &stats.total_ticks,
+ &stats.rq_ticks,
+ &stats.discard_merged,
+ &stats.discard_sectors,
+ &stats.discard_ticks);
+ }
+ snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+ stats.major,
+ stats.minor,
+ stats.dev_name,
+ stats.read,
+ stats.read_merged,
+ stats.read_sectors,
+ stats.read_ticks,
+ stats.write,
+ stats.write_merged,
+ stats.write_sectors,
+ stats.write_ticks,
+ stats.ios_pgr,
+ stats.total_ticks,
+ stats.rq_ticks,
+ stats.discard_merged,
+ stats.discard_sectors,
+ stats.discard_ticks);
+ } else if (need_record_diskstats(stats.major, stats.minor)) {
+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+ &stats.major,
+ &stats.minor,
+ tmp_dev_name,
+ &stats.read,
+ &stats.read_merged,
+ &stats.read_sectors,
+ &stats.read_ticks,
+ &stats.write,
+ &stats.write_merged,
+ &stats.write_sectors,
+ &stats.write_ticks,
+ &stats.ios_pgr,
+ &stats.total_ticks,
+ &stats.rq_ticks,
+ &stats.discard_merged,
+ &stats.discard_sectors,
+ &stats.discard_ticks);
snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
stats.major,
stats.minor,
@@ -811,44 +868,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
stats.discard_merged,
stats.discard_sectors,
stats.discard_ticks);
- else if (need_record_diskstats(stats.major, stats.minor)) {
- sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
- &stats.major,
- &stats.minor,
- tmp_dev_name,
- &stats.read,
- &stats.read_merged,
- &stats.read_sectors,
- &stats.read_ticks,
- &stats.write,
- &stats.write_merged,
- &stats.write_sectors,
- &stats.write_ticks,
- &stats.ios_pgr,
- &stats.total_ticks,
- &stats.rq_ticks,
- &stats.discard_merged,
- &stats.discard_sectors,
- &stats.discard_ticks);
- snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
- stats.major,
- stats.minor,
- stats.dev_name,
- stats.read,
- stats.read_merged,
- stats.read_sectors,
- stats.read_ticks,
- stats.write,
- stats.write_merged,
- stats.write_sectors,
- stats.write_ticks,
- stats.ios_pgr,
- stats.total_ticks,
- stats.rq_ticks,
- stats.discard_merged,
- stats.discard_sectors,
- stats.discard_ticks);
- } else {
+ } else {
continue;
}
--
2.27.0