Skip to content

Commit

Permalink
sysfs: fix hardlink count on device_move
Browse files Browse the repository at this point in the history
Update directory hardlink count when moving kobjects to a new parent.
Fixes the following problem which occurs when several devices are
moved to the same parent and then unregistered:

> ls -laF /sys/devices/css0/defunct/
> total 0
> drwxr-xr-x 4294967295 root root    0 2009-07-14 17:02 ./
> drwxr-xr-x        114 root root    0 2009-07-14 17:02 ../
> drwxr-xr-x          2 root root    0 2009-07-14 17:01 power/
> -rw-r--r--          1 root root 4096 2009-07-14 17:01 uevent

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Peter Oberparleiter authored and Greg Kroah-Hartman committed Jul 28, 2009
1 parent 4733fd3 commit 0f58b44
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,10 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
/* Remove from old parent's list and insert into new parent's list. */
sysfs_unlink_sibling(sd);
sysfs_get(new_parent_sd);
drop_nlink(old_parent->d_inode);
sysfs_put(sd->s_parent);
sd->s_parent = new_parent_sd;
inc_nlink(new_parent->d_inode);
sysfs_link_sibling(sd);

out_unlock:
Expand Down

0 comments on commit 0f58b44

Please sign in to comment.