* [PATCH] rbd: fix module sysfs setup/teardown code
@ 2012-02-29 4:00 Alex Elder
2012-02-29 20:25 ` Yehuda Sadeh Weinraub
2012-03-02 21:30 ` Sage Weil
0 siblings, 2 replies; 4+ messages in thread
From: Alex Elder @ 2012-02-29 4:00 UTC (permalink / raw)
To: ceph-devel
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: Alex Elder <elder@dreamhost.com>
---
drivers/block/rbd.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index bc539cd..b7c9af5 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2560,19 +2560,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)
+ 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)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rbd: fix module sysfs setup/teardown code
2012-02-29 4:00 [PATCH] rbd: fix module sysfs setup/teardown code Alex Elder
@ 2012-02-29 20:25 ` Yehuda Sadeh Weinraub
2012-02-29 21:28 ` Alex Elder
2012-03-02 21:30 ` Sage Weil
1 sibling, 1 reply; 4+ messages in thread
From: Yehuda Sadeh Weinraub @ 2012-02-29 20:25 UTC (permalink / raw)
To: Alex Elder; +Cc: ceph-devel
On Tue, Feb 28, 2012 at 8:00 PM, Alex Elder <elder@dreamhost.com> wrote:
>
> 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: Alex Elder <elder@dreamhost.com>
> ---
> drivers/block/rbd.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index bc539cd..b7c9af5 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -2560,19 +2560,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)
For consistency if (ret < 0) or change the previous one.
> + 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)
> --
> 1.7.5.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rbd: fix module sysfs setup/teardown code
2012-02-29 20:25 ` Yehuda Sadeh Weinraub
@ 2012-02-29 21:28 ` Alex Elder
0 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2012-02-29 21:28 UTC (permalink / raw)
To: Yehuda Sadeh Weinraub; +Cc: ceph-devel
On 02/29/2012 12:25 PM, Yehuda Sadeh Weinraub wrote:
> For consistency if (ret< 0) or change the previous one.
OK. I will update. -Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rbd: fix module sysfs setup/teardown code
2012-02-29 4:00 [PATCH] rbd: fix module sysfs setup/teardown code Alex Elder
2012-02-29 20:25 ` Yehuda Sadeh Weinraub
@ 2012-03-02 21:30 ` Sage Weil
1 sibling, 0 replies; 4+ messages in thread
From: Sage Weil @ 2012-03-02 21:30 UTC (permalink / raw)
To: Alex Elder; +Cc: ceph-devel
Reviewed-by: Sage Weil <sage@newdream.net>
On Tue, 28 Feb 2012, Alex Elder wrote:
> 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: Alex Elder <elder@dreamhost.com>
> ---
> drivers/block/rbd.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index bc539cd..b7c9af5 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -2560,19 +2560,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)
> + 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)
> --
> 1.7.5.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-03-02 21:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-29 4:00 [PATCH] rbd: fix module sysfs setup/teardown code Alex Elder
2012-02-29 20:25 ` Yehuda Sadeh Weinraub
2012-02-29 21:28 ` Alex Elder
2012-03-02 21:30 ` Sage Weil
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.