Re: [PATCH] erofs: fix lockdep false positives on initializing erofs_pseudo_mnt

From: Al Viro
Date: Thu Mar 07 2024 - 00:07:57 EST


On Thu, Mar 07, 2024 at 10:44:59AM +0800, Baokun Li wrote:

> +static int erofs_anon_init_fs_context(struct fs_context *fc)
> +{
> + fc->ops = &erofs_anon_context_ops;
> + return 0;
> +}


ITYM
struct pseudo_fs_context *ctx = init_pseudo(fc, EROFS_SUPER_MAGIC);
return ctx ? 0 : -ENOMEM;

and to hell with erofs_anon_context_ops, along with its fill_super, calls
of simple_fill_super(), etc. Unless I'm missing something, you are not
even creating dentries here, let alone making them possible to look up.

> +static void erofs_kill_pseudo_sb(struct super_block *sb)
> +{
> + kill_anon_super(sb);
> +}

*blink*

What's wrong with simply using kill_anon_super as ->kill_sb?

> +int erofs_anon_register_fs(void)
> +{
> + return register_filesystem(&erofs_anon_fs_type);
> +}

What for? The only thing it gives you is an ability to look it up by
name. Which is completely pointless, IMO,

> if (!erofs_pseudo_mnt) {
> - struct vfsmount *mnt = kern_mount(&erofs_fs_type);
> + struct vfsmount *mnt = kern_mount(&erofs_anon_fs_type);

.. since you are getting to it by direct reference to file_system_type
anyway. Same unregistering, of course...