Re: [PATCH 3/4] switch all filesystems over to d_obtain_alias

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The GFS2 bits look ok to me,

Steve.

On Mon, Aug 11, 2008 at 03:49:04PM +0200, Christoph Hellwig wrote:
> Switch all users of d_alloc_anon to d_obtain_alias.
> 
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> 
> Index: linux-2.6/fs/efs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/efs/namei.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/efs/namei.c	2008-08-11 10:35:18.000000000 -0300
> @@ -113,35 +113,14 @@ struct dentry *efs_fh_to_parent(struct s
>  
>  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;
>  }
> Index: linux-2.6/fs/ext2/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ext2/namei.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/ext2/namei.c	2008-08-11 10:35:18.000000000 -0300
> @@ -73,8 +73,6 @@ static struct dentry *ext2_lookup(struct
>  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 de
>  	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));
>  } 
>  
>  /*
> Index: linux-2.6/fs/ext3/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ext3/namei.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/ext3/namei.c	2008-08-11 10:35:18.000000000 -0300
> @@ -1057,8 +1057,6 @@ static struct dentry *ext3_lookup(struct
>  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 de
>  	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 de
>  		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
> Index: linux-2.6/fs/ext4/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/namei.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/ext4/namei.c	2008-08-11 10:35:18.000000000 -0300
> @@ -1060,8 +1060,6 @@ static struct dentry *ext4_lookup(struct
>  struct dentry *ext4_get_parent(struct dentry *child)
>  {
>  	unsigned long ino;
> -	struct dentry *parent;
> -	struct inode *inode;
>  	struct dentry dotdot;
>  	struct ext4_dir_entry_2 * de;
>  	struct buffer_head *bh;
> @@ -1071,7 +1069,6 @@ struct dentry *ext4_get_parent(struct de
>  	dotdot.d_parent = child; /* confusing, isn't it! */
>  
>  	bh = ext4_find_entry(&dotdot, &de);
> -	inode = NULL;
>  	if (!bh)
>  		return ERR_PTR(-ENOENT);
>  	ino = le32_to_cpu(de->inode);
> @@ -1083,16 +1080,7 @@ struct dentry *ext4_get_parent(struct de
>  		return ERR_PTR(-EIO);
>  	}
>  
> -	inode = ext4_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(ext4_iget(child->d_inode->i_sb, ino));
>  }
>  
>  #define S_SHIFT 12
> Index: linux-2.6/fs/isofs/export.c
> ===================================================================
> --- linux-2.6.orig/fs/isofs/export.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/isofs/export.c	2008-08-11 10:35:18.000000000 -0300
> @@ -22,7 +22,7 @@ isofs_export_iget(struct super_block *sb
>  		  __u32 generation)
>  {
>  	struct inode *inode;
> -	struct dentry *result;
> +
>  	if (block == 0)
>  		return ERR_PTR(-ESTALE);
>  	inode = isofs_iget(sb, block, offset);
> @@ -32,12 +32,7 @@ isofs_export_iget(struct super_block *sb
>  		iput(inode);
>  		return ERR_PTR(-ESTALE);
>  	}
> -	result = d_alloc_anon(inode);
> -	if (!result) {
> -		iput(inode);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -	return result;
> +	return d_obtain_alias(inode);
>  }
>  
>  /* This function is surprisingly simple.  The trick is understanding
> @@ -51,7 +46,6 @@ static struct dentry *isofs_export_get_p
>  	unsigned long parent_offset = 0;
>  	struct inode *child_inode = child->d_inode;
>  	struct iso_inode_info *e_child_inode = ISOFS_I(child_inode);
> -	struct inode *parent_inode = NULL;
>  	struct iso_directory_record *de = NULL;
>  	struct buffer_head * bh = NULL;
>  	struct dentry *rv = NULL;
> @@ -104,28 +98,11 @@ static struct dentry *isofs_export_get_p
>  	/* Normalize */
>  	isofs_normalize_block_and_offset(de, &parent_block, &parent_offset);
>  
> -	/* Get the inode. */
> -	parent_inode = isofs_iget(child_inode->i_sb,
> -				  parent_block,
> -				  parent_offset);
> -	if (IS_ERR(parent_inode)) {
> -		rv = ERR_CAST(parent_inode);
> -		if (rv != ERR_PTR(-ENOMEM))
> -			rv = ERR_PTR(-EACCES);
> -		goto out;
> -	}
> -
> -	/* Allocate the dentry. */
> -	rv = d_alloc_anon(parent_inode);
> -	if (rv == NULL) {
> -		rv = ERR_PTR(-ENOMEM);
> -		goto out;
> -	}
> -
> +	rv = d_obtain_alias(isofs_iget(child_inode->i_sb, parent_block,
> +				     parent_offset));
>   out:
> -	if (bh) {
> +	if (bh)
>  		brelse(bh);
> -	}
>  	return rv;
>  }
>  
> Index: linux-2.6/fs/jfs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/namei.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/jfs/namei.c	2008-08-11 10:35:18.000000000 -0300
> @@ -1511,25 +1511,12 @@ struct dentry *jfs_fh_to_parent(struct s
>  
>  struct dentry *jfs_get_parent(struct dentry *dentry)
>  {
> -	struct super_block *sb = dentry->d_inode->i_sb;
> -	struct dentry *parent = ERR_PTR(-ENOENT);
> -	struct inode *inode;
>  	unsigned long parent_ino;
>  
>  	parent_ino =
>  		le32_to_cpu(JFS_IP(dentry->d_inode)->i_dtroot.header.idotdot);
> -	inode = jfs_iget(sb, parent_ino);
> -	if (IS_ERR(inode)) {
> -		parent = ERR_CAST(inode);
> -	} else {
> -		parent = d_alloc_anon(inode);
> -		if (!parent) {
> -			parent = ERR_PTR(-ENOMEM);
> -			iput(inode);
> -		}
> -	}
>  
> -	return parent;
> +	return d_obtain_alias(jfs_iget(dentry->d_inode->i_sb, parent_ino));
>  }
>  
>  const struct inode_operations jfs_dir_inode_operations = {
> Index: linux-2.6/fs/ntfs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ntfs/namei.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/ntfs/namei.c	2008-08-11 10:35:18.000000000 -0300
> @@ -304,8 +304,6 @@ static struct dentry *ntfs_get_parent(st
>  	ntfs_attr_search_ctx *ctx;
>  	ATTR_RECORD *attr;
>  	FILE_NAME_ATTR *fn;
> -	struct inode *parent_vi;
> -	struct dentry *parent_dent;
>  	unsigned long parent_ino;
>  	int err;
>  
> @@ -345,24 +343,8 @@ try_next:
>  	/* Release the search context and the mft record of the child. */
>  	ntfs_attr_put_search_ctx(ctx);
>  	unmap_mft_record(ni);
> -	/* Get the inode of the parent directory. */
> -	parent_vi = ntfs_iget(vi->i_sb, parent_ino);
> -	if (IS_ERR(parent_vi) || unlikely(is_bad_inode(parent_vi))) {
> -		if (!IS_ERR(parent_vi))
> -			iput(parent_vi);
> -		ntfs_error(vi->i_sb, "Failed to get parent directory inode "
> -				"0x%lx of child inode 0x%lx.", parent_ino,
> -				vi->i_ino);
> -		return ERR_PTR(-EACCES);
> -	}
> -	/* Finally get a dentry for the parent directory and return it. */
> -	parent_dent = d_alloc_anon(parent_vi);
> -	if (unlikely(!parent_dent)) {
> -		iput(parent_vi);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -	ntfs_debug("Done for inode 0x%lx.", vi->i_ino);
> -	return parent_dent;
> +
> +	return d_obtain_alias(ntfs_iget(vi->i_sb, parent_ino));
>  }
>  
>  static struct inode *ntfs_nfs_get_inode(struct super_block *sb,
> Index: linux-2.6/fs/ocfs2/export.c
> ===================================================================
> --- linux-2.6.orig/fs/ocfs2/export.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/ocfs2/export.c	2008-08-11 10:35:18.000000000 -0300
> @@ -68,14 +68,9 @@ static struct dentry *ocfs2_get_dentry(s
>  		return ERR_PTR(-ESTALE);
>  	}
>  
> -	result = d_alloc_anon(inode);
> -
> -	if (!result) {
> -		iput(inode);
> -		mlog_errno(-ENOMEM);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -	result->d_op = &ocfs2_dentry_ops;
> +	result = d_obtain_alias(inode);
> +	if (result && !IS_ERR(result))
> +		result->d_op = &ocfs2_dentry_ops;
>  
>  	mlog_exit_ptr(result);
>  	return result;
> @@ -86,7 +81,6 @@ static struct dentry *ocfs2_get_parent(s
>  	int status;
>  	u64 blkno;
>  	struct dentry *parent;
> -	struct inode *inode;
>  	struct inode *dir = child->d_inode;
>  
>  	mlog_entry("(0x%p, '%.*s')\n", child,
> @@ -109,21 +103,9 @@ static struct dentry *ocfs2_get_parent(s
>  		goto bail_unlock;
>  	}
>  
> -	inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0);
> -	if (IS_ERR(inode)) {
> -		mlog(ML_ERROR, "Unable to create inode %llu\n",
> -		     (unsigned long long)blkno);
> -		parent = ERR_PTR(-EACCES);
> -		goto bail_unlock;
> -	}
> -
> -	parent = d_alloc_anon(inode);
> -	if (!parent) {
> -		iput(inode);
> -		parent = ERR_PTR(-ENOMEM);
> -	}
> -
> -	parent->d_op = &ocfs2_dentry_ops;
> +	parent = d_obtain_alias(ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0));
> +	if (parent && !IS_ERR(parent))
> +		parent->d_op = &ocfs2_dentry_ops;
>  
>  bail_unlock:
>  	ocfs2_inode_unlock(dir, 0);
> Index: linux-2.6/fs/reiserfs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/inode.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/reiserfs/inode.c	2008-08-11 10:35:18.000000000 -0300
> @@ -1522,7 +1522,6 @@ static struct dentry *reiserfs_get_dentr
>  
>  {
>  	struct cpu_key key;
> -	struct dentry *result;
>  	struct inode *inode;
>  
>  	key.on_disk_key.k_objectid = objectid;
> @@ -1535,16 +1534,8 @@ static struct dentry *reiserfs_get_dentr
>  		inode = NULL;
>  	}
>  	reiserfs_write_unlock(sb);
> -	if (!inode)
> -		inode = ERR_PTR(-ESTALE);
> -	if (IS_ERR(inode))
> -		return ERR_CAST(inode);
> -	result = d_alloc_anon(inode);
> -	if (!result) {
> -		iput(inode);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -	return result;
> +
> +	return d_obtain_alias(inode);
>  }
>  
>  struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
> Index: linux-2.6/fs/reiserfs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/namei.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/reiserfs/namei.c	2008-08-11 10:35:18.000000000 -0300
> @@ -383,7 +383,6 @@ struct dentry *reiserfs_get_parent(struc
>  	struct inode *inode = NULL;
>  	struct reiserfs_dir_entry de;
>  	INITIALIZE_PATH(path_to_entry);
> -	struct dentry *parent;
>  	struct inode *dir = child->d_inode;
>  
>  	if (dir->i_nlink == 0) {
> @@ -401,15 +400,7 @@ struct dentry *reiserfs_get_parent(struc
>  	inode = reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
>  	reiserfs_write_unlock(dir->i_sb);
>  
> -	if (!inode || IS_ERR(inode)) {
> -		return ERR_PTR(-EACCES);
> -	}
> -	parent = d_alloc_anon(inode);
> -	if (!parent) {
> -		iput(inode);
> -		parent = ERR_PTR(-ENOMEM);
> -	}
> -	return parent;
> +	return d_obtain_alias(inode);
>  }
>  
>  /* add entry to the directory (entry can be hidden). 
> Index: linux-2.6/fs/udf/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/udf/namei.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/udf/namei.c	2008-08-11 10:35:18.000000000 -0300
> @@ -1243,7 +1243,6 @@ end_rename:
>  
>  static struct dentry *udf_get_parent(struct dentry *child)
>  {
> -	struct dentry *parent;
>  	struct inode *inode = NULL;
>  	struct dentry dotdot;
>  	struct fileIdentDesc cfi;
> @@ -1266,13 +1265,7 @@ static struct dentry *udf_get_parent(str
>  		goto out_unlock;
>  	unlock_kernel();
>  
> -	parent = d_alloc_anon(inode);
> -	if (!parent) {
> -		iput(inode);
> -		parent = ERR_PTR(-ENOMEM);
> -	}
> -
> -	return parent;
> +	return d_obtain_alias(inode);
>  out_unlock:
>  	unlock_kernel();
>  	return ERR_PTR(-EACCES);
> @@ -1283,7 +1276,6 @@ static struct dentry *udf_nfs_get_inode(
>  					u16 partref, __u32 generation)
>  {
>  	struct inode *inode;
> -	struct dentry *result;
>  	kernel_lb_addr loc;
>  
>  	if (block == 0)
> @@ -1300,12 +1292,7 @@ static struct dentry *udf_nfs_get_inode(
>  		iput(inode);
>  		return ERR_PTR(-ESTALE);
>  	}
> -	result = d_alloc_anon(inode);
> -	if (!result) {
> -		iput(inode);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -	return result;
> +	return d_obtain_alias(inode);
>  }
>  
>  static struct dentry *udf_fh_to_dentry(struct super_block *sb,
> Index: linux-2.6/fs/fat/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/fat/inode.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/fat/inode.c	2008-08-11 10:35:18.000000000 -0300
> @@ -685,33 +685,24 @@ static struct dentry *fat_fh_to_dentry(s
>  			inode = NULL;
>  		}
>  	}
> -	if (!inode) {
> -		/* For now, do nothing
> -		 * What we could do is:
> -		 * follow the file starting at fh[4], and record
> -		 * the ".." entry, and the name of the fh[2] entry.
> -		 * The follow the ".." file finding the next step up.
> -		 * This way we build a path to the root of
> -		 * the tree. If this works, we lookup the path and so
> -		 * get this inode into the cache.
> -		 * Finally try the fat_iget lookup again
> -		 * If that fails, then weare totally out of luck
> -		 * But all that is for another day
> -		 */
> -	}
> -	if (!inode)
> -		return ERR_PTR(-ESTALE);
> -
>  
> -	/* now to find a dentry.
> -	 * If possible, get a well-connected one
> +	/*
> +	 * For now, do nothing if the inode is not found.
> +	 *
> +	 * What we could do is:
> +	 *
> +	 *	- follow the file starting at fh[4], and record the ".." entry,
> +	 *	  and the name of the fh[2] entry.
> +	 *	- then follow the ".." file finding the next step up.
> +	 *
> +	 * This way we build a path to the root of the tree. If this works, we
> +	 * lookup the path and so get this inode into the cache.  Finally try
> +	 * the fat_iget lookup again.  If that fails, then we are totally out
> +	 * of luck.  But all that is for another day
>  	 */
> -	result = d_alloc_anon(inode);
> -	if (result == NULL) {
> -		iput(inode);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -	result->d_op = sb->s_root->d_op;
> +	result = d_obtain_alias(inode);
> +	if (result && !IS_ERR(result))
> +		result->d_op = sb->s_root->d_op;
>  	return result;
>  }
>  
> @@ -758,15 +749,8 @@ static struct dentry *fat_get_parent(str
>  	}
>  	inode = fat_build_inode(sb, de, i_pos);
>  	brelse(bh);
> -	if (IS_ERR(inode)) {
> -		parent = ERR_CAST(inode);
> -		goto out;
> -	}
> -	parent = d_alloc_anon(inode);
> -	if (!parent) {
> -		iput(inode);
> -		parent = ERR_PTR(-ENOMEM);
> -	}
> +
> +	parent = d_obtain_alias(inode);
>  out:
>  	unlock_super(sb);
>  
> Index: linux-2.6/fs/fuse/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/fuse/inode.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/fuse/inode.c	2008-08-11 10:35:18.000000000 -0300
> @@ -596,12 +596,8 @@ static struct dentry *fuse_get_dentry(st
>  	if (inode->i_generation != handle->generation)
>  		goto out_iput;
>  
> -	entry = d_alloc_anon(inode);
> -	err = -ENOMEM;
> -	if (!entry)
> -		goto out_iput;
> -
> -	if (get_node_id(inode) != FUSE_ROOT_ID) {
> +	entry = d_obtain_alias(inode);
> +	if (entry && !IS_ERR(entry) && get_node_id(inode) != FUSE_ROOT_ID) {
>  		entry->d_op = &fuse_dentry_operations;
>  		fuse_invalidate_entry_cache(entry);
>  	}
> @@ -696,17 +692,14 @@ static struct dentry *fuse_get_parent(st
>  	name.name = "..";
>  	err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode),
>  			       &name, &outarg, &inode);
> -	if (err && err != -ENOENT)
> -		return ERR_PTR(err);
> -	if (err || !inode)
> -		return ERR_PTR(-ESTALE);
> -
> -	parent = d_alloc_anon(inode);
> -	if (!parent) {
> -		iput(inode);
> -		return ERR_PTR(-ENOMEM);
> +	if (err) {
> +		if (err == -ENOENT)
> +			return -ESTALE;
> +		return err;
>  	}
> -	if (get_node_id(inode) != FUSE_ROOT_ID) {
> +
> +	parent = d_obtain_alias(inode);
> +	if (parent && !IS_ERR(parent) && get_node_id(inode) != FUSE_ROOT_ID) {
>  		parent->d_op = &fuse_dentry_operations;
>  		fuse_invalidate_entry_cache(parent);
>  	}
> Index: linux-2.6/fs/gfs2/ops_export.c
> ===================================================================
> --- linux-2.6.orig/fs/gfs2/ops_export.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/gfs2/ops_export.c	2008-08-11 10:35:18.000000000 -0300
> @@ -130,28 +130,17 @@ static int gfs2_get_name(struct dentry *
>  static struct dentry *gfs2_get_parent(struct dentry *child)
>  {
>  	struct qstr dotdot;
> -	struct inode *inode;
>  	struct dentry *dentry;
>  
> -	gfs2_str2qstr(&dotdot, "..");
> -	inode = gfs2_lookupi(child->d_inode, &dotdot, 1);
> -
> -	if (!inode)
> -		return ERR_PTR(-ENOENT);
>  	/*
> -	 * In case of an error, @inode carries the error value, and we
> -	 * have to return that as a(n invalid) pointer to dentry.
> +	 * XXX(hch): it would be a good idea to keep this around as a
> +	 *	     static variable.
>  	 */
> -	if (IS_ERR(inode))
> -		return ERR_CAST(inode);
> -
> -	dentry = d_alloc_anon(inode);
> -	if (!dentry) {
> -		iput(inode);
> -		return ERR_PTR(-ENOMEM);
> -	}
> +	gfs2_str2qstr(&dotdot, "..");
>  
> -	dentry->d_op = &gfs2_dops;
> +	dentry = d_obtain_alias(gfs2_lookupi(child->d_inode, &dotdot, 1));
> +	if (dentry && !IS_ERR(dentry))
> +		dentry->d_op = &gfs2_dops;
>  	return dentry;
>  }
>  
> @@ -233,13 +222,9 @@ static struct dentry *gfs2_get_dentry(st
>  	gfs2_glock_dq_uninit(&i_gh);
>  
>  out_inode:
> -	dentry = d_alloc_anon(inode);
> -	if (!dentry) {
> -		iput(inode);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -
> -	dentry->d_op = &gfs2_dops;
> +	dentry = d_obtain_alias(inode);
> +	if (dentry && !IS_ERR(dentry))
> +		dentry->d_op = &gfs2_dops;
>  	return dentry;
>  
>  fail_rgd:
> Index: linux-2.6/fs/nfs/getroot.c
> ===================================================================
> --- linux-2.6.orig/fs/nfs/getroot.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/nfs/getroot.c	2008-08-11 10:35:18.000000000 -0300
> @@ -107,9 +107,8 @@ struct dentry *nfs_get_root(struct super
>  	 * if the dentry tree reaches them; however if the dentry already
>  	 * exists, we'll pick it up at this point and use it as the root
>  	 */
> -	mntroot = d_alloc_anon(inode);
> +	mntroot = d_obtain_alias(inode);
>  	if (!mntroot) {
> -		iput(inode);
>  		dprintk("nfs_get_root: get root dentry failed\n");
>  		return ERR_PTR(-ENOMEM);
>  	}
> @@ -277,9 +276,8 @@ struct dentry *nfs4_get_root(struct supe
>  	 * if the dentry tree reaches them; however if the dentry already
>  	 * exists, we'll pick it up at this point and use it as the root
>  	 */
> -	mntroot = d_alloc_anon(inode);
> +	mntroot = d_obtain_alias(inode);
>  	if (!mntroot) {
> -		iput(inode);
>  		dprintk("nfs_get_root: get root dentry failed\n");
>  		return ERR_PTR(-ENOMEM);
>  	}
> Index: linux-2.6/fs/xfs/linux-2.6/xfs_export.c
> ===================================================================
> --- linux-2.6.orig/fs/xfs/linux-2.6/xfs_export.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/xfs/linux-2.6/xfs_export.c	2008-08-11 10:35:18.000000000 -0300
> @@ -102,18 +102,12 @@ xfs_fs_get_parent(
>  {
>  	int			error;
>  	struct xfs_inode	*cip;
> -	struct dentry		*parent;
>  
>  	error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip, NULL);
>  	if (unlikely(error))
>  		return ERR_PTR(-error);
>  
> -	parent = d_alloc_anon(cip->i_vnode);
> -	if (unlikely(!parent)) {
> -		iput(cip->i_vnode);
> -		return ERR_PTR(-ENOMEM);
> -	}
> -	return parent;
> +	return d_obtain_alias(cip->i_vnode);
>  }
>  
>  const struct export_operations xfs_export_operations = {
> Index: linux-2.6/fs/xfs/linux-2.6/xfs_ioctl.c
> ===================================================================
> --- linux-2.6.orig/fs/xfs/linux-2.6/xfs_ioctl.c	2008-08-11 10:35:13.000000000 -0300
> +++ linux-2.6/fs/xfs/linux-2.6/xfs_ioctl.c	2008-08-11 10:35:18.000000000 -0300
> @@ -311,9 +311,8 @@ xfs_open_by_handle(
>  		return new_fd;
>  	}
>  
> -	dentry = d_alloc_anon(inode);
> +	dentry = d_obtain_alias(inode);
>  	if (dentry == NULL) {
> -		iput(inode);
>  		put_unused_fd(new_fd);
>  		return -XFS_ERROR(ENOMEM);
>  	}
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux