Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44003728 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro
Browse files

[PATCH] switch all filesystems over to d_obtain_alias



Switch all users of d_alloc_anon to d_obtain_alias.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4ea3ada2
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1187,17 +1187,17 @@ struct dentry * d_alloc_anon(struct inode *inode)
 * allocating a new one.
 *
 * On successful return, the reference to the inode has been transferred
 * to the dentry.  If %NULL is returned (indicating kmalloc failure),
 * the reference on the inode has been released.  To make it easier
 * to use in export operations a NULL or IS_ERR inode may be passed in
 * and will be casted to the corresponding NULL or IS_ERR dentry.
 * to the dentry.  In case of an error the reference on the inode is released.
 * To make it easier to use in export operations a %NULL or IS_ERR inode may
 * be passed in and will be the error will be propagate to the return value,
 * with a %NULL @inode replaced by ERR_PTR(-ESTALE).
 */
struct dentry *d_obtain_alias(struct inode *inode)
{
	struct dentry *dentry;

	if (!inode)
		return NULL;
		return ERR_PTR(-ESTALE);
	if (IS_ERR(inode))
		return ERR_CAST(inode);

+4 −25
Original line number Diff line number Diff line
@@ -112,35 +112,14 @@ struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid,

struct dentry *efs_get_parent(struct dentry *child)
{
	struct dentry *parent;
	struct inode *inode;
	struct dentry *parent = ERR_PTR(-ENOENT);
	efs_ino_t ino;
	long error;

	lock_kernel();

	error = -ENOENT;
	ino = efs_find_entry(child->d_inode, "..", 2);
	if (!ino)
		goto fail;

	inode = efs_iget(child->d_inode->i_sb, ino);
	if (IS_ERR(inode)) {
		error = PTR_ERR(inode);
		goto fail;
	}

	error = -ENOMEM;
	parent = d_alloc_anon(inode);
	if (!parent)
		goto fail_iput;

	if (ino)
		parent = d_obtain_alias(efs_iget(child->d_inode->i_sb, ino));
	unlock_kernel();
	return parent;

 fail_iput:
	iput(inode);
 fail:
	unlock_kernel();
	return ERR_PTR(error);
	return parent;
}
+0 −4
Original line number Diff line number Diff line
@@ -366,8 +366,6 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
	 * Try to get any dentry for the given file handle from the filesystem.
	 */
	result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type);
	if (!result)
		result = ERR_PTR(-ESTALE);
	if (IS_ERR(result))
		return result;

@@ -422,8 +420,6 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,

		target_dir = nop->fh_to_parent(mnt->mnt_sb, fid,
				fh_len, fileid_type);
		if (!target_dir)
			goto err_result;
		err = PTR_ERR(target_dir);
		if (IS_ERR(target_dir))
			goto err_result;
+1 −12
Original line number Diff line number Diff line
@@ -73,8 +73,6 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
struct dentry *ext2_get_parent(struct dentry *child)
{
	unsigned long ino;
	struct dentry *parent;
	struct inode *inode;
	struct dentry dotdot;

	dotdot.d_name.name = "..";
@@ -83,16 +81,7 @@ struct dentry *ext2_get_parent(struct dentry *child)
	ino = ext2_inode_by_name(child->d_inode, &dotdot);
	if (!ino)
		return ERR_PTR(-ENOENT);
	inode = ext2_iget(child->d_inode->i_sb, ino);

	if (IS_ERR(inode))
		return ERR_CAST(inode);
	parent = d_alloc_anon(inode);
	if (!parent) {
		iput(inode);
		parent = ERR_PTR(-ENOMEM);
	}
	return parent;
	return d_obtain_alias(ext2_iget(child->d_inode->i_sb, ino));
} 

/*
+1 −13
Original line number Diff line number Diff line
@@ -1057,8 +1057,6 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str
struct dentry *ext3_get_parent(struct dentry *child)
{
	unsigned long ino;
	struct dentry *parent;
	struct inode *inode;
	struct dentry dotdot;
	struct ext3_dir_entry_2 * de;
	struct buffer_head *bh;
@@ -1068,7 +1066,6 @@ struct dentry *ext3_get_parent(struct dentry *child)
	dotdot.d_parent = child; /* confusing, isn't it! */

	bh = ext3_find_entry(&dotdot, &de);
	inode = NULL;
	if (!bh)
		return ERR_PTR(-ENOENT);
	ino = le32_to_cpu(de->inode);
@@ -1080,16 +1077,7 @@ struct dentry *ext3_get_parent(struct dentry *child)
		return ERR_PTR(-EIO);
	}

	inode = ext3_iget(child->d_inode->i_sb, ino);
	if (IS_ERR(inode))
		return ERR_CAST(inode);

	parent = d_alloc_anon(inode);
	if (!parent) {
		iput(inode);
		parent = ERR_PTR(-ENOMEM);
	}
	return parent;
	return d_obtain_alias(ext3_iget(child->d_inode->i_sb, ino));
}

#define S_SHIFT 12
Loading