代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/lxcfs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 60eefa396251acebd02f06538ccee1081dcdcd0d Mon Sep 17 00:00:00 2001
From: vegbir <[email protected]>
Date: Thu, 27 Jul 2023 09:10:52 +0000
Subject: [PATCH 12/15] lxcfs adapt 4.18 kernel
Signed-off-by: vegbir <[email protected]>
---
src/proc_fuse.c | 69 +++++++++++++++++++++----------------------------
1 file changed, 30 insertions(+), 39 deletions(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 0dbbefe..392115c 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -686,8 +686,8 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
struct devinfo *container_devinfo = NULL, *ptr = NULL;
struct lxcfs_diskstats stats = {};
/* helper fields */
- uint64_t read_service_time, write_service_time, discard_service_time, read_wait_time,
- write_wait_time, discard_wait_time;
+ uint64_t read_service_time = 0, write_service_time = 0, discard_service_time = 0, read_wait_time = 0,
+ write_wait_time = 0, discard_wait_time = 0, total_ticks = 0;
char *cache = d->buf;
size_t cache_size = d->buflen;
size_t linelen = 0, total_len = 0;
@@ -726,29 +726,15 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
return read_file_fuse("/proc/diskstats", buf, size, d);
}
- ret = cgroup_ops->get_io_merged(cgroup_ops, cg, &io_merged_str);
- if (ret < 0) {
- if (ret == -EOPNOTSUPP)
- return read_file_fuse("/proc/diskstats", buf, size, d);
- }
-
ret = cgroup_ops->get_io_service_bytes(cgroup_ops, cg, &io_service_bytes_str);
if (ret < 0) {
if (ret == -EOPNOTSUPP)
return read_file_fuse("/proc/diskstats", buf, size, d);
}
- ret = cgroup_ops->get_io_wait_time(cgroup_ops, cg, &io_wait_time_str);
- if (ret < 0) {
- if (ret == -EOPNOTSUPP)
- return read_file_fuse("/proc/diskstats", buf, size, d);
- }
-
- ret = cgroup_ops->get_io_service_time(cgroup_ops, cg, &io_service_time_str);
- if (ret < 0) {
- if (ret == -EOPNOTSUPP)
- return read_file_fuse("/proc/diskstats", buf, size, d);
- }
+ cgroup_ops->get_io_merged(cgroup_ops, cg, &io_merged_str);
+ cgroup_ops->get_io_wait_time(cgroup_ops, cg, &io_wait_time_str);
+ cgroup_ops->get_io_service_time(cgroup_ops, cg, &io_service_time_str);
f = fopen_cached("/proc/diskstats", "re", &fopen_cache);
if (!f)
@@ -784,9 +770,11 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Write", &stats.write);
get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Discard", &stats.discard);
- get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Read", &stats.read_merged);
- get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Write", &stats.write_merged);
- get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Discard", &stats.discard_merged);
+ if (io_merged_str != NULL) {
+ get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Read", &stats.read_merged);
+ get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Write", &stats.write_merged);
+ get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Discard", &stats.discard_merged);
+ }
get_blkio_io_value(io_service_bytes_str, stats.major, stats.minor, "Read", &stats.read_sectors);
stats.read_sectors = stats.read_sectors / 512;
@@ -795,26 +783,29 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
get_blkio_io_value(io_service_bytes_str, stats.major, stats.minor, "Discard", &stats.discard_sectors);
stats.discard_sectors = stats.discard_sectors / 512;
- get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Read", &read_service_time);
- read_service_time = read_service_time / 1000000;
- get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Read", &read_wait_time);
- read_wait_time = read_wait_time / 1000000;
- stats.read_ticks = read_service_time + read_wait_time;
+ if (io_service_time_str != NULL) {
+ get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Read", &read_service_time);
+ read_service_time = read_service_time / 1000000;
+ get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Write", &write_service_time);
+ write_service_time = write_service_time / 1000000;
+ get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Discard", &discard_service_time);
+ discard_service_time = discard_service_time / 1000000;
+ get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Total", &total_ticks);
+ }
- get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Write", &write_service_time);
- write_service_time = write_service_time / 1000000;
- get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Write", &write_wait_time);
- write_wait_time = write_wait_time / 1000000;
- stats.write_ticks = write_service_time + write_wait_time;
+ if (io_wait_time_str != NULL) {
+ get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Read", &read_wait_time);
+ read_wait_time = read_wait_time / 1000000;
+ get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Write", &write_wait_time);
+ write_wait_time = write_wait_time / 1000000;
+ get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Discard", &discard_wait_time);
+ discard_wait_time = discard_wait_time / 1000000;
+ }
- get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Discard", &discard_service_time);
- discard_service_time = discard_service_time / 1000000;
- get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Discard", &discard_wait_time);
- discard_wait_time = discard_wait_time / 1000000;
+ stats.read_ticks = read_service_time + read_wait_time;
+ stats.write_ticks = write_service_time + write_wait_time;
stats.discard_ticks = discard_service_time + discard_wait_time;
-
- get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Total", &stats.total_ticks);
- stats.total_ticks = stats.total_ticks / 1000000;
+ stats.total_ticks = total_ticks / 1000000;
memset(lbuf, 0, sizeof(lbuf));
if (stats.read || stats.write || stats.read_merged || stats.write_merged ||
--
2.41.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。