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