aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfsd/nfscache.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index b6af150c96b8..f8f060ffbf4f 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -132,13 +132,6 @@ nfsd_reply_cache_alloc(void)
132} 132}
133 133
134static void 134static void
135nfsd_reply_cache_unhash(struct svc_cacherep *rp)
136{
137 hlist_del_init(&rp->c_hash);
138 list_del_init(&rp->c_lru);
139}
140
141static void
142nfsd_reply_cache_free_locked(struct svc_cacherep *rp) 135nfsd_reply_cache_free_locked(struct svc_cacherep *rp)
143{ 136{
144 if (rp->c_type == RC_REPLBUFF && rp->c_replvec.iov_base) { 137 if (rp->c_type == RC_REPLBUFF && rp->c_replvec.iov_base) {
@@ -416,22 +409,8 @@ nfsd_cache_lookup(struct svc_rqst *rqstp)
416 409
417 /* 410 /*
418 * Since the common case is a cache miss followed by an insert, 411 * Since the common case is a cache miss followed by an insert,
419 * preallocate an entry. First, try to reuse the first entry on the LRU 412 * preallocate an entry.
420 * if it works, then go ahead and prune the LRU list.
421 */ 413 */
422 spin_lock(&cache_lock);
423 if (!list_empty(&lru_head)) {
424 rp = list_first_entry(&lru_head, struct svc_cacherep, c_lru);
425 if (nfsd_cache_entry_expired(rp) ||
426 num_drc_entries >= max_drc_entries) {
427 nfsd_reply_cache_unhash(rp);
428 prune_cache_entries();
429 goto search_cache;
430 }
431 }
432
433 /* No expired ones available, allocate a new one. */
434 spin_unlock(&cache_lock);
435 rp = nfsd_reply_cache_alloc(); 414 rp = nfsd_reply_cache_alloc();
436 spin_lock(&cache_lock); 415 spin_lock(&cache_lock);
437 if (likely(rp)) { 416 if (likely(rp)) {
@@ -439,7 +418,9 @@ nfsd_cache_lookup(struct svc_rqst *rqstp)
439 drc_mem_usage += sizeof(*rp); 418 drc_mem_usage += sizeof(*rp);
440 } 419 }
441 420
442search_cache: 421 /* go ahead and prune the cache */
422 prune_cache_entries();
423
443 found = nfsd_cache_search(rqstp, csum); 424 found = nfsd_cache_search(rqstp, csum);
444 if (found) { 425 if (found) {
445 if (likely(rp)) 426 if (likely(rp))
@@ -453,15 +434,6 @@ search_cache:
453 goto out; 434 goto out;
454 } 435 }
455 436
456 /*
457 * We're keeping the one we just allocated. Are we now over the
458 * limit? Prune one off the tip of the LRU in trade for the one we
459 * just allocated if so.
460 */
461 if (num_drc_entries >= max_drc_entries)
462 nfsd_reply_cache_free_locked(list_first_entry(&lru_head,
463 struct svc_cacherep, c_lru));
464
465 nfsdstats.rcmisses++; 437 nfsdstats.rcmisses++;
466 rqstp->rq_cacherep = rp; 438 rqstp->rq_cacherep = rp;
467 rp->c_state = RC_INPROG; 439 rp->c_state = RC_INPROG;