From d8824718f0b21e1d8b94d39c2f14434d872d1a9c Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Sat, 14 Jan 2017 16:15:27 +0200 Subject: [PATCH] disable mountinfo statvfs() calls for modules that do not need this info --- src/plugin_proc_diskspace.c | 2 +- src/proc_diskstats.c | 2 +- src/proc_self_mountinfo.c | 4 ++-- src/proc_self_mountinfo.h | 2 +- src/sys_fs_cgroup.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugin_proc_diskspace.c b/src/plugin_proc_diskspace.c index 14168962..8ca5dd25 100644 --- a/src/plugin_proc_diskspace.c +++ b/src/plugin_proc_diskspace.c @@ -14,7 +14,7 @@ static inline void mountinfo_reload(int force) { mountinfo_free(disk_mountinfo_root); // re-read mountinfo in case something changed - disk_mountinfo_root = mountinfo_read(); + disk_mountinfo_root = mountinfo_read(1); last_loaded = now; } diff --git a/src/proc_diskstats.c b/src/proc_diskstats.c index ff036eb4..fc9d46c0 100644 --- a/src/proc_diskstats.c +++ b/src/proc_diskstats.c @@ -41,7 +41,7 @@ static inline void mountinfo_reload(int force) { mountinfo_free(disk_mountinfo_root); // re-read mountinfo in case something changed - disk_mountinfo_root = mountinfo_read(); + disk_mountinfo_root = mountinfo_read(0); last_loaded = now; } diff --git a/src/proc_self_mountinfo.c b/src/proc_self_mountinfo.c index 7c1d3155..08d5abce 100644 --- a/src/proc_self_mountinfo.c +++ b/src/proc_self_mountinfo.c @@ -173,7 +173,7 @@ static inline int is_read_only(const char *s) { } // read the whole mountinfo into a linked list -struct mountinfo *mountinfo_read() { +struct mountinfo *mountinfo_read(int do_statvfs) { char filename[FILENAME_MAX + 1]; snprintfz(filename, FILENAME_MAX, "%s/proc/self/mountinfo", global_host_prefix); procfile *ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT); @@ -316,7 +316,7 @@ struct mountinfo *mountinfo_read() { } // check if it has size - { + if(do_statvfs) { struct statvfs buff_statvfs; if(unlikely(statvfs(mi->mount_point, &buff_statvfs) < 0)) { mi->flags |= MOUNTINFO_NO_STAT; diff --git a/src/proc_self_mountinfo.h b/src/proc_self_mountinfo.h index 53f44564..00cf699a 100644 --- a/src/proc_self_mountinfo.h +++ b/src/proc_self_mountinfo.h @@ -50,6 +50,6 @@ extern struct mountinfo *mountinfo_find_by_filesystem_mount_source(struct mounti extern struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *root, const char *filesystem, const char *super_options); extern void mountinfo_free(struct mountinfo *mi); -extern struct mountinfo *mountinfo_read(); +extern struct mountinfo *mountinfo_read(int do_statvfs); #endif /* NETDATA_PROC_SELF_MOUNTINFO_H */ \ No newline at end of file diff --git a/src/sys_fs_cgroup.c b/src/sys_fs_cgroup.c index 98e5d527..2274c3f3 100644 --- a/src/sys_fs_cgroup.c +++ b/src/sys_fs_cgroup.c @@ -28,7 +28,7 @@ void read_cgroup_plugin_configuration() { cgroup_enable_blkio = config_get_boolean_ondemand("plugin:cgroups", "enable blkio", cgroup_enable_blkio); char filename[FILENAME_MAX + 1], *s; - struct mountinfo *mi, *root = mountinfo_read(); + struct mountinfo *mi, *root = mountinfo_read(0); mi = mountinfo_find_by_filesystem_super_option(root, "cgroup", "cpuacct"); if(!mi) mi = mountinfo_find_by_filesystem_mount_source(root, "cgroup", "cpuacct"); -- 2.39.2