Merge tag 'ovl-update-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs
[sfrench/cifs-2.6.git] / fs / super.c
index 4cedeb7a7d79cb500691586e62c7d3924aa18990..076392396e724e210d565e6f78b35d88613e471d 100644 (file)
@@ -178,7 +178,7 @@ static void super_wake(struct super_block *sb, unsigned int flag)
  * One thing we have to be careful of with a per-sb shrinker is that we don't
  * drop the last active reference to the superblock from within the shrinker.
  * If that happens we could trigger unregistering the shrinker from within the
- * shrinker path and that leads to deadlock on the shrinker_rwsem. Hence we
+ * shrinker path and that leads to deadlock on the shrinker_mutex. Hence we
  * take a passive reference to the superblock to avoid this from occurring.
  */
 static unsigned long super_cache_scan(struct shrinker *shrink,
@@ -191,7 +191,7 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
        long    dentries;
        long    inodes;
 
-       sb = container_of(shrink, struct super_block, s_shrink);
+       sb = shrink->private_data;
 
        /*
         * Deadlock avoidance.  We may hold various FS locks, and we don't want
@@ -244,7 +244,7 @@ static unsigned long super_cache_count(struct shrinker *shrink,
        struct super_block *sb;
        long    total_objects = 0;
 
-       sb = container_of(shrink, struct super_block, s_shrink);
+       sb = shrink->private_data;
 
        /*
         * We don't call super_trylock_shared() here as it is a scalability
@@ -306,7 +306,7 @@ static void destroy_unused_super(struct super_block *s)
        security_sb_free(s);
        put_user_ns(s->s_user_ns);
        kfree(s->s_subtype);
-       free_prealloced_shrinker(&s->s_shrink);
+       shrinker_free(s->s_shrink);
        /* no delays needed */
        destroy_super_work(&s->destroy_work);
 }
@@ -383,16 +383,19 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
        s->s_time_min = TIME64_MIN;
        s->s_time_max = TIME64_MAX;
 
-       s->s_shrink.seeks = DEFAULT_SEEKS;
-       s->s_shrink.scan_objects = super_cache_scan;
-       s->s_shrink.count_objects = super_cache_count;
-       s->s_shrink.batch = 1024;
-       s->s_shrink.flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE;
-       if (prealloc_shrinker(&s->s_shrink, "sb-%s", type->name))
+       s->s_shrink = shrinker_alloc(SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE,
+                                    "sb-%s", type->name);
+       if (!s->s_shrink)
                goto fail;
-       if (list_lru_init_memcg(&s->s_dentry_lru, &s->s_shrink))
+
+       s->s_shrink->scan_objects = super_cache_scan;
+       s->s_shrink->count_objects = super_cache_count;
+       s->s_shrink->batch = 1024;
+       s->s_shrink->private_data = s;
+
+       if (list_lru_init_memcg(&s->s_dentry_lru, s->s_shrink))
                goto fail;
-       if (list_lru_init_memcg(&s->s_inode_lru, &s->s_shrink))
+       if (list_lru_init_memcg(&s->s_inode_lru, s->s_shrink))
                goto fail;
        return s;
 
@@ -477,7 +480,7 @@ void deactivate_locked_super(struct super_block *s)
 {
        struct file_system_type *fs = s->s_type;
        if (atomic_dec_and_test(&s->s_active)) {
-               unregister_shrinker(&s->s_shrink);
+               shrinker_free(s->s_shrink);
                fs->kill_sb(s);
 
                kill_super_notify(s);
@@ -818,7 +821,7 @@ retry:
        hlist_add_head(&s->s_instances, &s->s_type->fs_supers);
        spin_unlock(&sb_lock);
        get_filesystem(s->s_type);
-       register_shrinker_prepared(&s->s_shrink);
+       shrinker_register(s->s_shrink);
        return s;
 
 share_extant_sb:
@@ -901,7 +904,7 @@ retry:
        hlist_add_head(&s->s_instances, &type->fs_supers);
        spin_unlock(&sb_lock);
        get_filesystem(type);
-       register_shrinker_prepared(&s->s_shrink);
+       shrinker_register(s->s_shrink);
        return s;
 }
 EXPORT_SYMBOL(sget);
@@ -1540,7 +1543,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
        mutex_unlock(&bdev->bd_fsfreeze_mutex);
 
        snprintf(sb->s_id, sizeof(sb->s_id), "%pg", bdev);
-       shrinker_debugfs_rename(&sb->s_shrink, "sb-%s:%s", sb->s_type->name,
+       shrinker_debugfs_rename(sb->s_shrink, "sb-%s:%s", sb->s_type->name,
                                sb->s_id);
        sb_set_blocksize(sb, block_size(bdev));
        return 0;