diff options
Diffstat (limited to 'net/sunrpc/auth.c')
| -rw-r--r-- | net/sunrpc/auth.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 95afe79dd9d7..73affb8624fa 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
| @@ -236,10 +236,15 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan) | |||
| 236 | 236 | ||
| 237 | list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) { | 237 | list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) { |
| 238 | 238 | ||
| 239 | /* Enforce a 60 second garbage collection moratorium */ | 239 | if (nr_to_scan-- == 0) |
| 240 | break; | ||
| 241 | /* | ||
| 242 | * Enforce a 60 second garbage collection moratorium | ||
| 243 | * Note that the cred_unused list must be time-ordered. | ||
| 244 | */ | ||
| 240 | if (time_in_range(cred->cr_expire, expired, jiffies) && | 245 | if (time_in_range(cred->cr_expire, expired, jiffies) && |
| 241 | test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) | 246 | test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) |
| 242 | continue; | 247 | return 0; |
| 243 | 248 | ||
| 244 | list_del_init(&cred->cr_lru); | 249 | list_del_init(&cred->cr_lru); |
| 245 | number_cred_unused--; | 250 | number_cred_unused--; |
| @@ -252,13 +257,10 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan) | |||
| 252 | get_rpccred(cred); | 257 | get_rpccred(cred); |
| 253 | list_add_tail(&cred->cr_lru, free); | 258 | list_add_tail(&cred->cr_lru, free); |
| 254 | rpcauth_unhash_cred_locked(cred); | 259 | rpcauth_unhash_cred_locked(cred); |
| 255 | nr_to_scan--; | ||
| 256 | } | 260 | } |
| 257 | spin_unlock(cache_lock); | 261 | spin_unlock(cache_lock); |
| 258 | if (nr_to_scan == 0) | ||
| 259 | break; | ||
| 260 | } | 262 | } |
| 261 | return nr_to_scan; | 263 | return (number_cred_unused / 100) * sysctl_vfs_cache_pressure; |
| 262 | } | 264 | } |
| 263 | 265 | ||
| 264 | /* | 266 | /* |
| @@ -270,11 +272,12 @@ rpcauth_cache_shrinker(int nr_to_scan, gfp_t gfp_mask) | |||
| 270 | LIST_HEAD(free); | 272 | LIST_HEAD(free); |
| 271 | int res; | 273 | int res; |
| 272 | 274 | ||
| 275 | if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL) | ||
| 276 | return (nr_to_scan == 0) ? 0 : -1; | ||
| 273 | if (list_empty(&cred_unused)) | 277 | if (list_empty(&cred_unused)) |
| 274 | return 0; | 278 | return 0; |
| 275 | spin_lock(&rpc_credcache_lock); | 279 | spin_lock(&rpc_credcache_lock); |
| 276 | nr_to_scan = rpcauth_prune_expired(&free, nr_to_scan); | 280 | res = rpcauth_prune_expired(&free, nr_to_scan); |
| 277 | res = (number_cred_unused / 100) * sysctl_vfs_cache_pressure; | ||
| 278 | spin_unlock(&rpc_credcache_lock); | 281 | spin_unlock(&rpc_credcache_lock); |
| 279 | rpcauth_destroy_credlist(&free); | 282 | rpcauth_destroy_credlist(&free); |
| 280 | return res; | 283 | return res; |
