!42 [sync] PR-40: update to 4.0.11

Merge pull request !42 from openeuler-sync-bot/sync-pr40-master-to-master
This commit is contained in:
openeuler-ci-bot 2021-12-17 02:14:21 +00:00 committed by Gitee
commit 3a61ee4ddc
20 changed files with 610 additions and 245 deletions

View File

@ -1,5 +1,14 @@
From fdc8835afc38ba10f2d1ef97d19a631e58552a27 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 11:03:32 +0800
Subject: [PATCH 01/17] systemd
---
config/init/systemd/lxcfs.service.in | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/config/init/systemd/lxcfs.service.in b/config/init/systemd/lxcfs.service.in diff --git a/config/init/systemd/lxcfs.service.in b/config/init/systemd/lxcfs.service.in
index 9cd4e59..2421a54 100644 index 9cd4e59..3d763c6 100644
--- a/config/init/systemd/lxcfs.service.in --- a/config/init/systemd/lxcfs.service.in
+++ b/config/init/systemd/lxcfs.service.in +++ b/config/init/systemd/lxcfs.service.in
@@ -5,12 +5,16 @@ Before=lxc.service @@ -5,12 +5,16 @@ Before=lxc.service
@ -22,3 +31,6 @@ index 9cd4e59..2421a54 100644
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
--
2.27.0

View File

@ -1,3 +1,13 @@
From 246b0b52ad671fc37a2bc289701260e5128ecd1f Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 11:11:05 +0800
Subject: [PATCH 02/17] remove-sysvinit-upstart
---
config/init/Makefile.am | 2 +-
configure.ac | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/config/init/Makefile.am b/config/init/Makefile.am diff --git a/config/init/Makefile.am b/config/init/Makefile.am
index e2ffe28..3439c97 100644 index e2ffe28..3439c97 100644
--- a/config/init/Makefile.am --- a/config/init/Makefile.am
@ -6,10 +16,10 @@ index e2ffe28..3439c97 100644
-SUBDIRS = systemd sysvinit upstart -SUBDIRS = systemd sysvinit upstart
+SUBDIRS = systemd +SUBDIRS = systemd
diff --git a/configure.ac b/configure.ac diff --git a/configure.ac b/configure.ac
index 3dc4571..5653dfd 100644 index ccea4ec..d15ac50 100644
--- a/configure.ac --- a/configure.ac
+++ b/configure.ac +++ b/configure.ac
@@ -44,8 +44,6 @@ AC_CONFIG_FILES([ @@ -45,8 +45,6 @@ AC_CONFIG_FILES([
config/init/Makefile config/init/Makefile
config/init/systemd/Makefile config/init/systemd/Makefile
config/init/systemd/lxcfs.service config/init/systemd/lxcfs.service
@ -18,3 +28,6 @@ index 3dc4571..5653dfd 100644
doc/Makefile doc/Makefile
--
2.27.0

View File

@ -1,16 +1,25 @@
From d6234626d7240952da42902b7ef513d56d5a18a7 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 11:32:37 +0800
Subject: [PATCH 03/17] show-dev-name-in-container
---
src/proc_fuse.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 143 insertions(+), 2 deletions(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index a99162c..b4f4129 100644 index 94168c9..7372a36 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -37,6 +37,7 @@ @@ -27,6 +27,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
+#include <sys/sysmacros.h> +#include <sys/sysmacros.h>
#include <sys/vfs.h> #include <sys/vfs.h>
#include "bindings.h" #include "proc_fuse.h"
@@ -374,6 +375,132 @@ static void get_blkio_io_value(char *str, unsigned major, unsigned minor, @@ -448,6 +449,132 @@ static void get_blkio_io_value(char *str, unsigned major, unsigned minor,
} }
} }
@ -120,8 +129,8 @@ index a99162c..b4f4129 100644
+ end->minor = minor(dev_num); + end->minor = minor(dev_num);
+ } + }
+err: +err:
+ if (stream) + if (stream)
+ fclose(stream); + fclose(stream);
+ if (child_pid > 0) + if (child_pid > 0)
+ wait_for_pid(child_pid); + wait_for_pid(child_pid);
+ return head; + return head;
@ -140,18 +149,18 @@ index a99162c..b4f4129 100644
+ } + }
+} +}
+ +
static int proc_diskstats_read(char *buf, size_t size, off_t offset, struct lxcfs_diskstats {
struct fuse_file_info *fi) unsigned int major; /* 1 - major number */
{ unsigned int minor; /* 2 - minor mumber */
@@ -385,6 +512,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -480,6 +607,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
__do_fclose FILE *f = NULL; __do_fclose FILE *f = NULL;
struct fuse_context *fc = fuse_get_context(); struct fuse_context *fc = fuse_get_context();
struct file_info *d = INTTYPE_TO_PTR(fi->fh); struct file_info *d = INTTYPE_TO_PTR(fi->fh);
+ struct devinfo *container_devinfo = NULL, *ptr = NULL; + struct devinfo *container_devinfo = NULL, *ptr = NULL;
uint64_t read = 0, write = 0; struct lxcfs_diskstats stats = {};
uint64_t read_merged = 0, write_merged = 0; /* helper fields */
uint64_t read_sectors = 0, write_sectors = 0; uint64_t read_service_time, write_service_time, discard_service_time, read_wait_time,
@@ -458,13 +586,22 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -549,13 +677,22 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
if (!f) if (!f)
return 0; return 0;
@ -161,20 +170,20 @@ index a99162c..b4f4129 100644
ssize_t l; ssize_t l;
char lbuf[256]; char lbuf[256];
+ memset(dev_name, 0, sizeof(dev_name)); + memset(stats.dev_name, 0, sizeof(stats.dev_name));
i = sscanf(line, "%u %u %71s", &major, &minor, dev_name); i = sscanf(line, "%u %u %71s", &stats.major, &stats.minor, stats.dev_name);
if (i != 3) if (i != 3)
continue; continue;
+ for (ptr = container_devinfo; ptr != NULL; ptr = ptr->next) { + for (ptr = container_devinfo; ptr != NULL; ptr = ptr->next) {
+ if (major == ptr->major && minor == ptr->minor) { + if (stats.major == ptr->major && stats.minor == ptr->minor) {
+ snprintf(dev_name, sizeof(dev_name), "%s", ptr->name); + snprintf(stats.dev_name, sizeof(stats.dev_name), "%s", ptr->name);
+ dev_name[71] = '\0'; + stats.dev_name[71] = '\0';
+ } + }
+ } + }
get_blkio_io_value(io_serviced_str, major, minor, "Read", &read); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Read", &stats.read);
get_blkio_io_value(io_serviced_str, major, minor, "Write", &write); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Write", &stats.write);
@@ -499,10 +636,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -620,10 +757,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
continue; continue;
l = snprintf(cache, cache_size, "%s", lbuf); l = snprintf(cache, cache_size, "%s", lbuf);
@ -182,12 +191,15 @@ index a99162c..b4f4129 100644
+ if (l < 0) { + if (l < 0) {
+ free_devinfo_list(container_devinfo); + free_devinfo_list(container_devinfo);
return log_error(0, "Failed to write cache"); return log_error(0, "Failed to write cache");
- if (l >= cache_size) - if ((size_t)l >= cache_size)
+ } + }
+ if (l >= cache_size) { + if ((size_t)l >= cache_size) {
+ free_devinfo_list(container_devinfo); + free_devinfo_list(container_devinfo);
return log_error(0, "Write to cache was truncated"); return log_error(0, "Write to cache was truncated");
+ } + }
cache += l; cache += l;
cache_size -= l; cache_size -= l;
--
2.27.0

View File

@ -1,8 +1,17 @@
From 1901edf2908551cf862f3deabf23acbda55d2dea Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 11:52:05 +0800
Subject: [PATCH 04/17] lxcfs-fix-cpuinfo-print
---
src/proc_cpuview.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/proc_cpuview.c b/src/proc_cpuview.c diff --git a/src/proc_cpuview.c b/src/proc_cpuview.c
index 7d6c0bd..3311c27 100644 index 9f6a55e..75006a6 100644
--- a/src/proc_cpuview.c --- a/src/proc_cpuview.c
+++ b/src/proc_cpuview.c +++ b/src/proc_cpuview.c
@@ -952,7 +952,17 @@ int proc_cpuinfo_read(char *buf, size_t size, off_t offset, @@ -970,7 +970,17 @@ int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
} }
if (am_printing) { if (am_printing) {
@ -20,4 +29,7 @@ index 7d6c0bd..3311c27 100644
+ } + }
if (l < 0) if (l < 0)
return log_error(0, "Failed to write cache"); return log_error(0, "Failed to write cache");
if (l >= cache_size) if ((size_t)l >= cache_size)
--
2.27.0

View File

@ -1,17 +1,26 @@
From a4f9b85c4ed1cc5128bcb6650cc8989310558769 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 12:06:31 +0800
Subject: [PATCH 05/17] fix-memory-leak
---
src/proc_fuse.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index b4f4129..6b503d6 100644 index 7372a36..bcd624d 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -224,6 +224,8 @@ static uint64_t get_min_memlimit(const char *cgroup, bool swap) @@ -278,6 +278,8 @@ static uint64_t get_min_memlimit(const char *cgroup, bool swap)
return log_error_errno(0, ENOMEM, "Failed to allocate memory"); return log_error_errno(0, ENOMEM, "Failed to allocate memory");
retlimit = get_memlimit(copy, swap); retlimit = get_memlimit(copy, swap);
+ if (retlimit == 0) + if (retlimit == 0)
+ return retlimit; + return 0;
while (strcmp(copy, "/") != 0) { /*
char *it = copy; * If the cgroup doesn't start with / (probably won't happen), dirname()
@@ -283,6 +285,8 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset, @@ -346,6 +348,8 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
prune_init_slice(cgroup); prune_init_slice(cgroup);
memlimit = get_min_memlimit(cgroup, false); memlimit = get_min_memlimit(cgroup, false);
@ -20,7 +29,7 @@ index b4f4129..6b503d6 100644
ret = cgroup_ops->get_memory_current(cgroup_ops, cgroup, &memusage_str); ret = cgroup_ops->get_memory_current(cgroup_ops, cgroup, &memusage_str);
if (ret < 0) if (ret < 0)
@@ -1209,6 +1213,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset, @@ -1329,6 +1333,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
return read_file_fuse("/proc/meminfo", buf, size, d); return read_file_fuse("/proc/meminfo", buf, size, d);
memlimit = get_min_memlimit(cgroup, false); memlimit = get_min_memlimit(cgroup, false);
@ -29,7 +38,7 @@ index b4f4129..6b503d6 100644
/* /*
* Following values are allowed to fail, because swapaccount might be * Following values are allowed to fail, because swapaccount might be
@@ -1237,9 +1243,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset, @@ -1361,9 +1367,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
memusage /= 1024; memusage /= 1024;
memlimit /= 1024; memlimit /= 1024;
@ -40,3 +49,6 @@ index b4f4129..6b503d6 100644
memset(lbuf, 0, 100); memset(lbuf, 0, 100);
if (startswith(line, "MemTotal:")) { if (startswith(line, "MemTotal:")) {
--
2.27.0

View File

@ -1,8 +1,19 @@
From 90fc9cd959bc6231eb3ddad5c74865d35e9f372d Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 14:12:57 +0800
Subject: [PATCH 06/17] fix-concurrency-problem
---
src/cgroups/cgroup_utils.c | 21 +++++++++++++--------
src/cgroups/cgroup_utils.h | 2 +-
src/proc_fuse.c | 3 +++
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/cgroups/cgroup_utils.c b/src/cgroups/cgroup_utils.c diff --git a/src/cgroups/cgroup_utils.c b/src/cgroups/cgroup_utils.c
index 078f864..c21e7bc 100644 index 83e4cbf..1224971 100644
--- a/src/cgroups/cgroup_utils.c --- a/src/cgroups/cgroup_utils.c
+++ b/src/cgroups/cgroup_utils.c +++ b/src/cgroups/cgroup_utils.c
@@ -521,23 +521,28 @@ static char *copy_to_eol(char *p) @@ -512,23 +512,28 @@ static char *copy_to_eol(char *p)
return sret; return sret;
} }
@ -37,7 +48,7 @@ index 078f864..c21e7bc 100644
} }
static inline void drop_trailing_newlines(char *s) static inline void drop_trailing_newlines(char *s)
@@ -561,7 +566,7 @@ char *read_file(const char *fnam) @@ -552,7 +557,7 @@ char *read_file(const char *fnam)
if (!f) if (!f)
return NULL; return NULL;
while ((linelen = getline(&line, &len, f)) != -1) { while ((linelen = getline(&line, &len, f)) != -1) {
@ -46,7 +57,7 @@ index 078f864..c21e7bc 100644
fulllen += linelen; fulllen += linelen;
} }
return buf; return buf;
@@ -691,7 +696,7 @@ char *readat_file(int dirfd, const char *path) @@ -682,7 +687,7 @@ char *readat_file(int dirfd, const char *path)
move_fd(fd); move_fd(fd);
while ((linelen = getline(&line, &len, f)) != -1) { while ((linelen = getline(&line, &len, f)) != -1) {
@ -56,10 +67,10 @@ index 078f864..c21e7bc 100644
} }
diff --git a/src/cgroups/cgroup_utils.h b/src/cgroups/cgroup_utils.h diff --git a/src/cgroups/cgroup_utils.h b/src/cgroups/cgroup_utils.h
index d1f5639..a40bdf5 100644 index f431686..d4c8598 100644
--- a/src/cgroups/cgroup_utils.h --- a/src/cgroups/cgroup_utils.h
+++ b/src/cgroups/cgroup_utils.h +++ b/src/cgroups/cgroup_utils.h
@@ -79,7 +79,7 @@ extern size_t strlcat(char *d, const char *s, size_t n); @@ -70,7 +70,7 @@ extern size_t strlcat(char *d, const char *s, size_t n);
#endif #endif
extern FILE *fopen_cloexec(const char *path, const char *mode); extern FILE *fopen_cloexec(const char *path, const char *mode);
@ -69,16 +80,19 @@ index d1f5639..a40bdf5 100644
extern char *readat_file(int fd, const char *path); extern char *readat_file(int fd, const char *path);
extern char *read_file_strip_newline(const char *fnam); extern char *read_file_strip_newline(const char *fnam);
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 6b503d6..334f6ea 100644 index bcd624d..0aaab71 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -1403,6 +1403,9 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size, @@ -1530,6 +1530,9 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size,
{ {
struct file_info *f = INTTYPE_TO_PTR(fi->fh); struct file_info *f = INTTYPE_TO_PTR(fi->fh);
+ if (!f->buf) + if (!f->buf)
+ return -EINVAL; + return -EINVAL;
+ +
switch (f->type) { switch (f->type) {
case LXC_TYPE_PROC_MEMINFO: case LXC_TYPE_PROC_MEMINFO:
if (liblxcfs_functional()) if (liblxcfs_functional())
--
2.27.0

View File

@ -1,8 +1,22 @@
From 7691f5c4a87d5fbc0f48fa96bba70b4ab9b52c65 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 14:45:12 +0800
Subject: [PATCH 07/17] set-null-after-free
---
src/cgroup_fuse.c | 26 +++++++++++++++++++++-----
src/cgroups/cgfsng.c | 5 ++++-
src/cgroups/cgroup_utils.c | 4 +++-
src/lxcfs.c | 4 ++++
src/memory_utils.h | 4 +++-
src/proc_loadavg.c | 5 ++++-
6 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/src/cgroup_fuse.c b/src/cgroup_fuse.c diff --git a/src/cgroup_fuse.c b/src/cgroup_fuse.c
index d4bdac1..76507f1 100644 index 5c22fd1..b396bbc 100644
--- a/src/cgroup_fuse.c --- a/src/cgroup_fuse.c
+++ b/src/cgroup_fuse.c +++ b/src/cgroup_fuse.c
@@ -187,7 +187,7 @@ static bool is_child_cgroup(const char *controller, const char *cgroup, @@ -179,7 +179,7 @@ static bool is_child_cgroup(const char *controller, const char *cgroup,
static bool caller_may_see_dir(pid_t pid, const char *contrl, const char *cg) static bool caller_may_see_dir(pid_t pid, const char *contrl, const char *cg)
{ {
bool answer = false; bool answer = false;
@ -11,7 +25,7 @@ index d4bdac1..76507f1 100644
size_t target_len, task_len; size_t target_len, task_len;
if (strcmp(cg, "/") == 0 || strcmp(cg, "./") == 0) if (strcmp(cg, "/") == 0 || strcmp(cg, "./") == 0)
@@ -229,6 +229,7 @@ static bool caller_may_see_dir(pid_t pid, const char *contrl, const char *cg) @@ -221,6 +221,7 @@ static bool caller_may_see_dir(pid_t pid, const char *contrl, const char *cg)
out: out:
free(c2); free(c2);
@ -19,7 +33,7 @@ index d4bdac1..76507f1 100644
return answer; return answer;
} }
@@ -268,8 +269,8 @@ static char *get_next_cgroup_dir(const char *taskcg, const char *querycg) @@ -260,8 +261,8 @@ static char *get_next_cgroup_dir(const char *taskcg, const char *querycg)
static bool caller_is_in_ancestor(pid_t pid, const char *contrl, const char *cg, char **nextcg) static bool caller_is_in_ancestor(pid_t pid, const char *contrl, const char *cg, char **nextcg)
{ {
bool answer = false; bool answer = false;
@ -30,7 +44,7 @@ index d4bdac1..76507f1 100644
c2 = get_pid_cgroup_handle_named(pid, contrl); c2 = get_pid_cgroup_handle_named(pid, contrl);
if (!c2) if (!c2)
@@ -299,6 +300,7 @@ static bool caller_is_in_ancestor(pid_t pid, const char *contrl, const char *cg, @@ -291,6 +292,7 @@ static bool caller_is_in_ancestor(pid_t pid, const char *contrl, const char *cg,
out: out:
free(c2); free(c2);
@ -38,7 +52,7 @@ index d4bdac1..76507f1 100644
return answer; return answer;
} }
@@ -618,6 +620,7 @@ __lxcfs_fuse_ops int cg_getattr(const char *path, struct stat *sb) @@ -612,6 +614,7 @@ __lxcfs_fuse_ops int cg_getattr(const char *path, struct stat *sb)
out: out:
free(cgdir); free(cgdir);
@ -46,7 +60,7 @@ index d4bdac1..76507f1 100644
return ret; return ret;
} }
@@ -740,7 +743,9 @@ __lxcfs_fuse_ops int cg_mkdir(const char *path, mode_t mode) @@ -734,7 +737,9 @@ __lxcfs_fuse_ops int cg_mkdir(const char *path, mode_t mode)
out: out:
free(cgdir); free(cgdir);
@ -56,7 +70,7 @@ index d4bdac1..76507f1 100644
return ret; return ret;
} }
@@ -875,7 +880,9 @@ __lxcfs_fuse_ops int cg_rmdir(const char *path) @@ -869,7 +874,9 @@ __lxcfs_fuse_ops int cg_rmdir(const char *path)
out: out:
free(cgdir); free(cgdir);
@ -66,7 +80,7 @@ index d4bdac1..76507f1 100644
return ret; return ret;
} }
@@ -964,6 +971,7 @@ __lxcfs_fuse_ops int cg_chmod(const char *path, mode_t mode) @@ -958,6 +965,7 @@ __lxcfs_fuse_ops int cg_chmod(const char *path, mode_t mode)
out: out:
free_key(k); free_key(k);
free(cgdir); free(cgdir);
@ -74,15 +88,16 @@ index d4bdac1..76507f1 100644
return ret; return ret;
} }
@@ -1073,6 +1081,7 @@ __lxcfs_fuse_ops int cg_chown(const char *path, uid_t uid, gid_t gid) @@ -1067,7 +1075,7 @@ __lxcfs_fuse_ops int cg_chown(const char *path, uid_t uid, gid_t gid)
out: out:
free_key(k); free_key(k);
free(cgdir); free(cgdir);
-
+ cgdir = NULL; + cgdir = NULL;
return ret; return ret;
} }
@@ -1145,6 +1154,7 @@ __lxcfs_fuse_ops int cg_open(const char *path, struct fuse_file_info *fi)
@@ -1139,6 +1147,7 @@ __lxcfs_fuse_ops int cg_open(const char *path, struct fuse_file_info *fi)
out: out:
free(cgdir); free(cgdir);
@ -90,7 +105,7 @@ index d4bdac1..76507f1 100644
return ret; return ret;
} }
@@ -1286,6 +1296,7 @@ static bool do_read_pids(pid_t tpid, const char *contrl, const char *cg, @@ -1280,6 +1289,7 @@ static bool do_read_pids(pid_t tpid, const char *contrl, const char *cg,
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0) { if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0) {
perror("socketpair"); perror("socketpair");
free(tmpdata); free(tmpdata);
@ -98,7 +113,7 @@ index d4bdac1..76507f1 100644
return false; return false;
} }
@@ -1337,6 +1348,7 @@ next: @@ -1331,6 +1341,7 @@ next:
out: out:
free(tmpdata); free(tmpdata);
@ -106,7 +121,7 @@ index d4bdac1..76507f1 100644
if (cpid != -1) if (cpid != -1)
wait_for_pid(cpid); wait_for_pid(cpid);
if (sock[0] != -1) { if (sock[0] != -1) {
@@ -1413,6 +1425,7 @@ __lxcfs_fuse_ops int cg_read(const char *path, char *buf, size_t size, @@ -1408,6 +1419,7 @@ __lxcfs_fuse_ops int cg_read(const char *path, char *buf, size_t size,
out: out:
free(data); free(data);
@ -114,15 +129,15 @@ index d4bdac1..76507f1 100644
return ret; return ret;
} }
@@ -1989,6 +2002,7 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf, @@ -1989,6 +2001,7 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf,
if (nextcg) { if (nextcg) {
ret = filler(buf, nextcg, NULL, 0); ret = DIR_FILLER(filler, buf, nextcg, NULL, 0);
free(nextcg); free(nextcg);
+ nextcg = NULL; + nextcg = NULL;
if (ret != 0) { if (ret != 0) {
ret = -EIO; ret = -EIO;
goto out; goto out;
@@ -2024,9 +2038,12 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf, @@ -2024,8 +2037,10 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf,
out: out:
free_keys(list); free_keys(list);
if (clist) { if (clist) {
@ -130,13 +145,11 @@ index d4bdac1..76507f1 100644
+ for (i = 0; clist[i]; i++) { + for (i = 0; clist[i]; i++) {
free(clist[i]); free(clist[i]);
+ clist[i] = NULL; + clist[i] = NULL;
+ } + }
free(clist); free(clist);
+ clist = NULL;
} }
return ret; return ret;
} @@ -2095,5 +2110,6 @@ __lxcfs_fuse_ops int cg_access(const char *path, int mode)
@@ -2095,5 +2112,6 @@ __lxcfs_fuse_ops int cg_access(const char *path, int mode)
out: out:
free(cgdir); free(cgdir);
@ -144,10 +157,10 @@ index d4bdac1..76507f1 100644
return ret; return ret;
} }
diff --git a/src/cgroups/cgfsng.c b/src/cgroups/cgfsng.c diff --git a/src/cgroups/cgfsng.c b/src/cgroups/cgfsng.c
index cf891b3..ca80a75 100644 index 3eb4227..781923c 100644
--- a/src/cgroups/cgfsng.c --- a/src/cgroups/cgfsng.c
+++ b/src/cgroups/cgfsng.c +++ b/src/cgroups/cgfsng.c
@@ -878,7 +878,7 @@ static int cg_hybrid_init(struct cgroup_ops *ops) @@ -875,7 +875,7 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
prune_init_scope(base_cgroup); prune_init_scope(base_cgroup);
if (type == CGROUP2_SUPER_MAGIC) { if (type == CGROUP2_SUPER_MAGIC) {
@ -156,7 +169,7 @@ index cf891b3..ca80a75 100644
cgv2_ctrl_path = must_make_path(mountpoint, base_cgroup, cgv2_ctrl_path = must_make_path(mountpoint, base_cgroup,
"cgroup.controllers", "cgroup.controllers",
@@ -886,6 +886,7 @@ static int cg_hybrid_init(struct cgroup_ops *ops) @@ -883,6 +883,7 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
controller_list = cg_unified_get_controllers(cgv2_ctrl_path); controller_list = cg_unified_get_controllers(cgv2_ctrl_path);
free(cgv2_ctrl_path); free(cgv2_ctrl_path);
@ -164,7 +177,7 @@ index cf891b3..ca80a75 100644
if (!controller_list) if (!controller_list)
controller_list = cg_unified_make_empty_controller(); controller_list = cg_unified_make_empty_controller();
} }
@@ -900,7 +901,9 @@ static int cg_hybrid_init(struct cgroup_ops *ops) @@ -897,7 +898,9 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
next: next:
free_string_list(controller_list); free_string_list(controller_list);
free(mountpoint); free(mountpoint);
@ -175,10 +188,10 @@ index cf891b3..ca80a75 100644
free_string_list(klist); free_string_list(klist);
diff --git a/src/cgroups/cgroup_utils.c b/src/cgroups/cgroup_utils.c diff --git a/src/cgroups/cgroup_utils.c b/src/cgroups/cgroup_utils.c
index c21e7bc..521ec8b 100644 index 1224971..d32a520 100644
--- a/src/cgroups/cgroup_utils.c --- a/src/cgroups/cgroup_utils.c
+++ b/src/cgroups/cgroup_utils.c +++ b/src/cgroups/cgroup_utils.c
@@ -710,7 +710,7 @@ bool mkdir_p(const char *dir, mode_t mode) @@ -701,7 +701,7 @@ bool mkdir_p(const char *dir, mode_t mode)
{ {
const char *tmp = dir; const char *tmp = dir;
const char *orig = dir; const char *orig = dir;
@ -187,7 +200,7 @@ index c21e7bc..521ec8b 100644
do { do {
dir = tmp + strspn(tmp, "/"); dir = tmp + strspn(tmp, "/");
@@ -722,9 +722,11 @@ bool mkdir_p(const char *dir, mode_t mode) @@ -713,9 +713,11 @@ bool mkdir_p(const char *dir, mode_t mode)
lxcfs_error("Failed to create directory '%s': %s.\n", lxcfs_error("Failed to create directory '%s': %s.\n",
makeme, strerror(errno)); makeme, strerror(errno));
free(makeme); free(makeme);
@ -200,22 +213,37 @@ index c21e7bc..521ec8b 100644
return true; return true;
diff --git a/src/lxcfs.c b/src/lxcfs.c diff --git a/src/lxcfs.c b/src/lxcfs.c
index 94256d4..2251a20 100644 index e24ebed..361ce71 100644
--- a/src/lxcfs.c --- a/src/lxcfs.c
+++ b/src/lxcfs.c +++ b/src/lxcfs.c
@@ -1130,6 +1130,7 @@ int main(int argc, char *argv[]) @@ -1237,10 +1237,12 @@ int main(int argc, char *argv[])
} else { if (append_comma_separate(&new_fuse_opts, token)) {
lxcfs_error("Warning: unexpected fuse option %s", v); lxcfs_error("Failed to copy fuse argument \"%s\"", token);
free(v); free(dup);
+ v = NULL; + dup = NULL;
exit(EXIT_FAILURE); goto out;
} }
} }
free(dup);
+ dup = NULL;
}
if (append_comma_separate(&new_fuse_opts, "allow_other,entry_timeout=0.5,attr_timeout=0.5")) {
@@ -1306,7 +1308,9 @@ out:
if (pidfile)
unlink(pidfile);
free(new_fuse_opts);
+ new_fuse_opts = NULL;
free(opts);
+ opts = NULL;
close_prot_errno_disarm(pidfile_fd);
exit(ret);
}
diff --git a/src/memory_utils.h b/src/memory_utils.h diff --git a/src/memory_utils.h b/src/memory_utils.h
index 2916f56..c903d48 100644 index c689c8e..a7e4a58 100644
--- a/src/memory_utils.h --- a/src/memory_utils.h
+++ b/src/memory_utils.h +++ b/src/memory_utils.h
@@ -65,8 +65,10 @@ static inline void free_disarm_function(void *ptr) @@ -67,8 +67,10 @@ static inline void free_disarm_function(void *ptr)
static inline void free_string_list(char **list) static inline void free_string_list(char **list)
{ {
if (list) { if (list) {
@ -223,15 +251,15 @@ index 2916f56..c903d48 100644
+ for (int i = 0; list[i]; i++) { + for (int i = 0; list[i]; i++) {
free(list[i]); free(list[i]);
+ list[i] = NULL; + list[i] = NULL;
+ } + }
free_disarm(list); free_disarm(list);
} }
} }
diff --git a/src/proc_loadavg.c b/src/proc_loadavg.c diff --git a/src/proc_loadavg.c b/src/proc_loadavg.c
index 7a7a39e..84787a9 100644 index 5f9bec7..c8daf35 100644
--- a/src/proc_loadavg.c --- a/src/proc_loadavg.c
+++ b/src/proc_loadavg.c +++ b/src/proc_loadavg.c
@@ -445,10 +445,13 @@ static int refresh_load(struct load_node *p, const char *path) @@ -436,10 +436,13 @@ static int refresh_load(struct load_node *p, const char *path)
p->last_pid = last_pid; p->last_pid = last_pid;
err_out: err_out:
@ -239,10 +267,13 @@ index 7a7a39e..84787a9 100644
+ for (; i > 0; i--) { + for (; i > 0; i--) {
free(idbuf[i - 1]); free(idbuf[i - 1]);
+ idbuf[i - 1] = NULL; + idbuf[i - 1] = NULL;
+ } + }
out: out:
free(idbuf); free(idbuf);
+ idbuf = NULL; + idbuf = NULL;
return sum; return sum;
} }
--
2.27.0

View File

@ -1,8 +1,17 @@
From 0025ea3988eefdf9a7a0eff5d55d2524c105c485 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 14:54:20 +0800
Subject: [PATCH 08/17] fix-hang
---
src/proc_fuse.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 334f6ea..3ceba73 100644 index 0aaab71..48c4e68 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -51,6 +51,26 @@ @@ -43,6 +43,26 @@
#include "proc_cpuview.h" #include "proc_cpuview.h"
#include "utils.h" #include "utils.h"
@ -29,7 +38,7 @@ index 334f6ea..3ceba73 100644
struct memory_stat { struct memory_stat {
uint64_t hierarchical_memory_limit; uint64_t hierarchical_memory_limit;
uint64_t hierarchical_memsw_limit; uint64_t hierarchical_memsw_limit;
@@ -418,6 +438,16 @@ struct devinfo* container_dev_read(pid_t pid) { @@ -492,6 +512,16 @@ struct devinfo* container_dev_read(pid_t pid) {
return head; return head;
} }
if (child_pid == 0) { if (child_pid == 0) {
@ -46,7 +55,7 @@ index 334f6ea..3ceba73 100644
close(mypipe[0]); close(mypipe[0]);
stream = fdopen(mypipe[1], "w"); stream = fdopen(mypipe[1], "w");
if (stream == NULL) { if (stream == NULL) {
@@ -464,6 +494,8 @@ child_out: @@ -538,6 +568,8 @@ child_out:
lxcfs_error("Error opening pipe for reading: %s\n", strerror(errno)); lxcfs_error("Error opening pipe for reading: %s\n", strerror(errno));
goto err; goto err;
} }
@ -55,7 +64,7 @@ index 334f6ea..3ceba73 100644
while (fscanf(stream, "%100s%d", dev_name, &dev_num) == 2) { while (fscanf(stream, "%100s%d", dev_name, &dev_num) == 2) {
if (dev_num == 0) { if (dev_num == 0) {
break; break;
@@ -590,7 +622,9 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -681,7 +713,9 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
if (!f) if (!f)
return 0; return 0;
@ -65,3 +74,6 @@ index 334f6ea..3ceba73 100644
while (getline(&line, &linelen, f) != -1) { while (getline(&line, &linelen, f) != -1) {
ssize_t l; ssize_t l;
--
2.27.0

View File

@ -1,8 +1,26 @@
From b0097ee3a4b0ac445271badac153293053bd03e1 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Tue, 30 Nov 2021 15:10:23 +0800
Subject: [PATCH 09/17] limit-stat-by-quota-period-setting
---
src/proc_fuse.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 3ceba73..5162a3b 100644 index 48c4e68..c6c32c7 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -910,6 +910,8 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, @@ -549,7 +549,7 @@ struct devinfo* container_dev_read(pid_t pid) {
memset(fpath, 0, sizeof(fpath));
snprintf(fpath, 99, "/dev/%s", ptr->d_name);
stat(fpath, &dev_stat);
- fprintf(stream, "%s %d ", ptr->d_name, dev_stat.st_rdev);
+ fprintf(stream, "%s %ld ", ptr->d_name, dev_stat.st_rdev);
fflush(stream);
}
closedir(dir);
@@ -1031,6 +1031,8 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
size_t linelen = 0, total_len = 0; size_t linelen = 0, total_len = 0;
int curcpu = -1; /* cpu numbering starts at 0 */ int curcpu = -1; /* cpu numbering starts at 0 */
int physcpu = 0; int physcpu = 0;
@ -11,7 +29,7 @@ index 3ceba73..5162a3b 100644
uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0,
softirq = 0, steal = 0, guest = 0, guest_nice = 0; softirq = 0, steal = 0, guest = 0, guest_nice = 0;
uint64_t user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0, uint64_t user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0,
@@ -958,6 +960,13 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, @@ -1079,6 +1081,13 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
if (!cpuset) if (!cpuset)
return 0; return 0;
@ -25,7 +43,7 @@ index 3ceba73..5162a3b 100644
f = fopen_cached("/proc/stat", "re", &fopen_cache); f = fopen_cached("/proc/stat", "re", &fopen_cache);
if (!f) if (!f)
return 0; return 0;
@@ -1006,6 +1015,9 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, @@ -1127,6 +1136,9 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
continue; continue;
} }
@ -35,3 +53,6 @@ index 3ceba73..5162a3b 100644
if (sscanf(cpu_char, "%d", &physcpu) != 1) if (sscanf(cpu_char, "%d", &physcpu) != 1)
continue; continue;
--
2.27.0

View File

@ -1,43 +1,52 @@
From 784830ba0066dae7a181df2b82795dda57427127 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Tue, 30 Nov 2021 15:23:01 +0800
Subject: [PATCH 10/17] diskstats-support-devicemapper-device
---
src/proc_fuse.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 145e2e2..7442d4c 100644 index c6c32c7..a613688 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -537,6 +537,15 @@ void free_devinfo_list(struct devinfo *ptr) @@ -611,6 +611,15 @@ void free_devinfo_list(struct devinfo *ptr)
} }
} }
+static bool need_record_diskstats(unsigned int major, unsigned int minor) +static bool need_record_diskstats(unsigned int major, unsigned int minor)
+{ +{
+ // support device which major is 253 and 252 + // support device which major is 253 and 252
+ if (major == 253 || major == 252) { + if (major == 253 || major == 252) {
+ return true; + return true;
+ } + }
+ return false; + return false;
+} +}
+ +
static int proc_diskstats_read(char *buf, size_t size, off_t offset, struct lxcfs_diskstats {
struct fuse_file_info *fi) unsigned int major; /* 1 - major number */
{ unsigned int minor; /* 2 - minor mumber */
@@ -562,6 +571,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -653,6 +662,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 i = 0;
int ret; int ret;
char dev_name[72];
+ char tmp_dev_name[72]; + char tmp_dev_name[72];
if (offset) { if (offset) {
int left; size_t left;
@@ -629,6 +639,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -720,6 +730,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
while (getline(&line, &linelen, f) != -1) { while (getline(&line, &linelen, f) != -1) {
ssize_t l; ssize_t l;
char lbuf[256]; char lbuf[256];
+ bool match = false; + bool match = false;
memset(dev_name, 0, sizeof(dev_name)); memset(stats.dev_name, 0, sizeof(stats.dev_name));
i = sscanf(line, "%u %u %71s", &major, &minor, dev_name); i = sscanf(line, "%u %u %71s", &stats.major, &stats.minor, stats.dev_name);
@@ -638,9 +649,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -729,9 +740,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
if (major == ptr->major && minor == ptr->minor) { if (stats.major == ptr->major && stats.minor == ptr->minor) {
snprintf(dev_name, sizeof(dev_name), "%s", ptr->name); snprintf(stats.dev_name, sizeof(stats.dev_name), "%s", ptr->name);
dev_name[71] = '\0'; stats.dev_name[71] = '\0';
+ match = true; + match = true;
} }
} }
@ -46,24 +55,57 @@ index 145e2e2..7442d4c 100644
+ continue; + continue;
+ } + }
+ +
get_blkio_io_value(io_serviced_str, major, minor, "Read", &read); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Read", &stats.read);
get_blkio_io_value(io_serviced_str, major, minor, "Write", &write); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Write", &stats.write);
get_blkio_io_value(io_merged_str, major, minor, "Read", &read_merged); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Discard", &stats.discard);
@@ -670,8 +686,16 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -791,8 +807,46 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", stats.discard_merged,
major, minor, dev_name, read, read_merged, read_sectors, read_ticks, stats.discard_sectors,
write, write_merged, write_sectors, write_ticks, ios_pgr, tot_ticks, rq_ticks); stats.discard_ticks);
- else - else
+ else if (need_record_diskstats(major, minor)) { + 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\n", + sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+ &major, &minor, tmp_dev_name, &read, &read_merged, &read_sectors, &read_ticks, + &stats.major,
+ &write, &write_merged, &write_sectors, &write_ticks, &ios_pgr, &tot_ticks, &rq_ticks); + &stats.minor,
+ snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", + tmp_dev_name,
+ major, minor, dev_name, read, read_merged, read_sectors, read_ticks, + &stats.read,
+ write, write_merged, write_sectors, write_ticks, ios_pgr, tot_ticks, rq_ticks); + &stats.read_merged,
+ } else { + &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 {
continue; continue;
+ } + }
l = snprintf(cache, cache_size, "%s", lbuf); l = snprintf(cache, cache_size, "%s", lbuf);
if (l < 0) { if (l < 0) {
--
2.27.0

View File

@ -1,8 +1,18 @@
From f4486dde281016cda897f1564dcb8ca0303f2fbf Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 16:01:12 +0800
Subject: [PATCH 11/17] lxcfs-add-proc-partitions
---
src/bindings.h | 3 ++
src/proc_fuse.c | 131 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 126 insertions(+), 8 deletions(-)
diff --git a/src/bindings.h b/src/bindings.h diff --git a/src/bindings.h b/src/bindings.h
index e260902..241b2fd 100644 index cd7d466..91d44c7 100644
--- a/src/bindings.h --- a/src/bindings.h
+++ b/src/bindings.h +++ b/src/bindings.h
@@ -62,6 +62,9 @@ enum lxcfs_virt_t { @@ -55,6 +55,9 @@ enum lxcfs_virt_t {
LXC_TYPE_PROC_LOADAVG, LXC_TYPE_PROC_LOADAVG,
#define LXC_TYPE_PROC_LOADAVG_PATH "/proc/loadavg" #define LXC_TYPE_PROC_LOADAVG_PATH "/proc/loadavg"
@ -13,10 +23,10 @@ index e260902..241b2fd 100644
LXC_TYPE_SYS_DEVICES_SYSTEM, LXC_TYPE_SYS_DEVICES_SYSTEM,
LXC_TYPE_SYS_DEVICES_SYSTEM_CPU, LXC_TYPE_SYS_DEVICES_SYSTEM_CPU,
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 7442d4c..4ceea4c 100644 index a613688..72f6de6 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -109,13 +109,14 @@ __lxcfs_fuse_ops int proc_getattr(const char *path, struct stat *sb) @@ -118,13 +118,14 @@ __lxcfs_fuse_ops int proc_getattr(const char *path, struct stat *sb)
return 0; return 0;
} }
@ -34,21 +44,21 @@ index 7442d4c..4ceea4c 100644
+ strcmp(path, "/proc/diskstats") == 0 || + strcmp(path, "/proc/diskstats") == 0 ||
+ strcmp(path, "/proc/swaps") == 0 || + strcmp(path, "/proc/swaps") == 0 ||
+ strcmp(path, "/proc/loadavg") == 0 || + strcmp(path, "/proc/loadavg") == 0 ||
+ strcmp(path, "/proc/partitions") == 0) { + strcmp(path, "/proc/partitions") == 0) {
sb->st_size = 0; sb->st_size = get_procfile_size(path);
sb->st_mode = S_IFREG | 00444; sb->st_mode = S_IFREG | 00444;
sb->st_nlink = 1; sb->st_nlink = 1;
@@ -137,7 +138,8 @@ __lxcfs_fuse_ops int proc_readdir(const char *path, void *buf, @@ -146,7 +147,8 @@ __lxcfs_fuse_ops int proc_readdir(const char *path, void *buf,
filler(buf, "uptime", NULL, 0) != 0 || DIR_FILLER(filler, buf, "uptime", NULL, 0) != 0 ||
filler(buf, "diskstats", NULL, 0) != 0 || DIR_FILLER(filler, buf, "diskstats", NULL, 0) != 0 ||
filler(buf, "swaps", NULL, 0) != 0 || DIR_FILLER(filler, buf, "swaps", NULL, 0) != 0 ||
- filler(buf, "loadavg", NULL, 0) != 0) - DIR_FILLER(filler, buf, "loadavg", NULL, 0) != 0)
+ filler(buf, "loadavg", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "loadavg", NULL, 0) != 0 ||
+ filler(buf, "partitions", NULL, 0) != 0 ) + DIR_FILLER(filler, buf, "partitions", NULL, 0) != 0)
return -EINVAL; return -EINVAL;
return 0; return 0;
@@ -179,6 +181,8 @@ __lxcfs_fuse_ops int proc_open(const char *path, struct fuse_file_info *fi) @@ -171,6 +173,8 @@ __lxcfs_fuse_ops int proc_open(const char *path, struct fuse_file_info *fi)
type = LXC_TYPE_PROC_SWAPS; type = LXC_TYPE_PROC_SWAPS;
else if (strcmp(path, "/proc/loadavg") == 0) else if (strcmp(path, "/proc/loadavg") == 0)
type = LXC_TYPE_PROC_LOADAVG; type = LXC_TYPE_PROC_LOADAVG;
@ -57,7 +67,7 @@ index 7442d4c..4ceea4c 100644
if (type == -1) if (type == -1)
return -ENOENT; return -ENOENT;
@@ -721,6 +725,110 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -872,6 +876,111 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
return total_len; return total_len;
} }
@ -157,6 +167,7 @@ index 7442d4c..4ceea4c 100644
+ rv = total_len; + rv = total_len;
+err: +err:
+ free(cg); + free(cg);
+ cg = NULL;
+ if (f != NULL) + if (f != NULL)
+ fclose(f); + fclose(f);
+ free(line); + free(line);
@ -165,10 +176,10 @@ index 7442d4c..4ceea4c 100644
+ return rv; + return rv;
+} +}
+ +
#if RELOADTEST #ifdef RELOADTEST
static inline void iwashere(void) static inline void iwashere(void)
{ {
@@ -1519,6 +1627,12 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size, @@ -1676,6 +1785,12 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size,
return read_file_fuse_with_offset(LXC_TYPE_PROC_LOADAVG_PATH, return read_file_fuse_with_offset(LXC_TYPE_PROC_LOADAVG_PATH,
buf, size, offset, f); buf, size, offset, f);
@ -181,3 +192,6 @@ index 7442d4c..4ceea4c 100644
} }
return -EINVAL; return -EINVAL;
--
2.27.0

View File

@ -1,8 +1,17 @@
From a0d132e43d22153908e392b8274570bacd9cb6ce Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 16:10:39 +0800
Subject: [PATCH 12/17] lxcfs-proc_diskstats_read-func-obtain-data-from-blki
---
src/cgroups/cgfsng.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/cgroups/cgfsng.c b/src/cgroups/cgfsng.c diff --git a/src/cgroups/cgfsng.c b/src/cgroups/cgfsng.c
index ca80a75..5ec0352 100644 index 781923c..e50c87d 100644
--- a/src/cgroups/cgfsng.c --- a/src/cgroups/cgfsng.c
+++ b/src/cgroups/cgfsng.c +++ b/src/cgroups/cgfsng.c
@@ -754,7 +754,11 @@ static int cgfsng_get_io(struct cgroup_ops *ops, const char *cgroup, @@ -751,7 +751,11 @@ static int cgfsng_get_io(struct cgroup_ops *ops, const char *cgroup,
static int cgfsng_get_io_service_bytes(struct cgroup_ops *ops, static int cgfsng_get_io_service_bytes(struct cgroup_ops *ops,
const char *cgroup, char **value) const char *cgroup, char **value)
{ {
@ -15,7 +24,7 @@ index ca80a75..5ec0352 100644
} }
static int cgfsng_get_io_service_time(struct cgroup_ops *ops, static int cgfsng_get_io_service_time(struct cgroup_ops *ops,
@@ -766,7 +770,11 @@ static int cgfsng_get_io_service_time(struct cgroup_ops *ops, @@ -763,7 +767,11 @@ static int cgfsng_get_io_service_time(struct cgroup_ops *ops,
static int cgfsng_get_io_serviced(struct cgroup_ops *ops, const char *cgroup, static int cgfsng_get_io_serviced(struct cgroup_ops *ops, const char *cgroup,
char **value) char **value)
{ {
@ -28,3 +37,6 @@ index ca80a75..5ec0352 100644
} }
static int cgfsng_get_io_merged(struct cgroup_ops *ops, const char *cgroup, static int cgfsng_get_io_merged(struct cgroup_ops *ops, const char *cgroup,
--
2.27.0

View File

@ -1,5 +1,14 @@
From cc7fb353c259830179c7371afb7b141c0f8290ae Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 16:48:55 +0800
Subject: [PATCH 13/17] add-secure-compile-option-in-Makefile
---
src/Makefile.am | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/Makefile.am b/src/Makefile.am diff --git a/src/Makefile.am b/src/Makefile.am
index 030d6b5..96d884e 100644 index 2734334..437a377 100644
--- a/src/Makefile.am --- a/src/Makefile.am
+++ b/src/Makefile.am +++ b/src/Makefile.am
@@ -6,6 +6,8 @@ AM_LDFLAGS = $(FUSE_LIBS) -pthread @@ -6,6 +6,8 @@ AM_LDFLAGS = $(FUSE_LIBS) -pthread
@ -11,3 +20,6 @@ index 030d6b5..96d884e 100644
liblxcfs_la_SOURCES = api_extensions.h \ liblxcfs_la_SOURCES = api_extensions.h \
bindings.c bindings.h \ bindings.c bindings.h \
--
2.27.0

View File

@ -1,23 +1,128 @@
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 diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 4ceea4c..519cda4 100644 index 72f6de6..0d5ba89 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -686,11 +686,16 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -792,7 +792,64 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
tot_ticks = tot_ticks/1000000; 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
memset(lbuf, 0, 256);
- if (read || write || read_merged || write_merged || read_sectors || write_sectors || read_ticks || write_ticks)
+ if (read || write || read_merged || write_merged || read_sectors || write_sectors || read_ticks || write_ticks) {
+ if (need_record_diskstats(major, minor)) {
+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+ &major, &minor, tmp_dev_name, &read, &read_merged, &read_sectors, &read_ticks,
+ &write, &write_merged, &write_sectors, &write_ticks, &ios_pgr, &tot_ticks, &rq_ticks);
+ }
snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
major, minor, dev_name, read, read_merged, read_sectors, read_ticks,
write, write_merged, write_sectors, write_ticks, ios_pgr, tot_ticks, rq_ticks);
- else if (need_record_diskstats(major, minor)) {
+ } else if (need_record_diskstats(major, minor)) {
sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
&major, &minor, tmp_dev_name, &read, &read_merged, &read_sectors, &read_ticks,
&write, &write_merged, &write_sectors, &write_ticks, &ios_pgr, &tot_ticks, &rq_ticks);

View File

@ -1,23 +1,43 @@
From 7418289cfc1e14dc4aa71fd473a083a75fda75a7 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 25 Nov 2021 20:21:46 +0800
Subject: [PATCH 15/17] lxcfs-adapt-4.18-kernel
---
src/proc_fuse.c | 69 +++++++++++++++++++++----------------------------
1 file changed, 30 insertions(+), 39 deletions(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 519cda4..96eb9d7 100644 index 0d5ba89..a72d6a2 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -608,11 +608,6 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -659,8 +659,8 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
return read_file_fuse("/proc/diskstats", buf, size, d); 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;
@@ -699,29 +699,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); - ret = cgroup_ops->get_io_merged(cgroup_ops, cg, &io_merged_str);
- if (ret < 0) { - if (ret < 0) {
- if (ret == -EOPNOTSUPP) - if (ret == -EOPNOTSUPP)
- return read_file_fuse("/proc/diskstats", buf, size, d); - return read_file_fuse("/proc/diskstats", buf, size, d);
- } - }
-
ret = cgroup_ops->get_io_service_bytes(cgroup_ops, cg, &io_service_bytes_str); ret = cgroup_ops->get_io_service_bytes(cgroup_ops, cg, &io_service_bytes_str);
if (ret < 0) { if (ret < 0) {
@@ -620,17 +615,9 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, if (ret == -EOPNOTSUPP)
return read_file_fuse("/proc/diskstats", buf, size, d); return read_file_fuse("/proc/diskstats", buf, size, d);
} }
- ret = cgroup_ops->get_io_wait_time(cgroup_ops, cg, &io_wait_time_str); - ret = cgroup_ops->get_io_wait_time(cgroup_ops, cg, &io_wait_time_str);
- if (ret < 0) { - if (ret < 0) {
- if (ret == -EOPNOTSUPP) - if (ret == -EOPNOTSUPP)
@ -32,52 +52,71 @@ index 519cda4..96eb9d7 100644
+ cgroup_ops->get_io_merged(cgroup_ops, cg, &io_merged_str); + 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_wait_time(cgroup_ops, cg, &io_wait_time_str);
+ cgroup_ops->get_io_service_time(cgroup_ops, cg, &io_service_time_str); + cgroup_ops->get_io_service_time(cgroup_ops, cg, &io_service_time_str);
f = fopen_cached("/proc/diskstats", "re", &fopen_cache); f = fopen_cached("/proc/diskstats", "re", &fopen_cache);
if (!f) if (!f)
@@ -663,26 +650,32 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -756,9 +742,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, major, minor, "Read", &read); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Discard", &stats.discard);
get_blkio_io_value(io_serviced_str, major, minor, "Write", &write);
- get_blkio_io_value(io_merged_str, major, minor, "Read", &read_merged); - get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Read", &stats.read_merged);
- get_blkio_io_value(io_merged_str, major, minor, "Write", &write_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) { + if (io_merged_str != NULL) {
+ get_blkio_io_value(io_merged_str, major, minor, "Read", &read_merged); + get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Read", &stats.read_merged);
+ get_blkio_io_value(io_merged_str, major, minor, "Write", &write_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, major, minor, "Read", &read_sectors);
read_sectors = read_sectors/512; get_blkio_io_value(io_service_bytes_str, stats.major, stats.minor, "Read", &stats.read_sectors);
get_blkio_io_value(io_service_bytes_str, major, minor, "Write", &write_sectors); stats.read_sectors = stats.read_sectors / 512;
write_sectors = write_sectors/512; @@ -767,26 +755,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);
- get_blkio_io_value(io_service_time_str, major, minor, "Read", &rd_svctm); stats.discard_sectors = stats.discard_sectors / 512;
- rd_svctm = rd_svctm/1000000;
- get_blkio_io_value(io_wait_time_str, major, minor, "Read", &rd_wait); - get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Read", &read_service_time);
- rd_wait = rd_wait/1000000; - read_service_time = read_service_time / 1000000;
- read_ticks = rd_svctm + rd_wait; - 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) { + if (io_service_time_str != NULL) {
+ get_blkio_io_value(io_service_time_str, major, minor, "Read", &rd_svctm); + get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Read", &read_service_time);
+ rd_svctm = rd_svctm/1000000; + read_service_time = read_service_time / 1000000;
+ get_blkio_io_value(io_service_time_str, major, minor, "Write", &wr_svctm); + get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Write", &write_service_time);
+ wr_svctm = wr_svctm/1000000; + write_service_time = write_service_time / 1000000;
+ get_blkio_io_value(io_service_time_str, major, minor, "Total", &tot_ticks); + 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, major, minor, "Write", &wr_svctm); - get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Write", &write_service_time);
- wr_svctm = wr_svctm/1000000; - write_service_time = write_service_time / 1000000;
- get_blkio_io_value(io_wait_time_str, major, minor, "Write", &wr_wait); - get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Write", &write_wait_time);
- wr_wait = wr_wait/1000000; - write_wait_time = write_wait_time / 1000000;
- write_ticks = wr_svctm + wr_wait; - stats.write_ticks = write_service_time + write_wait_time;
+ if (io_wait_time_str != NULL) { + if (io_wait_time_str != NULL) {
+ get_blkio_io_value(io_wait_time_str, major, minor, "Read", &rd_wait); + get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Read", &read_wait_time);
+ rd_wait = rd_wait/1000000; + read_wait_time = read_wait_time / 1000000;
+ get_blkio_io_value(io_wait_time_str, major, minor, "Write", &wr_wait); + get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Write", &write_wait_time);
+ wr_wait = wr_wait/1000000; + 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, 256);
if (stats.read || stats.write || stats.read_merged || stats.write_merged ||
--
2.27.0
- get_blkio_io_value(io_service_time_str, major, minor, "Total", &tot_ticks);
+ read_ticks = rd_svctm + rd_wait;
+ write_ticks = wr_svctm + wr_wait;
tot_ticks = tot_ticks/1000000;
memset(lbuf, 0, 256);

View File

@ -1,9 +1,8 @@
From 93a91769aaece5bcdac817443e31cd0a15a0952a Mon Sep 17 00:00:00 2001 From 035571472fa6c5772cc6ac467cad7f8ffb9e1d8e Mon Sep 17 00:00:00 2001
From: zhangsong234 <zhangsong34@huawei.com> From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Tue, 30 Mar 2021 15:14:24 +0800 Date: Thu, 25 Nov 2021 20:26:45 +0800
Subject: [PATCH] remove lxcfs-tools dependency for common use Subject: [PATCH 16/17] remove-lxcfs-tools-dependency-for-common-use
Signed-off-by: zhangsong234 <zhangsong34@huawei.com>
--- ---
config/init/systemd/lxcfs.service.in | 6 +++--- config/init/systemd/lxcfs.service.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-) 1 file changed, 3 insertions(+), 3 deletions(-)
@ -28,5 +27,5 @@ index 3d763c6..bdaa2fa 100644
Delegate=yes Delegate=yes
ExecReload=/bin/kill -USR1 $MAINPID ExecReload=/bin/kill -USR1 $MAINPID
-- --
1.8.3.1 2.27.0

View File

@ -1,18 +1,17 @@
From aa362b383ca5e79e03fd350867fb4f96a1335ae5 Mon Sep 17 00:00:00 2001 From 798bb221b5862418bfb965dc93ce785c743919ff Mon Sep 17 00:00:00 2001
From: zhangsong234 <zhangsong34@huawei.com> From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 27 May 2021 10:16:00 +0800 Date: Thu, 25 Nov 2021 20:30:09 +0800
Subject: [PATCH] proc_fuse: fix wait child process hang Subject: [PATCH 17/17] proc_fuse-fix-wait-child-process-hang
Signed-off-by: zhangsong234 <zhangsong34@huawei.com>
--- ---
src/proc_fuse.c | 2 +- src/proc_fuse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 96eb9d7..82b32c1 100644 index a72d6a2..d02f841 100644
--- a/src/proc_fuse.c --- a/src/proc_fuse.c
+++ b/src/proc_fuse.c +++ b/src/proc_fuse.c
@@ -487,11 +487,11 @@ struct devinfo* container_dev_read(pid_t pid) { @@ -561,11 +561,11 @@ struct devinfo* container_dev_read(pid_t pid) {
dev_num = dev_stat.st_dev & (~0xf); dev_num = dev_stat.st_dev & (~0xf);
fprintf(stream, "sda %d end 0 ", dev_num); fprintf(stream, "sda %d end 0 ", dev_num);
fflush(stream); fflush(stream);

BIN
lxcfs-4.0.11.tar.gz Normal file

Binary file not shown.

Binary file not shown.

View File

@ -3,8 +3,8 @@
#Basic Information #Basic Information
Name: lxcfs Name: lxcfs
Version: 4.0.5 Version: 4.0.11
Release: 6 Release: 1
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 @@ Patch9017: 0017-proc_fuse-fix-wait-child-process-hang.patch
BuildRequires: autoconf automake libtool help2man BuildRequires: autoconf automake libtool help2man
BuildRequires: fuse-devel libattr-devel BuildRequires: fuse-devel libattr-devel
BuildRequires: gcc systemd-units BuildRequires: gcc systemd-units
Requires: fuse-libs
%description %description
lxcfs is a simple userspace filesystem designed to make containers lxcfs is a simple userspace filesystem designed to make containers
@ -87,6 +88,9 @@ fi
%{_unitdir}/* %{_unitdir}/*
%changelog %changelog
* Sat Nov 27 2021 yangjiaqi <yangjiaqi16@huawei.com> - 4.0.11-1
- update to 4.0.11
* Mon Jun 28 2021 zhangsong234 <zhangsong34@huawei.com> - 4.0.5-6 * Mon Jun 28 2021 zhangsong234 <zhangsong34@huawei.com> - 4.0.5-6
- fix rpm build failed - fix rpm build failed
@ -102,7 +106,7 @@ fi
* Fri Aug 28 2020 openEuler Buildteam <buildteam@openeuler.org> - 4.0.5-1 * Fri Aug 28 2020 openEuler Buildteam <buildteam@openeuler.org> - 4.0.5-1
- update to 4.0.5 - update to 4.0.5
* Thu July 02 2020 openEuler Buildteam <buildteam@openeuler.org> - 3.0.2-0.12 * Thu Jul 02 2020 openEuler Buildteam <buildteam@openeuler.org> - 3.0.2-0.12
- Sync from internal changes - Sync from internal changes
* Thu Dec 26 2019 openEuler Buildteam <buildteam@openeuler.org> - 3.0.2-0.5.h2 * Thu Dec 26 2019 openEuler Buildteam <buildteam@openeuler.org> - 3.0.2-0.5.h2