|
|
96dc52 |
autofs-5.1.7 - set offset parent in update_offset_entry()
|
|
|
96dc52 |
|
|
|
96dc52 |
From: Ian Kent <raven@themaw.net>
|
|
|
96dc52 |
|
|
|
96dc52 |
Avoid the list traversal in cache_set_parents() by setting the
|
|
|
96dc52 |
offset parent when updating the offset.
|
|
|
96dc52 |
|
|
|
96dc52 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
96dc52 |
---
|
|
|
96dc52 |
CHANGELOG | 1 +
|
|
|
96dc52 |
include/automount.h | 2 +-
|
|
|
96dc52 |
lib/cache.c | 26 +++++++++++---------------
|
|
|
96dc52 |
modules/parse_sun.c | 5 ++++-
|
|
|
96dc52 |
4 files changed, 17 insertions(+), 17 deletions(-)
|
|
|
96dc52 |
|
|
|
96dc52 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
96dc52 |
index ee746277..c4ebb52f 100644
|
|
|
96dc52 |
--- a/CHANGELOG
|
|
|
96dc52 |
+++ b/CHANGELOG
|
|
|
96dc52 |
@@ -8,6 +8,7 @@
|
|
|
96dc52 |
- eliminate cache_lookup_offset() usage.
|
|
|
96dc52 |
- fix is mounted check on non existent path.
|
|
|
96dc52 |
- simplify cache_get_parent().
|
|
|
96dc52 |
+- set offset parent in update_offset_entry().
|
|
|
96dc52 |
|
|
|
96dc52 |
25/01/2021 autofs-5.1.7
|
|
|
96dc52 |
- make bind mounts propagation slave by default.
|
|
|
96dc52 |
diff --git a/include/automount.h b/include/automount.h
|
|
|
96dc52 |
index 2f09e8e7..730be19a 100644
|
|
|
96dc52 |
--- a/include/automount.h
|
|
|
96dc52 |
+++ b/include/automount.h
|
|
|
96dc52 |
@@ -208,7 +208,7 @@ int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, c
|
|
|
96dc52 |
int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age);
|
|
|
96dc52 |
int cache_lookup_negative(struct mapent *me, const char *key);
|
|
|
96dc52 |
void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout);
|
|
|
96dc52 |
-int cache_set_parents(struct mapent *mm);
|
|
|
96dc52 |
+int cache_set_offset_parent(struct mapent_cache *mc, const char *offset);
|
|
|
96dc52 |
int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
|
|
|
96dc52 |
int cache_delete(struct mapent_cache *mc, const char *key);
|
|
|
96dc52 |
int cache_delete_offset(struct mapent_cache *mc, const char *key);
|
|
|
96dc52 |
diff --git a/lib/cache.c b/lib/cache.c
|
|
|
96dc52 |
index 53f290cd..ce9e9bd2 100644
|
|
|
96dc52 |
--- a/lib/cache.c
|
|
|
96dc52 |
+++ b/lib/cache.c
|
|
|
96dc52 |
@@ -864,25 +864,21 @@ static struct mapent *get_offset_parent(struct mapent_cache *mc,
|
|
|
96dc52 |
return NULL;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
-int cache_set_parents(struct mapent *mm)
|
|
|
96dc52 |
+int cache_set_offset_parent(struct mapent_cache *mc, const char *offset)
|
|
|
96dc52 |
{
|
|
|
96dc52 |
- struct list_head *multi_head, *p;
|
|
|
96dc52 |
- struct mapent *this;
|
|
|
96dc52 |
+ struct mapent *this, *parent;
|
|
|
96dc52 |
|
|
|
96dc52 |
- if (!mm->multi)
|
|
|
96dc52 |
+ this = cache_lookup_distinct(mc, offset);
|
|
|
96dc52 |
+ if (!this)
|
|
|
96dc52 |
+ return 0;
|
|
|
96dc52 |
+ if (!this->multi)
|
|
|
96dc52 |
return 0;
|
|
|
96dc52 |
|
|
|
96dc52 |
- multi_head = &mm->multi->multi_list;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- list_for_each(p, multi_head) {
|
|
|
96dc52 |
- struct mapent *parent;
|
|
|
96dc52 |
- this = list_entry(p, struct mapent, multi_list);
|
|
|
96dc52 |
- parent = get_offset_parent(mm->mc, this->key);
|
|
|
96dc52 |
- if (parent)
|
|
|
96dc52 |
- this->parent = parent;
|
|
|
96dc52 |
- else
|
|
|
96dc52 |
- this->parent = mm->multi;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
+ parent = get_offset_parent(mc, offset);
|
|
|
96dc52 |
+ if (parent)
|
|
|
96dc52 |
+ this->parent = parent;
|
|
|
96dc52 |
+ else
|
|
|
96dc52 |
+ this->parent = this->multi;
|
|
|
96dc52 |
|
|
|
96dc52 |
return 1;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
|
|
|
96dc52 |
index 819d6adc..f42af7b7 100644
|
|
|
96dc52 |
--- a/modules/parse_sun.c
|
|
|
96dc52 |
+++ b/modules/parse_sun.c
|
|
|
96dc52 |
@@ -859,6 +859,10 @@ update_offset_entry(struct autofs_point *ap, const char *name,
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
ret = cache_update_offset(mc, name, m_key, m_mapent, age);
|
|
|
96dc52 |
+
|
|
|
96dc52 |
+ if (!cache_set_offset_parent(mc, m_key))
|
|
|
96dc52 |
+ error(ap->logopt, "failed to set offset parent");
|
|
|
96dc52 |
+
|
|
|
96dc52 |
if (ret == CHE_DUPLICATE) {
|
|
|
96dc52 |
warn(ap->logopt, MODPREFIX
|
|
|
96dc52 |
"syntax error or duplicate offset %s -> %s", path, loc);
|
|
|
96dc52 |
@@ -1613,7 +1617,6 @@ dont_expand:
|
|
|
96dc52 |
*/
|
|
|
96dc52 |
if (me == me->multi)
|
|
|
96dc52 |
clean_stale_multi_triggers(ap, me, NULL, NULL);
|
|
|
96dc52 |
- cache_set_parents(me);
|
|
|
96dc52 |
|
|
|
96dc52 |
rv = mount_subtree(ap, me, name, NULL, options, ctxt);
|
|
|
96dc52 |
|