public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Chinner <dgc@sgi.com>
To: Barry Naujok <bnaujok@sgi.com>
Cc: "xfs@oss.sgi.com" <xfs@oss.sgi.com>, xfs-dev <xfs-dev@sgi.com>
Subject: Re: [REVIEW] cleanup - remove bhv_vname_t
Date: Tue, 8 Apr 2008 15:13:24 +1000	[thread overview]
Message-ID: <20080408051324.GW108924158@sgi.com> (raw)
In-Reply-To: <op.t89zp3j63jf8g2@pc-bnaujok.melbourne.sgi.com>

On Tue, Apr 08, 2008 at 02:50:17PM +1000, Barry Naujok wrote:
> +static inline struct xfs_name *
> +xfs_dentry_name(
> +	struct xfs_name	*namep,
> +	struct dentry	*dentry)
> +{
> +	namep->name = dentry->d_name.name;
> +	namep->len = dentry->d_name.len;
> +	return namep;
> +}

xfs_dentry_to_name()

> @@ -246,20 +256,19 @@ xfs_cleanup_inode(
>  	struct dentry	*dentry,
>  	int		mode)
>  {
> -	struct dentry   teardown = {};
> +	struct xfs_name	name;

I'd leave the variable name as 'teardown'. ie.

+	struct xfs_name	teardown;

> @@ -371,12 +383,13 @@ xfs_vn_lookup(
>  	struct nameidata *nd)
>  {
>  	struct xfs_inode *cip;
> +	struct xfs_name	name;
>  	int		error;
> 
>  	if (dentry->d_name.len >= MAXNAMELEN)
>  		return ERR_PTR(-ENAMETOOLONG);
> 
> -	error = xfs_lookup(XFS_I(dir), dentry, &cip);
> +	error = xfs_lookup(XFS_I(dir), xfs_dentry_name(&name, dentry), &cip);

I'd prefer this to be separate operations:

+	xfs_dentry_to_name(&name, dentry);
+	error = xfs_lookup(XFS_I(dir), &name, &cip);

that way it's clear that we're passing name down the stack....

Same for all the others....

> @@ -489,9 +509,12 @@ xfs_vn_rename(
>  	struct dentry	*ndentry)
>  {
>  	struct inode	*new_inode = ndentry->d_inode;
> +	struct xfs_name	oname, nname;

+	struct xfs_name	oname;
+	struct xfs_name	nname;

......

> -	args.hashval = xfs_da_hashname(name, namelen);
> +	args.name = name->name;
> +	args.namelen = name->len;
> +	args.hashval = xfs_da_hashname(name->name, name->len);

Seems like future work would be to drive the xfs_name_t further
into these leaf functions....

> @@ -83,17 +83,16 @@ int xfs_rename_skip, xfs_rename_nskip;
>   */
>  STATIC int
>  xfs_lock_for_rename(
> -	xfs_inode_t	*dp1,	/* old (source) directory inode */
> -	xfs_inode_t	*dp2,	/* new (target) directory inode */
> -	bhv_vname_t	*vname1,/* old entry name */
> -	bhv_vname_t	*vname2,/* new entry name */
> -	xfs_inode_t	**ipp1,	/* inode of old entry */
> -	xfs_inode_t	**ipp2,	/* inode of new entry, if it
> +	xfs_inode_t	*dp1,	/* in: old (source) directory inode */
> +	xfs_inode_t	*dp2,	/* in: new (target) directory inode */
> +	xfs_name_t	*name2,	/* in: new entry name */
> +	xfs_inode_t	**ipp1,	/* in/out: inode of old entry */
> +	xfs_inode_t	**ipp2,	/* out: inode of new entry, if it
>  				   already exists, NULL otherwise. */
> -	xfs_inode_t	**i_tab,/* array of inode returned, sorted */
> -	int		*num_inodes)  /* number of inodes in array */
> +	xfs_inode_t	**i_tab,/* out: array of inode returned, sorted */
> +	int		*num_inodes)  /* out: number of inodes in array */
>  {
> -	xfs_inode_t		*ip1 = VNAME_TO_INODE(vname1);
> +	xfs_inode_t		*ip1;
>  	xfs_inode_t		*ip2, *temp;
>  	xfs_ino_t		inum1, inum2;
>  	int			error;
> @@ -101,6 +100,7 @@ xfs_lock_for_rename(
>  	uint			lock_mode;
>  	int			diff_dirs = (dp1 != dp2);
> 
> +	ip1 = *ipp1;
>  	ip2 = NULL;

	ASSERT(ip1);
.....
>  	 * Initially assume that the file does not exist and
>  	 * reserve the resources for that case.  If that is not
> @@ -1883,7 +1879,7 @@ xfs_create(
>  	if (error)
>  		goto error_return;
> 
> -	if (resblks == 0 && (error = xfs_dir_canenter(tp, dp, name, 
> namelen)))
> +	if (resblks == 0 && (error = xfs_dir_canenter(tp, dp, name)))
>  		goto error_return;

If you're touching lines like that, you should restructure it at the
same time to match accepted style more closely.

	if (!resblks) {
		error = xfs_dir_canenter(tp, dp, name);
		if (error)
			goto error_return;
	}

> @@ -2567,12 +2558,12 @@ xfs_link(
>  	}
> 
>  	if (resblks == 0 &&
> -	    (error = xfs_dir_canenter(tp, tdp, target_name, target_namelen)))
> +	    (error = xfs_dir_canenter(tp, tdp, target_name)))
>  		goto error_return;

Same again.

> @@ -2719,7 +2708,7 @@ xfs_mkdir(
>  		goto error_return;
> 
>  	if (resblks == 0 &&
> -	    (error = xfs_dir_canenter(tp, dp, dir_name, dir_namelen)))
> +	    (error = xfs_dir_canenter(tp, dp, dir_name)))
>  		goto error_return;

more!

> @@ -3201,7 +3184,7 @@ xfs_symlink(
>  	 * Check for ability to enter directory entry, if no space reserved.
>  	 */
>  	if (resblks == 0 &&
> -	    (error = xfs_dir_canenter(tp, dp, link_name, link_namelen)))
> +	    (error = xfs_dir_canenter(tp, dp, link_name)))
>  		goto error_return;

how many times do we do almost the same thing? :P

Looks pretty good, otherwise....

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

  reply	other threads:[~2008-04-08  5:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-08  4:50 [REVIEW] cleanup - remove bhv_vname_t Barry Naujok
2008-04-08  5:13 ` David Chinner [this message]
2008-04-08  6:38 ` Christoph Hellwig
2008-04-08  6:50   ` Barry Naujok
2008-04-08  7:41     ` Christoph Hellwig
2008-04-08  7:48       ` Barry Naujok

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080408051324.GW108924158@sgi.com \
    --to=dgc@sgi.com \
    --cc=bnaujok@sgi.com \
    --cc=xfs-dev@sgi.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox