From: "Serge E. Hallyn" <serue@us.ibm.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>, Greg KH <gregkh@suse.de>,
Benjamin Thery <benjamin.thery@bull.net>,
linux-kernel@vger.kernel.org, Al Viro <viro@ftp.linux.org.uk>,
Tejun Heo <htejun@gmail.com>,
Daniel Lezcano <dlezcano@fr.ibm.com>,
Pavel Emelyanov <xemul@openvz.org>,
netdev@vger.kernel.org
Subject: Re: [PATCH 00/10] sysfs tagged directories
Date: Fri, 2 May 2008 12:42:22 -0500 [thread overview]
Message-ID: <20080502174222.GA16493@sergelap.austin.ibm.com> (raw)
In-Reply-To: <m1prs5fzzd.fsf@frodo.ebiederm.org>
Quoting Eric W. Biederman (ebiederm@xmission.com):
> "Serge E. Hallyn" <serue@us.ibm.com> writes:
>
> > Quoting Eric W. Biederman (ebiederm@xmission.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@bull.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@googlegroups.com
To unsubscribe from this group, send email to lxc-dev-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/lxc-dev?hl=en
-~----------~----~----~----~------~----~------~--~---
next prev parent reply other threads:[~2008-05-02 17:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-29 17:10 Benjamin Thery
2008-04-29 17:10 ` [PATCH 01/10] sysfs: Support for preventing unmounts Benjamin Thery
2008-04-29 17:10 ` [PATCH 02/10] sysfs: sysfs_get_dentry add a sb parameter Benjamin Thery
2008-04-29 17:10 ` [PATCH 03/10] sysfs: Implement __sysfs_get_dentry Benjamin Thery
2008-04-29 17:10 ` [PATCH 04/10] sysfs: Rename Support multiple superblocks Benjamin Thery
2008-04-29 17:11 ` [PATCH 05/10] sysfs: sysfs_chmod_file handle " Benjamin Thery
2008-04-29 17:11 ` [PATCH 06/10] sysfs: Implement sysfs tagged directory support Benjamin Thery
2008-04-29 17:11 ` [PATCH 07/10] sysfs: Implement sysfs_delete_link and sysfs_rename_link Benjamin Thery
2008-04-29 17:11 ` [PATCH 08/10] driver core: Implement tagged directory support for device classes Benjamin Thery
2008-04-29 17:11 ` [PATCH 09/10] net: netns: Enable tagging for net_class directories in sysfs Benjamin Thery
2008-04-29 17:11 ` [PATCH 10/10] sysfs: user namespaces: add ns to user_struct Benjamin Thery
2008-04-29 19:51 ` Eric W. Biederman
2008-04-29 23:18 ` Serge E. Hallyn
2008-04-29 17:36 ` [PATCH 00/10] sysfs tagged directories Greg KH
2008-04-29 18:04 ` Serge E. Hallyn
2008-04-29 18:41 ` Greg KH
2008-04-29 19:34 ` Serge E. Hallyn
2008-04-29 20:10 ` Eric W. Biederman
2008-05-01 3:12 ` Greg KH
2008-05-01 3:13 ` Greg KH
2008-05-01 15:10 ` Serge E. Hallyn
2008-05-01 18:34 ` Eric W. Biederman
2008-05-01 21:05 ` Serge E. Hallyn
2008-05-01 21:58 ` Eric W. Biederman
2008-05-02 17:42 ` Serge E. Hallyn [this message]
2008-05-04 23:13 ` Daniel Lezcano
2008-05-05 16:18 ` Serge E. Hallyn
2008-05-06 16:53 ` Benjamin Thery
2008-04-29 19:35 ` Eric W. Biederman
2008-04-29 19:14 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080502174222.GA16493@sergelap.austin.ibm.com \
--to=serue@us.ibm.com \
--cc=benjamin.thery@bull.net \
--cc=dlezcano@fr.ibm.com \
--cc=ebiederm@xmission.com \
--cc=gregkh@suse.de \
--cc=htejun@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=viro@ftp.linux.org.uk \
--cc=xemul@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®