diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-12 18:01:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-12 18:01:38 -0400 |
commit | 26935fb06ee88f1188789807687c03041f3c70d9 (patch) | |
tree | 381c487716540b52348d78bee6555f8fa61d77ef /net | |
parent | 3cc69b638e11bfda5d013c2b75b60934aa0e88a1 (diff) | |
parent | bf2ba3bc185269eca274b458aac46ba1ad7c1121 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile 4 from Al Viro:
"list_lru pile, mostly"
This came out of Andrew's pile, Al ended up doing the merge work so that
Andrew didn't have to.
Additionally, a few fixes.
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (42 commits)
super: fix for destroy lrus
list_lru: dynamically adjust node arrays
shrinker: Kill old ->shrink API.
shrinker: convert remaining shrinkers to count/scan API
staging/lustre/libcfs: cleanup linux-mem.h
staging/lustre/ptlrpc: convert to new shrinker API
staging/lustre/obdclass: convert lu_object shrinker to count/scan API
staging/lustre/ldlm: convert to shrinkers to count/scan API
hugepage: convert huge zero page shrinker to new shrinker API
i915: bail out earlier when shrinker cannot acquire mutex
drivers: convert shrinkers to new count/scan API
fs: convert fs shrinkers to new scan/count API
xfs: fix dquot isolation hang
xfs-convert-dquot-cache-lru-to-list_lru-fix
xfs: convert dquot cache lru to list_lru
xfs: rework buffer dispose list tracking
xfs-convert-buftarg-lru-to-generic-code-fix
xfs: convert buftarg LRU to generic code
fs: convert inode and dentry shrinking to be node aware
vmscan: per-node deferred work
...
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/auth.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 415159061cd0..5285ead196c0 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -434,12 +434,13 @@ EXPORT_SYMBOL_GPL(rpcauth_destroy_credcache); | |||
434 | /* | 434 | /* |
435 | * Remove stale credentials. Avoid sleeping inside the loop. | 435 | * Remove stale credentials. Avoid sleeping inside the loop. |
436 | */ | 436 | */ |
437 | static int | 437 | static long |
438 | rpcauth_prune_expired(struct list_head *free, int nr_to_scan) | 438 | rpcauth_prune_expired(struct list_head *free, int nr_to_scan) |
439 | { | 439 | { |
440 | spinlock_t *cache_lock; | 440 | spinlock_t *cache_lock; |
441 | struct rpc_cred *cred, *next; | 441 | struct rpc_cred *cred, *next; |
442 | unsigned long expired = jiffies - RPC_AUTH_EXPIRY_MORATORIUM; | 442 | unsigned long expired = jiffies - RPC_AUTH_EXPIRY_MORATORIUM; |
443 | long freed = 0; | ||
443 | 444 | ||
444 | list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) { | 445 | list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) { |
445 | 446 | ||
@@ -451,10 +452,11 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan) | |||
451 | */ | 452 | */ |
452 | if (time_in_range(cred->cr_expire, expired, jiffies) && | 453 | if (time_in_range(cred->cr_expire, expired, jiffies) && |
453 | test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) | 454 | test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) |
454 | return 0; | 455 | break; |
455 | 456 | ||
456 | list_del_init(&cred->cr_lru); | 457 | list_del_init(&cred->cr_lru); |
457 | number_cred_unused--; | 458 | number_cred_unused--; |
459 | freed++; | ||
458 | if (atomic_read(&cred->cr_count) != 0) | 460 | if (atomic_read(&cred->cr_count) != 0) |
459 | continue; | 461 | continue; |
460 | 462 | ||
@@ -467,29 +469,39 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan) | |||
467 | } | 469 | } |
468 | spin_unlock(cache_lock); | 470 | spin_unlock(cache_lock); |
469 | } | 471 | } |
470 | return (number_cred_unused / 100) * sysctl_vfs_cache_pressure; | 472 | return freed; |
471 | } | 473 | } |
472 | 474 | ||
473 | /* | 475 | /* |
474 | * Run memory cache shrinker. | 476 | * Run memory cache shrinker. |
475 | */ | 477 | */ |
476 | static int | 478 | static unsigned long |
477 | rpcauth_cache_shrinker(struct shrinker *shrink, struct shrink_control *sc) | 479 | rpcauth_cache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) |
480 | |||
478 | { | 481 | { |
479 | LIST_HEAD(free); | 482 | LIST_HEAD(free); |
480 | int res; | 483 | unsigned long freed; |
481 | int nr_to_scan = sc->nr_to_scan; | 484 | |
482 | gfp_t gfp_mask = sc->gfp_mask; | 485 | if ((sc->gfp_mask & GFP_KERNEL) != GFP_KERNEL) |
486 | return SHRINK_STOP; | ||
483 | 487 | ||
484 | if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL) | 488 | /* nothing left, don't come back */ |
485 | return (nr_to_scan == 0) ? 0 : -1; | ||
486 | if (list_empty(&cred_unused)) | 489 | if (list_empty(&cred_unused)) |
487 | return 0; | 490 | return SHRINK_STOP; |
491 | |||
488 | spin_lock(&rpc_credcache_lock); | 492 | spin_lock(&rpc_credcache_lock); |
489 | res = rpcauth_prune_expired(&free, nr_to_scan); | 493 | freed = rpcauth_prune_expired(&free, sc->nr_to_scan); |
490 | spin_unlock(&rpc_credcache_lock); | 494 | spin_unlock(&rpc_credcache_lock); |
491 | rpcauth_destroy_credlist(&free); | 495 | rpcauth_destroy_credlist(&free); |
492 | return res; | 496 | |
497 | return freed; | ||
498 | } | ||
499 | |||
500 | static unsigned long | ||
501 | rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc) | ||
502 | |||
503 | { | ||
504 | return (number_cred_unused / 100) * sysctl_vfs_cache_pressure; | ||
493 | } | 505 | } |
494 | 506 | ||
495 | /* | 507 | /* |
@@ -805,7 +817,8 @@ rpcauth_uptodatecred(struct rpc_task *task) | |||
805 | } | 817 | } |
806 | 818 | ||
807 | static struct shrinker rpc_cred_shrinker = { | 819 | static struct shrinker rpc_cred_shrinker = { |
808 | .shrink = rpcauth_cache_shrinker, | 820 | .count_objects = rpcauth_cache_shrink_count, |
821 | .scan_objects = rpcauth_cache_shrink_scan, | ||
809 | .seeks = DEFAULT_SEEKS, | 822 | .seeks = DEFAULT_SEEKS, |
810 | }; | 823 | }; |
811 | 824 | ||