Skip to content

Commit 4e45886

Browse files
z00467499Damien Le Moal
authored andcommitted
zonefs: Fix race between modprobe and mount
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: 9277a6d ("zonefs: Export open zone resource information through sysfs") Signed-off-by: Zhang Xiaoxu <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Damien Le Moal <[email protected]>
1 parent 61ba9e9 commit 4e45886

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/zonefs/super.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,18 +1922,18 @@ static int __init zonefs_init(void)
19221922
if (ret)
19231923
return ret;
19241924

1925-
ret = register_filesystem(&zonefs_type);
1925+
ret = zonefs_sysfs_init();
19261926
if (ret)
19271927
goto destroy_inodecache;
19281928

1929-
ret = zonefs_sysfs_init();
1929+
ret = register_filesystem(&zonefs_type);
19301930
if (ret)
1931-
goto unregister_fs;
1931+
goto sysfs_exit;
19321932

19331933
return 0;
19341934

1935-
unregister_fs:
1936-
unregister_filesystem(&zonefs_type);
1935+
sysfs_exit:
1936+
zonefs_sysfs_exit();
19371937
destroy_inodecache:
19381938
zonefs_destroy_inodecache();
19391939

@@ -1942,9 +1942,9 @@ static int __init zonefs_init(void)
19421942

19431943
static void __exit zonefs_exit(void)
19441944
{
1945+
unregister_filesystem(&zonefs_type);
19451946
zonefs_sysfs_exit();
19461947
zonefs_destroy_inodecache();
1947-
unregister_filesystem(&zonefs_type);
19481948
}
19491949

19501950
MODULE_AUTHOR("Damien Le Moal");

0 commit comments

Comments
 (0)