[PATCH 03/11] autofs-5.1.9 - fix cache writelock must be taken in update_map_cache()
Ian Kent <[email protected]> Fri, 31 Oct 2025 09:31:31 +0800
| Newsgroups | org.kernel.vger.autofs |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- CHANGELOG | 1 + daemon/automount.c | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9308e0392..d0d040bae 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -70,6 +70,7 @@ - add en xtra 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; } -- 2.51.0