linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver-core: document restrictions on device_rename()
@ 2010-12-01 23:40 Timur Tabi
  2010-12-10 23:12 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Timur Tabi @ 2010-12-01 23:40 UTC (permalink / raw)
  To: greg, kay.sievers, linux-kernel

Add text, courtesy of Kay Sievers, that provides some background on
device_rename() and why it shouldn't be used.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 drivers/base/core.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6ed6454..8ff1531 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1513,6 +1513,34 @@ EXPORT_SYMBOL_GPL(device_destroy);
  * exclusion between two different calls of device_rename
  * on the same device to ensure that new_name is valid and
  * won't conflict with other devices.
+ *
+ * Note: Don't call this function.  Currently, the networking layer calls this
+ * function, but that will change.  The following text from Kay Sievers offer
+ * some insight:
+ *
+ * Renaming devices is racy at many levels, symlinks and other stuff are not
+ * replaced atomically, you get a "move" uevent", but it's not easy to connect
+ * the event to the old and new device. Device nodes are not renamed at all,
+ * there isn't even support for that in the kernel now.
+ *
+ * In the meantime during renaming, your target name might be taken by another
+ * driver, creating conflicts. Or the old name is taken directly after you
+ * renamed it -- then you get events for the same DEVPATH, before you even seet
+ * the "move" event. It's just a mess, and nothing new should ever rely on
+ * kernel device renaming. Besides that it's not even implemented now for other
+ * things than (driver-core wise very simple) network devices.
+ *
+ * We are currently about to change network renaming in udev to completely
+ * disallow renaming of devices in the same namespace as the kernel uses,
+ * because we can't solve the problems properly, that arise with swapping names
+ * of multiple interfaces without races. Means, renaming of eth[0-9]* will only
+ * be allowed to some other name than eth[0-9]*, for the mentioned reasons.
+ *
+ * Make up a "real" name in the driver before you register anything, or add
+ * some other attributes for userspace to find the device, or use udev to add
+ * symlinks -- but never rename kernel devices later, it's a complete mess. We
+ * don't even want to get into that and try to implement the missing pieces in
+ * the core. We really have other pieces to fix in the driver core mess. :)
  */
 int device_rename(struct device *dev, const char *new_name)
 {
-- 
1.7.2.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver-core: document restrictions on device_rename()
  2010-12-01 23:40 [PATCH] driver-core: document restrictions on device_rename() Timur Tabi
@ 2010-12-10 23:12 ` Greg KH
  2010-12-10 23:47   ` Tabi Timur-B04825
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2010-12-10 23:12 UTC (permalink / raw)
  To: Timur Tabi; +Cc: kay.sievers, linux-kernel

On Wed, Dec 01, 2010 at 05:40:54PM -0600, Timur Tabi wrote:
> Add text, courtesy of Kay Sievers, that provides some background on
> device_rename() and why it shouldn't be used.
> 
> Signed-off-by: Timur Tabi <timur@freescale.com>
> ---
>  drivers/base/core.c |   28 ++++++++++++++++++++++++++++

This patch doesn't apply to the linux-next branch, care to refresh it so
I can apply it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver-core: document restrictions on device_rename()
  2010-12-10 23:12 ` Greg KH
@ 2010-12-10 23:47   ` Tabi Timur-B04825
  0 siblings, 0 replies; 3+ messages in thread
From: Tabi Timur-B04825 @ 2010-12-10 23:47 UTC (permalink / raw)
  To: Greg KH; +Cc: kay.sievers, linux-kernel

I'm on vacation, so it'll have to wait until Monday.


On Dec 10, 2010, at 4:17 PM, "Greg KH" <greg@kroah.com> wrote:

> On Wed, Dec 01, 2010 at 05:40:54PM -0600, Timur Tabi wrote:
>> Add text, courtesy of Kay Sievers, that provides some background on
>> device_rename() and why it shouldn't be used.
>> 
>> Signed-off-by: Timur Tabi <timur@freescale.com>
>> ---
>> drivers/base/core.c |   28 ++++++++++++++++++++++++++++
> 
> This patch doesn't apply to the linux-next branch, care to refresh it so
> I can apply it?
> 
> thanks,
> 
> greg k-h
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-10 23:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-01 23:40 [PATCH] driver-core: document restrictions on device_rename() Timur Tabi
2010-12-10 23:12 ` Greg KH
2010-12-10 23:47   ` Tabi Timur-B04825

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).