autofs-5.1.9 - fix cache writelock must be taken in update_map_cache() From: Ian Kent In update_map_cache() the cache writelock must be taken because we need to clean up the map entry as it will be a problem later if we don't. It's possible that some other process has taken the lock temporarily but when this function is called the thread does not hold any cache locks so it should be ok to aquire it. Signed-off-by: Ian Kent --- CHANGELOG | 1 + daemon/automount.c | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5f7b2e5e9..a6cf77484 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -71,6 +71,7 @@ - add en extra logging entry to tree_mapent_mount_offsets(). - quiet possibly noisy log message. - fix devid update on reload. +- fix cache writelock must be taken in update_map_cache(). 02/11/2023 autofs-5.1.9 - fix kernel mount status notification. diff --git a/daemon/automount.c b/daemon/automount.c index e567daf82..c071e63f8 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -536,13 +536,11 @@ static void update_map_cache(struct autofs_point *ap, const char *path) } mc = map->mc; - /* If the lock is busy try later */ - if (cache_try_writelock(mc)) { - me = cache_lookup_distinct(mc, key); - if (me && me->ioctlfd == -1) - cache_delete(mc, key); - cache_unlock(mc); - } + cache_writelock(mc); + me = cache_lookup_distinct(mc, key); + if (me && me->ioctlfd == -1) + cache_delete(mc, key); + cache_unlock(mc); map = map->next; }