]> git.proxmox.com Git - lxcfs.git/commitdiff
update patches for 4.0.12
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 4 Apr 2022 09:21:13 +0000 (11:21 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 4 Apr 2022 09:29:30 +0000 (11:29 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
debian/patches/extra/0001-cgv2-assume-swap-is-supported.patch [new file with mode: 0644]
debian/patches/extra/0001-make-meminfo-and-swaps-cgroupv2-aware.patch [deleted file]
debian/patches/extra/0002-build-with-fuse2.patch [new file with mode: 0644]
debian/patches/extra/0002-cgv2-assume-swap-is-supported.patch [deleted file]
debian/patches/extra/0003-build-with-fuse2.patch [deleted file]
debian/patches/series

diff --git a/debian/patches/extra/0001-cgv2-assume-swap-is-supported.patch b/debian/patches/extra/0001-cgv2-assume-swap-is-supported.patch
new file mode 100644 (file)
index 0000000..c5d4a1a
--- /dev/null
@@ -0,0 +1,33 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Wolfgang Bumiller <w.bumiller@proxmox.com>
+Date: Thu, 2 Dec 2021 13:05:28 +0100
+Subject: [PATCH lxcfs] cgv2: assume swap is supported
+
+because this is just wrong and fixing it is annoying
+
+Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
+---
+ src/cgroups/cgfsng.c | 10 ++++------
+ 1 file changed, 4 insertions(+), 6 deletions(-)
+
+diff --git a/src/cgroups/cgfsng.c b/src/cgroups/cgfsng.c
+index 3eb4227..fed7911 100644
+--- a/src/cgroups/cgfsng.c
++++ b/src/cgroups/cgfsng.c
+@@ -626,12 +626,10 @@ static bool cgfsng_can_use_swap(struct cgroup_ops *ops)
+               return false;
+       if (is_unified_hierarchy(h)) {
+-              if (faccessat(h->fd, "memory.swap.max", F_OK, 0))
+-                      return false;
+-
+-              if (faccessat(h->fd, "memory.swap.current", F_OK, 0))
+-                      return false;
+-
++              /* the files to check for don't exist at the root cgroup
++               * directory so let's assume yes, other kernel configs are
++               * simply not supported on pve
++               */
+               has_swap = true;
+       } else {
+               if (faccessat(h->fd, "memory.memsw.limit_in_bytes", F_OK, 0))
diff --git a/debian/patches/extra/0001-make-meminfo-and-swaps-cgroupv2-aware.patch b/debian/patches/extra/0001-make-meminfo-and-swaps-cgroupv2-aware.patch
deleted file mode 100644 (file)
index a8ee397..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Wolfgang Bumiller <w.bumiller@proxmox.com>
-Date: Thu, 8 Jul 2021 12:04:05 +0200
-Subject: [PATCH lxcfs] make meminfo and swaps cgroupv2 aware
-
-and deduplicate the corresponding code
-
-Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
----
- src/bindings.c  | 10 ++++++
- src/bindings.h  |  1 +
- src/proc_fuse.c | 89 +++++++++++++++++++++++++------------------------
- 3 files changed, 57 insertions(+), 43 deletions(-)
-
-diff --git a/src/bindings.c b/src/bindings.c
-index eb62ddb..e417a13 100644
---- a/src/bindings.c
-+++ b/src/bindings.c
-@@ -44,6 +44,7 @@ static bool can_use_pidfd;
- static bool can_use_swap;
- static bool can_use_sys_cpu;
- static bool has_versioned_opts;
-+static bool memory_is_cgroupv2;
- static volatile sig_atomic_t reload_successful;
-@@ -67,6 +68,11 @@ bool liblxcfs_has_versioned_opts(void)
-       return has_versioned_opts;
- }
-+bool liblxcfs_memory_is_cgroupv2(void)
-+{
-+      return memory_is_cgroupv2;
-+}
-+
- /* Define pivot_root() if missing from the C library */
- #ifndef HAVE_PIVOT_ROOT
- static int pivot_root(const char *new_root, const char *put_old)
-@@ -837,6 +843,7 @@ static void __attribute__((constructor)) lxcfs_init(void)
-                                 pidfd = -EBADF;
-       int i = 0;
-       pid_t pid;
-+      struct hierarchy *hierarchy;
-       lxcfs_info("Running constructor %s to reload liblxcfs", __func__);
-@@ -894,6 +901,9 @@ static void __attribute__((constructor)) lxcfs_init(void)
-       else
-               lxcfs_info("Kernel does not support swap accounting");
-+      hierarchy = cgroup_ops->get_hierarchy(cgroup_ops, "memory");
-+      memory_is_cgroupv2 = hierarchy && is_unified_hierarchy(hierarchy);
-+
-       lxcfs_info("api_extensions:");
-       for (size_t nr = 0; nr < nr_api_extensions; nr++)
-               lxcfs_info("- %s", api_extensions[nr]);
-diff --git a/src/bindings.h b/src/bindings.h
-index cd7d466..2b7c8f4 100644
---- a/src/bindings.h
-+++ b/src/bindings.h
-@@ -98,6 +98,7 @@ extern void prune_init_slice(char *cg);
- extern bool supports_pidfd(void);
- extern bool liblxcfs_functional(void);
- extern bool liblxcfs_can_use_swap(void);
-+extern bool liblxcfs_memory_is_cgroupv2(void);
- extern bool liblxcfs_can_use_sys_cpu(void);
- extern bool liblxcfs_has_versioned_opts(void);
-diff --git a/src/proc_fuse.c b/src/proc_fuse.c
-index 94168c9..a07e8d6 100644
---- a/src/proc_fuse.c
-+++ b/src/proc_fuse.c
-@@ -299,6 +299,43 @@ static inline bool startswith(const char *line, const char *pref)
-       return strncmp(line, pref, strlen(pref)) == 0;
- }
-+static void get_swap_info(const char *cgroup, uint64_t memlimit,
-+                        uint64_t memusage, uint64_t *swtotal,
-+                        uint64_t *swusage, uint64_t *memswpriority)
-+{
-+      __do_free char *memswusage_str = NULL, *memswpriority_str = NULL;
-+      size_t memswlimit = 0, memswusage = 0;
-+      int ret;
-+
-+      *swtotal = *swusage = 0;
-+      *memswpriority = 1;
-+
-+      memswlimit = get_min_memlimit(cgroup, true);
-+      if (memswlimit > 0) {
-+              ret = cgroup_ops->get_memory_swap_current(cgroup_ops, cgroup, &memswusage_str);
-+              if (ret < 0 || safe_uint64(memswusage_str, &memswusage, 10) != 0)
-+                      return;
-+
-+              if (liblxcfs_memory_is_cgroupv2()) {
-+                      *swtotal = memswlimit / 1024;
-+                      *swusage = memswusage / 1024;
-+              } else {
-+                      if (memlimit > memswlimit)
-+                              *swtotal = 0;
-+                      else
-+                              *swtotal = (memswlimit - memlimit) / 1024;
-+                      if (memusage > memswusage || swtotal == 0)
-+                              *swusage = 0;
-+                      else
-+                              *swusage = (memswusage - memusage) / 1024;
-+              }
-+
-+              ret = cgroup_ops->get_memory_swappiness(cgroup_ops, cgroup, &memswpriority_str);
-+              if (ret >= 0)
-+                      safe_uint64(memswpriority_str, memswpriority, 10);
-+      }
-+}
-+
- static int proc_swaps_read(char *buf, size_t size, off_t offset,
-                          struct fuse_file_info *fi)
- {
-@@ -307,7 +344,7 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
-       struct fuse_context *fc = fuse_get_context();
-       bool wants_swap = lxcfs_has_opt(fuse_get_context()->private_data, LXCFS_SWAP_ON);
-       struct file_info *d = INTTYPE_TO_PTR(fi->fh);
--      uint64_t memswlimit = 0, memlimit = 0, memusage = 0, memswusage = 0,
-+      uint64_t memlimit = 0, memusage = 0,
-                swtotal = 0, swusage = 0, memswpriority = 1,
-                hostswtotal = 0, hostswfree = 0;
-       ssize_t total_len = 0;
-@@ -353,26 +390,8 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
-       if (safe_uint64(memusage_str, &memusage, 10) < 0)
-               lxcfs_error("Failed to convert memusage %s", memusage_str);
--      if (wants_swap) {
--              memswlimit = get_min_memlimit(cgroup, true);
--              if (memswlimit > 0) {
--                      ret = cgroup_ops->get_memory_swap_current(cgroup_ops, cgroup, &memswusage_str);
--                      if (ret >= 0 && safe_uint64(memswusage_str, &memswusage, 10) == 0) {
--                              if (memlimit > memswlimit)
--                                      swtotal = 0;
--                              else
--                                      swtotal = (memswlimit - memlimit) / 1024;
--                              if (memusage > memswusage || swtotal == 0)
--                                      swusage = 0;
--                              else
--                                      swusage = (memswusage - memusage) / 1024;
--                      }
--
--                      ret = cgroup_ops->get_memory_swappiness(cgroup_ops, cgroup, &memswpriority_str);
--                      if (ret >= 0)
--                              safe_uint64(memswpriority_str, &memswpriority, 10);
--              }
--      }
-+      if (wants_swap)
-+              get_swap_info(cgroup, memlimit, memusage, &swtotal, &swusage, &memswpriority);
-       total_len = snprintf(d->buf, d->size, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
-@@ -1141,7 +1160,7 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
-       struct fuse_context *fc = fuse_get_context();
-       bool wants_swap = lxcfs_has_opt(fuse_get_context()->private_data, LXCFS_SWAP_ON);
-       struct file_info *d = INTTYPE_TO_PTR(fi->fh);
--      uint64_t memlimit = 0, memusage = 0, memswlimit = 0, memswusage = 0,
-+      uint64_t memlimit = 0, memusage = 0,
-                hosttotal = 0, swfree = 0, swusage = 0, swtotal = 0,
-                memswpriority = 1;
-       struct memory_stat mstat = {};
-@@ -1193,26 +1212,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
-        * Following values are allowed to fail, because swapaccount might be
-        * turned off for current kernel.
-        */
--      if (wants_swap) {
--              memswlimit = get_min_memlimit(cgroup, true);
--              if (memswlimit > 0) {
--                      ret = cgroup_ops->get_memory_swap_current(cgroup_ops, cgroup, &memswusage_str);
--                      if (ret >= 0 && safe_uint64(memswusage_str, &memswusage, 10) == 0) {
--                              if (memlimit > memswlimit)
--                                      swtotal = 0;
--                              else
--                                      swtotal = (memswlimit - memlimit) / 1024;
--                              if (memusage > memswusage || swtotal == 0)
--                                      swusage = 0;
--                              else
--                                      swusage = (memswusage - memusage) / 1024;
--                      }
--              }
--
--              ret = cgroup_ops->get_memory_swappiness(cgroup_ops, cgroup, &memswpriority_str);
--              if (ret >= 0)
--                      safe_uint64(memswpriority_str, &memswpriority, 10);
--      }
-+      if (wants_swap)
-+              get_swap_info(cgroup, memlimit, memusage, &swtotal, &swusage, &memswpriority);
-       f = fopen_cached("/proc/meminfo", "re", &fopen_cache);
-       if (!f)
-@@ -1251,7 +1252,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
-                                  This is because the kernel can swap as much as it
-                                  wants and not only up to swtotal. */
--                              swtotal = memlimit + swtotal;
-+                              if (!liblxcfs_memory_is_cgroupv2())
-+                                      swtotal += memlimit;
-+
-                               if (hostswtotal < swtotal) {
-                                       swtotal = hostswtotal;
-                               }
diff --git a/debian/patches/extra/0002-build-with-fuse2.patch b/debian/patches/extra/0002-build-with-fuse2.patch
new file mode 100644 (file)
index 0000000..bb046e5
--- /dev/null
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Wolfgang Bumiller <w.bumiller@proxmox.com>
+Date: Thu, 2 Dec 2021 13:47:24 +0100
+Subject: [PATCH lxcfs] build with fuse2
+
+this stuff is a PITA
+
+Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
+---
+ configure.ac | 6 ------
+ 1 file changed, 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 07ac0c9..925dac4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -62,13 +62,7 @@ AC_CONFIG_FILES([
+ AC_CHECK_LIB(pthread, main)
+-PKG_CHECK_MODULES(FUSE, fuse3, [have_fuse3=yes], [have_fuse3=no])
+-if test "x$have_fuse3" = "xyes"; then
+-      AC_DEFINE([HAVE_FUSE3], [1], [Use fuse3])
+-      AC_DEFINE_UNQUOTED([FUSE_USE_VERSION], [30], [Use fuse version 30])
+-else
+       PKG_CHECK_MODULES(FUSE, fuse, [AC_DEFINE_UNQUOTED([FUSE_USE_VERSION], [26], [Use fuse])])
+-fi
+ AC_PATH_PROG(HELP2MAN, help2man, false // No help2man //)
+ AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN" != "xfalse // No help2man //" ])
diff --git a/debian/patches/extra/0002-cgv2-assume-swap-is-supported.patch b/debian/patches/extra/0002-cgv2-assume-swap-is-supported.patch
deleted file mode 100644 (file)
index c5d4a1a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Wolfgang Bumiller <w.bumiller@proxmox.com>
-Date: Thu, 2 Dec 2021 13:05:28 +0100
-Subject: [PATCH lxcfs] cgv2: assume swap is supported
-
-because this is just wrong and fixing it is annoying
-
-Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
----
- src/cgroups/cgfsng.c | 10 ++++------
- 1 file changed, 4 insertions(+), 6 deletions(-)
-
-diff --git a/src/cgroups/cgfsng.c b/src/cgroups/cgfsng.c
-index 3eb4227..fed7911 100644
---- a/src/cgroups/cgfsng.c
-+++ b/src/cgroups/cgfsng.c
-@@ -626,12 +626,10 @@ static bool cgfsng_can_use_swap(struct cgroup_ops *ops)
-               return false;
-       if (is_unified_hierarchy(h)) {
--              if (faccessat(h->fd, "memory.swap.max", F_OK, 0))
--                      return false;
--
--              if (faccessat(h->fd, "memory.swap.current", F_OK, 0))
--                      return false;
--
-+              /* the files to check for don't exist at the root cgroup
-+               * directory so let's assume yes, other kernel configs are
-+               * simply not supported on pve
-+               */
-               has_swap = true;
-       } else {
-               if (faccessat(h->fd, "memory.memsw.limit_in_bytes", F_OK, 0))
diff --git a/debian/patches/extra/0003-build-with-fuse2.patch b/debian/patches/extra/0003-build-with-fuse2.patch
deleted file mode 100644 (file)
index a39f58e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Wolfgang Bumiller <w.bumiller@proxmox.com>
-Date: Thu, 2 Dec 2021 13:47:24 +0100
-Subject: [PATCH lxcfs] build with fuse2
-
-this stuff is a PITA
-
-Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
----
- configure.ac | 6 ------
- 1 file changed, 6 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index ccea4ec..9260137 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -61,13 +61,7 @@ AC_CONFIG_FILES([
- AC_CHECK_LIB(pthread, main)
--PKG_CHECK_MODULES(FUSE, fuse3, [have_fuse3=yes], [have_fuse3=no])
--if test "x$have_fuse3" = "xyes"; then
--      AC_DEFINE([HAVE_FUSE3], [1], [Use fuse3])
--      AC_DEFINE_UNQUOTED([FUSE_USE_VERSION], [30], [Use fuse version 30])
--else
-       PKG_CHECK_MODULES(FUSE, fuse, [AC_DEFINE_UNQUOTED([FUSE_USE_VERSION], [26], [Use fuse])])
--fi
- AC_PATH_PROG(HELP2MAN, help2man, false // No help2man //)
- AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN" != "xfalse // No help2man //" ])
index 3e7f4c4ce12503e6bf7f9d92f1c9d5f93bf3b9e9..a5299ef4fa16ad18b2c82811a5d41b7d97168874 100644 (file)
@@ -1,4 +1,3 @@
 do-not-start-without-lxcfs.patch
-extra/0001-make-meminfo-and-swaps-cgroupv2-aware.patch
-extra/0002-cgv2-assume-swap-is-supported.patch
-extra/0003-build-with-fuse2.patch
+extra/0001-cgv2-assume-swap-is-supported.patch
+extra/0002-build-with-fuse2.patch