]> git.baikalelectronics.ru Git - kernel.git/commit
zonefs: Fix race between modprobe and mount
authorZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Sun, 20 Nov 2022 10:57:59 +0000 (18:57 +0800)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Tue, 22 Nov 2022 05:18:32 +0000 (14:18 +0900)
commit8b61e51d09bd487e5f21e03367fda57b2e26911a
tree67a28fe370db741219eeb1b5a7cc9ee255876af2
parent7bbe094022ae45d4f31c8a80e7e30b9dc5a06cde
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: 03f275f2371f ("zonefs: Export open zone resource information through sysfs")
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
fs/zonefs/super.c