Re: WARNING in kill_block_super
From: Al Viro
Date: Tue Apr 10 2018 - 20:59:53 EST
On Wed, Apr 04, 2018 at 07:53:07PM +0900, Tetsuo Handa wrote:
> Al and Michal, are you OK with this patch?
First of all, it does *NOT* fix the problems with careless ->kill_sb().
The fuse-blk case is the only real rationale so far. Said that,
> @@ -166,6 +166,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);
> + kfree(s->s_shrink.nr_deferred);
is probably better done with an inlined helper (fs/super.c has no business knowing
about ->nr_deferred name, and there probably will be other users of that
preallocation of yours). And the same helper would be better off zeroing the
pointer, same as unregister_shrinker() does.
> -int register_shrinker(struct shrinker *shrinker)
> +int prepare_shrinker(struct shrinker *shrinker)
preallocate_shrinker(), perhaps?
> +int register_shrinker(struct shrinker *shrinker)
> +{
> + int err = prepare_shrinker(shrinker);
> +
> + if (err)
> + return err;
> + register_shrinker_prepared(shrinker);
if (!err)
register_....;
return err;
would be better, IMO.