configfs: move d_rehash() into configfs_create() for regular files
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 7 Mar 2016 19:25:46 +0000 (14:25 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 14 Mar 2016 04:15:55 +0000 (00:15 -0400)
... and turn it into d_add in there

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/configfs/dir.c
fs/configfs/inode.c

index f419519ec41fb4f3e932fe18561b34f3313e747b..214ec14149d9cef836f9ea76fe54634ecd594149 100644 (file)
@@ -432,14 +432,9 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
                                (sd->s_type & CONFIGFS_ITEM_BIN_ATTR) ?
                                        configfs_init_bin_file :
                                        configfs_init_file);
-       if (error) {
+       if (error)
                configfs_put(sd);
-               return error;
-       }
-
-       d_rehash(dentry);
-
-       return 0;
+       return error;
 }
 
 static struct dentry * configfs_lookup(struct inode *dir,
index cee087d8f7e02f5b62198a6091a5a7f23cf0109f..45811ea3fd875e50ccdd7a02aec4d7df517ba25f 100644 (file)
@@ -199,9 +199,17 @@ int configfs_create(struct dentry * dentry, umode_t mode, void (*init)(struct in
        configfs_set_inode_lock_class(sd, inode);
 
        init(inode);
-       d_instantiate(dentry, inode);
-       if (S_ISDIR(mode) || S_ISLNK(mode))
+       if (S_ISDIR(mode) || S_ISLNK(mode)) {
+               /*
+                * ->symlink(), ->mkdir(), configfs_register_subsystem() or
+                * create_default_group() - already hashed.
+                */
+               d_instantiate(dentry, inode);
                dget(dentry);  /* pin link and directory dentries in core */
+       } else {
+               /* ->lookup() */
+               d_add(dentry, inode);
+       }
        return error;
 }