]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/super.c
fs: consolidate {nr,free}_cached_objects args in shrink_control
[karo-tx-linux.git] / fs / super.c
index b9a214d2fe98b8b37a7560ebf1a7d1dc7c5d83e0..a2b735a42e74d7eb5aaa88b854714590ff636629 100644 (file)
@@ -75,28 +75,31 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
                return SHRINK_STOP;
 
        if (sb->s_op->nr_cached_objects)
-               fs_objects = sb->s_op->nr_cached_objects(sb, sc->nid);
+               fs_objects = sb->s_op->nr_cached_objects(sb, sc);
 
-       inodes = list_lru_count_node(&sb->s_inode_lru, sc->nid);
-       dentries = list_lru_count_node(&sb->s_dentry_lru, sc->nid);
+       inodes = list_lru_shrink_count(&sb->s_inode_lru, sc);
+       dentries = list_lru_shrink_count(&sb->s_dentry_lru, sc);
        total_objects = dentries + inodes + fs_objects + 1;
+       if (!total_objects)
+               total_objects = 1;
 
        /* proportion the scan between the caches */
        dentries = mult_frac(sc->nr_to_scan, dentries, total_objects);
        inodes = mult_frac(sc->nr_to_scan, inodes, total_objects);
+       fs_objects = mult_frac(sc->nr_to_scan, fs_objects, total_objects);
 
        /*
         * prune the dcache first as the icache is pinned by it, then
         * prune the icache, followed by the filesystem specific caches
         */
-       freed = prune_dcache_sb(sb, dentries, sc->nid);
-       freed += prune_icache_sb(sb, inodes, sc->nid);
+       sc->nr_to_scan = dentries;
+       freed = prune_dcache_sb(sb, sc);
+       sc->nr_to_scan = inodes;
+       freed += prune_icache_sb(sb, sc);
 
        if (fs_objects) {
-               fs_objects = mult_frac(sc->nr_to_scan, fs_objects,
-                                                               total_objects);
-               freed += sb->s_op->free_cached_objects(sb, fs_objects,
-                                                      sc->nid);
+               sc->nr_to_scan = fs_objects;
+               freed += sb->s_op->free_cached_objects(sb, sc);
        }
 
        drop_super(sb);
@@ -116,17 +119,14 @@ static unsigned long super_cache_count(struct shrinker *shrink,
         * scalability bottleneck. The counts could get updated
         * between super_cache_count and super_cache_scan anyway.
         * Call to super_cache_count with shrinker_rwsem held
-        * ensures the safety of call to list_lru_count_node() and
+        * ensures the safety of call to list_lru_shrink_count() and
         * s_op->nr_cached_objects().
         */
        if (sb->s_op && sb->s_op->nr_cached_objects)
-               total_objects = sb->s_op->nr_cached_objects(sb,
-                                                sc->nid);
+               total_objects = sb->s_op->nr_cached_objects(sb, sc);
 
-       total_objects += list_lru_count_node(&sb->s_dentry_lru,
-                                                sc->nid);
-       total_objects += list_lru_count_node(&sb->s_inode_lru,
-                                                sc->nid);
+       total_objects += list_lru_shrink_count(&sb->s_dentry_lru, sc);
+       total_objects += list_lru_shrink_count(&sb->s_inode_lru, sc);
 
        total_objects = vfs_pressure_ratio(total_objects);
        return total_objects;
@@ -175,7 +175,8 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
                goto fail;
 
        for (i = 0; i < SB_FREEZE_LEVELS; i++) {
-               if (percpu_counter_init(&s->s_writers.counter[i], 0) < 0)
+               if (percpu_counter_init(&s->s_writers.counter[i], 0,
+                                       GFP_KERNEL) < 0)
                        goto fail;
                lockdep_init_map(&s->s_writers.lock_map[i], sb_writers_name[i],
                                 &type->s_writers_key[i], 0);