diff options
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index e79bc6ce828e..de434f309af0 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -2006,17 +2006,18 @@ static void nfs_access_free_list(struct list_head *head) | |||
2006 | } | 2006 | } |
2007 | } | 2007 | } |
2008 | 2008 | ||
2009 | int nfs_access_cache_shrinker(struct shrinker *shrink, | 2009 | unsigned long |
2010 | struct shrink_control *sc) | 2010 | nfs_access_cache_scan(struct shrinker *shrink, struct shrink_control *sc) |
2011 | { | 2011 | { |
2012 | LIST_HEAD(head); | 2012 | LIST_HEAD(head); |
2013 | struct nfs_inode *nfsi, *next; | 2013 | struct nfs_inode *nfsi, *next; |
2014 | struct nfs_access_entry *cache; | 2014 | struct nfs_access_entry *cache; |
2015 | int nr_to_scan = sc->nr_to_scan; | 2015 | int nr_to_scan = sc->nr_to_scan; |
2016 | gfp_t gfp_mask = sc->gfp_mask; | 2016 | gfp_t gfp_mask = sc->gfp_mask; |
2017 | long freed = 0; | ||
2017 | 2018 | ||
2018 | if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL) | 2019 | if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL) |
2019 | return (nr_to_scan == 0) ? 0 : -1; | 2020 | return SHRINK_STOP; |
2020 | 2021 | ||
2021 | spin_lock(&nfs_access_lru_lock); | 2022 | spin_lock(&nfs_access_lru_lock); |
2022 | list_for_each_entry_safe(nfsi, next, &nfs_access_lru_list, access_cache_inode_lru) { | 2023 | list_for_each_entry_safe(nfsi, next, &nfs_access_lru_list, access_cache_inode_lru) { |
@@ -2032,6 +2033,7 @@ int nfs_access_cache_shrinker(struct shrinker *shrink, | |||
2032 | struct nfs_access_entry, lru); | 2033 | struct nfs_access_entry, lru); |
2033 | list_move(&cache->lru, &head); | 2034 | list_move(&cache->lru, &head); |
2034 | rb_erase(&cache->rb_node, &nfsi->access_cache); | 2035 | rb_erase(&cache->rb_node, &nfsi->access_cache); |
2036 | freed++; | ||
2035 | if (!list_empty(&nfsi->access_cache_entry_lru)) | 2037 | if (!list_empty(&nfsi->access_cache_entry_lru)) |
2036 | list_move_tail(&nfsi->access_cache_inode_lru, | 2038 | list_move_tail(&nfsi->access_cache_inode_lru, |
2037 | &nfs_access_lru_list); | 2039 | &nfs_access_lru_list); |
@@ -2046,7 +2048,13 @@ remove_lru_entry: | |||
2046 | } | 2048 | } |
2047 | spin_unlock(&nfs_access_lru_lock); | 2049 | spin_unlock(&nfs_access_lru_lock); |
2048 | nfs_access_free_list(&head); | 2050 | nfs_access_free_list(&head); |
2049 | return (atomic_long_read(&nfs_access_nr_entries) / 100) * sysctl_vfs_cache_pressure; | 2051 | return freed; |
2052 | } | ||
2053 | |||
2054 | unsigned long | ||
2055 | nfs_access_cache_count(struct shrinker *shrink, struct shrink_control *sc) | ||
2056 | { | ||
2057 | return vfs_pressure_ratio(atomic_long_read(&nfs_access_nr_entries)); | ||
2050 | } | 2058 | } |
2051 | 2059 | ||
2052 | static void __nfs_access_zap_cache(struct nfs_inode *nfsi, struct list_head *head) | 2060 | static void __nfs_access_zap_cache(struct nfs_inode *nfsi, struct list_head *head) |