diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-04-28 08:36:39 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-04-28 08:36:39 +0400 |
commit | d35cc56ddfc948d8df1aa6d41ac345fcec01854d (patch) | |
tree | 7e23a0e3dde639236e019aa88309d919941958e5 /fs/kernfs/dir.c | |
parent | 86d56134f1b67d0c18025ba5cade95c048ed528d (diff) | |
parent | d1db0eea852497762cab43b905b879dfcd3b8987 (diff) | |
download | linux-d35cc56ddfc948d8df1aa6d41ac345fcec01854d.tar.xz |
Merge 3.15-rc3 into staging-next
Diffstat (limited to 'fs/kernfs/dir.c')
-rw-r--r-- | fs/kernfs/dir.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 43aa97988c31..a693f5b01ae6 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -232,9 +232,6 @@ static int kernfs_link_sibling(struct kernfs_node *kn) struct rb_node **node = &kn->parent->dir.children.rb_node; struct rb_node *parent = NULL; - if (kernfs_type(kn) == KERNFS_DIR) - kn->parent->dir.subdirs++; - while (*node) { struct kernfs_node *pos; int result; @@ -249,9 +246,15 @@ static int kernfs_link_sibling(struct kernfs_node *kn) else return -EEXIST; } + /* add new node and rebalance the tree */ rb_link_node(&kn->rb, parent, node); rb_insert_color(&kn->rb, &kn->parent->dir.children); + + /* successfully added, account subdir number */ + if (kernfs_type(kn) == KERNFS_DIR) + kn->parent->dir.subdirs++; + return 0; } |