Skip to contentSkip to conversation

sysfs: Update the name hash for an entry after changing the namespace

PATCH In review Tom Goff 2 participants 4 messages Apr 4, 2012 Driver core

lore
Share & tools
lore

Tom Goff

author
#0 lore raw

PATCH 1/1 sysfs: Update the name hash for an entry after changing the namespace

This is needed to allow renaming network devices that have been moved to another network namespace.

---
 fs/sysfs/dir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/sysfs/dir.c +1 -1
index 2a7a3f5..8ddc102 100644
@@ -878,7 +878,6 @@ int sysfs_rename(struct sysfs_dirent *sd,
 
 		dup_name = sd->s_name;
 		sd->s_name = new_name;
-		sd->s_hash = sysfs_name_hash(sd->s_ns, sd->s_name);
 	}
 
 	/* Move to the appropriate place in the appropriate directories rbtree. */
@@ -886,6 +885,7 @@ int sysfs_rename(struct sysfs_dirent *sd,
 	sysfs_get(new_parent_sd);
 	sysfs_put(sd->s_parent);
 	sd->s_ns = new_ns;
+	sd->s_hash = sysfs_name_hash(sd->s_ns, sd->s_name);
 	sd->s_parent = new_parent_sd;
 	sysfs_link_sibling(sd);
 
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 7 lines · Tom Goff

This is needed to allow renaming network devices that have been moved to another network namespace.

---
 fs/sysfs/dir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Is this a bug in 3.4-rc1 and older kernels? If so, how old?

thanks,

greg k-h

author
#2 lore raw
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Tom Goff

This is needed to allow renaming network devices that have been moved to another network namespace.

---
 fs/sysfs/dir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 5 lines

Is this a bug in 3.4-rc1 and older kernels? If so, how old?

thanks,

greg k-h

Yes, this is a bug in 3.4-rc1. The patch is really a change to d5c38b137ac8a6e3dbed13bc494d60df5b69dfc4 'sysfs: Update the name hash when renaming sysfs entries', committed on January 31.

Thanks for looking at this.

Tom

#3 lore raw
Quoted 12 lines · Tom Goff
Quoted 11 lines · Greg Kroah-Hartman
Quoted 7 lines · Tom Goff

This is needed to allow renaming network devices that have been moved to another network namespace.

---
 fs/sysfs/dir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Is this a bug in 3.4-rc1 and older kernels? If so, how old?

Quoted 7 lines
Quoted 3 lines

thanks,

greg k-h

Yes, this is a bug in 3.4-rc1. The patch is really a change to d5c38b137ac8a6e3dbed13bc494d60df5b69dfc4 'sysfs: Update the name hash when renaming sysfs entries', committed on January 31.

Good, that patch only went into 3.4-rc1 and nothing newer, I'll queue this up for 3.4-only, thanks for letting me know.

greg k-h