提交 fed4c143 编写于 作者: A Alex Elder

rbd: fix module sysfs setup/teardown code

Once rbd_bus_type is registered, it allows an "add" operation via
the /sys/bus/rbd/add bus attribute, and adding a new rbd device that
way establishes a connection between the device and rbd_root_dev.
But rbd_root_dev is not registered until after the rbd_bus_type
registration is complete.  This could (in principle anyway) result
in an invalid state.

Since rbd_root_dev has no tie to rbd_bus_type we can reorder these
two initializations and never be faced with this scenario.

In addition, unregister the device in the event the bus registration
fails at module init time.
Signed-off-by: NAlex Elder <elder@dreamhost.com>
Signed-off-by: NSage Weil <sage@newdream.net>
上级 7ef3214a
......@@ -2564,19 +2564,21 @@ static int rbd_sysfs_init(void)
{
int ret;
ret = bus_register(&rbd_bus_type);
ret = device_register(&rbd_root_dev);
if (ret < 0)
return ret;
ret = device_register(&rbd_root_dev);
ret = bus_register(&rbd_bus_type);
if (ret < 0)
device_unregister(&rbd_root_dev);
return ret;
}
static void rbd_sysfs_cleanup(void)
{
device_unregister(&rbd_root_dev);
bus_unregister(&rbd_bus_type);
device_unregister(&rbd_root_dev);
}
int __init rbd_init(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册