Merge tag 'for-5.0-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[sfrench/cifs-2.6.git] / net / sunrpc / cache.c
index f96345b1180ee9cf41013008ac2f052a29496818..12bb23b8e0c50c80abd51c69a5c5a2ea6433a723 100644 (file)
@@ -54,6 +54,11 @@ static void cache_init(struct cache_head *h, struct cache_detail *detail)
        h->last_refresh = now;
 }
 
+static void cache_fresh_locked(struct cache_head *head, time_t expiry,
+                               struct cache_detail *detail);
+static void cache_fresh_unlocked(struct cache_head *head,
+                               struct cache_detail *detail);
+
 static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail,
                                                struct cache_head *key,
                                                int hash)
@@ -100,6 +105,7 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
                        if (cache_is_expired(detail, tmp)) {
                                hlist_del_init_rcu(&tmp->cache_list);
                                detail->entries --;
+                               cache_fresh_locked(tmp, 0, detail);
                                freeme = tmp;
                                break;
                        }
@@ -115,8 +121,10 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
        cache_get(new);
        spin_unlock(&detail->hash_lock);
 
-       if (freeme)
+       if (freeme) {
+               cache_fresh_unlocked(freeme, detail);
                cache_put(freeme, detail);
+       }
        return new;
 }