summaryrefslogtreecommitdiffstats
path: root/fs/kernfs/dir.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-27 21:36:39 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-27 21:36:39 -0700
commitd35cc56ddfc948d8df1aa6d41ac345fcec01854d (patch)
tree7e23a0e3dde639236e019aa88309d919941958e5 /fs/kernfs/dir.c
parent86d56134f1b67d0c18025ba5cade95c048ed528d (diff)
parentd1db0eea852497762cab43b905b879dfcd3b8987 (diff)
downloadlinux-stable-d35cc56ddfc948d8df1aa6d41ac345fcec01854d.tar.gz
linux-stable-d35cc56ddfc948d8df1aa6d41ac345fcec01854d.tar.bz2
linux-stable-d35cc56ddfc948d8df1aa6d41ac345fcec01854d.zip
Merge 3.15-rc3 into staging-next
Diffstat (limited to 'fs/kernfs/dir.c')
-rw-r--r--fs/kernfs/dir.c9
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;
}