Skip to content

Commit

Permalink
switch open-coded instances of d_make_root() to new helper
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Mar 21, 2012
1 parent 6b4231e commit 48fde70
Show file tree
Hide file tree
Showing 64 changed files with 105 additions and 264 deletions.
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,9 +757,9 @@ spufs_create_root(struct super_block *sb, void *data)
goto out_iput;

ret = -ENOMEM;
sb->s_root = d_alloc_root(inode);
sb->s_root = d_make_root(inode);
if (!sb->s_root)
goto out_iput;
goto out;

return 0;
out_iput:
Expand Down
6 changes: 2 additions & 4 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,9 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent)
return -ENOMEM;
root_inode->i_op = &simple_dir_inode_operations;
root_inode->i_fop = &simple_dir_operations;
sb->s_root = root_dentry = d_alloc_root(root_inode);
if (!root_dentry) {
iput(root_inode);
sb->s_root = root_dentry = d_make_root(root_inode);
if (!root_dentry)
return -ENOMEM;
}
if (MACHINE_IS_VM)
rc = hypfs_vm_create_files(sb, root_dentry);
else
Expand Down
6 changes: 2 additions & 4 deletions drivers/misc/ibmasm/ibmasmfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,9 @@ static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent)
root->i_op = &simple_dir_inode_operations;
root->i_fop = ibmasmfs_dir_ops;

root_dentry = d_alloc_root(root);
if (!root_dentry) {
iput(root);
root_dentry = d_make_root(root);
if (!root_dentry)
return -ENOMEM;
}
sb->s_root = root_dentry;

ibmasmfs_create_files(sb, root_dentry);
Expand Down
6 changes: 2 additions & 4 deletions drivers/oprofile/oprofilefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,9 @@ static int oprofilefs_fill_super(struct super_block *sb, void *data, int silent)
return -ENOMEM;
root_inode->i_op = &simple_dir_inode_operations;
root_inode->i_fop = &simple_dir_operations;
root_dentry = d_alloc_root(root_inode);
if (!root_dentry) {
iput(root_inode);
root_dentry = d_make_root(root_inode);
if (!root_dentry)
return -ENOMEM;
}

sb->s_root = root_dentry;

Expand Down
9 changes: 1 addition & 8 deletions drivers/usb/core/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,16 +462,9 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_op = &usbfs_ops;
sb->s_time_gran = 1;
inode = usbfs_get_inode(sb, S_IFDIR | 0755, 0);

if (!inode) {
dbg("%s: could not get inode!",__func__);
return -ENOMEM;
}

root = d_alloc_root(inode);
root = d_make_root(inode);
if (!root) {
dbg("%s: could not get root dentry!",__func__);
iput(inode);
return -ENOMEM;
}
sb->s_root = root;
Expand Down
8 changes: 2 additions & 6 deletions drivers/usb/gadget/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,13 +1063,9 @@ static int ffs_sb_fill(struct super_block *sb, void *_data, int silent)
&simple_dir_operations,
&simple_dir_inode_operations,
&data->perms);
if (unlikely(!inode))
sb->s_root = d_make_root(inode);
if (unlikely(!sb->s_root))
goto Enomem;
sb->s_root = d_alloc_root(inode);
if (unlikely(!sb->s_root)) {
iput(inode);
goto Enomem;
}

/* EP0 file */
if (unlikely(!ffs_sb_create_file(sb, "ep0", ffs,
Expand Down
4 changes: 1 addition & 3 deletions drivers/usb/gadget/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2059,10 +2059,8 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
if (!inode)
goto Enomem;
inode->i_op = &simple_dir_inode_operations;
if (!(sb->s_root = d_alloc_root (inode))) {
iput(inode);
if (!(sb->s_root = d_make_root (inode)))
goto Enomem;
}

/* the ep0 file is named after the controller we expect;
* user mode code can use it for sanity checks, like we do.
Expand Down
3 changes: 1 addition & 2 deletions fs/9p/vfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
goto release_sb;
}

root = d_alloc_root(inode);
root = d_make_root(inode);
if (!root) {
iput(inode);
retval = -ENOMEM;
goto release_sb;
}
Expand Down
3 changes: 1 addition & 2 deletions fs/adfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,9 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)

sb->s_d_op = &adfs_dentry_operations;
root = adfs_iget(sb, &root_obj);
sb->s_root = d_alloc_root(root);
sb->s_root = d_make_root(root);
if (!sb->s_root) {
int i;
iput(root);
for (i = 0; i < asb->s_map_size; i++)
brelse(asb->s_map[i].dm_bh);
kfree(asb->s_map);
Expand Down
7 changes: 2 additions & 5 deletions fs/affs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,15 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
root_inode = affs_iget(sb, root_block);
if (IS_ERR(root_inode)) {
ret = PTR_ERR(root_inode);
goto out_error_noinode;
goto out_error;
}

if (AFFS_SB(sb)->s_flags & SF_INTL)
sb->s_d_op = &affs_intl_dentry_operations;
else
sb->s_d_op = &affs_dentry_operations;

sb->s_root = d_alloc_root(root_inode);
sb->s_root = d_make_root(root_inode);
if (!sb->s_root) {
printk(KERN_ERR "AFFS: Get root inode failed\n");
goto out_error;
Expand All @@ -494,9 +494,6 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
* Begin the cascaded cleanup ...
*/
out_error:
if (root_inode)
iput(root_inode);
out_error_noinode:
kfree(sbi->s_bitmap);
affs_brelse(root_bh);
kfree(sbi->s_prefix);
Expand Down
7 changes: 2 additions & 5 deletions fs/afs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ static int afs_fill_super(struct super_block *sb,
{
struct afs_super_info *as = sb->s_fs_info;
struct afs_fid fid;
struct dentry *root = NULL;
struct inode *inode = NULL;
int ret;

Expand All @@ -327,18 +326,16 @@ static int afs_fill_super(struct super_block *sb,
set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags);

ret = -ENOMEM;
root = d_alloc_root(inode);
if (!root)
sb->s_root = d_make_root(inode);
if (!sb->s_root)
goto error;

sb->s_d_op = &afs_fs_dentry_operations;
sb->s_root = root;

_leave(" = 0");
return 0;

error:
iput(inode);
_leave(" = %d", ret);
return ret;
}
Expand Down
10 changes: 2 additions & 8 deletions fs/autofs4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,9 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
if (!ino)
goto fail_free;
root_inode = autofs4_get_inode(s, S_IFDIR | 0755);
if (!root_inode)
goto fail_ino;

root = d_alloc_root(root_inode);
root = d_make_root(root_inode);
if (!root)
goto fail_iput;
goto fail_ino;
pipe = NULL;

root->d_fsdata = ino;
Expand Down Expand Up @@ -317,9 +314,6 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
fail_dput:
dput(root);
goto fail_free;
fail_iput:
printk("autofs: get root dentry failed\n");
iput(root_inode);
fail_ino:
kfree(ino);
fail_free:
Expand Down
3 changes: 1 addition & 2 deletions fs/befs/linuxvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,8 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
ret = PTR_ERR(root);
goto unacquire_priv_sbp;
}
sb->s_root = d_alloc_root(root);
sb->s_root = d_make_root(root);
if (!sb->s_root) {
iput(root);
befs_error(sb, "get root inode failed");
goto unacquire_priv_sbp;
}
Expand Down
3 changes: 1 addition & 2 deletions fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
ret = PTR_ERR(inode);
goto out2;
}
s->s_root = d_alloc_root(inode);
s->s_root = d_make_root(inode);
if (!s->s_root) {
iput(inode);
ret = -ENOMEM;
goto out2;
}
Expand Down
8 changes: 2 additions & 6 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ static int btrfs_fill_super(struct super_block *sb,
void *data, int silent)
{
struct inode *inode;
struct dentry *root_dentry;
struct btrfs_fs_info *fs_info = btrfs_sb(sb);
struct btrfs_key key;
int err;
Expand Down Expand Up @@ -660,15 +659,12 @@ static int btrfs_fill_super(struct super_block *sb,
goto fail_close;
}

root_dentry = d_alloc_root(inode);
if (!root_dentry) {
iput(inode);
sb->s_root = d_make_root(inode);
if (!sb->s_root) {
err = -ENOMEM;
goto fail_close;
}

sb->s_root = root_dentry;

save_mount_options(sb, data);
cleancache_init_fs(sb);
sb->s_flags |= MS_ACTIVE;
Expand Down
3 changes: 1 addition & 2 deletions fs/ceph/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,8 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,
dout("open_root_inode success\n");
if (ceph_ino(inode) == CEPH_INO_ROOT &&
fsc->sb->s_root == NULL) {
root = d_alloc_root(inode);
root = d_make_root(inode);
if (!root) {
iput(inode);
root = ERR_PTR(-ENOMEM);
goto out;
}
Expand Down
4 changes: 1 addition & 3 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ cifs_read_super(struct super_block *sb)
goto out_no_root;
}

sb->s_root = d_alloc_root(inode);

sb->s_root = d_make_root(inode);
if (!sb->s_root) {
rc = -ENOMEM;
iput(inode);
goto out_no_root;
}

Expand Down
3 changes: 1 addition & 2 deletions fs/coda/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)

printk("coda_read_super: rootinode is %ld dev %s\n",
root->i_ino, root->i_sb->s_id);
sb->s_root = d_alloc_root(root);
sb->s_root = d_make_root(root);
if (!sb->s_root) {
iput(root);
error = -EINVAL;
goto error;
}
Expand Down
3 changes: 1 addition & 2 deletions fs/configfs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent)
return -ENOMEM;
}

root = d_alloc_root(inode);
root = d_make_root(inode);
if (!root) {
pr_debug("%s: could not get root dentry!\n",__func__);
iput(inode);
return -ENOMEM;
}
config_group_init(&configfs_root_group);
Expand Down
6 changes: 2 additions & 4 deletions fs/cramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,9 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
root = get_cramfs_inode(sb, &super.root, 0);
if (IS_ERR(root))
goto out;
sb->s_root = d_alloc_root(root);
if (!sb->s_root) {
iput(root);
sb->s_root = d_make_root(root);
if (!sb->s_root)
goto out;
}
return 0;
out:
kfree(sbi);
Expand Down
3 changes: 1 addition & 2 deletions fs/devpts/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,11 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
inode->i_fop = &simple_dir_operations;
set_nlink(inode, 2);

s->s_root = d_alloc_root(inode);
s->s_root = d_make_root(inode);
if (s->s_root)
return 0;

printk(KERN_ERR "devpts: get root dentry failed\n");
iput(inode);

fail:
return -ENOMEM;
Expand Down
3 changes: 1 addition & 2 deletions fs/ecryptfs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,8 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
if (IS_ERR(inode))
goto out_free;

s->s_root = d_alloc_root(inode);
s->s_root = d_make_root(inode);
if (!s->s_root) {
iput(inode);
rc = -ENOMEM;
goto out_free;
}
Expand Down
3 changes: 1 addition & 2 deletions fs/efs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,9 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
goto out_no_fs;
}

s->s_root = d_alloc_root(root);
s->s_root = d_make_root(root);
if (!(s->s_root)) {
printk(KERN_ERR "EFS: get root dentry failed\n");
iput(root);
ret = -ENOMEM;
goto out_no_fs;
}
Expand Down
3 changes: 1 addition & 2 deletions fs/exofs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,9 +819,8 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
ret = PTR_ERR(root);
goto free_sbi;
}
sb->s_root = d_alloc_root(root);
sb->s_root = d_make_root(root);
if (!sb->s_root) {
iput(root);
EXOFS_ERR("ERROR: get root inode failed\n");
ret = -ENOMEM;
goto free_sbi;
Expand Down
3 changes: 1 addition & 2 deletions fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
goto failed_mount3;
}

sb->s_root = d_alloc_root(root);
sb->s_root = d_make_root(root);
if (!sb->s_root) {
iput(root);
ext2_msg(sb, KERN_ERR, "error: get root inode failed");
ret = -ENOMEM;
goto failed_mount3;
Expand Down
3 changes: 1 addition & 2 deletions fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2046,10 +2046,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
ext3_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
goto failed_mount3;
}
sb->s_root = d_alloc_root(root);
sb->s_root = d_make_root(root);
if (!sb->s_root) {
ext3_msg(sb, KERN_ERR, "error: get root dentry failed");
iput(root);
ret = -ENOMEM;
goto failed_mount3;
}
Expand Down
3 changes: 1 addition & 2 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3735,9 +3735,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
iput(root);
goto failed_mount4;
}
sb->s_root = d_alloc_root(root);
sb->s_root = d_make_root(root);
if (!sb->s_root) {
iput(root);
ext4_msg(sb, KERN_ERR, "get root dentry failed");
ret = -ENOMEM;
goto failed_mount4;
Expand Down
Loading

0 comments on commit 48fde70

Please sign in to comment.