|
|
f83ba4 |
From 513224ceee718af980b6bc01a3e5f3f0e6452307 Mon Sep 17 00:00:00 2001
|
|
|
f83ba4 |
From: Laine Stump <laine@laine.org>
|
|
|
f83ba4 |
Date: Mon, 28 Sep 2015 17:11:11 -0400
|
|
|
f83ba4 |
Subject: [PATCH 1/2] call aug_load() at most once per second
|
|
|
f83ba4 |
|
|
|
f83ba4 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1268382
|
|
|
f83ba4 |
|
|
|
f83ba4 |
Previously, netcf would call aug_load() at the start of each public
|
|
|
f83ba4 |
API call, and rely on augeas quickly determining if the files needed
|
|
|
f83ba4 |
to be reread based on checking the mtime of all files. With a large
|
|
|
f83ba4 |
number of files (i.e. several hundred ifcfg files) just checking the
|
|
|
f83ba4 |
mtime of all files ends up taking quite a long time; enough to turn a
|
|
|
f83ba4 |
simple "virsh iface-list" of 300 bridges + 300 vlans into a 22 second
|
|
|
f83ba4 |
ordeal.
|
|
|
f83ba4 |
|
|
|
f83ba4 |
With this patch applied, netcf will only call aug_load() at most once
|
|
|
f83ba4 |
every second, resulting in runtime for virsh iface-list going down to
|
|
|
f83ba4 |
< 1 second.
|
|
|
f83ba4 |
|
|
|
f83ba4 |
The trade-off is that the results of a netcf API call could be up to 1
|
|
|
f83ba4 |
second out of date (but only due to changes in the config external to
|
|
|
f83ba4 |
netcf). Since ifcfg files change very infrequently, this is likely
|
|
|
f83ba4 |
acceptable.
|
|
|
f83ba4 |
|
|
|
f83ba4 |
(cherry picked from commit 9b5f4eb57af28a604cd7ac8b2c1be9e49f0b517d)
|
|
|
f83ba4 |
---
|
|
|
f83ba4 |
src/dutil_linux.c | 8 +++++++-
|
|
|
f83ba4 |
src/dutil_linux.h | 1 +
|
|
|
f83ba4 |
2 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
f83ba4 |
|
|
|
f83ba4 |
diff --git a/src/dutil_linux.c b/src/dutil_linux.c
|
|
|
f83ba4 |
index 0850593..24f4d95 100644
|
|
|
f83ba4 |
--- a/src/dutil_linux.c
|
|
|
f83ba4 |
+++ b/src/dutil_linux.c
|
|
|
f83ba4 |
@@ -32,6 +32,7 @@
|
|
|
f83ba4 |
#include <unistd.h>
|
|
|
f83ba4 |
#include <ctype.h>
|
|
|
f83ba4 |
#include <errno.h>
|
|
|
f83ba4 |
+#include <time.h>
|
|
|
f83ba4 |
|
|
|
f83ba4 |
#include <dirent.h>
|
|
|
f83ba4 |
#include <sys/wait.h>
|
|
|
f83ba4 |
@@ -151,6 +152,7 @@ int remove_augeas_xfm_table(struct netcf *ncf,
|
|
|
f83ba4 |
*/
|
|
|
f83ba4 |
augeas *get_augeas(struct netcf *ncf) {
|
|
|
f83ba4 |
int r;
|
|
|
f83ba4 |
+ time_t current_time;
|
|
|
f83ba4 |
|
|
|
f83ba4 |
if (ncf->driver->augeas == NULL) {
|
|
|
f83ba4 |
augeas *aug;
|
|
|
f83ba4 |
@@ -186,9 +188,12 @@ augeas *get_augeas(struct netcf *ncf) {
|
|
|
f83ba4 |
}
|
|
|
f83ba4 |
ncf->driver->copy_augeas_xfm = 0;
|
|
|
f83ba4 |
ncf->driver->load_augeas = 1;
|
|
|
f83ba4 |
+ ncf->driver->load_augeas_time = 0;
|
|
|
f83ba4 |
}
|
|
|
f83ba4 |
|
|
|
f83ba4 |
- if (ncf->driver->load_augeas) {
|
|
|
f83ba4 |
+ current_time = time(NULL);
|
|
|
f83ba4 |
+ if (ncf->driver->load_augeas &&
|
|
|
f83ba4 |
+ ncf->driver->load_augeas_time != current_time) {
|
|
|
f83ba4 |
augeas *aug = ncf->driver->augeas;
|
|
|
f83ba4 |
|
|
|
f83ba4 |
r = aug_load(aug);
|
|
|
f83ba4 |
@@ -207,6 +212,7 @@ augeas *get_augeas(struct netcf *ncf) {
|
|
|
f83ba4 |
}
|
|
|
f83ba4 |
ERR_THROW(r > 0, ncf, EOTHER, "errors in loading some config files");
|
|
|
f83ba4 |
ncf->driver->load_augeas = 0;
|
|
|
f83ba4 |
+ ncf->driver->load_augeas_time = current_time;
|
|
|
f83ba4 |
}
|
|
|
f83ba4 |
return ncf->driver->augeas;
|
|
|
f83ba4 |
error:
|
|
|
f83ba4 |
diff --git a/src/dutil_linux.h b/src/dutil_linux.h
|
|
|
f83ba4 |
index a06a15c..75ac631 100644
|
|
|
f83ba4 |
--- a/src/dutil_linux.h
|
|
|
f83ba4 |
+++ b/src/dutil_linux.h
|
|
|
f83ba4 |
@@ -41,6 +41,7 @@ struct driver {
|
|
|
f83ba4 |
struct nl_sock *nl_sock;
|
|
|
f83ba4 |
struct nl_cache *link_cache;
|
|
|
f83ba4 |
struct nl_cache *addr_cache;
|
|
|
f83ba4 |
+ time_t load_augeas_time;
|
|
|
f83ba4 |
unsigned int load_augeas : 1;
|
|
|
f83ba4 |
unsigned int copy_augeas_xfm : 1;
|
|
|
f83ba4 |
unsigned int augeas_xfm_num_tables;
|
|
|
f83ba4 |
--
|
|
|
f83ba4 |
1.8.3.1
|
|
|
f83ba4 |
|