浏览代码

configfs: move d_rehash() into configfs_create() for regular files

... and turn it into d_add in there

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Al Viro 9 年之前
父节点
当前提交
5cf3b560af
共有 2 个文件被更改,包括 12 次插入9 次删除
  1. 2 7
      fs/configfs/dir.c
  2. 10 2
      fs/configfs/inode.c

+ 2 - 7
fs/configfs/dir.c

@@ -432,14 +432,9 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
 				(sd->s_type & CONFIGFS_ITEM_BIN_ATTR) ?
 				(sd->s_type & CONFIGFS_ITEM_BIN_ATTR) ?
 					configfs_init_bin_file :
 					configfs_init_bin_file :
 					configfs_init_file);
 					configfs_init_file);
-	if (error) {
+	if (error)
 		configfs_put(sd);
 		configfs_put(sd);
-		return error;
-	}
-
-	d_rehash(dentry);
-
-	return 0;
+	return error;
 }
 }
 
 
 static struct dentry * configfs_lookup(struct inode *dir,
 static struct dentry * configfs_lookup(struct inode *dir,

+ 10 - 2
fs/configfs/inode.c

@@ -199,9 +199,17 @@ int configfs_create(struct dentry * dentry, umode_t mode, void (*init)(struct in
 	configfs_set_inode_lock_class(sd, inode);
 	configfs_set_inode_lock_class(sd, inode);
 
 
 	init(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 */
 		dget(dentry);  /* pin link and directory dentries in core */
+	} else {
+		/* ->lookup() */
+		d_add(dentry, inode);
+	}
 	return error;
 	return error;
 }
 }