代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/lxcfs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 0dded445efa7b53886081beab5b74facf0378287 Mon Sep 17 00:00:00 2001
From: vegbir <[email protected]>
Date: Thu, 27 Jul 2023 08:15:49 +0000
Subject: [PATCH 08/15] diskstats support devicemapper device
Signed-off-by: vegbir <[email protected]>
---
src/proc_fuse.c | 133 ++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 117 insertions(+), 16 deletions(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index e69e867..1f732ff 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -638,6 +638,15 @@ void free_devinfo_list(struct devinfo *ptr)
}
}
+static bool need_record_diskstats(unsigned int major, unsigned int minor)
+{
+ // support device which major is 253 and 252
+ if (major == 253 || major == 252) {
+ return true;
+ }
+ return false;
+}
+
struct lxcfs_diskstats {
unsigned int major; /* 1 - major number */
unsigned int minor; /* 2 - minor mumber */
@@ -680,6 +689,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
size_t linelen = 0, total_len = 0;
int i = 0;
int ret;
+ char tmp_dev_name[72];
if (offset) {
size_t left;
@@ -747,6 +757,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
while (getline(&line, &linelen, f) != -1) {
ssize_t l;
char lbuf[256];
+ bool match = false;
memset(stats.dev_name, 0, sizeof(stats.dev_name));
i = sscanf(line, "%u %u %71s", &stats.major, &stats.minor, stats.dev_name);
@@ -757,9 +768,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
if (stats.major == ptr->major && stats.minor == ptr->minor) {
snprintf(stats.dev_name, sizeof(stats.dev_name), "%s", ptr->name);
stats.dev_name[71] = '\0';
+ match = true;
}
}
+ if (!match) {
+ continue;
+ }
+
get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Read", &stats.read);
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);
@@ -801,26 +817,111 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
stats.read_sectors || stats.write_sectors || stats.read_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 %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,
+ &stats.discard_merged,
+ &stats.discard_sectors,
+ &stats.discard_ticks);
+ }
+ ret = strnprintf(
+ lbuf,
+ sizeof(lbuf),
+ "%u %u" /* major, minor */
+ " %s" /* dev_name */
+ " %" PRIu64 /* read */
+ " %" PRIu64 /* read_merged */
+ " %" PRIu64 /* read_sectors */
+ " %" PRIu64 /* read_ticks */
+ " %" PRIu64 /* write */
+ " %" PRIu64 /* write_merged */
+ " %" PRIu64 /* write_sectors */
+ " %" PRIu64 /* write_ticks */
+ " %" PRIu64 /* ios_pgr */
+ " %" PRIu64 /* total_ticks */
+ " %" PRIu64 /* rq_ticks */
+ " %" PRIu64 /* discard */
+ " %" PRIu64 /* discard_merged */
+ " %" PRIu64 /* discard_sectors */
+ " %" PRIu64 /* discard_ticks */
+ "\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,
+ stats.discard_merged,
+ stats.discard_sectors,
+ stats.discard_ticks);
+ if (ret < 0) {
+ 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 %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,
+ &stats.discard_merged,
+ &stats.discard_sectors,
+ &stats.discard_ticks);
ret = strnprintf(
lbuf,
sizeof(lbuf),
"%u %u" /* major, minor */
- " %s" /* dev_name */
- " %" PRIu64 /* read */
- " %" PRIu64 /* read_merged */
- " %" PRIu64 /* read_sectors */
- " %" PRIu64 /* read_ticks */
- " %" PRIu64 /* write */
- " %" PRIu64 /* write_merged */
- " %" PRIu64 /* write_sectors */
- " %" PRIu64 /* write_ticks */
- " %" PRIu64 /* ios_pgr */
- " %" PRIu64 /* total_ticks */
- " %" PRIu64 /* rq_ticks */
- " %" PRIu64 /* discard */
- " %" PRIu64 /* discard_merged */
- " %" PRIu64 /* discard_sectors */
- " %" PRIu64 /* discard_ticks */
+ " %s" /* dev_name */
+ " %" PRIu64 /* read */
+ " %" PRIu64 /* read_merged */
+ " %" PRIu64 /* read_sectors */
+ " %" PRIu64 /* read_ticks */
+ " %" PRIu64 /* write */
+ " %" PRIu64 /* write_merged */
+ " %" PRIu64 /* write_sectors */
+ " %" PRIu64 /* write_ticks */
+ " %" PRIu64 /* ios_pgr */
+ " %" PRIu64 /* total_ticks */
+ " %" PRIu64 /* rq_ticks */
+ " %" PRIu64 /* discard */
+ " %" PRIu64 /* discard_merged */
+ " %" PRIu64 /* discard_sectors */
+ " %" PRIu64 /* discard_ticks */
"\n",
stats.major,
stats.minor,
--
2.41.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。