Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package lxcfs for openSUSE:Factory checked in at 2021-06-01 10:37:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lxcfs (Old) and /work/SRC/openSUSE:Factory/.lxcfs.new.1898 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lxcfs" Tue Jun 1 10:37:43 2021 rev:16 rq:895789 version:4.0.8 Changes: -------- --- /work/SRC/openSUSE:Factory/lxcfs/lxcfs.changes 2020-08-21 19:07:16.424466586 +0200 +++ /work/SRC/openSUSE:Factory/.lxcfs.new.1898/lxcfs.changes 2021-06-01 10:38:56.408964067 +0200 @@ -1,0 +2,26 @@ +Mon May 24 06:38:24 UTC 2021 - Johannes Kastl <[email protected]> + +- update to 4.0.8: + * Correct file size for proc files + * for full list of changes see + https://discuss.linuxcontainers.org/t/lxcfs-4-0-8-lts-has-been-released/10998 + +------------------------------------------------------------------- +Mon May 24 06:35:56 UTC 2021 - Johannes Kastl <[email protected]> + +- update to 4.0.7: + * Consistent swap behavior (documented in README) + * for full list of changes see + https://discuss.linuxcontainers.org/t/lxcfs-4-0-7-lts-has-been-released/9893 + +------------------------------------------------------------------- +Mon May 24 06:34:21 UTC 2021 - Johannes Kastl <[email protected]> + +- update to 4.0.6: + * Add support for fuse3 + * Update for new diskstats fields + * Fix some build issues + * for full list of changes see + https://discuss.linuxcontainers.org/t/lxcfs-4-0-6-lts-has-been-released/9236 + +------------------------------------------------------------------- Old: ---- lxcfs-4.0.5.tar.gz lxcfs-4.0.5.tar.gz.asc New: ---- lxcfs-4.0.8.tar.gz lxcfs-4.0.8.tar.gz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lxcfs.spec ++++++ --- /var/tmp/diff_new_pack.CJKerz/_old 2021-06-01 10:38:56.964965014 +0200 +++ /var/tmp/diff_new_pack.CJKerz/_new 2021-06-01 10:38:56.964965014 +0200 @@ -1,7 +1,7 @@ # # spec file for package lxcfs # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -22,7 +22,7 @@ %endif Name: lxcfs -Version: 4.0.5 +Version: 4.0.8 Release: 0 Summary: FUSE filesystem for LXC License: Apache-2.0 ++++++ lxcfs-4.0.5.tar.gz -> lxcfs-4.0.8.tar.gz ++++++ ++++ 2135 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/config.h.in new/lxcfs-4.0.8/config.h.in --- old/lxcfs-4.0.5/config.h.in 2020-08-04 00:17:23.000000000 +0200 +++ new/lxcfs-4.0.8/config.h.in 2021-04-29 21:04:39.000000000 +0200 @@ -3,6 +3,9 @@ /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H +/* Use fuse3 */ +#undef HAVE_FUSE3 + /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/configure.ac new/lxcfs-4.0.8/configure.ac --- old/lxcfs-4.0.5/configure.ac 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/configure.ac 2021-04-29 21:04:33.000000000 +0200 @@ -1,6 +1,6 @@ AC_PREREQ([2.69]) -AC_INIT([lxcfs], [4.0.5], [[email protected]]) +AC_INIT([lxcfs], [4.0.8], [[email protected]]) # We need pkg-config PKG_PROG_PKG_CONFIG @@ -60,7 +60,9 @@ AC_CHECK_LIB(pthread, main) -PKG_CHECK_MODULES(FUSE, fuse) +PKG_CHECK_MODULES(FUSE, fuse, [], [ + PKG_CHECK_MODULES(FUSE, fuse3, [AC_DEFINE([HAVE_FUSE3], [1], [Use fuse3])]) +]) AC_PATH_PROG(HELP2MAN, help2man, false // No help2man //) AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN" != "xfalse // No help2man //" ]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/lxcfs.spec new/lxcfs-4.0.8/lxcfs.spec --- old/lxcfs-4.0.5/lxcfs.spec 2020-08-04 00:17:32.000000000 +0200 +++ new/lxcfs-4.0.8/lxcfs.spec 2021-04-29 21:04:46.000000000 +0200 @@ -20,7 +20,7 @@ Summary: Linux Containers File System Name: lxcfs -Version: 4.0.5 +Version: 4.0.8 Release: 1%{?dist} URL: https://linuxcontainers.org/lxcfs/downloads/ Source0: %{name}-%{version}.tar.gz diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/m4/libtool.m4 new/lxcfs-4.0.8/m4/libtool.m4 --- old/lxcfs-4.0.5/m4/libtool.m4 2020-03-02 10:35:42.000000000 +0100 +++ new/lxcfs-4.0.8/m4/libtool.m4 2021-01-09 21:49:30.000000000 +0100 @@ -1071,11 +1071,11 @@ # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + 10.0,*86*-darwin8*|10.0,*-darwin[[912]]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[[012]][[,.]]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - 10.*) + 10.*|11.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/Makefile.am new/lxcfs-4.0.8/src/Makefile.am --- old/lxcfs-4.0.5/src/Makefile.am 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/src/Makefile.am 2021-04-29 21:04:33.000000000 +0200 @@ -15,6 +15,7 @@ cgroups/cgroup2_devices.c cgroups/cgroup2_devices.h \ cgroups/cgroup_utils.c cgroups/cgroup_utils.h \ cpuset_parse.c cpuset_parse.h \ + lxcfs_fuse_compat.h \ macro.h \ memory_utils.h \ proc_cpuview.c proc_cpuview.h \ @@ -44,6 +45,7 @@ cgroups/cgroup2_devices.c cgroups/cgroup2_devices.h \ cgroups/cgroup_utils.c cgroups/cgroup_utils.h \ cpuset_parse.c cpuset_parse.h \ + lxcfs_fuse_compat.h \ macro.h \ memory_utils.h \ proc_cpuview.c proc_cpuview.h \ @@ -72,6 +74,7 @@ cgroups/cgroup2_devices.h \ cgroups/cgroup_utils.h \ cpuset_parse.h \ + lxcfs_fuse_compat.h \ macro.h \ memory_utils.h \ proc_cpuview.h \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/bindings.c new/lxcfs-4.0.8/src/bindings.c --- old/lxcfs-4.0.5/src/bindings.c 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/src/bindings.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -43,7 +51,6 @@ #include "cgroup_fuse.h" #include "cgroups/cgroup.h" #include "cgroups/cgroup_utils.h" -#include "config.h" #include "memory_utils.h" #include "proc_cpuview.h" #include "syscall_numbers.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/cgroup_fuse.c new/lxcfs-4.0.8/src/cgroup_fuse.c --- old/lxcfs-4.0.5/src/cgroup_fuse.c 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/src/cgroup_fuse.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -40,9 +48,9 @@ #include <sys/vfs.h> #include "bindings.h" -#include "config.h" #include "cgroups/cgroup.h" #include "cgroups/cgroup_utils.h" +#include "lxcfs_fuse_compat.h" #include "memory_utils.h" #include "utils.h" @@ -607,7 +615,7 @@ sb->st_nlink = 1; sb->st_uid = k->uid; sb->st_gid = k->gid; - sb->st_size = 0; + sb->st_size = 4096; free_key(k); if (!caller_is_in_ancestor(initpid, controller, path1, NULL)) { ret = -ENOENT; @@ -1953,7 +1961,7 @@ if (!fc || !cgroup_ops || pure_unified_layout(cgroup_ops)) return -EIO; - if (filler(buf, ".", NULL, 0) != 0 || filler(buf, "..", NULL, 0) != 0) + if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || DIR_FILLER(filler, buf, "..", NULL, 0) != 0) return -EIO; if (d->type != LXC_TYPE_CGDIR) { @@ -1969,7 +1977,7 @@ if (is_unified_hierarchy(*h)) continue; - if ((*h)->__controllers && filler(buf, (*h)->__controllers, NULL, 0)) + if ((*h)->__controllers && DIR_FILLER(filler, buf, (*h)->__controllers, NULL, 0)) return -EIO; } @@ -1987,7 +1995,7 @@ initpid = fc->pid; if (!caller_is_in_ancestor(initpid, d->controller, d->cgroup, &nextcg)) { if (nextcg) { - ret = filler(buf, nextcg, NULL, 0); + ret = DIR_FILLER(filler, buf, nextcg, NULL, 0); free(nextcg); if (ret != 0) { ret = -EIO; @@ -1999,7 +2007,7 @@ } for (i = 0; list && list[i]; i++) { - if (filler(buf, list[i]->name, NULL, 0) != 0) { + if (DIR_FILLER(filler, buf, list[i]->name, NULL, 0) != 0) { ret = -EIO; goto out; } @@ -2013,7 +2021,7 @@ } if (clist) { for (i = 0; clist[i]; i++) { - if (filler(buf, clist[i], NULL, 0) != 0) { + if (DIR_FILLER(filler, buf, clist[i], NULL, 0) != 0) { ret = -EIO; goto out; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/cgroups/cgfsng.c new/lxcfs-4.0.8/src/cgroups/cgfsng.c --- old/lxcfs-4.0.5/src/cgroups/cgfsng.c 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/src/cgroups/cgfsng.c 2021-04-29 21:04:33.000000000 +0200 @@ -16,9 +16,17 @@ #define _GNU_SOURCE #endif +#include "../config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -38,7 +46,6 @@ #include <sys/types.h> #include <unistd.h> -#include "../config.h" #include "../macro.h" #include "../memory_utils.h" #include "../utils.h" @@ -613,6 +620,12 @@ return cgfsng_get_memory(ops, cgroup, "memory.max", value); } +static int cgfsng_get_memory_swappiness(struct cgroup_ops *ops, const char *cgroup, + char **value) +{ + return cgfsng_get_memory(ops, cgroup, "memory.swappiness", value); +} + static int cgfsng_get_memory_swap_max(struct cgroup_ops *ops, const char *cgroup, char **value) { @@ -1004,6 +1017,7 @@ cgfsng_ops->get_memory_stats_fd = cgfsng_get_memory_stats_fd; cgfsng_ops->get_memory_stats = cgfsng_get_memory_stats; cgfsng_ops->get_memory_max = cgfsng_get_memory_max; + cgfsng_ops->get_memory_swappiness = cgfsng_get_memory_swappiness; cgfsng_ops->get_memory_swap_max = cgfsng_get_memory_swap_max; cgfsng_ops->get_memory_current = cgfsng_get_memory_current; cgfsng_ops->get_memory_swap_current = cgfsng_get_memory_swap_current; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/cgroups/cgroup.c new/lxcfs-4.0.8/src/cgroups/cgroup.c --- old/lxcfs-4.0.5/src/cgroups/cgroup.c 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/src/cgroups/cgroup.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "../config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -30,7 +38,6 @@ #include <sys/vfs.h> #include <unistd.h> -#include "../config.h" #include "../macro.h" #include "../memory_utils.h" #include "cgroup.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/cgroups/cgroup.h new/lxcfs-4.0.8/src/cgroups/cgroup.h --- old/lxcfs-4.0.5/src/cgroups/cgroup.h 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/src/cgroups/cgroup.h 2021-04-29 21:04:33.000000000 +0200 @@ -151,6 +151,8 @@ const char *cgroup, char **value); int (*get_memory_max)(struct cgroup_ops *ops, const char *cgroup, char **value); + int (*get_memory_swappiness)(struct cgroup_ops *ops, const char *cgroup, + char **value); int (*get_memory_swap_max)(struct cgroup_ops *ops, const char *cgroup, char **value); bool (*can_use_swap)(struct cgroup_ops *ops); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/cgroups/cgroup2_devices.c new/lxcfs-4.0.8/src/cgroups/cgroup2_devices.c --- old/lxcfs-4.0.5/src/cgroups/cgroup2_devices.c 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/src/cgroups/cgroup2_devices.c 2021-04-29 21:04:33.000000000 +0200 @@ -6,9 +6,17 @@ #define _GNU_SOURCE #endif +#include "../config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -22,7 +30,6 @@ #include <sys/types.h> #include <unistd.h> -#include "../config.h" #include "../macro.h" #include "../memory_utils.h" #include "cgroup2_devices.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/cgroups/cgroup_utils.c new/lxcfs-4.0.8/src/cgroups/cgroup_utils.c --- old/lxcfs-4.0.5/src/cgroups/cgroup_utils.c 2020-08-04 00:17:18.000000000 +0200 +++ new/lxcfs-4.0.8/src/cgroups/cgroup_utils.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "../config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -22,7 +30,6 @@ #include <sys/vfs.h> #include <unistd.h> -#include "../config.h" #include "../macro.h" #include "../memory_utils.h" #include "cgroup.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/cpuset_parse.c new/lxcfs-4.0.8/src/cpuset_parse.c --- old/lxcfs-4.0.5/src/cpuset_parse.c 2020-08-04 00:17:19.000000000 +0200 +++ new/lxcfs-4.0.8/src/cpuset_parse.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -20,7 +28,6 @@ #include "bindings.h" #include "cgroups/cgroup.h" #include "cgroups/cgroup_utils.h" -#include "config.h" #include "memory_utils.h" #include "proc_loadavg.h" #include "utils.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/lxcfs.c new/lxcfs-4.0.8/src/lxcfs.c --- old/lxcfs-4.0.5/src/lxcfs.c 2020-08-04 00:17:19.000000000 +0200 +++ new/lxcfs-4.0.8/src/lxcfs.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -33,7 +41,7 @@ #include <linux/limits.h> #include "bindings.h" -#include "config.h" +#include "lxcfs_fuse_compat.h" #include "macro.h" #include "memory_utils.h" @@ -562,7 +570,11 @@ return __sys_releasedir(path, fi); } +#ifdef HAVE_FUSE3 +static int lxcfs_getattr(const char *path, struct stat *sb, struct fuse_file_info *fi) +#else static int lxcfs_getattr(const char *path, struct stat *sb) +#endif { int ret; struct timespec now; @@ -625,17 +637,22 @@ return -ENOENT; } +#ifdef HAVE_FUSE3 +static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, + off_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags flags) +#else static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) +#endif { int ret; if (strcmp(path, "/") == 0) { - if (filler(buf, ".", NULL, 0) != 0 || - filler(buf, "..", NULL, 0) != 0 || - filler(buf, "proc", NULL, 0) != 0 || - filler(buf, "sys", NULL, 0) != 0 || - filler(buf, "cgroup", NULL, 0) != 0) + if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "..", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "proc", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "sys", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "cgroup", NULL, 0) != 0) return -ENOMEM; return 0; @@ -847,7 +864,11 @@ return -EPERM; } +#ifdef HAVE_FUSE3 +int lxcfs_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi) +#else int lxcfs_chown(const char *path, uid_t uid, gid_t gid) +#endif { int ret; @@ -872,7 +893,11 @@ * really make sense for cgroups. So just return 0 always but do * nothing. */ +#ifdef HAVE_FUSE3 +int lxcfs_truncate(const char *path, off_t newsize, struct fuse_file_info *fi) +#else int lxcfs_truncate(const char *path, off_t newsize) +#endif { if (strncmp(path, "/cgroup", 7) == 0) return 0; @@ -894,7 +919,11 @@ return -EPERM; } +#ifdef HAVE_FUSE3 +int lxcfs_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) +#else int lxcfs_chmod(const char *path, mode_t mode) +#endif { int ret; @@ -934,10 +963,14 @@ .create = NULL, .destroy = NULL, +#ifndef HAVE_FUSE3 .fgetattr = NULL, +#endif .fsyncdir = NULL, +#ifndef HAVE_FUSE3 .ftruncate = NULL, .getdir = NULL, +#endif .getxattr = NULL, .init = NULL, .link = NULL, @@ -950,7 +983,9 @@ .statfs = NULL, .symlink = NULL, .unlink = NULL, +#ifndef HAVE_FUSE3 .utime = NULL, +#endif }; static void usage() @@ -1068,7 +1103,10 @@ int ret = EXIT_FAILURE; char *pidfile = NULL, *saveptr = NULL, *token = NULL, *v = NULL; char pidfile_buf[STRLITERALLEN(RUNTIME_PATH) + STRLITERALLEN("/lxcfs.pid") + 1] = {}; - bool debug = false, foreground = false, nonempty = false; + bool debug = false, foreground = false; +#ifndef HAVE_FUSE3 + bool nonempty = false; +#endif bool load_use = false; /* * what we pass to fuse_main is: @@ -1126,7 +1164,11 @@ if (strcmp(token, "allow_other") == 0) { /* Noop. this is the default. Always enabled. */ } else if (strcmp(token, "nonempty") == 0) { +#ifdef HAVE_FUSE3 + /* FUSE3: Noop. this is the default. */ +#else nonempty = true; +#endif } else { lxcfs_error("Warning: unexpected fuse option %s", v); free(v); @@ -1173,10 +1215,14 @@ * shouldn't guarantee that we don't need more complicated access * helpers for proc and sys virtualization in the future. */ +#ifdef HAVE_FUSE3 + newargv[cnt++] = "allow_other,entry_timeout=0.5,attr_timeout=0.5"; +#else if (nonempty) newargv[cnt++] = "allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5,nonempty"; else newargv[cnt++] = "allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5"; +#endif newargv[cnt++] = argv[1]; newargv[cnt++] = NULL; @@ -1194,6 +1240,7 @@ if (!fuse_main(nargs, newargv, &lxcfs_ops, opts)) ret = EXIT_SUCCESS; + if (load_use) stop_loadavg(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/lxcfs_fuse_compat.h new/lxcfs-4.0.8/src/lxcfs_fuse_compat.h --- old/lxcfs-4.0.5/src/lxcfs_fuse_compat.h 1970-01-01 01:00:00.000000000 +0100 +++ new/lxcfs-4.0.8/src/lxcfs_fuse_compat.h 2021-04-29 21:04:33.000000000 +0200 @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +#ifndef __LXCFS_FUSE_COMPAT_H +#define __LXCFS_FUSE_COMPAT_H + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#ifdef HAVE_FUSE3 +#define DIR_FILLER(F,B,N,S,O) F(B,N,S,O,FUSE_FILL_DIR_PLUS) +#else +#define DIR_FILLER(F,B,N,S,O) F(B,N,S,O) +#endif +#endif /* __LXCFS_FUSE_COMPAT_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/proc_cpuview.c new/lxcfs-4.0.8/src/proc_cpuview.c --- old/lxcfs-4.0.5/src/proc_cpuview.c 2020-08-04 00:17:19.000000000 +0200 +++ new/lxcfs-4.0.8/src/proc_cpuview.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -40,7 +48,6 @@ #include <sys/vfs.h> #include "bindings.h" -#include "config.h" #include "cgroup_fuse.h" #include "cpuset_parse.h" #include "cgroups/cgroup.h" @@ -308,7 +315,8 @@ return node; } -static struct cg_proc_stat *find_or_create_proc_stat_node(struct cpuacct_usage *usage, int cpu_count, const char *cg) +static struct cg_proc_stat *find_or_create_proc_stat_node(struct cpuacct_usage *usage, + int cpu_count, const char *cg) { int hash = calc_hash(cg) % CPUVIEW_HASH_SIZE; struct cg_proc_stat_head *head = proc_stat_history[hash]; @@ -404,7 +412,7 @@ /* * Read cgroup CPU quota parameters from `cpu.cfs_quota_us` or * `cpu.cfs_period_us`, depending on `param`. Parameter value is returned - * throuh `value`. + * through `value`. */ static bool read_cpu_cfs_param(const char *cg, const char *param, int64_t *value) { @@ -598,6 +606,7 @@ if (max_cpus > cpu_cnt || !max_cpus) max_cpus = cpu_cnt; + /* takes lock pthread_mutex_lock(&node->lock) */ stat_node = find_or_create_proc_stat_node(cg_cpu_usage, nprocs, cg); if (!stat_node) return log_error(0, "Failed to find/create stat node for %s", cg); @@ -753,8 +762,11 @@ "cpu %" PRIu64 " 0 %" PRIu64 " %" PRIu64 " 0 0 0 0 0 0\n", user_sum, system_sum, idle_sum); lxcfs_v("cpu-all: %s\n", buf); - if (l < 0) - return log_error(0, "Failed to write cache"); + if (l < 0) { + lxcfs_error("Failed to write cache"); + total_len = 0; + goto out_pthread_mutex_unlock; + } if (l >= buf_size) return log_error(0, "Write to cache was truncated"); @@ -778,10 +790,16 @@ stat_node->view[curcpu].system, stat_node->view[curcpu].idle); lxcfs_v("cpu: %s\n", buf); - if (l < 0) - return log_error(0, "Failed to write cache"); - if (l >= buf_size) - return log_error(0, "Write to cache was truncated"); + if (l < 0) { + lxcfs_error("Failed to write cache"); + total_len = 0; + goto out_pthread_mutex_unlock; + } + if (l >= buf_size) { + lxcfs_error("Write to cache was truncated"); + total_len = 0; + goto out_pthread_mutex_unlock; + } buf += l; buf_size -= l; @@ -790,10 +808,16 @@ /* Pass the rest of /proc/stat, start with the last line read */ l = snprintf(buf, buf_size, "%s", line); - if (l < 0) - return log_error(0, "Failed to write cache"); - if (l >= buf_size) - return log_error(0, "Write to cache was truncated"); + if (l < 0) { + lxcfs_error("Failed to write cache"); + total_len = 0; + goto out_pthread_mutex_unlock; + } + if (l >= buf_size) { + lxcfs_error("Write to cache was truncated"); + total_len = 0; + goto out_pthread_mutex_unlock; + } buf += l; buf_size -= l; @@ -802,16 +826,23 @@ /* Pass the rest of the host's /proc/stat */ while (getline(&line, &linelen, f) != -1) { l = snprintf(buf, buf_size, "%s", line); - if (l < 0) - return log_error(0, "Failed to write cache"); - if (l >= buf_size) - return log_error(0, "Write to cache was truncated"); + if (l < 0) { + lxcfs_error("Failed to write cache"); + total_len = 0; + goto out_pthread_mutex_unlock; + } + if (l >= buf_size) { + lxcfs_error("Write to cache was truncated"); + total_len = 0; + goto out_pthread_mutex_unlock; + } buf += l; buf_size -= l; total_len += l; } +out_pthread_mutex_unlock: if (stat_node) pthread_mutex_unlock(&stat_node->lock); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/proc_fuse.c new/lxcfs-4.0.8/src/proc_fuse.c --- old/lxcfs-4.0.5/src/proc_fuse.c 2020-08-04 00:17:19.000000000 +0200 +++ new/lxcfs-4.0.8/src/proc_fuse.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -40,11 +48,11 @@ #include <sys/vfs.h> #include "bindings.h" -#include "config.h" #include "cgroup_fuse.h" #include "cgroups/cgroup.h" #include "cgroups/cgroup_utils.h" #include "cpuset_parse.h" +#include "lxcfs_fuse_compat.h" #include "memory_utils.h" #include "proc_loadavg.h" #include "proc_cpuview.h" @@ -72,6 +80,23 @@ uint64_t total_unevictable; }; +static off_t get_procfile_size(const char *path) +{ + __do_fclose FILE *f = NULL; + __do_free char *line = NULL; + size_t len = 0; + ssize_t sz, answer = 0; + + f = fopen(path, "re"); + if (!f) + return 0; + + while ((sz = getline(&line, &len, f)) != -1) + answer += sz; + + return answer; +} + __lxcfs_fuse_ops int proc_getattr(const char *path, struct stat *sb) { struct timespec now; @@ -95,7 +120,7 @@ strcmp(path, "/proc/diskstats") == 0 || strcmp(path, "/proc/swaps") == 0 || strcmp(path, "/proc/loadavg") == 0) { - sb->st_size = 0; + sb->st_size = get_procfile_size(path); sb->st_mode = S_IFREG | 00444; sb->st_nlink = 1; return 0; @@ -108,37 +133,20 @@ fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { - if (filler(buf, ".", NULL, 0) != 0 || - filler(buf, "..", NULL, 0) != 0 || - filler(buf, "cpuinfo", NULL, 0) != 0 || - filler(buf, "meminfo", NULL, 0) != 0 || - filler(buf, "stat", NULL, 0) != 0 || - filler(buf, "uptime", NULL, 0) != 0 || - filler(buf, "diskstats", NULL, 0) != 0 || - filler(buf, "swaps", NULL, 0) != 0 || - filler(buf, "loadavg", NULL, 0) != 0) + if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "..", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "cpuinfo", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "meminfo", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "stat", NULL, 0) != 0 || + 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) return -EINVAL; return 0; } -static off_t get_procfile_size(const char *path) -{ - __do_fclose FILE *f = NULL; - __do_free char *line = NULL; - size_t len = 0; - ssize_t sz, answer = 0; - - f = fopen(path, "re"); - if (!f) - return 0; - - while ((sz = getline(&line, &len, f)) != -1) - answer += sz; - - return answer; -} - __lxcfs_fuse_ops int proc_open(const char *path, struct fuse_file_info *fi) { __do_free struct file_info *info = NULL; @@ -213,6 +221,68 @@ return memlimit; } +/* + * This function taken from glibc-2.32, as POSIX dirname("/some-dir") will + * return "/some-dir" as opposed to "/", which breaks `get_min_memlimit()` + */ +static char *gnu_dirname(char *path) +{ + static const char dot[] = "."; + char *last_slash; + + /* Find last '/'. */ + last_slash = path != NULL ? strrchr(path, '/') : NULL; + + if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') { + /* Determine whether all remaining characters are slashes. */ + char *runp; + + for (runp = last_slash; runp != path; --runp) + if (runp[-1] != '/') + break; + + /* The '/' is the last character, we have to look further. */ + if (runp != path) + last_slash = memrchr(path, '/', runp - path); + } + + if (last_slash != NULL) { + /* Determine whether all remaining characters are slashes. */ + char *runp; + + for (runp = last_slash; runp != path; --runp) + if (runp[-1] != '/') + break; + + /* Terminate the path. */ + if (runp == path) { + /* + * The last slash is the first character in the string. + * We have to return "/". As a special case we have to + * return "//" if there are exactly two slashes at the + * beginning of the string. See XBD 4.10 Path Name + * Resolution for more information + */ + if (last_slash == path + 1) + ++last_slash; + else + last_slash = path + 1; + } else + last_slash = runp; + + last_slash[0] = '\0'; + } else { + /* + * This assignment is ill-designed but the XPG specs require to + * return a string containing "." in any case no directory part + * is found and so a static and constant string is required. + */ + path = (char *)dot; + } + + return path; +} + static uint64_t get_min_memlimit(const char *cgroup, bool swap) { __do_free char *copy = NULL; @@ -224,10 +294,14 @@ retlimit = get_memlimit(copy, swap); - while (strcmp(copy, "/") != 0) { + /* + * If the cgroup doesn't start with / (probably won't happen), dirname() + * will terminate with "" instead of "/" + */ + while (*copy && strcmp(copy, "/") != 0) { char *it = copy; - it = dirname(it); + it = gnu_dirname(it); memlimit = get_memlimit(it, swap); if (memlimit > 0 && memlimit < retlimit) retlimit = memlimit; @@ -244,17 +318,23 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { - __do_free char *cgroup = NULL, *memusage_str = NULL, *memswusage_str = NULL; + __do_free char *cgroup = NULL, *memusage_str = NULL, + *memswusage_str = NULL, *memswpriority_str = NULL; struct fuse_context *fc = fuse_get_context(); struct lxcfs_opts *opts = (struct lxcfs_opts *)fuse_get_context()->private_data; bool wants_swap = opts && !opts->swap_off && liblxcfs_can_use_swap(); struct file_info *d = INTTYPE_TO_PTR(fi->fh); uint64_t memswlimit = 0, memlimit = 0, memusage = 0, memswusage = 0, - swtotal = 0, swfree = 0, swusage = 0; + swtotal = 0, swusage = 0, memswpriority = 1, + hostswtotal = 0, hostswfree = 0; ssize_t total_len = 0; ssize_t l = 0; char *cache = d->buf; int ret; + __do_free char *line = NULL; + __do_free void *fopen_cache = NULL; + __do_fclose FILE *f = NULL; + size_t linelen = 0; if (offset) { int left; @@ -303,37 +383,48 @@ swusage = 0; else swusage = (memswusage - memusage) / 1024; - if (swtotal >= swusage) - swfree = swtotal - swusage; } + + ret = cgroup_ops->get_memory_swappiness(cgroup_ops, cgroup, &memswpriority_str); + if (ret >= 0) + safe_uint64(memswpriority_str, &memswpriority, 10); } } total_len = snprintf(d->buf, d->size, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); - /* When no mem + swap limit is specified or swapaccount=0*/ - if (!memswlimit) { - __do_free char *line = NULL; - __do_free void *fopen_cache = NULL; - __do_fclose FILE *f = NULL; - size_t linelen = 0; + /* Read host total and free values */ + f = fopen_cached("/proc/meminfo", "re", &fopen_cache); + if (!f) + return 0; + + while (getline(&line, &linelen, f) != -1) { + if (startswith(line, "SwapTotal:")) + sscanf(line, "SwapTotal: %8" PRIu64 " kB", &hostswtotal); + else if (startswith(line, "SwapFree:")) + sscanf(line, "SwapFree: %8" PRIu64 " kB", &hostswfree); + } - f = fopen_cached("/proc/meminfo", "re", &fopen_cache); - if (!f) - return 0; + if (wants_swap) { + /* The total amount of swap is always reported to be the + lesser of the RAM+SWAP limit or the SWAP device size. + This is because the kernel can swap as much as it + wants and not only up to swtotal. */ + swtotal = memlimit / 1024 + swtotal; + if (hostswtotal < swtotal) { + swtotal = hostswtotal; + } - while (getline(&line, &linelen, f) != -1) { - if (startswith(line, "SwapTotal:")) - sscanf(line, "SwapTotal: %8" PRIu64 " kB", &swtotal); - else if (startswith(line, "SwapFree:")) - sscanf(line, "SwapFree: %8" PRIu64 " kB", &swfree); + /* When swappiness is 0, pretend we can't swap. */ + if (memswpriority == 0) { + swtotal = swusage; } } if (swtotal > 0) { l = snprintf(d->buf + total_len, d->size - total_len, "none%*svirtual\t\t%" PRIu64 "\t%" PRIu64 "\t0\n", - 36, " ", swtotal, swfree); + 36, " ", swtotal, swusage); total_len += l; } @@ -374,6 +465,27 @@ } } +struct lxcfs_diskstats { + unsigned int major; /* 1 - major number */ + unsigned int minor; /* 2 - minor mumber */ + char dev_name[72]; /* 3 - device name */ + uint64_t read; /* 4 - reads completed successfully */ + uint64_t read_merged; /* 5 - reads merged */ + uint64_t read_sectors; /* 6 - sectors read */ + uint64_t read_ticks; /* 7 - time spent reading (ms) */ + uint64_t write; /* 8 - writes completed */ + uint64_t write_merged; /* 9 - writes merged */ + uint64_t write_sectors; /* 10 - sectors written */ + uint64_t write_ticks; /* 11 - time spent writing (ms) */ + uint64_t ios_pgr; /* 12 - I/Os currently in progress */ + uint64_t total_ticks; /* 13 - time spent doing I/Os (ms) */ + uint64_t rq_ticks; /* 14 - weighted time spent doing I/Os (ms) */ + uint64_t discard; /* 15 - discards completed successfully (4.18+) */ + uint64_t discard_merged; /* 16 - discards merged (4.18+) */ + uint64_t discard_sectors; /* 17 - sectors discarded (4.18+) */ + uint64_t discard_ticks; /* 18 - time spent discarding (4.18+) */ +}; + static int proc_diskstats_read(char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { @@ -385,19 +497,15 @@ __do_fclose FILE *f = NULL; struct fuse_context *fc = fuse_get_context(); struct file_info *d = INTTYPE_TO_PTR(fi->fh); - uint64_t read = 0, write = 0; - uint64_t read_merged = 0, write_merged = 0; - uint64_t read_sectors = 0, write_sectors = 0; - uint64_t read_ticks = 0, write_ticks = 0; - uint64_t ios_pgr = 0, tot_ticks = 0, rq_ticks = 0; - uint64_t rd_svctm = 0, wr_svctm = 0, rd_wait = 0, wr_wait = 0; + 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; char *cache = d->buf; size_t cache_size = d->buflen; size_t linelen = 0, total_len = 0; - unsigned int major = 0, minor = 0; int i = 0; int ret; - char dev_name[72]; if (offset) { int left; @@ -462,39 +570,69 @@ ssize_t l; char lbuf[256]; - 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) continue; - get_blkio_io_value(io_serviced_str, major, minor, "Read", &read); - 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, major, minor, "Write", &write_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, major, minor, "Write", &write_sectors); - write_sectors = write_sectors/512; - - get_blkio_io_value(io_service_time_str, major, minor, "Read", &rd_svctm); - rd_svctm = rd_svctm/1000000; - get_blkio_io_value(io_wait_time_str, major, minor, "Read", &rd_wait); - rd_wait = rd_wait/1000000; - read_ticks = rd_svctm + rd_wait; - - get_blkio_io_value(io_service_time_str, major, minor, "Write", &wr_svctm); - wr_svctm = wr_svctm/1000000; - get_blkio_io_value(io_wait_time_str, major, minor, "Write", &wr_wait); - wr_wait = wr_wait/1000000; - write_ticks = wr_svctm + wr_wait; + 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); + + get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Read", &stats.read_merged); + get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Write", &stats.write_merged); + get_blkio_io_value(io_merged_str, stats.major, stats.minor, "Discard", &stats.discard_merged); + + get_blkio_io_value(io_service_bytes_str, stats.major, stats.minor, "Read", &stats.read_sectors); + stats.read_sectors = stats.read_sectors / 512; + get_blkio_io_value(io_service_bytes_str, stats.major, stats.minor, "Write", &stats.write_sectors); + stats.write_sectors = stats.write_sectors / 512; + get_blkio_io_value(io_service_bytes_str, stats.major, stats.minor, "Discard", &stats.discard_sectors); + stats.discard_sectors = stats.discard_sectors / 512; + + get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Read", &read_service_time); + read_service_time = read_service_time / 1000000; + get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Read", &read_wait_time); + read_wait_time = read_wait_time / 1000000; + stats.read_ticks = read_service_time + read_wait_time; + + get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Write", &write_service_time); + write_service_time = write_service_time / 1000000; + get_blkio_io_value(io_wait_time_str, stats.major, stats.minor, "Write", &write_wait_time); + write_wait_time = write_wait_time / 1000000; + stats.write_ticks = write_service_time + write_wait_time; + + 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.discard_ticks = discard_service_time + discard_wait_time; - get_blkio_io_value(io_service_time_str, major, minor, "Total", &tot_ticks); - tot_ticks = tot_ticks/1000000; + get_blkio_io_value(io_service_time_str, stats.major, stats.minor, "Total", &stats.total_ticks); + stats.total_ticks = stats.total_ticks / 1000000; memset(lbuf, 0, 256); - if (read || write || read_merged || write_merged || read_sectors || write_sectors || read_ticks || write_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); + 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) + 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; @@ -1015,15 +1153,16 @@ struct fuse_file_info *fi) { __do_free char *cgroup = NULL, *line = NULL, *memusage_str = NULL, - *memswusage_str = NULL; + *memswusage_str = NULL, *memswpriority_str = NULL; __do_free void *fopen_cache = NULL; __do_fclose FILE *f = NULL; struct fuse_context *fc = fuse_get_context(); struct lxcfs_opts *opts = (struct lxcfs_opts *)fuse_get_context()->private_data; - bool wants_swap = opts && !opts->swap_off && liblxcfs_can_use_swap(), host_swap = false; + bool wants_swap = opts && !opts->swap_off && liblxcfs_can_use_swap(); struct file_info *d = INTTYPE_TO_PTR(fi->fh); uint64_t memlimit = 0, memusage = 0, memswlimit = 0, memswusage = 0, - hosttotal = 0, swfree = 0, swusage = 0, swtotal = 0; + hosttotal = 0, swfree = 0, swusage = 0, swtotal = 0, + memswpriority = 1; struct memory_stat mstat = {}; size_t linelen = 0, total_len = 0; char *cache = d->buf; @@ -1088,6 +1227,10 @@ swusage = (memswusage - memusage) / 1024; } } + + ret = cgroup_ops->get_memory_swappiness(cgroup_ops, cgroup, &memswpriority_str); + if (ret >= 0) + safe_uint64(memswpriority_str, &memswpriority, 10); } f = fopen_cached("/proc/meminfo", "re", &fopen_cache); @@ -1122,9 +1265,19 @@ sscanf(line + STRLITERALLEN("SwapTotal:"), "%" PRIu64, &hostswtotal); + /* The total amount of swap is always reported to be the + lesser of the RAM+SWAP limit or the SWAP device size. + This is because the kernel can swap as much as it + wants and not only up to swtotal. */ + + swtotal = memlimit + swtotal; if (hostswtotal < swtotal) { swtotal = hostswtotal; - host_swap = true; + } + + /* When swappiness is 0, pretend we can't swap. */ + if (memswpriority == 0) { + swtotal = swusage; } } @@ -1132,14 +1285,7 @@ printme = lbuf; } else if (startswith(line, "SwapFree:")) { if (wants_swap) { - uint64_t hostswfree = 0; - - if (host_swap) { - sscanf(line + STRLITERALLEN("SwapFree:"), "%" PRIu64, &hostswfree); - swfree = hostswfree; - } else if (swtotal >= swusage) { - swfree = swtotal - swusage; - } + swfree = swtotal - swusage; } snprintf(lbuf, 100, "SwapFree: %8" PRIu64 " kB\n", swfree); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/proc_loadavg.c new/lxcfs-4.0.8/src/proc_loadavg.c --- old/lxcfs-4.0.5/src/proc_loadavg.c 2020-08-04 00:17:19.000000000 +0200 +++ new/lxcfs-4.0.8/src/proc_loadavg.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -40,7 +48,6 @@ #include <sys/vfs.h> #include "bindings.h" -#include "config.h" #include "cgroup_fuse.h" #include "cgroups/cgroup.h" #include "cgroups/cgroup_utils.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/sysfs_fuse.c new/lxcfs-4.0.8/src/sysfs_fuse.c --- old/lxcfs-4.0.5/src/sysfs_fuse.c 2020-08-04 00:17:19.000000000 +0200 +++ new/lxcfs-4.0.8/src/sysfs_fuse.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -41,7 +49,7 @@ #include "bindings.h" #include "memory_utils.h" #include "cgroups/cgroup.h" -#include "config.h" +#include "lxcfs_fuse_compat.h" #include "sysfs_fuse.h" #include "utils.h" @@ -170,7 +178,7 @@ } if (strcmp(path, "/sys/devices/system/cpu/online") == 0) { - sb->st_size = 0; + sb->st_size = get_sysfile_size (path); sb->st_mode = S_IFREG | 00444; sb->st_nlink = 1; return 0; @@ -184,33 +192,33 @@ struct fuse_file_info *fi) { if (strcmp(path, "/sys") == 0) { - if (filler(buf, ".", NULL, 0) != 0 || - filler(buf, "..", NULL, 0) != 0 || - filler(buf, "devices", NULL, 0) != 0) + if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "..", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "devices", NULL, 0) != 0) return -ENOENT; return 0; } if (strcmp(path, "/sys/devices") == 0) { - if (filler(buf, ".", NULL, 0) != 0 || - filler(buf, "..", NULL, 0) != 0 || - filler(buf, "system", NULL, 0) != 0) + if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "..", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "system", NULL, 0) != 0) return -ENOENT; return 0; } if (strcmp(path, "/sys/devices/system") == 0) { - if (filler(buf, ".", NULL, 0) != 0 || - filler(buf, "..", NULL, 0) != 0 || - filler(buf, "cpu", NULL, 0) != 0) + if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "..", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "cpu", NULL, 0) != 0) return -ENOENT; return 0; } if (strcmp(path, "/sys/devices/system/cpu") == 0) { - if (filler(buf, ".", NULL, 0) != 0 || - filler(buf, "..", NULL, 0) != 0 || - filler(buf, "online", NULL, 0) != 0) + if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "..", NULL, 0) != 0 || + DIR_FILLER(filler, buf, "online", NULL, 0) != 0) return -ENOENT; return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lxcfs-4.0.5/src/utils.c new/lxcfs-4.0.8/src/utils.c --- old/lxcfs-4.0.5/src/utils.c 2020-08-04 00:17:19.000000000 +0200 +++ new/lxcfs-4.0.8/src/utils.c 2021-04-29 21:04:33.000000000 +0200 @@ -4,9 +4,17 @@ #define _GNU_SOURCE #endif +#include "config.h" + +#ifdef HAVE_FUSE3 +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 30 +#endif +#else #ifndef FUSE_USE_VERSION #define FUSE_USE_VERSION 26 #endif +#endif #define _FILE_OFFSET_BITS 64 @@ -29,7 +37,6 @@ #include <unistd.h> #include "bindings.h" -#include "config.h" #include "macro.h" #include "memory_utils.h" #include "utils.h" @@ -188,7 +195,7 @@ epfd = epoll_create(1); if (epfd < 0) - return log_error(false, "%s\n", "Failed to create epoll socket: %m"); + return log_error(false, "%m - Failed to create epoll socket"); ev.events = POLLIN_SET; ev.data.fd = sock;
