All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Eric Sandeen <sandeen@redhat.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 1/4] xfs: check resblks before calling xfs_dir_canenter
Date: Fri, 22 Aug 2014 09:19:31 -0400	[thread overview]
Message-ID: <20140822131930.GA3915@laptop.bfoster> (raw)
In-Reply-To: <53F694F9.9030406@sandeen.net>

On Thu, Aug 21, 2014 at 07:55:21PM -0500, Eric Sandeen wrote:
> Move the resblks test out of the xfs_dir_canenter,
> and into the caller.
> 
> This makes a little more sense on the face of it;
> xfs_dir_canenter immediately returns if resblks !=0;
> and given some of the comments preceding the calls:
> 
>  * Check for ability to enter directory entry, if no space reserved.
> 
> even more so.
> 
> It also facilitates the next patch.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

> 
> 
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 6cef221..ea84e1c 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -535,22 +535,17 @@ out_free:
>  
>  /*
>   * See if this entry can be added to the directory without allocating space.
> - * First checks that the caller couldn't reserve enough space (resblks = 0).
>   */
>  int
>  xfs_dir_canenter(
>  	xfs_trans_t	*tp,
>  	xfs_inode_t	*dp,
> -	struct xfs_name	*name,		/* name of entry to add */
> -	uint		resblks)
> +	struct xfs_name	*name)		/* name of entry to add */
>  {
>  	struct xfs_da_args *args;
>  	int		rval;
>  	int		v;		/* type-checking value */
>  
> -	if (resblks)
> -		return 0;
> -
>  	ASSERT(S_ISDIR(dp->i_d.di_mode));
>  
>  	args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
> diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
> index c8e86b0..4dff261 100644
> --- a/fs/xfs/libxfs/xfs_dir2.h
> +++ b/fs/xfs/libxfs/xfs_dir2.h
> @@ -136,7 +136,7 @@ extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
>  				xfs_fsblock_t *first,
>  				struct xfs_bmap_free *flist, xfs_extlen_t tot);
>  extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
> -				struct xfs_name *name, uint resblks);
> +				struct xfs_name *name);
>  
>  /*
>   * Direct call from the bmap code, bypassing the generic directory layer.
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index fea3c92..c92cb48 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1153,9 +1153,11 @@ xfs_create(
>  	if (error)
>  		goto out_trans_cancel;
>  
> -	error = xfs_dir_canenter(tp, dp, name, resblks);
> -	if (error)
> -		goto out_trans_cancel;
> +	if (!resblks) {
> +		error = xfs_dir_canenter(tp, dp, name);
> +		if (error)
> +			goto out_trans_cancel;
> +	}
>  
>  	/*
>  	 * A newly created regular or special file just has one directory
> @@ -1421,9 +1423,11 @@ xfs_link(
>  		goto error_return;
>  	}
>  
> -	error = xfs_dir_canenter(tp, tdp, target_name, resblks);
> -	if (error)
> -		goto error_return;
> +	if (!resblks) {
> +		error = xfs_dir_canenter(tp, tdp, target_name);
> +		if (error)
> +			goto error_return;
> +	}
>  
>  	xfs_bmap_init(&free_list, &first_block);
>  
> @@ -2759,9 +2763,11 @@ xfs_rename(
>  		 * If there's no space reservation, check the entry will
>  		 * fit before actually inserting it.
>  		 */
> -		error = xfs_dir_canenter(tp, target_dp, target_name, spaceres);
> -		if (error)
> -			goto error_return;
> +		if (!spaceres) {
> +			error = xfs_dir_canenter(tp, target_dp, target_name);
> +			if (error)
> +				goto error_return;
> +		}
>  		/*
>  		 * If target does not exist and the rename crosses
>  		 * directories, adjust the target directory link count
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 6a944a2..02ae62a 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -269,9 +269,11 @@ xfs_symlink(
>  	/*
>  	 * Check for ability to enter directory entry, if no space reserved.
>  	 */
> -	error = xfs_dir_canenter(tp, dp, link_name, resblks);
> -	if (error)
> -		goto error_return;
> +	if (!resblks) {
> +		error = xfs_dir_canenter(tp, dp, link_name);
> +		if (error)
> +			goto error_return;
> +	}
>  	/*
>  	 * Initialize the bmap freelist prior to calling either
>  	 * bmapi or the directory create code.
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2014-08-22 13:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-22  0:51 [PATCH 0/4] xfs: more code refactoring Eric Sandeen
2014-08-22  0:55 ` [PATCH 1/4] xfs: check resblks before calling xfs_dir_canenter Eric Sandeen
2014-08-22 13:19   ` Brian Foster [this message]
2014-08-29  0:59   ` Christoph Hellwig
2014-08-22  0:58 ` [PATCH 2/4] xfs: combine xfs_dir_canenter into xfs_dir_createname Eric Sandeen
2014-08-22 13:19   ` Brian Foster
2014-08-29  1:00   ` Christoph Hellwig
2014-08-29  2:14   ` [PATCH 2/4 V2] " Eric Sandeen
2014-08-22  1:00 ` [PATCH 3/4] xfs: combine xfs_rtmodify_summary and xfs_rtget_summary Eric Sandeen
2014-08-22 13:19   ` Brian Foster
2014-08-22 15:01     ` Eric Sandeen
2014-08-22 15:23       ` Eric Sandeen
2014-08-22  1:03 ` [PATCH 4/4] xfs: remove rbpp check from xfs_rtmodify_summary_int Eric Sandeen
2014-08-22 13:20   ` Brian Foster
2014-08-23 23:50     ` Eric Sandeen

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=20140822131930.GA3915@laptop.bfoster \
    --to=bfoster@redhat.com \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.