proc: fix /proc/diskstats output format
Reference:https://github.com/lxc/lxcfs/pull/590 Signed-off-by: yangjiaqi <yangjiaqi16@huawei.com>
This commit is contained in:
parent
c4b6dca0f6
commit
754e051ea0
91
0023-proc-fix-proc-diskstats-output-format.patch
Normal file
91
0023-proc-fix-proc-diskstats-output-format.patch
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
From d928f8d073f87fdacaf9e93b616f5b84695036e3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: yangjiaqi <yangjiaqi16@huawei.com>
|
||||||
|
Date: Wed, 22 Mar 2023 15:31:34 +0800
|
||||||
|
Subject: [PATCH] proc: fix /proc/diskstats output format
|
||||||
|
|
||||||
|
---
|
||||||
|
src/proc_fuse.c | 24 +++++++++++++++++++-----
|
||||||
|
1 file changed, 19 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||||
|
index fe81cad..ce22974 100644
|
||||||
|
--- a/src/proc_fuse.c
|
||||||
|
+++ b/src/proc_fuse.c
|
||||||
|
@@ -784,10 +784,10 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||||
|
memset(lbuf, 0, 256);
|
||||||
|
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.write_ticks || stats.ios_pgr || stats.total_ticks || stats.rq_ticks || stats.discard ||
|
||||||
|
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",
|
||||||
|
+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
|
||||||
|
&stats.major,
|
||||||
|
&stats.minor,
|
||||||
|
tmp_dev_name,
|
||||||
|
@@ -802,11 +802,12 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||||
|
&stats.ios_pgr,
|
||||||
|
&stats.total_ticks,
|
||||||
|
&stats.rq_ticks,
|
||||||
|
+ &stats.discard,
|
||||||
|
&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",
|
||||||
|
+ ret = snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
|
||||||
|
stats.major,
|
||||||
|
stats.minor,
|
||||||
|
stats.dev_name,
|
||||||
|
@@ -821,11 +822,17 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||||
|
stats.ios_pgr,
|
||||||
|
stats.total_ticks,
|
||||||
|
stats.rq_ticks,
|
||||||
|
+ stats.discard,
|
||||||
|
stats.discard_merged,
|
||||||
|
stats.discard_sectors,
|
||||||
|
stats.discard_ticks);
|
||||||
|
+ if(ret >= 256) {
|
||||||
|
+ lxcfs_error("Insufficient buffer for %u:%u %s diskstats",
|
||||||
|
+ stats.major, stats.minor, stats.dev_name);
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
} 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",
|
||||||
|
+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
|
||||||
|
&stats.major,
|
||||||
|
&stats.minor,
|
||||||
|
tmp_dev_name,
|
||||||
|
@@ -840,10 +847,11 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||||
|
&stats.ios_pgr,
|
||||||
|
&stats.total_ticks,
|
||||||
|
&stats.rq_ticks,
|
||||||
|
+ &stats.discard,
|
||||||
|
&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",
|
||||||
|
+ ret = snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
|
||||||
|
stats.major,
|
||||||
|
stats.minor,
|
||||||
|
stats.dev_name,
|
||||||
|
@@ -858,9 +866,15 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||||
|
stats.ios_pgr,
|
||||||
|
stats.total_ticks,
|
||||||
|
stats.rq_ticks,
|
||||||
|
+ stats.discard,
|
||||||
|
stats.discard_merged,
|
||||||
|
stats.discard_sectors,
|
||||||
|
stats.discard_ticks);
|
||||||
|
+ if(ret >= 256) {
|
||||||
|
+ lxcfs_error("Insufficient buffer for %u:%u %s diskstats",
|
||||||
|
+ stats.major, stats.minor, stats.dev_name);
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@ -4,7 +4,7 @@
|
|||||||
#Basic Information
|
#Basic Information
|
||||||
Name: lxcfs
|
Name: lxcfs
|
||||||
Version: 4.0.11
|
Version: 4.0.11
|
||||||
Release: 7
|
Release: 8
|
||||||
Summary: FUSE filesystem for LXC
|
Summary: FUSE filesystem for LXC
|
||||||
License: LGPL 2.1+
|
License: LGPL 2.1+
|
||||||
URL: http://linuxcontainers.org
|
URL: http://linuxcontainers.org
|
||||||
@ -32,6 +32,7 @@ Patch9019: 0019-fix-dev-read-memory-leak-in-container.patch
|
|||||||
Patch9020: 0020-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch
|
Patch9020: 0020-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch
|
||||||
Patch9021: 0021-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch
|
Patch9021: 0021-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch
|
||||||
Patch9022: 0022-cpuview-fix-possible-use-after-free-in-find_proc_sta.patch
|
Patch9022: 0022-cpuview-fix-possible-use-after-free-in-find_proc_sta.patch
|
||||||
|
Patch9023: 0023-proc-fix-proc-diskstats-output-format.patch
|
||||||
|
|
||||||
#Dependency
|
#Dependency
|
||||||
BuildRequires: autoconf automake libtool help2man
|
BuildRequires: autoconf automake libtool help2man
|
||||||
@ -93,6 +94,12 @@ fi
|
|||||||
%{_unitdir}/*
|
%{_unitdir}/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Mar 22 2023 yangjiaqi <yangjiaqi16@huawei.com> - 4.0.11-8
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:fix /proc/diskstats output format
|
||||||
|
|
||||||
* Wed Mar 22 2023 yangjiaqi <yangjiaqi16@huawei.com> - 4.0.11-7
|
* Wed Mar 22 2023 yangjiaqi <yangjiaqi16@huawei.com> - 4.0.11-7
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- CVE:NA
|
- CVE:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user