public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs: xfs_swap_extents needs to handle dynamic fork offsets
Date: Tue, 12 Jan 2010 08:09:22 -0500	[thread overview]
Message-ID: <20100112130922.GA30985@infradead.org> (raw)
In-Reply-To: <1263272506-15085-1-git-send-email-david@fromorbit.com>

> +	TP_printk("dev %d:%d %s inode 0x%llx, %s format, num_extents %d, "
> +		  "Max in-fork extents %d, broot size %d, fork offset %d",

It would be nice to keep the

	"dev %d:%d ino 0x%llx"

prefix as a convention so that all trace records are similar at their
beginning.

>  #undef TRACE_INCLUDE_PATH
> diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
> @@ -53,7 +53,7 @@ xfs_swapext(
>  	xfs_swapext_t	*sxp)
>  {
>  	xfs_inode_t     *ip, *tip;
> -	struct file	*file, *target_file;
> +	struct file	*file, *tmp_file;

I think these xfs_swapext belong into a separate patch.  While they
make the code quite a bit more redable they're purely cleanups and
can wait for 2.6.34.  And while you're at it you might also want to
merge xfs_swap_extents into xfs_swapext - there's no need for that
split at all.

> +static int
> +xfs_swap_extents_check_format(
> +	xfs_inode_t	*ip,	/* target inode */
> +	xfs_inode_t	*tip)	/* tmp inode */

What about just using struct xfs_inode * for new code?

> +	/* Should never get a local format */
> +	if (ip->i_d.di_format == XFS_DINODE_FMT_LOCAL ||
> +	    tip->i_d.di_format == XFS_DINODE_FMT_LOCAL)
> +		return EINVAL;

Ok, same check as in the old code.  Any reason we drop the XFS_ERROR
here?

> +	/*
> +	 * if the target inode has less extents that then temporary inode then
> +	 * why did userspace call us?
> +	 */
> +	if (ip->i_d.di_nextents < tip->i_d.di_nextents)
> +		return EINVAL;

Ok.
> +	/*
> +	 * if the target inode is in extent form and the temp inode is in btree
> +	 * form then we will end up with the target inode in the wrong format
> +	 * as we already know there are less extents in the temp inode.
> +	 */
> +	if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
> +	    tip->i_d.di_format == XFS_DINODE_FMT_BTREE)
> +		return EINVAL;

Ok.

> +	/* Check temp in extent form to max in target */
> +	if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
> +	    XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) > ip->i_df.if_ext_max)
> +		return EINVAL;
> +
> +	/* Check target in extent form to max in temp */
> +	if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
> +	    XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > tip->i_df.if_ext_max)
> +		return EINVAL;

So we check this either way just to be sure, ok.

> +	/* Check root block of temp in btree form to max in target */
> +	if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE &&
> +	    XFS_IFORK_BOFF(ip) &&
> +	    tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip))
> +		return EINVAL;
> +
> +	/* Check root block of target in btree form to max in temp */
> +	if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE &&
> +	    XFS_IFORK_BOFF(tip) &&
> +	    ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip))
> +		return EINVAL;

Same here.


Patch looks good,


Reviewed-by: Christoph Hellwig <hch@lst.de>

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

  reply	other threads:[~2010-01-12 13:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-12  5:01 [PATCH] xfs: xfs_swap_extents needs to handle dynamic fork offsets Dave Chinner
2010-01-12 13:09 ` Christoph Hellwig [this message]
2010-01-13 22:32   ` Alex Elder
2010-01-13 23:03     ` Dave Chinner
2010-01-14  6:35     ` Christoph Hellwig

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=20100112130922.GA30985@infradead.org \
    --to=hch@infradead.org \
    --cc=david@fromorbit.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