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 ...
This commit is contained in:
@@ -434,12 +434,13 @@ EXPORT_SYMBOL_GPL(rpcauth_destroy_credcache);
|
||||
/*
|
||||
* Remove stale credentials. Avoid sleeping inside the loop.
|
||||
*/
|
||||
static int
|
||||
static long
|
||||
rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
|
||||
{
|
||||
spinlock_t *cache_lock;
|
||||
struct rpc_cred *cred, *next;
|
||||
unsigned long expired = jiffies - RPC_AUTH_EXPIRY_MORATORIUM;
|
||||
long freed = 0;
|
||||
|
||||
list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) {
|
||||
|
||||
@@ -451,10 +452,11 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
|
||||
*/
|
||||
if (time_in_range(cred->cr_expire, expired, jiffies) &&
|
||||
test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
list_del_init(&cred->cr_lru);
|
||||
number_cred_unused--;
|
||||
freed++;
|
||||
if (atomic_read(&cred->cr_count) != 0)
|
||||
continue;
|
||||
|
||||
@@ -467,29 +469,39 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
|
||||
}
|
||||
spin_unlock(cache_lock);
|
||||
}
|
||||
return (number_cred_unused / 100) * sysctl_vfs_cache_pressure;
|
||||
return freed;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run memory cache shrinker.
|
||||
*/
|
||||
static int
|
||||
rpcauth_cache_shrinker(struct shrinker *shrink, struct shrink_control *sc)
|
||||
static unsigned long
|
||||
rpcauth_cache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
|
||||
|
||||
{
|
||||
LIST_HEAD(free);
|
||||
int res;
|
||||
int nr_to_scan = sc->nr_to_scan;
|
||||
gfp_t gfp_mask = sc->gfp_mask;
|
||||
unsigned long freed;
|
||||
|
||||
if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL)
|
||||
return (nr_to_scan == 0) ? 0 : -1;
|
||||
if ((sc->gfp_mask & GFP_KERNEL) != GFP_KERNEL)
|
||||
return SHRINK_STOP;
|
||||
|
||||
/* nothing left, don't come back */
|
||||
if (list_empty(&cred_unused))
|
||||
return 0;
|
||||
return SHRINK_STOP;
|
||||
|
||||
spin_lock(&rpc_credcache_lock);
|
||||
res = rpcauth_prune_expired(&free, nr_to_scan);
|
||||
freed = rpcauth_prune_expired(&free, sc->nr_to_scan);
|
||||
spin_unlock(&rpc_credcache_lock);
|
||||
rpcauth_destroy_credlist(&free);
|
||||
return res;
|
||||
|
||||
return freed;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
|
||||
|
||||
{
|
||||
return (number_cred_unused / 100) * sysctl_vfs_cache_pressure;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -805,7 +817,8 @@ rpcauth_uptodatecred(struct rpc_task *task)
|
||||
}
|
||||
|
||||
static struct shrinker rpc_cred_shrinker = {
|
||||
.shrink = rpcauth_cache_shrinker,
|
||||
.count_objects = rpcauth_cache_shrink_count,
|
||||
.scan_objects = rpcauth_cache_shrink_scan,
|
||||
.seeks = DEFAULT_SEEKS,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user