|
|
d702dc |
autofs-5.1.6 - move readall into struct master
|
|
|
d702dc |
|
|
|
d702dc |
From: Ian Kent <raven@themaw.net>
|
|
|
d702dc |
|
|
|
d702dc |
The lookup modules may need to know if the master map is being re-read
|
|
|
d702dc |
vis a HUP signal or is being read for the first time.
|
|
|
d702dc |
|
|
|
d702dc |
This is indicated by the readall variable so move it into the master
|
|
|
d702dc |
map structure so it's accessable to lookup modules.
|
|
|
d702dc |
|
|
|
d702dc |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
d702dc |
---
|
|
|
d702dc |
CHANGELOG | 1 +
|
|
|
d702dc |
daemon/automount.c | 28 +++++++++++++++++-----------
|
|
|
d702dc |
include/master.h | 5 +++--
|
|
|
d702dc |
lib/master.c | 15 ++++++++-------
|
|
|
d702dc |
4 files changed, 29 insertions(+), 20 deletions(-)
|
|
|
d702dc |
|
|
|
d702dc |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
d702dc |
index 4d83df2..4a6c042 100644
|
|
|
d702dc |
--- a/CHANGELOG
|
|
|
d702dc |
+++ b/CHANGELOG
|
|
|
d702dc |
@@ -103,6 +103,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
d702dc |
- refactor sss getautomntent().
|
|
|
d702dc |
- improve sss getautomntent() error handling.
|
|
|
d702dc |
- sss introduce calculate_retry_count() function.
|
|
|
d702dc |
+- move readall into struct master.
|
|
|
d702dc |
|
|
|
d702dc |
19/12/2017 autofs-5.1.4
|
|
|
d702dc |
- fix spec file url.
|
|
|
d702dc |
diff --git a/daemon/automount.c b/daemon/automount.c
|
|
|
d702dc |
index 019bd81..9660f3f 100644
|
|
|
d702dc |
--- a/daemon/automount.c
|
|
|
d702dc |
+++ b/daemon/automount.c
|
|
|
d702dc |
@@ -1465,7 +1465,6 @@ static void *do_read_master(void *arg)
|
|
|
d702dc |
struct master *master;
|
|
|
d702dc |
unsigned int logopt;
|
|
|
d702dc |
time_t age;
|
|
|
d702dc |
- int readall = 1;
|
|
|
d702dc |
int status;
|
|
|
d702dc |
|
|
|
d702dc |
status = pthread_mutex_lock(&mrc.mutex);
|
|
|
d702dc |
@@ -1496,8 +1495,11 @@ static void *do_read_master(void *arg)
|
|
|
d702dc |
|
|
|
d702dc |
info(logopt, "re-reading master map %s", master->name);
|
|
|
d702dc |
|
|
|
d702dc |
- status = master_read_master(master, age, readall);
|
|
|
d702dc |
+ master->readall = 1;
|
|
|
d702dc |
|
|
|
d702dc |
+ status = master_read_master(master, age);
|
|
|
d702dc |
+
|
|
|
d702dc |
+ master->readall = 0;
|
|
|
d702dc |
master->reading = 0;
|
|
|
d702dc |
|
|
|
d702dc |
return NULL;
|
|
|
d702dc |
@@ -2196,7 +2198,7 @@ static void do_master_list_reset(struct master *master)
|
|
|
d702dc |
master_mutex_unlock();
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
-static int do_master_read_master(struct master *master, int wait)
|
|
|
d702dc |
+static int do_master_read_master(struct master *master, time_t *age, int wait)
|
|
|
d702dc |
{
|
|
|
d702dc |
sigset_t signalset;
|
|
|
d702dc |
/* Wait must be at least 1 second */
|
|
|
d702dc |
@@ -2204,7 +2206,6 @@ static int do_master_read_master(struct master *master, int wait)
|
|
|
d702dc |
unsigned int elapsed = 0;
|
|
|
d702dc |
int max_wait = wait;
|
|
|
d702dc |
int ret = 0;
|
|
|
d702dc |
- time_t age;
|
|
|
d702dc |
|
|
|
d702dc |
sigemptyset(&signalset);
|
|
|
d702dc |
sigaddset(&signalset, SIGTERM);
|
|
|
d702dc |
@@ -2217,8 +2218,8 @@ static int do_master_read_master(struct master *master, int wait)
|
|
|
d702dc |
|
|
|
d702dc |
do_master_list_reset(master);
|
|
|
d702dc |
|
|
|
d702dc |
- age = monotonic_time(NULL);
|
|
|
d702dc |
- if (master_read_master(master, age, 0)) {
|
|
|
d702dc |
+ *age = monotonic_time(NULL);
|
|
|
d702dc |
+ if (master_read_master(master, *age)) {
|
|
|
d702dc |
ret = 1;
|
|
|
d702dc |
break;
|
|
|
d702dc |
}
|
|
|
d702dc |
@@ -2692,14 +2693,14 @@ int main(int argc, char *argv[])
|
|
|
d702dc |
dh_tirpc = dlopen("libtirpc.so.3", RTLD_NOW);
|
|
|
d702dc |
#endif
|
|
|
d702dc |
|
|
|
d702dc |
- master_read = master_read_master(master_list, age, 0);
|
|
|
d702dc |
+ master_read = master_read_master(master_list, age);
|
|
|
d702dc |
if (!master_read) {
|
|
|
d702dc |
/*
|
|
|
d702dc |
* Read master map, waiting until it is available, unless
|
|
|
d702dc |
* a signal is received, in which case exit returning an
|
|
|
d702dc |
* error.
|
|
|
d702dc |
*/
|
|
|
d702dc |
- if (!do_master_read_master(master_list, master_wait)) {
|
|
|
d702dc |
+ if (!do_master_read_master(master_list, &age, master_wait)) {
|
|
|
d702dc |
logmsg("%s: warning: could not read at least one "
|
|
|
d702dc |
"map source after waiting, continuing ...",
|
|
|
d702dc |
program);
|
|
|
d702dc |
@@ -2707,9 +2708,14 @@ int main(int argc, char *argv[])
|
|
|
d702dc |
* Failed to read master map, continue with what
|
|
|
d702dc |
* we have anyway.
|
|
|
d702dc |
*/
|
|
|
d702dc |
- do_master_list_reset(master_list);
|
|
|
d702dc |
- age = monotonic_time(NULL);
|
|
|
d702dc |
- master_read_master(master_list, age, 1);
|
|
|
d702dc |
+ master_mutex_lock();
|
|
|
d702dc |
+ master_list->readall = 1;
|
|
|
d702dc |
+ master_mount_mounts(master_list, age);
|
|
|
d702dc |
+ master_list->readall = 0;
|
|
|
d702dc |
+
|
|
|
d702dc |
+ if (list_empty(&master_list->mounts))
|
|
|
d702dc |
+ warn(master_list->logopt, "no mounts in table");
|
|
|
d702dc |
+ master_mutex_unlock();
|
|
|
d702dc |
}
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
diff --git a/include/master.h b/include/master.h
|
|
|
d702dc |
index e1d272f..f689297 100644
|
|
|
d702dc |
--- a/include/master.h
|
|
|
d702dc |
+++ b/include/master.h
|
|
|
d702dc |
@@ -63,6 +63,7 @@ struct master {
|
|
|
d702dc |
unsigned int depth;
|
|
|
d702dc |
unsigned int reading;
|
|
|
d702dc |
unsigned int read_fail;
|
|
|
d702dc |
+ unsigned int readall;
|
|
|
d702dc |
unsigned int default_ghost;
|
|
|
d702dc |
unsigned int default_logging;
|
|
|
d702dc |
unsigned int default_timeout;
|
|
|
d702dc |
@@ -118,11 +119,11 @@ void master_remove_mapent(struct master_mapent *);
|
|
|
d702dc |
void master_free_mapent_sources(struct master_mapent *, unsigned int);
|
|
|
d702dc |
void master_free_mapent(struct master_mapent *);
|
|
|
d702dc |
struct master *master_new(const char *, unsigned int, unsigned int);
|
|
|
d702dc |
-int master_read_master(struct master *, time_t, int);
|
|
|
d702dc |
+int master_read_master(struct master *, time_t);
|
|
|
d702dc |
int master_submount_list_empty(struct autofs_point *ap);
|
|
|
d702dc |
int master_notify_submount(struct autofs_point *, const char *path, enum states);
|
|
|
d702dc |
void master_notify_state_change(struct master *, int);
|
|
|
d702dc |
-int master_mount_mounts(struct master *, time_t, int);
|
|
|
d702dc |
+int master_mount_mounts(struct master *, time_t);
|
|
|
d702dc |
int dump_map(struct master *, const char *, const char *);
|
|
|
d702dc |
int master_show_mounts(struct master *);
|
|
|
d702dc |
unsigned int master_get_logopt(void);
|
|
|
d702dc |
diff --git a/lib/master.c b/lib/master.c
|
|
|
d702dc |
index fedf807..d87d7e2 100644
|
|
|
d702dc |
--- a/lib/master.c
|
|
|
d702dc |
+++ b/lib/master.c
|
|
|
d702dc |
@@ -951,6 +951,7 @@ struct master *master_new(const char *name, unsigned int timeout, unsigned int f
|
|
|
d702dc |
master->depth = 0;
|
|
|
d702dc |
master->reading = 0;
|
|
|
d702dc |
master->read_fail = 0;
|
|
|
d702dc |
+ master->readall = 0;
|
|
|
d702dc |
master->default_ghost = flags & DAEMON_FLAGS_GHOST;
|
|
|
d702dc |
master->default_timeout = timeout;
|
|
|
d702dc |
master->default_logging = defaults_get_logging();
|
|
|
d702dc |
@@ -1126,7 +1127,7 @@ again:
|
|
|
d702dc |
}
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
-int master_read_master(struct master *master, time_t age, int readall)
|
|
|
d702dc |
+int master_read_master(struct master *master, time_t age)
|
|
|
d702dc |
{
|
|
|
d702dc |
unsigned int logopt = master->logopt;
|
|
|
d702dc |
struct mapent_cache *nc;
|
|
|
d702dc |
@@ -1157,15 +1158,15 @@ int master_read_master(struct master *master, time_t age, int readall)
|
|
|
d702dc |
master_add_amd_mount_section_mounts(master, age);
|
|
|
d702dc |
|
|
|
d702dc |
if (!master->read_fail)
|
|
|
d702dc |
- master_mount_mounts(master, age, readall);
|
|
|
d702dc |
+ master_mount_mounts(master, age);
|
|
|
d702dc |
else {
|
|
|
d702dc |
master->read_fail = 0;
|
|
|
d702dc |
- /* HUP signal sets readall == 1 only */
|
|
|
d702dc |
- if (!readall) {
|
|
|
d702dc |
+ /* HUP signal sets master->readall == 1 only */
|
|
|
d702dc |
+ if (!master->readall) {
|
|
|
d702dc |
master_mutex_unlock();
|
|
|
d702dc |
return 0;
|
|
|
d702dc |
} else
|
|
|
d702dc |
- master_mount_mounts(master, age, readall);
|
|
|
d702dc |
+ master_mount_mounts(master, age);
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
if (list_empty(&master->mounts))
|
|
|
d702dc |
@@ -1452,7 +1453,7 @@ static void check_update_map_sources(struct master_mapent *entry, int readall)
|
|
|
d702dc |
return;
|
|
|
d702dc |
}
|
|
|
d702dc |
|
|
|
d702dc |
-int master_mount_mounts(struct master *master, time_t age, int readall)
|
|
|
d702dc |
+int master_mount_mounts(struct master *master, time_t age)
|
|
|
d702dc |
{
|
|
|
d702dc |
struct mapent_cache *nc = master->nc;
|
|
|
d702dc |
struct list_head *p, *head;
|
|
|
d702dc |
@@ -1536,7 +1537,7 @@ cont:
|
|
|
d702dc |
st_mutex_unlock();
|
|
|
d702dc |
|
|
|
d702dc |
if (!ret)
|
|
|
d702dc |
- check_update_map_sources(this, readall);
|
|
|
d702dc |
+ check_update_map_sources(this, master->readall);
|
|
|
d702dc |
else if (ret == -1 && save_errno == EBADF) {
|
|
|
d702dc |
if (!master_do_mount(this)) {
|
|
|
d702dc |
list_del_init(&this->list);
|