[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080502174222.GA16493@sergelap.austin.ibm.com>
Date: Fri, 2 May 2008 12:42:22 -0500
From: "Serge E. Hallyn" <serue@...ibm.com>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: "Serge E. Hallyn" <serue@...ibm.com>, Greg KH <gregkh@...e.de>,
Benjamin Thery <benjamin.thery@...l.net>,
linux-kernel@...r.kernel.org, Al Viro <viro@....linux.org.uk>,
Tejun Heo <htejun@...il.com>,
Daniel Lezcano <dlezcano@...ibm.com>,
Pavel Emelyanov <xemul@...nvz.org>, netdev@...r.kernel.org
Subject: Re: [PATCH 00/10] sysfs tagged directories
Quoting Eric W. Biederman (ebiederm@...ssion.com):
> "Serge E. Hallyn" <serue@...ibm.com> writes:
>
> > Quoting Eric W. Biederman (ebiederm@...ssion.com):
>
> > Ok as it turns out Benjamin Thery does in fact have a patch to fix this.
> > Benjamin, please send your renaming patch out tomorrow if you can?
> >
> > I guess this is why I didn't really see the problem Benjamin said there
> > was - it just works with SYSFS_DEPRECATED :)
>
> It will be nice to see that patch. I'm curious what the problem was.
>
> Eric
Here is the patch he had privately sent. As the comments indicate he's
still refining it so yell at me not him... but this on top of the
tagged dir patchset makes everything work for me.
(I'd *really* like to see network namespaces be generally usable sometime
in 2.6.26.)
thanks,
-serge
[This is a proposal to fix the issue with network devices movement
and sysfs not being updated correctly.
Please comment.
There is no locking in sysfs_tag_will_change(), this may be wrong.]
When a network device is moved between namespaces its sysfs entry isn't
updated correctly because kobject_rename() fails before sysfs_rename_dir()
is called. kobject_rename() prints a warning and returns when it detects
a kobject in the same kset already has the same name.
When moving between namespaces the device keeps its name but the sysfs
tag associated with its sysfs_dirent should be updated to reflect the fact
it now belongs to another namespace. This is done in sysfs_rename_dir().
* The simplest change we can make to "fix" kobject_rename() is to allow
a kobject to be renamed to the same name without complaining: we allow
dumb renaming. We only check the name is actually "owned" by it.
(lib/kobject.c: kobject_rename())
temp_kobj = kset_find_obj(kobj->kset, new_name);
if (temp_kobj) {
- printk(KERN_WARNING "kobject '%s' cannot be renamed "
- "to '%s' as '%s' is already in existence.\n",
- kobject_name(kobj), new_name, new_name);
+ if (kobj != temp_kobj) {
+ printk(KERN_WARNING "kobject '%s' cannot be renamed "
+ "to '%s' as '%s' is already in existence.\n",
+ kobject_name(kobj), new_name, new_name);
+ kobject_put(temp_kobj);
+ return -EINVAL;
+ }
kobject_put(temp_kobj);
- return -EINVAL;
}
* This patch goes a bit further, it allows a kobject to be renamed to
the same name only if the sysfs tag associated with it will change.
This patch applies on 2.6.25-mm1 on top of the sysfs tagged directories
patchset.
Signed-off-by: Benjamin Thery <benjamin.thery@...l.net>
---
fs/sysfs/dir.c | 11 +++++++++++
include/linux/sysfs.h | 6 ++++++
lib/kobject.c | 16 +++++++++++-----
3 files changed, 28 insertions(+), 5 deletions(-)
Index: linux-mm/fs/sysfs/dir.c
===================================================================
--- linux-mm.orig/fs/sysfs/dir.c
+++ linux-mm/fs/sysfs/dir.c
@@ -909,6 +909,17 @@ err_out:
return error;
}
+int sysfs_tag_will_change(struct kobject * kobj)
+{
+ struct sysfs_dirent *sd = kobj->sd;
+ const void *old_tag, *tag;
+
+ old_tag = sysfs_dirent_tag(sd);
+ tag = sysfs_creation_tag(sd->s_parent, sd);
+
+ return old_tag != tag;
+}
+
int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
{
struct sysfs_dirent *sd = kobj->sd;
Index: linux-mm/include/linux/sysfs.h
===================================================================
--- linux-mm.orig/include/linux/sysfs.h
+++ linux-mm/include/linux/sysfs.h
@@ -95,6 +95,7 @@ int sysfs_schedule_callback(struct kobje
int __must_check sysfs_create_dir(struct kobject *kobj);
void sysfs_remove_dir(struct kobject *kobj);
+int sysfs_tag_will_change(struct kobject *kobj);
int __must_check sysfs_rename_dir(struct kobject *kobj, const char *new_name);
int __must_check sysfs_move_dir(struct kobject *kobj,
struct kobject *new_parent_kobj);
@@ -152,6 +153,11 @@ static inline void sysfs_remove_dir(stru
{
}
+static inline int sysfs_tag_will_change(struct kobject *kobj)
+{
+ return 0;
+}
+
static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
{
return 0;
Index: linux-mm/lib/kobject.c
===================================================================
--- linux-mm.orig/lib/kobject.c
+++ linux-mm/lib/kobject.c
@@ -466,11 +466,17 @@ int kobject_rename(struct kobject *kobj,
struct kobject *temp_kobj;
temp_kobj = kset_find_obj(kobj->kset, new_name);
if (temp_kobj) {
- printk(KERN_WARNING "kobject '%s' cannot be renamed "
- "to '%s' as '%s' is already in existence.\n",
- kobject_name(kobj), new_name, new_name);
- kobject_put(temp_kobj);
- return -EINVAL;
+ if (temp_kobj == kobj && sysfs_tag_will_change(kobj)) {
+ /* OK: Same name, but the sysfs tag will change */
+ kobject_put(temp_kobj);
+ } else {
+ /* Even sysfs tag won't change */
+ printk(KERN_WARNING "kobject '%s' cannot be renamed "
+ "to '%s' as '%s' is already in existence.\n",
+ kobject_name(kobj), new_name, new_name);
+ kobject_put(temp_kobj);
+ return -EINVAL;
+ }
}
}
--
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "lxc-dev" group.
To post to this group, send email to lxc-dev@...glegroups.com
To unsubscribe from this group, send email to lxc-dev-unsubscribe@...glegroups.com
For more options, visit this group at http://groups.google.com/group/lxc-dev?hl=en
-~----------~----~----~----~------~----~------~--~---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists