netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Jiri Slaby <jslaby@suse.cz>
Cc: Greg KH <gregkh@suse.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	Mikulas Patocka <mpatocka@redhat.com>,
	akpm@linux-foundation.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jiri Slaby <jirislaby@gmail.com>
Subject: Re: Broken link in /sys/class/net/ [was: [GIT] Networking]
Date: Sat, 29 Oct 2011 21:49:47 -0700	[thread overview]
Message-ID: <m11utvytg4.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <4EAC8642.3050309@suse.cz> (Jiri Slaby's message of "Sun, 30 Oct 2011 01:03:30 +0200")

Jiri Slaby <jslaby@suse.cz> writes:

> On 10/25/2011 03:13 PM, Greg KH wrote:
>> On Tue, Oct 25, 2011 at 01:46:11PM +0200, Linus Torvalds wrote:
>>> Anyway, after that rant about really bad practices, let me say that I
>>> did fix up the conflict and I think it's right. But I won't guarantee
>>> it, so please check the changes to fs/sysfs/dir.c.
>> 
>> I think it looks ok, I've booted the merge result, and am typing and
>> sending this from the new kernel, and it hasn't crashed yet :)
>
> Hi, maybe this was not caused by the merge, but the patch[1] causes this
> mess in /sys/class/net/ for me:
> l????????? ? ?    ?    ?             ? eth1
>
> This happens after one renames a net device -- the new name is eth1 here.
>
> [1] 4f72c0cab40 (sysfs: use rb-tree for name lookups)

This looks pretty fixable but today sysfs_rename does not do anything
with the to move a renamed entry to a different position in the rbtree.

If the directory itself changes sysfs_rename should be fine, and it
looks like a trivial patch to always apply the directory rename logic
in sysfs_rename. 

I think all we need is something like the untested patch below to fix
the network device rename problem.

Eric

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 48ffbdf..a294068 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -865,14 +865,13 @@ int sysfs_rename(struct sysfs_dirent *sd,
 		sd->s_name = new_name;
 	}
 
-	/* Remove from old parent's list and insert into new parent's list. */
-	if (sd->s_parent != new_parent_sd) {
-		sysfs_unlink_sibling(sd);
-		sysfs_get(new_parent_sd);
-		sysfs_put(sd->s_parent);
-		sd->s_parent = new_parent_sd;
-		sysfs_link_sibling(sd);
-	}
+	/* Move to the appropriate place in the appropriate directories rbtree. */
+	sysfs_unlink_sibling(sd);
+	sysfs_get(new_parent_sd);
+	sysfs_put(sd->s_parent);
+	sd->s_parent = new_parent_sd;
+	sysfs_link_sibling(sd);
+
 	sd->s_ns = new_ns;
 
 	error = 0;

  reply	other threads:[~2011-10-30  4:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-25 10:32 [GIT] Networking David Miller
2011-10-25 11:46 ` Linus Torvalds
2011-10-25 11:56   ` Greg KH
2011-10-25 12:03     ` Linus Torvalds
     [not found]   ` <m1wrbtb4rj.fsf@fess.ebiederm.org>
2011-10-25 13:12     ` Linus Torvalds
2011-10-25 13:13   ` Greg KH
2011-10-29 23:03     ` Broken link in /sys/class/net/ [was: [GIT] Networking] Jiri Slaby
2011-10-30  4:49       ` Eric W. Biederman [this message]
2011-10-30 20:49         ` Jiri Slaby
     [not found]           ` <m1mxcgrl7q.fsf_-_@fess.ebiederm.org>
2011-11-01 21:19             ` [PATCH] sysfs: Make sysfs_rename safe with sysfs_dirents in rbtrees Greg KH
2011-10-25 12:26 ` [GIT] Networking Linus Torvalds
2011-11-04 17:03   ` Johannes Berg
2011-11-04 17:07     ` Ben Greear
2011-11-07 11:40     ` Stanislaw Gruszka

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=m11utvytg4.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=gregkh@suse.de \
    --cc=jirislaby@gmail.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).