From: NeilBrown <[email protected]> These d_add() calls cannot be necessary. The inode given is NULL so all they do is attach the dentry to the hash table.
If configfs_attach_group() fails, then d_drop() is called so the dentry will be detached. If configfs_attach_group() succeeds, then configfs_attach_group -> configfs_attach_item ->configfs_create_dir must have succeeded, so d_instantiate() will have been called and the dentry hashed there. So the only effect is that the dentry will be hashed-negative for a short period which will allow a lookup to find nothing without waiting for the directory i_rwsem. I can find no indication that this might be important. Adding a dentry as negative, and then later making it positive is an unusual pattern and appears to be unnecessary, so it is best avoided. Signed-off-by: NeilBrown <[email protected]> --- fs/configfs/dir.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 362b6ff9b908..c82eca0b5d73 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -706,8 +706,6 @@ static int create_default_group(struct config_group *parent_group, ret = -ENOMEM; child = d_alloc_name(parent, group->cg_item.ci_name); if (child) { - d_add(child, NULL); - ret = configfs_attach_group(&parent_group->cg_item, &group->cg_item, child, frag); if (!ret) { @@ -1904,8 +1902,6 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) err = -ENOMEM; dentry = d_alloc_name(root, group->cg_item.ci_name); if (dentry) { - d_add(dentry, NULL); - err = configfs_dirent_exists(dentry); if (!err) err = configfs_attach_group(sd->s_element, -- 2.50.0.107.gf914562f5916.dirty
