From 310725eb72899a17cea2aa628a1e309d9c7ff670 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 1 Jul 2022 10:02:35 -0700 Subject: [PATCH] Free omap rid list as server exits The omap code keeps track of rids that are connected to the server. It only freed the tracked rids as the server told it that rids were being removed. But that removal only happened as clients were evicted. If the server shutdown it'd leave the old rid entries around. They'd be leaked as the mount was unmounted and could linger and crate duplicate entries if the server started back up and the same clients reconnected. The fix is to free the tracking rids as the server shuts down. They'll be rebuilt as clients reconnect if the server restarts. Signed-off-by: Zach Brown --- kmod/src/omap.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kmod/src/omap.c b/kmod/src/omap.c index 604c397e..c39dbc9c 100644 --- a/kmod/src/omap.c +++ b/kmod/src/omap.c @@ -157,6 +157,15 @@ static int free_rid(struct omap_rid_list *list, struct omap_rid_entry *entry) return nr; } +static void free_rid_list(struct omap_rid_list *list) +{ + struct omap_rid_entry *entry; + struct omap_rid_entry *tmp; + + list_for_each_entry_safe(entry, tmp, &list->head, head) + free_rid(list, entry); +} + static int copy_rids(struct omap_rid_list *to, struct omap_rid_list *from, spinlock_t *from_lock) { struct omap_rid_entry *entry; @@ -804,6 +813,10 @@ void scoutfs_omap_server_shutdown(struct super_block *sb) llist_for_each_entry_safe(req, tmp, requests, llnode) kfree(req); + spin_lock(&ominf->lock); + free_rid_list(&ominf->rids); + spin_unlock(&ominf->lock); + synchronize_rcu(); } @@ -864,6 +877,10 @@ void scoutfs_omap_destroy(struct super_block *sb) rhashtable_walk_stop(&iter); rhashtable_walk_exit(&iter); + spin_lock(&ominf->lock); + free_rid_list(&ominf->rids); + spin_unlock(&ominf->lock); + rhashtable_destroy(&ominf->group_ht); rhashtable_destroy(&ominf->req_ht); kfree(ominf);