diff options
author | Vladimir Davydov <vdavydov@parallels.com> | 2015-02-12 17:58:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-12 21:54:08 -0500 |
commit | 4101b624352fddb5ed72e7a1b6f8be8cffaa20fa (patch) | |
tree | 0823d26ef8ad4eaab98a6dce8280c78139aafec7 | |
parent | 503c358cf1925853195ee39ec437e51138bbb7df (diff) |
fs: consolidate {nr,free}_cached_objects args in shrink_control
We are going to make FS shrinkers memcg-aware. To achieve that, we will
have to pass the memcg to scan to the nr_cached_objects and
free_cached_objects VFS methods, which currently take only the NUMA node
to scan. Since the shrink_control structure already holds the node, and
the memcg to scan will be added to it when we introduce memcg-aware
vmscan, let us consolidate the methods' arguments in this structure to
keep things clean.
Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Suggested-by: Dave Chinner <david@fromorbit.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Greg Thelen <gthelen@google.com>
Cc: Glauber Costa <glommer@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/super.c | 12 | ||||
-rw-r--r-- | fs/xfs/xfs_super.c | 7 | ||||
-rw-r--r-- | include/linux/fs.h | 6 |
3 files changed, 13 insertions, 12 deletions
diff --git a/fs/super.c b/fs/super.c index 4554ac257647..a2b735a42e74 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -75,7 +75,7 @@ static unsigned long super_cache_scan(struct shrinker *shrink, | |||
75 | return SHRINK_STOP; | 75 | return SHRINK_STOP; |
76 | 76 | ||
77 | if (sb->s_op->nr_cached_objects) | 77 | if (sb->s_op->nr_cached_objects) |
78 | fs_objects = sb->s_op->nr_cached_objects(sb, sc->nid); | 78 | fs_objects = sb->s_op->nr_cached_objects(sb, sc); |
79 | 79 | ||
80 | inodes = list_lru_shrink_count(&sb->s_inode_lru, sc); | 80 | inodes = list_lru_shrink_count(&sb->s_inode_lru, sc); |
81 | dentries = list_lru_shrink_count(&sb->s_dentry_lru, sc); | 81 | dentries = list_lru_shrink_count(&sb->s_dentry_lru, sc); |
@@ -97,9 +97,10 @@ static unsigned long super_cache_scan(struct shrinker *shrink, | |||
97 | sc->nr_to_scan = inodes; | 97 | sc->nr_to_scan = inodes; |
98 | freed += prune_icache_sb(sb, sc); | 98 | freed += prune_icache_sb(sb, sc); |
99 | 99 | ||
100 | if (fs_objects) | 100 | if (fs_objects) { |
101 | freed += sb->s_op->free_cached_objects(sb, fs_objects, | 101 | sc->nr_to_scan = fs_objects; |
102 | sc->nid); | 102 | freed += sb->s_op->free_cached_objects(sb, sc); |
103 | } | ||
103 | 104 | ||
104 | drop_super(sb); | 105 | drop_super(sb); |
105 | return freed; | 106 | return freed; |
@@ -122,8 +123,7 @@ static unsigned long super_cache_count(struct shrinker *shrink, | |||
122 | * s_op->nr_cached_objects(). | 123 | * s_op->nr_cached_objects(). |
123 | */ | 124 | */ |
124 | if (sb->s_op && sb->s_op->nr_cached_objects) | 125 | if (sb->s_op && sb->s_op->nr_cached_objects) |
125 | total_objects = sb->s_op->nr_cached_objects(sb, | 126 | total_objects = sb->s_op->nr_cached_objects(sb, sc); |
126 | sc->nid); | ||
127 | 127 | ||
128 | total_objects += list_lru_shrink_count(&sb->s_dentry_lru, sc); | 128 | total_objects += list_lru_shrink_count(&sb->s_dentry_lru, sc); |
129 | total_objects += list_lru_shrink_count(&sb->s_inode_lru, sc); | 129 | total_objects += list_lru_shrink_count(&sb->s_inode_lru, sc); |
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index f2449fd86926..8fcc4ccc5c79 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -1537,7 +1537,7 @@ xfs_fs_mount( | |||
1537 | static long | 1537 | static long |
1538 | xfs_fs_nr_cached_objects( | 1538 | xfs_fs_nr_cached_objects( |
1539 | struct super_block *sb, | 1539 | struct super_block *sb, |
1540 | int nid) | 1540 | struct shrink_control *sc) |
1541 | { | 1541 | { |
1542 | return xfs_reclaim_inodes_count(XFS_M(sb)); | 1542 | return xfs_reclaim_inodes_count(XFS_M(sb)); |
1543 | } | 1543 | } |
@@ -1545,10 +1545,9 @@ xfs_fs_nr_cached_objects( | |||
1545 | static long | 1545 | static long |
1546 | xfs_fs_free_cached_objects( | 1546 | xfs_fs_free_cached_objects( |
1547 | struct super_block *sb, | 1547 | struct super_block *sb, |
1548 | long nr_to_scan, | 1548 | struct shrink_control *sc) |
1549 | int nid) | ||
1550 | { | 1549 | { |
1551 | return xfs_reclaim_inodes_nr(XFS_M(sb), nr_to_scan); | 1550 | return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan); |
1552 | } | 1551 | } |
1553 | 1552 | ||
1554 | static const struct super_operations xfs_super_operations = { | 1553 | static const struct super_operations xfs_super_operations = { |
diff --git a/include/linux/fs.h b/include/linux/fs.h index cdcb1e9d9613..a20d6586e517 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1635,8 +1635,10 @@ struct super_operations { | |||
1635 | struct dquot **(*get_dquots)(struct inode *); | 1635 | struct dquot **(*get_dquots)(struct inode *); |
1636 | #endif | 1636 | #endif |
1637 | int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); | 1637 | int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); |
1638 | long (*nr_cached_objects)(struct super_block *, int); | 1638 | long (*nr_cached_objects)(struct super_block *, |
1639 | long (*free_cached_objects)(struct super_block *, long, int); | 1639 | struct shrink_control *); |
1640 | long (*free_cached_objects)(struct super_block *, | ||
1641 | struct shrink_control *); | ||
1640 | }; | 1642 | }; |
1641 | 1643 | ||
1642 | /* | 1644 | /* |