linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>,
	linux-fsdevel@vger.kernel.org, naohiro.aota@wdc.com,
	jth@kernel.org
Subject: Re: [PATCH] zonefs: Fix race between modprobe and mount
Date: Tue, 22 Nov 2022 14:22:48 +0900	[thread overview]
Message-ID: <2a34be8d-1eab-48bc-9bb9-ed406aed5c04@opensource.wdc.com> (raw)
In-Reply-To: <20221120105759.2917556-1-zhangxiaoxu5@huawei.com>

On 11/20/22 19:57, Zhang Xiaoxu wrote:
> There is a race between modprobe and mount as below:
> 
>  modprobe zonefs                | mount -t zonefs
> --------------------------------|-------------------------
>  zonefs_init                    |
>   register_filesystem       [1] |
>                                 | zonefs_fill_super    [2]
>   zonefs_sysfs_init         [3] |
> 
> 1. register zonefs suceess, then
> 2. user can mount the zonefs
> 3. if sysfs initialize failed, the module initialize failed.
> 
> Then the mount process maybe some error happened since the module
> initialize failed.
> 
> Let's register zonefs after all dependency resource ready. And
> reorder the dependency resource release in module exit.
> 
> Fixes: 9277a6d4fbd4 ("zonefs: Export open zone resource information through sysfs")
> Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>

Applied to for-6.1-fixes. Thanks !

> ---
>  fs/zonefs/super.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 860f0b1032c6..625749fbedf4 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1905,18 +1905,18 @@ static int __init zonefs_init(void)
>  	if (ret)
>  		return ret;
>  
> -	ret = register_filesystem(&zonefs_type);
> +	ret = zonefs_sysfs_init();
>  	if (ret)
>  		goto destroy_inodecache;
>  
> -	ret = zonefs_sysfs_init();
> +	ret = register_filesystem(&zonefs_type);
>  	if (ret)
> -		goto unregister_fs;
> +		goto sysfs_exit;
>  
>  	return 0;
>  
> -unregister_fs:
> -	unregister_filesystem(&zonefs_type);
> +sysfs_exit:
> +	zonefs_sysfs_exit();
>  destroy_inodecache:
>  	zonefs_destroy_inodecache();
>  
> @@ -1925,9 +1925,9 @@ static int __init zonefs_init(void)
>  
>  static void __exit zonefs_exit(void)
>  {
> +	unregister_filesystem(&zonefs_type);
>  	zonefs_sysfs_exit();
>  	zonefs_destroy_inodecache();
> -	unregister_filesystem(&zonefs_type);
>  }
>  
>  MODULE_AUTHOR("Damien Le Moal");

-- 
Damien Le Moal
Western Digital Research


      parent reply	other threads:[~2022-11-22  5:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20 10:57 [PATCH] zonefs: Fix race between modprobe and mount Zhang Xiaoxu
2022-11-21  8:46 ` Johannes Thumshirn
2022-11-22  5:12 ` Chaitanya Kulkarni
2022-11-22  5:22 ` Damien Le Moal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a34be8d-1eab-48bc-9bb9-ed406aed5c04@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=jth@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=zhangxiaoxu5@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).