From 933fc687c392041e98f52128a3b450fec2947451 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 4 May 2021 11:18:28 -0700 Subject: [PATCH] omap remove_rid might not find entry Client recovery in the server doesn't add the omap rid for all the clients that it's waiting for. It only adds the rid as they connect. A client whose recovery timeout expires and is evicted will try to have its omap rid removed without being added. Today this triggers a warning and returns an error from a time when the omap rid lifecycle was more rigid. Now that it's being called by the server's reclaim_rid, along with a bunch of other functions that succeed if called for non-existant clients, let's have the omap remove_rid do the same. Signed-off-by: Zach Brown --- kmod/src/omap.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/kmod/src/omap.c b/kmod/src/omap.c index bb3ac8c4..37893914 100644 --- a/kmod/src/omap.c +++ b/kmod/src/omap.c @@ -485,6 +485,10 @@ static int remove_rid_from_reqs(struct omap_info *ominf, u64 rid, u64 *resp_rid, * response if it was the last rid waiting for a response. * * If this returns an error then the server will shut down. + * + * This can be called multiple times by different servers if there are + * errors reclaiming an evicted mount, so we allow asking to remove a + * rid that hasn't been added. */ int scoutfs_omap_remove_rid(struct super_block *sb, u64 rid) { @@ -495,21 +499,20 @@ int scoutfs_omap_remove_rid(struct super_block *sb, u64 rid) u64 resp_id = 0; int ret; - map = kmalloc(sizeof(struct scoutfs_open_ino_map), GFP_NOFS); - if (!map) { - ret = -ENOMEM; - goto out; - } - spin_lock(&ominf->lock); entry = find_rid(&ominf->rids, rid); if (entry) free_rid(&ominf->rids, entry); spin_unlock(&ominf->lock); - /* the server really shouldn't be removing a rid it never added */ - if (WARN_ON_ONCE(!entry)) { - ret = -ENOENT; + if (!entry) { + ret = 0; + goto out; + } + + map = kmalloc(sizeof(struct scoutfs_open_ino_map), GFP_NOFS); + if (!map) { + ret = -ENOMEM; goto out; }