diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-08-27 20:18:14 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-10 18:56:32 -0400 |
commit | 70534a739c12b908789e27b08512d2615ba40f2f (patch) | |
tree | e41d776d76de06a64b08cb787d87590f80e94f7e /net/sunrpc/auth.c | |
parent | ea8352c289294e21ee13bdb105f55dc63497acff (diff) |
shrinker: convert remaining shrinkers to count/scan API
Convert the remaining couple of random shrinkers in the tree to the new
API.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Glauber Costa <glommer@openvz.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: J. Bruce Fields <bfields@redhat.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Carlos Maiolino <cmaiolino@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Rientjes <rientjes@google.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: J. Bruce Fields <bfields@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Kent Overstreet <koverstreet@google.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/sunrpc/auth.c')
-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 | ||