Compare commits
10 Commits
f52286e154
...
8ef97f8c61
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ef97f8c61 | ||
|
|
739ec96cbe | ||
|
|
065619baf9 | ||
|
|
9cae669874 | ||
|
|
113939866c | ||
|
|
009a8a78f7 | ||
|
|
2728fd1e33 | ||
|
|
754e051ea0 | ||
|
|
f8d5bd3b69 | ||
|
|
c4b6dca0f6 |
@ -1,28 +1,31 @@
|
||||
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
|
||||
From c0a2baa7e79ef6d7a0060611b4244c4946c246b8 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Tue, 11 Jul 2023 08:41:53 +0000
|
||||
Subject: [PATCH 01/15] systemd
|
||||
|
||||
append:remove-lxcfs-tools-dependency-for-common-use
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
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
|
||||
index 9cd4e59..3d763c6 100644
|
||||
index 8b43f5a..bae1d08 100644
|
||||
--- a/config/init/systemd/lxcfs.service.in
|
||||
+++ b/config/init/systemd/lxcfs.service.in
|
||||
@@ -5,12 +5,16 @@ Before=lxc.service
|
||||
Documentation=man:lxcfs(1)
|
||||
@@ -6,12 +6,16 @@ Documentation=man:lxcfs(1)
|
||||
|
||||
[Service]
|
||||
-ExecStart=/usr/bin/lxcfs @LXCFSTARGETDIR@
|
||||
+ExecStartPre=/usr/local/bin/lxcfs-tools prestart
|
||||
OOMScoreAdjust=-1000
|
||||
-ExecStart=/usr/bin/lxcfs {{LXCFSTARGETDIR}}
|
||||
+ExecStartPre=-/usr/local/bin/lxcfs-tools prestart
|
||||
+ExecStart=/usr/bin/lxcfs /var/lib/lxc/lxcfs/
|
||||
+ExecStartPost=/usr/local/bin/lxcfs-tools remount -a
|
||||
+ExecStartPost=-/usr/local/bin/lxcfs-tools remount -a
|
||||
KillMode=process
|
||||
-Restart=on-failure
|
||||
-ExecStopPost=-/bin/fusermount -u @LXCFSTARGETDIR@
|
||||
+ExecStop=/usr/local/bin/lxcfs-tools umount -a
|
||||
-ExecStopPost=-/bin/fusermount -u {{LXCFSTARGETDIR}}
|
||||
+ExecStop=-/usr/local/bin/lxcfs-tools umount -a
|
||||
+ExecStopPost=-/bin/fusermount -u /var/lib/lxc/
|
||||
Delegate=yes
|
||||
ExecReload=/bin/kill -USR1 $MAINPID
|
||||
@ -32,5 +35,5 @@ index 9cd4e59..3d763c6 100644
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
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
|
||||
index e2ffe28..3439c97 100644
|
||||
--- a/config/init/Makefile.am
|
||||
+++ b/config/init/Makefile.am
|
||||
@@ -1 +1 @@
|
||||
-SUBDIRS = systemd sysvinit upstart
|
||||
+SUBDIRS = systemd
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index ccea4ec..d15ac50 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -45,8 +45,6 @@ AC_CONFIG_FILES([
|
||||
config/init/Makefile
|
||||
config/init/systemd/Makefile
|
||||
config/init/systemd/lxcfs.service
|
||||
- config/init/sysvinit/Makefile
|
||||
- config/init/upstart/Makefile
|
||||
|
||||
doc/Makefile
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,17 +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
|
||||
From 79d335011ffccfee542ee5068fda6257a9ac1e59 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 27 Jul 2023 06:40:47 +0000
|
||||
Subject: [PATCH 02/15] show dev name in container
|
||||
|
||||
append: fix hang
|
||||
append: limit-stat-by-quota-period-setting
|
||||
append: fix-proc-diskstats-show-in-container
|
||||
append: proc_fuse fix wait child process hang
|
||||
append: fix deadlock problem when subprocess exit
|
||||
append: fix dev read memory leak in container
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/proc_fuse.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 143 insertions(+), 2 deletions(-)
|
||||
src/proc_fuse.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 181 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||
index 94168c9..7372a36 100644
|
||||
index 25af10a..cde48ca 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -27,6 +27,7 @@
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/sysinfo.h>
|
||||
@ -19,13 +27,40 @@ index 94168c9..7372a36 100644
|
||||
#include <sys/vfs.h>
|
||||
|
||||
#include "proc_fuse.h"
|
||||
@@ -448,6 +449,132 @@ static void get_blkio_io_value(char *str, unsigned major, unsigned minor,
|
||||
@@ -43,6 +44,26 @@
|
||||
#include "proc_cpuview.h"
|
||||
#include "utils.h"
|
||||
|
||||
+static pthread_mutex_t container_dev_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
+
|
||||
+static void lock_mutex(pthread_mutex_t *l)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = pthread_mutex_lock(l);
|
||||
+ if (ret)
|
||||
+ log_exit("%s - returned %d\n", strerror(ret), ret);
|
||||
+}
|
||||
+
|
||||
+static void unlock_mutex(pthread_mutex_t *l)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = pthread_mutex_unlock(l);
|
||||
+ if (ret)
|
||||
+ log_exit("%s - returned %d\n", strerror(ret), ret);
|
||||
+}
|
||||
+
|
||||
struct memory_stat {
|
||||
uint64_t hierarchical_memory_limit;
|
||||
uint64_t hierarchical_memsw_limit;
|
||||
@@ -473,6 +494,146 @@ static void get_blkio_io_value(char *str, unsigned major, unsigned minor,
|
||||
}
|
||||
}
|
||||
|
||||
+struct devinfo {
|
||||
+ char *name;
|
||||
+ int major, minor;
|
||||
+ unsigned int major, minor;
|
||||
+ struct devinfo *next;
|
||||
+};
|
||||
+
|
||||
@ -43,7 +78,7 @@ index 94168c9..7372a36 100644
|
||||
+ struct dirent *ptr;
|
||||
+ struct stat dev_stat;
|
||||
+ struct devinfo *head = NULL, *end;
|
||||
+ char fpath[100], dev_name[100];
|
||||
+ char fpath[261], dev_name[101];
|
||||
+ pid_t child_pid;
|
||||
+ int mypipe[2];
|
||||
+ int dev_num;
|
||||
@ -62,6 +97,16 @@ index 94168c9..7372a36 100644
|
||||
+ return head;
|
||||
+ }
|
||||
+ if (child_pid == 0) {
|
||||
+ /* Disallow signal reception in child process */
|
||||
+ sigset_t oldset;
|
||||
+ sigset_t newset;
|
||||
+ sigemptyset(&newset);
|
||||
+ sigaddset(&newset, SIGTERM);
|
||||
+ sigaddset(&newset, SIGINT);
|
||||
+ sigaddset(&newset, SIGHUP);
|
||||
+ sigaddset(&newset, SIGQUIT);
|
||||
+ sigprocmask(SIG_BLOCK,&newset,&oldset);
|
||||
+
|
||||
+ close(mypipe[0]);
|
||||
+ stream = fdopen(mypipe[1], "w");
|
||||
+ if (stream == NULL) {
|
||||
@ -87,27 +132,30 @@ index 94168c9..7372a36 100644
|
||||
+ continue;
|
||||
+ }
|
||||
+ memset(fpath, 0, sizeof(fpath));
|
||||
+ snprintf(fpath, 99, "/dev/%s", ptr->d_name);
|
||||
+ snprintf(fpath, 261, "/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);
|
||||
+ stat("/", &dev_stat);
|
||||
+ dev_num = dev_stat.st_dev & (~0xf);
|
||||
+ dev_num = dev_stat.st_dev;
|
||||
+ fprintf(stream, "sda %d end 0 ", dev_num);
|
||||
+ fflush(stream);
|
||||
+child_out:
|
||||
+ fclose(stream);
|
||||
+ exit(0);
|
||||
+ _exit(EXIT_SUCCESS);
|
||||
+ }
|
||||
+
|
||||
+child_out:
|
||||
+ close(mypipe[1]);
|
||||
+ stream = fdopen(mypipe[0], "r");
|
||||
+ if (stream == NULL) {
|
||||
+ lxcfs_error("Error opening pipe for reading: %s\n", strerror(errno));
|
||||
+ goto err;
|
||||
+ }
|
||||
+ wait_for_pid(child_pid);
|
||||
+ child_pid = 0;
|
||||
+ memset(dev_name, 0, sizeof(dev_name));
|
||||
+ while (fscanf(stream, "%100s%d", dev_name, &dev_num) == 2) {
|
||||
+ if (dev_num == 0) {
|
||||
+ break;
|
||||
@ -127,6 +175,7 @@ index 94168c9..7372a36 100644
|
||||
+ end->name = must_copy_string(dev_name);
|
||||
+ end->major = major(dev_num);
|
||||
+ end->minor = minor(dev_num);
|
||||
+ memset(dev_name, 0, sizeof(dev_name));
|
||||
+ }
|
||||
+err:
|
||||
+ if (stream)
|
||||
@ -152,7 +201,7 @@ index 94168c9..7372a36 100644
|
||||
struct lxcfs_diskstats {
|
||||
unsigned int major; /* 1 - major number */
|
||||
unsigned int minor; /* 2 - minor mumber */
|
||||
@@ -480,6 +607,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
@@ -505,6 +666,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
__do_fclose FILE *f = NULL;
|
||||
struct fuse_context *fc = fuse_get_context();
|
||||
struct file_info *d = INTTYPE_TO_PTR(fi->fh);
|
||||
@ -160,11 +209,13 @@ index 94168c9..7372a36 100644
|
||||
struct lxcfs_diskstats stats = {};
|
||||
/* helper fields */
|
||||
uint64_t read_service_time, write_service_time, discard_service_time, read_wait_time,
|
||||
@@ -549,13 +677,22 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
@@ -574,14 +736,26 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
if (!f)
|
||||
return 0;
|
||||
|
||||
+ lock_mutex(&container_dev_mutex);
|
||||
+ container_devinfo = container_dev_read(initpid);
|
||||
+ unlock_mutex(&container_dev_mutex);
|
||||
+
|
||||
while (getline(&line, &linelen, f) != -1) {
|
||||
ssize_t l;
|
||||
@ -174,17 +225,19 @@ index 94168c9..7372a36 100644
|
||||
i = sscanf(line, "%u %u %71s", &stats.major, &stats.minor, stats.dev_name);
|
||||
if (i != 3)
|
||||
continue;
|
||||
|
||||
+ for (ptr = container_devinfo; ptr != NULL; ptr = ptr->next) {
|
||||
+ 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';
|
||||
+ }
|
||||
+ }
|
||||
|
||||
+
|
||||
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);
|
||||
@@ -620,10 +757,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
continue;
|
||||
get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Discard", &stats.discard);
|
||||
@@ -672,10 +846,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
}
|
||||
|
||||
l = snprintf(cache, cache_size, "%s", lbuf);
|
||||
- if (l < 0)
|
||||
@ -200,6 +253,14 @@ index 94168c9..7372a36 100644
|
||||
|
||||
cache += l;
|
||||
cache_size -= l;
|
||||
@@ -687,6 +865,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
if (total_len > size)
|
||||
total_len = size;
|
||||
memcpy(buf, d->buf, total_len);
|
||||
+ free_devinfo_list(container_devinfo);
|
||||
|
||||
return total_len;
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
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
|
||||
From 735d69c8696b5ddc8090ad7906f07fe2fe5f9992 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 27 Jul 2023 07:00:28 +0000
|
||||
Subject: [PATCH 03/15] lxcfs fix cpuinfo print
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/proc_cpuview.c | 12 +++++++++++-
|
||||
1 file changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/proc_cpuview.c b/src/proc_cpuview.c
|
||||
index 9f6a55e..75006a6 100644
|
||||
index f5464de..76f8089 100644
|
||||
--- a/src/proc_cpuview.c
|
||||
+++ b/src/proc_cpuview.c
|
||||
@@ -970,7 +970,17 @@ int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
|
||||
@@ -1051,7 +1051,17 @@ int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
|
||||
|
||||
}
|
||||
if (am_printing) {
|
||||
@ -31,5 +32,5 @@ index 9f6a55e..75006a6 100644
|
||||
return log_error(0, "Failed to write cache");
|
||||
if ((size_t)l >= cache_size)
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
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
|
||||
From 611a0dec7317fa0441a5923a8e825e804060c998 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 27 Jul 2023 07:07:55 +0000
|
||||
Subject: [PATCH 04/15] fix memory leak
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/proc_fuse.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||
index 7372a36..bcd624d 100644
|
||||
index cde48ca..ed70ea7 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -278,6 +278,8 @@ static uint64_t get_min_memlimit(const char *cgroup, bool swap)
|
||||
@@ -304,6 +304,8 @@ static uint64_t get_min_memlimit(const char *cgroup, bool swap)
|
||||
return log_error_errno(0, ENOMEM, "Failed to allocate memory");
|
||||
|
||||
retlimit = get_memlimit(copy, swap);
|
||||
@ -20,7 +21,7 @@ index 7372a36..bcd624d 100644
|
||||
|
||||
/*
|
||||
* If the cgroup doesn't start with / (probably won't happen), dirname()
|
||||
@@ -346,6 +348,8 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
|
||||
@@ -409,6 +411,8 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
|
||||
prune_init_slice(cgroup);
|
||||
|
||||
memlimit = get_min_memlimit(cgroup, false);
|
||||
@ -29,7 +30,7 @@ index 7372a36..bcd624d 100644
|
||||
|
||||
ret = cgroup_ops->get_memory_current(cgroup_ops, cgroup, &memusage_str);
|
||||
if (ret < 0)
|
||||
@@ -1329,6 +1333,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
|
||||
@@ -1453,6 +1457,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
|
||||
return read_file_fuse("/proc/meminfo", buf, size, d);
|
||||
|
||||
memlimit = get_min_memlimit(cgroup, false);
|
||||
@ -38,7 +39,7 @@ index 7372a36..bcd624d 100644
|
||||
|
||||
/*
|
||||
* Following values are allowed to fail, because swapaccount might be
|
||||
@@ -1361,9 +1367,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
|
||||
@@ -1467,9 +1473,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
|
||||
|
||||
memusage /= 1024;
|
||||
memlimit /= 1024;
|
||||
@ -50,5 +51,5 @@ index 7372a36..bcd624d 100644
|
||||
memset(lbuf, 0, 100);
|
||||
if (startswith(line, "MemTotal:")) {
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
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
|
||||
From a7f9759ef8ce354ab2ad420d4a8c5b4260d491fc Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 27 Jul 2023 07:24:18 +0000
|
||||
Subject: [PATCH 05/15] fix concurrency problem
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/cgroups/cgroup_utils.c | 21 +++++++++++++--------
|
||||
src/cgroups/cgroup_utils.h | 2 +-
|
||||
@ -80,10 +81,10 @@ index f431686..d4c8598 100644
|
||||
extern char *readat_file(int fd, const char *path);
|
||||
extern char *read_file_strip_newline(const char *fnam);
|
||||
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||
index bcd624d..0aaab71 100644
|
||||
index ed70ea7..0af559f 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -1530,6 +1530,9 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size,
|
||||
@@ -1747,6 +1747,9 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size,
|
||||
{
|
||||
struct file_info *f = INTTYPE_TO_PTR(fi->fh);
|
||||
|
||||
@ -94,5 +95,5 @@ index bcd624d..0aaab71 100644
|
||||
case LXC_TYPE_PROC_MEMINFO:
|
||||
if (liblxcfs_functional())
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
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
|
||||
From 6a744fd9ba541e535e611f066c4038330605fe2b Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Wed, 12 Jul 2023 07:48:40 +0000
|
||||
Subject: [PATCH 06/15] set null after free
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/cgroup_fuse.c | 26 +++++++++++++++++++++-----
|
||||
src/cgroup_fuse.c | 27 ++++++++++++++++++++++-----
|
||||
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(-)
|
||||
6 files changed, 40 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/cgroup_fuse.c b/src/cgroup_fuse.c
|
||||
index 5c22fd1..b396bbc 100644
|
||||
index 693b67d..0d4dd10 100644
|
||||
--- a/src/cgroup_fuse.c
|
||||
+++ b/src/cgroup_fuse.c
|
||||
@@ -179,7 +179,7 @@ static bool is_child_cgroup(const char *controller, const char *cgroup,
|
||||
@ -52,7 +53,7 @@ index 5c22fd1..b396bbc 100644
|
||||
return answer;
|
||||
}
|
||||
|
||||
@@ -612,6 +614,7 @@ __lxcfs_fuse_ops int cg_getattr(const char *path, struct stat *sb)
|
||||
@@ -613,6 +615,7 @@ __lxcfs_fuse_ops int cg_getattr(const char *path, struct stat *sb)
|
||||
|
||||
out:
|
||||
free(cgdir);
|
||||
@ -60,7 +61,7 @@ index 5c22fd1..b396bbc 100644
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -734,7 +737,9 @@ __lxcfs_fuse_ops int cg_mkdir(const char *path, mode_t mode)
|
||||
@@ -735,7 +738,9 @@ __lxcfs_fuse_ops int cg_mkdir(const char *path, mode_t mode)
|
||||
|
||||
out:
|
||||
free(cgdir);
|
||||
@ -70,7 +71,7 @@ index 5c22fd1..b396bbc 100644
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -869,7 +874,9 @@ __lxcfs_fuse_ops int cg_rmdir(const char *path)
|
||||
@@ -870,7 +875,9 @@ __lxcfs_fuse_ops int cg_rmdir(const char *path)
|
||||
|
||||
out:
|
||||
free(cgdir);
|
||||
@ -80,7 +81,7 @@ index 5c22fd1..b396bbc 100644
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -958,6 +965,7 @@ __lxcfs_fuse_ops int cg_chmod(const char *path, mode_t mode)
|
||||
@@ -959,6 +966,7 @@ __lxcfs_fuse_ops int cg_chmod(const char *path, mode_t mode)
|
||||
out:
|
||||
free_key(k);
|
||||
free(cgdir);
|
||||
@ -88,7 +89,7 @@ index 5c22fd1..b396bbc 100644
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1067,7 +1075,7 @@ __lxcfs_fuse_ops int cg_chown(const char *path, uid_t uid, gid_t gid)
|
||||
@@ -1068,7 +1076,7 @@ __lxcfs_fuse_ops int cg_chown(const char *path, uid_t uid, gid_t gid)
|
||||
out:
|
||||
free_key(k);
|
||||
free(cgdir);
|
||||
@ -97,7 +98,7 @@ index 5c22fd1..b396bbc 100644
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1139,6 +1147,7 @@ __lxcfs_fuse_ops int cg_open(const char *path, struct fuse_file_info *fi)
|
||||
@@ -1140,6 +1148,7 @@ __lxcfs_fuse_ops int cg_open(const char *path, struct fuse_file_info *fi)
|
||||
|
||||
out:
|
||||
free(cgdir);
|
||||
@ -105,7 +106,7 @@ index 5c22fd1..b396bbc 100644
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1280,6 +1289,7 @@ static bool do_read_pids(pid_t tpid, const char *contrl, const char *cg,
|
||||
@@ -1281,6 +1290,7 @@ static bool do_read_pids(pid_t tpid, const char *contrl, const char *cg,
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0) {
|
||||
perror("socketpair");
|
||||
free(tmpdata);
|
||||
@ -113,7 +114,7 @@ index 5c22fd1..b396bbc 100644
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1331,6 +1341,7 @@ next:
|
||||
@@ -1332,6 +1342,7 @@ next:
|
||||
|
||||
out:
|
||||
free(tmpdata);
|
||||
@ -121,7 +122,7 @@ index 5c22fd1..b396bbc 100644
|
||||
if (cpid != -1)
|
||||
wait_for_pid(cpid);
|
||||
if (sock[0] != -1) {
|
||||
@@ -1408,6 +1419,7 @@ __lxcfs_fuse_ops int cg_read(const char *path, char *buf, size_t size,
|
||||
@@ -1409,6 +1420,7 @@ __lxcfs_fuse_ops int cg_read(const char *path, char *buf, size_t size,
|
||||
|
||||
out:
|
||||
free(data);
|
||||
@ -129,15 +130,15 @@ index 5c22fd1..b396bbc 100644
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1989,6 +2001,7 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf,
|
||||
@@ -1995,6 +2007,7 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf,
|
||||
if (nextcg) {
|
||||
ret = DIR_FILLER(filler, buf, nextcg, NULL, 0);
|
||||
ret = dir_filler(filler, buf, nextcg, 0);
|
||||
free(nextcg);
|
||||
+ nextcg = NULL;
|
||||
if (ret != 0) {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
@@ -2024,8 +2037,10 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf,
|
||||
@@ -2030,9 +2043,12 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf,
|
||||
out:
|
||||
free_keys(list);
|
||||
if (clist) {
|
||||
@ -147,9 +148,11 @@ index 5c22fd1..b396bbc 100644
|
||||
+ clist[i] = NULL;
|
||||
+ }
|
||||
free(clist);
|
||||
+ clist = NULL;
|
||||
}
|
||||
return ret;
|
||||
@@ -2095,5 +2110,6 @@ __lxcfs_fuse_ops int cg_access(const char *path, int mode)
|
||||
}
|
||||
@@ -2101,5 +2117,6 @@ __lxcfs_fuse_ops int cg_access(const char *path, int mode)
|
||||
|
||||
out:
|
||||
free(cgdir);
|
||||
@ -157,10 +160,10 @@ index 5c22fd1..b396bbc 100644
|
||||
return ret;
|
||||
}
|
||||
diff --git a/src/cgroups/cgfsng.c b/src/cgroups/cgfsng.c
|
||||
index 3eb4227..781923c 100644
|
||||
index 72a4503..e2d9807 100644
|
||||
--- a/src/cgroups/cgfsng.c
|
||||
+++ b/src/cgroups/cgfsng.c
|
||||
@@ -875,7 +875,7 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
|
||||
@@ -891,7 +891,7 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
|
||||
prune_init_scope(base_cgroup);
|
||||
|
||||
if (type == CGROUP2_SUPER_MAGIC) {
|
||||
@ -169,7 +172,7 @@ index 3eb4227..781923c 100644
|
||||
|
||||
cgv2_ctrl_path = must_make_path(mountpoint, base_cgroup,
|
||||
"cgroup.controllers",
|
||||
@@ -883,6 +883,7 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
|
||||
@@ -899,6 +899,7 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
|
||||
|
||||
controller_list = cg_unified_get_controllers(cgv2_ctrl_path);
|
||||
free(cgv2_ctrl_path);
|
||||
@ -177,7 +180,7 @@ index 3eb4227..781923c 100644
|
||||
if (!controller_list)
|
||||
controller_list = cg_unified_make_empty_controller();
|
||||
}
|
||||
@@ -897,7 +898,9 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
|
||||
@@ -913,7 +914,9 @@ static int cg_hybrid_init(struct cgroup_ops *ops)
|
||||
next:
|
||||
free_string_list(controller_list);
|
||||
free(mountpoint);
|
||||
@ -213,10 +216,10 @@ index 1224971..d32a520 100644
|
||||
|
||||
return true;
|
||||
diff --git a/src/lxcfs.c b/src/lxcfs.c
|
||||
index e24ebed..361ce71 100644
|
||||
index 92ed991..e9155ca 100644
|
||||
--- a/src/lxcfs.c
|
||||
+++ b/src/lxcfs.c
|
||||
@@ -1237,10 +1237,12 @@ int main(int argc, char *argv[])
|
||||
@@ -1357,10 +1357,12 @@ int main(int argc, char *argv[])
|
||||
if (append_comma_separate(&new_fuse_opts, token)) {
|
||||
lxcfs_error("Failed to copy fuse argument \"%s\"", token);
|
||||
free(dup);
|
||||
@ -229,7 +232,7 @@ index e24ebed..361ce71 100644
|
||||
}
|
||||
|
||||
if (append_comma_separate(&new_fuse_opts, "allow_other,entry_timeout=0.5,attr_timeout=0.5")) {
|
||||
@@ -1306,7 +1308,9 @@ out:
|
||||
@@ -1426,7 +1428,9 @@ out:
|
||||
if (pidfile)
|
||||
unlink(pidfile);
|
||||
free(new_fuse_opts);
|
||||
@ -240,7 +243,7 @@ index e24ebed..361ce71 100644
|
||||
exit(ret);
|
||||
}
|
||||
diff --git a/src/memory_utils.h b/src/memory_utils.h
|
||||
index c689c8e..a7e4a58 100644
|
||||
index c689c8e..13343e1 100644
|
||||
--- a/src/memory_utils.h
|
||||
+++ b/src/memory_utils.h
|
||||
@@ -67,8 +67,10 @@ static inline void free_disarm_function(void *ptr)
|
||||
@ -256,7 +259,7 @@ index c689c8e..a7e4a58 100644
|
||||
}
|
||||
}
|
||||
diff --git a/src/proc_loadavg.c b/src/proc_loadavg.c
|
||||
index 5f9bec7..c8daf35 100644
|
||||
index b7411c4..8cd1e02 100644
|
||||
--- a/src/proc_loadavg.c
|
||||
+++ b/src/proc_loadavg.c
|
||||
@@ -436,10 +436,13 @@ static int refresh_load(struct load_node *p, const char *path)
|
||||
@ -275,5 +278,5 @@ index 5f9bec7..c8daf35 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
@ -1,26 +1,18 @@
|
||||
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
|
||||
From a6e4ec48f7ad6e64eb95bcd46e8656f1cef95cfd Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Wed, 12 Jul 2023 08:25:20 +0000
|
||||
Subject: [PATCH 07/15] limit stat by quota period setting
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/proc_fuse.c | 14 +++++++++++++-
|
||||
1 file changed, 13 insertions(+), 1 deletion(-)
|
||||
src/proc_fuse.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||
index 48c4e68..c6c32c7 100644
|
||||
index 0af559f..e69e867 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -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,
|
||||
@@ -1087,6 +1087,8 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
|
||||
size_t linelen = 0, total_len = 0;
|
||||
int curcpu = -1; /* cpu numbering starts at 0 */
|
||||
int physcpu = 0;
|
||||
@ -29,7 +21,7 @@ index 48c4e68..c6c32c7 100644
|
||||
uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0,
|
||||
softirq = 0, steal = 0, guest = 0, guest_nice = 0;
|
||||
uint64_t user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0,
|
||||
@@ -1079,6 +1081,13 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
|
||||
@@ -1138,6 +1140,13 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
|
||||
if (!cpuset)
|
||||
return 0;
|
||||
|
||||
@ -38,12 +30,12 @@ index 48c4e68..c6c32c7 100644
|
||||
+ else
|
||||
+ use_view = false;
|
||||
+ if (use_view)
|
||||
+ max_cpus = max_cpu_count(cg);
|
||||
+ max_cpus = max_cpu_count(cg, cpu_cg);
|
||||
+
|
||||
f = fopen_cached("/proc/stat", "re", &fopen_cache);
|
||||
if (!f)
|
||||
return 0;
|
||||
@@ -1127,6 +1136,9 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
|
||||
@@ -1186,6 +1195,9 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -54,5 +46,5 @@ index 48c4e68..c6c32c7 100644
|
||||
continue;
|
||||
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
192
0008-diskstats-support-devicemapper-device.patch
Normal file
192
0008-diskstats-support-devicemapper-device.patch
Normal file
@ -0,0 +1,192 @@
|
||||
From 0dded445efa7b53886081beab5b74facf0378287 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 27 Jul 2023 08:15:49 +0000
|
||||
Subject: [PATCH 08/15] diskstats support devicemapper device
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
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
|
||||
index 0aaab71..48c4e68 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -43,6 +43,26 @@
|
||||
#include "proc_cpuview.h"
|
||||
#include "utils.h"
|
||||
|
||||
+static pthread_mutex_t container_dev_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
+
|
||||
+static void lock_mutex(pthread_mutex_t *l)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = pthread_mutex_lock(l);
|
||||
+ if (ret)
|
||||
+ log_exit("%s - returned %d\n", strerror(ret), ret);
|
||||
+}
|
||||
+
|
||||
+static void unlock_mutex(pthread_mutex_t *l)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = pthread_mutex_unlock(l);
|
||||
+ if (ret)
|
||||
+ log_exit("%s - returned %d\n", strerror(ret), ret);
|
||||
+}
|
||||
+
|
||||
struct memory_stat {
|
||||
uint64_t hierarchical_memory_limit;
|
||||
uint64_t hierarchical_memsw_limit;
|
||||
@@ -492,6 +512,16 @@ struct devinfo* container_dev_read(pid_t pid) {
|
||||
return head;
|
||||
}
|
||||
if (child_pid == 0) {
|
||||
+ /* Disallow signal reception in child process */
|
||||
+ sigset_t oldset;
|
||||
+ sigset_t newset;
|
||||
+ sigemptyset(&newset);
|
||||
+ sigaddset(&newset, SIGTERM);
|
||||
+ sigaddset(&newset, SIGINT);
|
||||
+ sigaddset(&newset, SIGHUP);
|
||||
+ sigaddset(&newset, SIGQUIT);
|
||||
+ sigprocmask(SIG_BLOCK,&newset,&oldset);
|
||||
+
|
||||
close(mypipe[0]);
|
||||
stream = fdopen(mypipe[1], "w");
|
||||
if (stream == NULL) {
|
||||
@@ -538,6 +568,8 @@ child_out:
|
||||
lxcfs_error("Error opening pipe for reading: %s\n", strerror(errno));
|
||||
goto err;
|
||||
}
|
||||
+ wait_for_pid(child_pid);
|
||||
+ child_pid = 0;
|
||||
while (fscanf(stream, "%100s%d", dev_name, &dev_num) == 2) {
|
||||
if (dev_num == 0) {
|
||||
break;
|
||||
@@ -681,7 +713,9 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
if (!f)
|
||||
return 0;
|
||||
|
||||
+ lock_mutex(&container_dev_mutex);
|
||||
container_devinfo = container_dev_read(initpid);
|
||||
+ unlock_mutex(&container_dev_mutex);
|
||||
|
||||
while (getline(&line, &linelen, f) != -1) {
|
||||
ssize_t l;
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,32 +1,33 @@
|
||||
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
|
||||
From f230a8816877cc803d52661a444cb6d1b9d55f96 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 27 Jul 2023 08:28:00 +0000
|
||||
Subject: [PATCH 09/15] lxcfs add proc partitions
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/bindings.h | 3 ++
|
||||
src/proc_fuse.c | 131 +++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 126 insertions(+), 8 deletions(-)
|
||||
src/proc_fuse.c | 137 ++++++++++++++++++++++++++++++++++++++++++++----
|
||||
2 files changed, 131 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/bindings.h b/src/bindings.h
|
||||
index cd7d466..91d44c7 100644
|
||||
index 8d9d6eb..fcf408a 100644
|
||||
--- a/src/bindings.h
|
||||
+++ b/src/bindings.h
|
||||
@@ -55,6 +55,9 @@ enum lxcfs_virt_t {
|
||||
LXC_TYPE_PROC_LOADAVG,
|
||||
#define LXC_TYPE_PROC_LOADAVG_PATH "/proc/loadavg"
|
||||
@@ -60,6 +60,9 @@ enum lxcfs_virt_t {
|
||||
LXC_TYPE_PROC_SLABINFO,
|
||||
#define LXC_TYPE_PROC_SLABINFO_PATH "/proc/slabinfo"
|
||||
|
||||
+ LXC_TYPE_PROC_PARTITIONS,
|
||||
+#define LXC_TYPE_PROC_PARTITIONS_PATH "/proc/partitions"
|
||||
+
|
||||
LXC_TYPE_SYS,
|
||||
LXC_TYPE_SYS_DEVICES,
|
||||
LXC_TYPE_SYS_DEVICES_SYSTEM,
|
||||
LXC_TYPE_SYS_DEVICES_SYSTEM_CPU,
|
||||
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||
index a613688..72f6de6 100644
|
||||
index 1f732ff..0dbbefe 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -118,13 +118,14 @@ __lxcfs_fuse_ops int proc_getattr(const char *path, struct stat *sb)
|
||||
@@ -119,14 +119,15 @@ __lxcfs_fuse_ops int proc_getattr(const char *path, struct stat *sb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -36,7 +37,8 @@ index a613688..72f6de6 100644
|
||||
- strcmp(path, "/proc/stat") == 0 ||
|
||||
- strcmp(path, "/proc/diskstats") == 0 ||
|
||||
- strcmp(path, "/proc/swaps") == 0 ||
|
||||
- strcmp(path, "/proc/loadavg") == 0) {
|
||||
- strcmp(path, "/proc/loadavg") == 0 ||
|
||||
- strcmp(path, "/proc/slabinfo") == 0) {
|
||||
+ if (strcmp(path, "/proc/meminfo") == 0 ||
|
||||
+ strcmp(path, "/proc/cpuinfo") == 0 ||
|
||||
+ strcmp(path, "/proc/uptime") == 0 ||
|
||||
@ -44,30 +46,31 @@ index a613688..72f6de6 100644
|
||||
+ strcmp(path, "/proc/diskstats") == 0 ||
|
||||
+ strcmp(path, "/proc/swaps") == 0 ||
|
||||
+ strcmp(path, "/proc/loadavg") == 0 ||
|
||||
+ strcmp(path, "/proc/slabinfo") == 0 ||
|
||||
+ strcmp(path, "/proc/partitions") == 0) {
|
||||
sb->st_size = get_procfile_size(path);
|
||||
sb->st_mode = S_IFREG | 00444;
|
||||
sb->st_nlink = 1;
|
||||
@@ -146,7 +147,8 @@ __lxcfs_fuse_ops int proc_readdir(const char *path, void *buf,
|
||||
DIR_FILLER(filler, buf, "uptime", NULL, 0) != 0 ||
|
||||
DIR_FILLER(filler, buf, "diskstats", NULL, 0) != 0 ||
|
||||
DIR_FILLER(filler, buf, "swaps", NULL, 0) != 0 ||
|
||||
- DIR_FILLER(filler, buf, "loadavg", NULL, 0) != 0)
|
||||
+ DIR_FILLER(filler, buf, "loadavg", NULL, 0) != 0 ||
|
||||
+ DIR_FILLER(filler, buf, "partitions", NULL, 0) != 0)
|
||||
@@ -149,7 +150,8 @@ __lxcfs_fuse_ops int proc_readdir(const char *path, void *buf,
|
||||
dir_filler(filler, buf, "diskstats", 0) != 0 ||
|
||||
dir_filler(filler, buf, "swaps", 0) != 0 ||
|
||||
dir_filler(filler, buf, "loadavg", 0) != 0 ||
|
||||
- dir_filler(filler, buf, "slabinfo", 0) != 0)
|
||||
+ dir_filler(filler, buf, "slabinfo", 0) != 0 ||
|
||||
+ dir_filler(filler, buf, "partitions", 0) != 0)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
@@ -171,6 +173,8 @@ __lxcfs_fuse_ops int proc_open(const char *path, struct fuse_file_info *fi)
|
||||
type = LXC_TYPE_PROC_SWAPS;
|
||||
else if (strcmp(path, "/proc/loadavg") == 0)
|
||||
@@ -176,6 +178,8 @@ __lxcfs_fuse_ops int proc_open(const char *path, struct fuse_file_info *fi)
|
||||
type = LXC_TYPE_PROC_LOADAVG;
|
||||
else if (strcmp(path, "/proc/slabinfo") == 0)
|
||||
type = LXC_TYPE_PROC_SLABINFO;
|
||||
+ else if (strcmp(path, "/proc/partitions") == 0)
|
||||
+ type = LXC_TYPE_PROC_PARTITIONS;
|
||||
if (type == -1)
|
||||
return -ENOENT;
|
||||
|
||||
@@ -872,6 +876,111 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
@@ -975,6 +979,115 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
return total_len;
|
||||
}
|
||||
|
||||
@ -91,14 +94,18 @@ index a613688..72f6de6 100644
|
||||
+ FILE *f = NULL;
|
||||
+
|
||||
+ if (offset > 0){
|
||||
+ size_t left;
|
||||
+
|
||||
+ if (offset > d->size)
|
||||
+ return -EINVAL;
|
||||
+ if (d->cached == 0)
|
||||
+ return 0;
|
||||
+ int left = d->size - offset;
|
||||
+ total_len = left > size ? size: left;
|
||||
+
|
||||
+ if (!d->cached)
|
||||
+ return 0;
|
||||
+
|
||||
+ left = d->size - offset;
|
||||
+ total_len = left > size ? size: left;
|
||||
+ memcpy(buf, cache + offset, total_len);
|
||||
+
|
||||
+ return total_len;
|
||||
+ }
|
||||
+
|
||||
@ -148,7 +155,7 @@ index a613688..72f6de6 100644
|
||||
+ rv = 0;
|
||||
+ goto err;
|
||||
+ }
|
||||
+ if (l >= cache_size) {
|
||||
+ if ((size_t)l >= cache_size) {
|
||||
+ lxcfs_error("%s\n", "Internal error: truncated write to cache.");
|
||||
+ rv = 0;
|
||||
+ goto err;
|
||||
@ -179,9 +186,9 @@ index a613688..72f6de6 100644
|
||||
#ifdef RELOADTEST
|
||||
static inline void iwashere(void)
|
||||
{
|
||||
@@ -1676,6 +1785,12 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size,
|
||||
@@ -1912,6 +2025,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_SLABINFO_PATH,
|
||||
buf, size, offset, f);
|
||||
+ case LXC_TYPE_PROC_PARTITIONS:
|
||||
+ if(liblxcfs_functional())
|
||||
@ -193,5 +200,5 @@ index a613688..72f6de6 100644
|
||||
|
||||
return -EINVAL;
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
@ -1,111 +0,0 @@
|
||||
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
|
||||
index c6c32c7..a613688 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -611,6 +611,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 */
|
||||
@@ -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 ret;
|
||||
+ char tmp_dev_name[72];
|
||||
|
||||
if (offset) {
|
||||
size_t left;
|
||||
@@ -720,6 +730,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);
|
||||
@@ -729,9 +740,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);
|
||||
@@ -791,8 +807,46 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
stats.discard_merged,
|
||||
stats.discard_sectors,
|
||||
stats.discard_ticks);
|
||||
- else
|
||||
+ 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 {
|
||||
continue;
|
||||
+ }
|
||||
|
||||
l = snprintf(cache, cache_size, "%s", lbuf);
|
||||
if (l < 0) {
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
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
|
||||
From d7582ba91869e19936c76f4d63b803d82d8e1caf Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Wed, 12 Jul 2023 08:53:42 +0000
|
||||
Subject: [PATCH 10/15] lxcfs proc_diskstats_read func obtain data from blki
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/cgroups/cgfsng.c | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/cgroups/cgfsng.c b/src/cgroups/cgfsng.c
|
||||
index 781923c..e50c87d 100644
|
||||
index e2d9807..15b4539 100644
|
||||
--- a/src/cgroups/cgfsng.c
|
||||
+++ b/src/cgroups/cgfsng.c
|
||||
@@ -751,7 +751,11 @@ static int cgfsng_get_io(struct cgroup_ops *ops, const char *cgroup,
|
||||
@@ -767,7 +767,11 @@ static int cgfsng_get_io(struct cgroup_ops *ops, const char *cgroup,
|
||||
static int cgfsng_get_io_service_bytes(struct cgroup_ops *ops,
|
||||
const char *cgroup, char **value)
|
||||
{
|
||||
@ -24,7 +25,7 @@ index 781923c..e50c87d 100644
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -779,7 +783,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,
|
||||
char **value)
|
||||
{
|
||||
@ -38,5 +39,5 @@ index 781923c..e50c87d 100644
|
||||
|
||||
static int cgfsng_get_io_merged(struct cgroup_ops *ops, const char *cgroup,
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
49
0011-add-secure-compile-option-in-meson.patch
Normal file
49
0011-add-secure-compile-option-in-meson.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From cd4988df0a9f7140758c0429485322dc6d9467d5 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Fri, 14 Jul 2023 07:54:27 +0000
|
||||
Subject: [PATCH 11/15] add secure compile option in meson
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
Makefile | 2 +-
|
||||
meson.build | 4 ++++
|
||||
2 files changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 94f2021..38fbe04 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
.PHONY: all
|
||||
all: meson
|
||||
- ninja -C build
|
||||
+ ninja -v -C build
|
||||
|
||||
.PHONY: meson
|
||||
meson:
|
||||
diff --git a/meson.build b/meson.build
|
||||
index a0289ad..7eb1f06 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -12,6 +12,7 @@ project(
|
||||
'b_pie=true',
|
||||
'c_std=gnu11',
|
||||
'warning_level=2',
|
||||
+ 'optimization=2',
|
||||
],
|
||||
meson_version: '>= 0.50')
|
||||
|
||||
@@ -109,6 +110,9 @@ possible_cc_flags = [
|
||||
'-Wreturn-local-addr',
|
||||
'-fsanitize=cfi',
|
||||
'-Wstringop-overflow',
|
||||
+ '-ftrapv',
|
||||
+ '-fPIC',
|
||||
+ '-D_FORTIFY_SOURCE=2',
|
||||
]
|
||||
|
||||
possible_link_flags = [
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
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
|
||||
From 60eefa396251acebd02f06538ccee1081dcdcd0d Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 27 Jul 2023 09:10:52 +0000
|
||||
Subject: [PATCH 12/15] lxcfs adapt 4.18 kernel
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
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 0d5ba89..a72d6a2 100644
|
||||
index 0dbbefe..392115c 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -659,8 +659,8 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
@@ -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 */
|
||||
@ -22,7 +23,7 @@ index 0d5ba89..a72d6a2 100644
|
||||
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,
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@ -55,7 +56,7 @@ index 0d5ba89..a72d6a2 100644
|
||||
|
||||
f = fopen_cached("/proc/diskstats", "re", &fopen_cache);
|
||||
if (!f)
|
||||
@@ -756,9 +742,11 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
@@ -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);
|
||||
|
||||
@ -70,7 +71,7 @@ index 0d5ba89..a72d6a2 100644
|
||||
|
||||
get_blkio_io_value(io_service_bytes_str, stats.major, stats.minor, "Read", &stats.read_sectors);
|
||||
stats.read_sectors = stats.read_sectors / 512;
|
||||
@@ -767,26 +755,29 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
@@ -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;
|
||||
|
||||
@ -115,8 +116,8 @@ index 0d5ba89..a72d6a2 100644
|
||||
- stats.total_ticks = stats.total_ticks / 1000000;
|
||||
+ stats.total_ticks = total_ticks / 1000000;
|
||||
|
||||
memset(lbuf, 0, 256);
|
||||
memset(lbuf, 0, sizeof(lbuf));
|
||||
if (stats.read || stats.write || stats.read_merged || stats.write_merged ||
|
||||
--
|
||||
2.27.0
|
||||
2.41.0
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
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
|
||||
index 2734334..437a377 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -6,6 +6,8 @@ AM_LDFLAGS = $(FUSE_LIBS) -pthread
|
||||
#AM_CFLAGS += -DVERBOSE
|
||||
|
||||
AM_CFLAGS += -DRUNTIME_PATH=\"$(RUNTIME_PATH)\"
|
||||
+AM_CFLAGS += -Wl,-z,now -fPIE
|
||||
+AM_LDFLAGS += -Wl,-z,now -pie
|
||||
|
||||
liblxcfs_la_SOURCES = api_extensions.h \
|
||||
bindings.c bindings.h \
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
From ed5823bf5b0d8bd425417d9b3590ece248fe1655 Mon Sep 17 00:00:00 2001
|
||||
From: yangjiaqi <yangjiaqi16@huawei.com>
|
||||
Date: Sat, 26 Nov 2022 11:48:14 +0800
|
||||
Subject: [PATCH] enable cfs option to show correct proc cpuinfo view
|
||||
From 30f3e8cf0c6e34c5a8e4dd9d599c6c96646bd2ba Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Sat, 15 Jul 2023 03:43:12 +0000
|
||||
Subject: [PATCH 13/15] enable cfs option to show correct proc cpuinfo view
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
config/init/systemd/lxcfs.service.in | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config/init/systemd/lxcfs.service.in b/config/init/systemd/lxcfs.service.in
|
||||
index bdaa2fa..3ee006b 100644
|
||||
index bae1d08..c3bfd0f 100644
|
||||
--- a/config/init/systemd/lxcfs.service.in
|
||||
+++ b/config/init/systemd/lxcfs.service.in
|
||||
@@ -6,7 +6,7 @@ Documentation=man:lxcfs(1)
|
||||
|
||||
@@ -7,7 +7,7 @@ Documentation=man:lxcfs(1)
|
||||
[Service]
|
||||
OOMScoreAdjust=-1000
|
||||
ExecStartPre=-/usr/local/bin/lxcfs-tools prestart
|
||||
-ExecStart=/usr/bin/lxcfs /var/lib/lxc/lxcfs/
|
||||
+ExecStart=/usr/bin/lxcfs --enable-cfs /var/lib/lxc/lxcfs/
|
||||
@ -21,5 +22,5 @@ index bdaa2fa..3ee006b 100644
|
||||
KillMode=process
|
||||
ExecStop=-/usr/local/bin/lxcfs-tools umount -a
|
||||
--
|
||||
2.30.0
|
||||
2.41.0
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
From e3ca16cd280bea10a63e959623fd6625f7b868ce Mon Sep 17 00:00:00 2001
|
||||
From: yangjiaqi <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 24 Nov 2022 15:53:53 +0800
|
||||
Subject: [PATCH] fix pidfd_open&pidfd_send_signal function compilation bug in
|
||||
glibc2.36+
|
||||
From 2c07195cd633c270ddcc6ef5349dbbc7063302d5 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Sat, 15 Jul 2023 04:25:53 +0000
|
||||
Subject: [PATCH 14/15] fix pidfd_open pidfd_send_signal function compilation
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/utils.h | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/src/utils.h b/src/utils.h
|
||||
index 18d85a7..ab2da0f 100644
|
||||
index 7ed021a..5f19946 100644
|
||||
--- a/src/utils.h
|
||||
+++ b/src/utils.h
|
||||
@@ -46,6 +46,9 @@ static inline int pidfd_open(pid_t pid, unsigned int flags)
|
||||
@ -33,5 +33,5 @@ index 18d85a7..ab2da0f 100644
|
||||
|
||||
extern FILE *fopen_cached(const char *path, const char *mode,
|
||||
--
|
||||
2.30.0
|
||||
2.41.0
|
||||
|
||||
@ -1,128 +0,0 @@
|
||||
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
|
||||
|
||||
39
0015-adapt-meson-build-install.patch
Normal file
39
0015-adapt-meson-build-install.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From c79ce840026f83a8582d31e5e80529f0c230126c Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 27 Jul 2023 09:18:15 +0000
|
||||
Subject: [PATCH 15/15] adapt meson build & install
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
Makefile | 2 +-
|
||||
config/init/meson.build | 1 +
|
||||
2 files changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 38fbe04..891d7ad 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -6,7 +6,7 @@ all: meson
|
||||
|
||||
.PHONY: meson
|
||||
meson:
|
||||
- [ -d build ] || meson setup build/
|
||||
+ [ -d build ] || meson setup build/ --prefix=/usr
|
||||
|
||||
.PHONY: dist
|
||||
dist: meson
|
||||
diff --git a/config/init/meson.build b/config/init/meson.build
|
||||
index 5200570..c781b59 100644
|
||||
--- a/config/init/meson.build
|
||||
+++ b/config/init/meson.build
|
||||
@@ -14,6 +14,7 @@ if 'systemd' in init_script
|
||||
'@OUTPUT@',
|
||||
],
|
||||
install: true,
|
||||
+ install_mode: 'rw-r--r--',
|
||||
install_dir: systemd_system_unit_dir)
|
||||
endif
|
||||
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
From 035571472fa6c5772cc6ac467cad7f8ffb9e1d8e Mon Sep 17 00:00:00 2001
|
||||
From: yangjiaqi <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 25 Nov 2021 20:26:45 +0800
|
||||
Subject: [PATCH 16/17] remove-lxcfs-tools-dependency-for-common-use
|
||||
|
||||
---
|
||||
config/init/systemd/lxcfs.service.in | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/config/init/systemd/lxcfs.service.in b/config/init/systemd/lxcfs.service.in
|
||||
index 3d763c6..bdaa2fa 100644
|
||||
--- a/config/init/systemd/lxcfs.service.in
|
||||
+++ b/config/init/systemd/lxcfs.service.in
|
||||
@@ -5,11 +5,11 @@ Before=lxc.service
|
||||
Documentation=man:lxcfs(1)
|
||||
|
||||
[Service]
|
||||
-ExecStartPre=/usr/local/bin/lxcfs-tools prestart
|
||||
+ExecStartPre=-/usr/local/bin/lxcfs-tools prestart
|
||||
ExecStart=/usr/bin/lxcfs /var/lib/lxc/lxcfs/
|
||||
-ExecStartPost=/usr/local/bin/lxcfs-tools remount -a
|
||||
+ExecStartPost=-/usr/local/bin/lxcfs-tools remount -a
|
||||
KillMode=process
|
||||
-ExecStop=/usr/local/bin/lxcfs-tools umount -a
|
||||
+ExecStop=-/usr/local/bin/lxcfs-tools umount -a
|
||||
ExecStopPost=-/bin/fusermount -u /var/lib/lxc/
|
||||
Delegate=yes
|
||||
ExecReload=/bin/kill -USR1 $MAINPID
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
From c27c750ba028a65a3d136999e85939dbb9601b06 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 14 Dec 2023 07:27:07 +0000
|
||||
Subject: [PATCH] typofix: fix incorrect printing in lxcfs help interface
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
src/lxcfs.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/lxcfs.c b/src/lxcfs.c
|
||||
index cb0739c..c55a388 100644
|
||||
--- a/src/lxcfs.c
|
||||
+++ b/src/lxcfs.c
|
||||
@@ -1181,7 +1181,7 @@ static void usage(void)
|
||||
lxcfs_info("Options :");
|
||||
lxcfs_info(" -d, --debug Run lxcfs with debugging enabled");
|
||||
lxcfs_info(" -f, --foreground Run lxcfs in the foreground");
|
||||
- lxcfs_info(" -n, --help Print help");
|
||||
+ lxcfs_info(" -h, --help Print help");
|
||||
lxcfs_info(" -l, --enable-loadavg Enable loadavg virtualization");
|
||||
lxcfs_info(" -o Options to pass directly through fuse");
|
||||
lxcfs_info(" -p, --pidfile=FILE Path to use for storing lxcfs pid");
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
From 798bb221b5862418bfb965dc93ce785c743919ff Mon Sep 17 00:00:00 2001
|
||||
From: yangjiaqi <yangjiaqi16@huawei.com>
|
||||
Date: Thu, 25 Nov 2021 20:30:09 +0800
|
||||
Subject: [PATCH 17/17] proc_fuse-fix-wait-child-process-hang
|
||||
|
||||
---
|
||||
src/proc_fuse.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||
index a72d6a2..d02f841 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -561,11 +561,11 @@ struct devinfo* container_dev_read(pid_t pid) {
|
||||
dev_num = dev_stat.st_dev & (~0xf);
|
||||
fprintf(stream, "sda %d end 0 ", dev_num);
|
||||
fflush(stream);
|
||||
+child_out:
|
||||
fclose(stream);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
-child_out:
|
||||
close(mypipe[1]);
|
||||
stream = fdopen(mypipe[0], "r");
|
||||
if (stream == NULL) {
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
From 4ad5ee6eafcdef8178adf1cea53ab8a617d3fd78 Mon Sep 17 00:00:00 2001
|
||||
From: yangjiaqi <yangjiaqi16@huawei.com>
|
||||
Date: Wed, 15 Dec 2021 17:19:01 +0800
|
||||
Subject: [PATCH] fix deadlock problem when subprocess exit
|
||||
|
||||
---
|
||||
src/proc_fuse.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||
index d02f841..0f66c40 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -563,7 +563,7 @@ struct devinfo* container_dev_read(pid_t pid) {
|
||||
fflush(stream);
|
||||
child_out:
|
||||
fclose(stream);
|
||||
- exit(0);
|
||||
+ _exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
close(mypipe[1]);
|
||||
--
|
||||
2.32.0 (Apple Git-132)
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
From d67982ddf6d742b92799d1fb2e4c89e8ff87d95b Mon Sep 17 00:00:00 2001
|
||||
From: zhangsong234 <zhangsong34@huawei.com>
|
||||
Date: Wed, 11 May 2022 15:55:47 +0800
|
||||
Subject: [PATCH] fix dev read memory leak in container
|
||||
|
||||
Signed-off-by: zhangsong234 <zhangsong34@huawei.com>
|
||||
---
|
||||
src/proc_fuse.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||||
index 0f66c40..6051e9a 100644
|
||||
--- a/src/proc_fuse.c
|
||||
+++ b/src/proc_fuse.c
|
||||
@@ -497,7 +497,7 @@ struct devinfo* container_dev_read(pid_t pid) {
|
||||
struct dirent *ptr;
|
||||
struct stat dev_stat;
|
||||
struct devinfo *head = NULL, *end;
|
||||
- char fpath[100], dev_name[100];
|
||||
+ char fpath[100], dev_name[101];
|
||||
pid_t child_pid;
|
||||
int mypipe[2];
|
||||
int dev_num;
|
||||
@@ -558,7 +558,7 @@ struct devinfo* container_dev_read(pid_t pid) {
|
||||
}
|
||||
closedir(dir);
|
||||
stat("/", &dev_stat);
|
||||
- dev_num = dev_stat.st_dev & (~0xf);
|
||||
+ dev_num = dev_stat.st_dev;
|
||||
fprintf(stream, "sda %d end 0 ", dev_num);
|
||||
fflush(stream);
|
||||
child_out:
|
||||
@@ -574,6 +574,7 @@ child_out:
|
||||
}
|
||||
wait_for_pid(child_pid);
|
||||
child_pid = 0;
|
||||
+ memset(dev_name, 0, sizeof(dev_name));
|
||||
while (fscanf(stream, "%100s%d", dev_name, &dev_num) == 2) {
|
||||
if (dev_num == 0) {
|
||||
break;
|
||||
@@ -593,6 +594,7 @@ child_out:
|
||||
end->name = must_copy_string(dev_name);
|
||||
end->major = major(dev_num);
|
||||
end->minor = minor(dev_num);
|
||||
+ memset(dev_name, 0, sizeof(dev_name));
|
||||
}
|
||||
err:
|
||||
if (stream)
|
||||
@@ -883,6 +885,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||||
if (total_len > size)
|
||||
total_len = size;
|
||||
memcpy(buf, d->buf, total_len);
|
||||
+ free_devinfo_list(container_devinfo);
|
||||
|
||||
return total_len;
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
Binary file not shown.
BIN
lxcfs-5.0.4.tar.gz
Normal file
BIN
lxcfs-5.0.4.tar.gz
Normal file
Binary file not shown.
78
lxcfs.spec
78
lxcfs.spec
@ -3,37 +3,32 @@
|
||||
|
||||
#Basic Information
|
||||
Name: lxcfs
|
||||
Version: 4.0.11
|
||||
Release: 6
|
||||
Version: 5.0.4
|
||||
Release: 2
|
||||
Summary: FUSE filesystem for LXC
|
||||
License: LGPL 2.1+
|
||||
URL: http://linuxcontainers.org
|
||||
Source: https://linuxcontainers.org/downloads/%{name}/%{name}-%{version}.tar.gz
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
Patch9001: 0001-systemd.patch
|
||||
Patch9002: 0002-remove-sysvinit-upstart.patch
|
||||
Patch9003: 0003-show-dev-name-in-container.patch
|
||||
Patch9004: 0004-lxcfs-fix-cpuinfo-print.patch
|
||||
Patch9005: 0005-fix-memory-leak.patch
|
||||
Patch9006: 0006-fix-concurrency-problem.patch
|
||||
Patch9007: 0007-set-null-after-free.patch
|
||||
Patch9008: 0008-fix-hang.patch
|
||||
Patch9009: 0009-limit-stat-by-quota-period-setting.patch
|
||||
Patch9010: 0010-diskstats-support-devicemapper-device.patch
|
||||
Patch9011: 0011-lxcfs-add-proc-partitions.patch
|
||||
Patch9012: 0012-lxcfs-proc_diskstats_read-func-obtain-data-from-blki.patch
|
||||
Patch9013: 0013-add-secure-compile-option-in-Makefile.patch
|
||||
Patch9014: 0014-fix-proc-diskstats-show-in-container.patch
|
||||
Patch9015: 0015-lxcfs-adapt-4.18-kernel.patch
|
||||
Patch9016: 0016-remove-lxcfs-tools-dependency-for-common-use.patch
|
||||
Patch9017: 0017-proc_fuse-fix-wait-child-process-hang.patch
|
||||
Patch9018: 0018-fix-deadlock-problem-when-subprocess-exit.patch
|
||||
Patch9019: 0019-fix-dev-read-memory-leak-in-container.patch
|
||||
Patch9020: 0020-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch
|
||||
Patch9021: 0021-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch
|
||||
Patch9002: 0002-show-dev-name-in-container.patch
|
||||
Patch9003: 0003-lxcfs-fix-cpuinfo-print.patch
|
||||
Patch9004: 0004-fix-memory-leak.patch
|
||||
Patch9005: 0005-fix-concurrency-problem.patch
|
||||
Patch9006: 0006-set-null-after-free.patch
|
||||
Patch9007: 0007-limit-stat-by-quota-period-setting.patch
|
||||
Patch9008: 0008-diskstats-support-devicemapper-device.patch
|
||||
Patch9009: 0009-lxcfs-add-proc-partitions.patch
|
||||
Patch9010: 0010-lxcfs-proc_diskstats_read-func-obtain-data-from-blki.patch
|
||||
Patch9011: 0011-add-secure-compile-option-in-meson.patch
|
||||
Patch9012: 0012-lxcfs-adapt-4.18-kernel.patch
|
||||
Patch9013: 0013-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch
|
||||
Patch9014: 0014-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch
|
||||
Patch9015: 0015-adapt-meson-build-install.patch
|
||||
Patch9016: 0016-typofix-fix-incorrect-printing-in-lxcfs-help-interfa.patch
|
||||
|
||||
#Dependency
|
||||
BuildRequires: autoconf automake libtool help2man
|
||||
BuildRequires: meson python3-jinja2 help2man
|
||||
BuildRequires: fuse-devel libattr-devel
|
||||
BuildRequires: gcc systemd-units
|
||||
Requires: fuse-libs
|
||||
@ -47,15 +42,11 @@ any runtime, written in C using libfuse and glib.
|
||||
%autosetup -p1
|
||||
|
||||
%build
|
||||
autoreconf --force --install
|
||||
%configure
|
||||
make tests
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
make install DESTDIR=%{buildroot} %{?_smp_mflags}
|
||||
install -d -m 0755 %{buildroot}%{_unitdir}
|
||||
install -p -m 0644 config/init/systemd/*.service %{buildroot}%{_unitdir}/
|
||||
make install DESTDIR=%{buildroot} %{?_smp_mflags}
|
||||
install -d -m 0755 %{buildroot}%{_sbindir}
|
||||
ln -sf service %{buildroot}%{_sbindir}/rc%{name}
|
||||
install -d -m 0755 %{buildroot}%{_includedir}/%{name}
|
||||
@ -87,11 +78,40 @@ fi
|
||||
%dir %{_localstatedir}/lib/lxc/%{name}
|
||||
%dir %{_libdir}/%{name}
|
||||
%{_libdir}/%{name}/lib%{name}.so
|
||||
%exclude %{_libdir}/%{name}/lib%{name}.la
|
||||
%{_mandir}/man1/*
|
||||
%{_unitdir}/*
|
||||
|
||||
%changelog
|
||||
* Fri Dec 15 2023 yangjiaqi <yangjiaqi16@huawei.com> - 5.0.4-2
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:fix incorrect printing in lxcfs help interface
|
||||
|
||||
* Thu July 27 2023 yangjiaqi <yangjiaqi16@huawei.com> - 5.0.4-1
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:upgrade to 5.0.4
|
||||
|
||||
* Mon July 17 2023 yangjiaqi <yangjiaqi16@huawei.com> - 5.0.3-1
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:upgrade to 5.0.3
|
||||
|
||||
* 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
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:fix possible use-after-free in find_proc_stat_node
|
||||
|
||||
* Mon Dec 12 2022 yangjiaqi <yangjiaqi16@huawei.com> - 4.0.11-6
|
||||
- add yaml
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user