All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 04/11] xfs: remove the if_ext_max field in struct xfs_ifork
Date: Wed, 14 Dec 2011 08:59:58 +1100	[thread overview]
Message-ID: <20111213215958.GC3179@dastard> (raw)
In-Reply-To: <20111208155918.162879660@bombadil.infradead.org>

On Thu, Dec 08, 2011 at 10:57:59AM -0500, Christoph Hellwig wrote:
> We spent a lot of effort to maintain this field, but it always equalts to the
> fork size divided by the constant size of an extent.  The prime use of it is
> to assert that the two stay in sync.  Just divide the fork size by the extent
> size in the few places that we actually use it and remove the overhead
> of maintaining it.

Ok, so you are trading off the overhead of initialising once with
runtime overhead of a read, against a runtime overhead read and a
integer division. Some platforms have slow integer division, so at
face value this migh tbe a bit slower.

However, sizeof(struct xfs_bmbt_rec) == 16, which is determined at
compile time so the compiler can optimise that to a shift, which has
basically no overhead compared to a division on platforms where
division is slow.

>From taht perspective, this seems like a good tradeoff to make -
very little additional runtime overhead, much simpler code.

> Also introduce a few helpers to consolidate the places
> where we actually care about the value.

The helpers are a vast improvement.

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

Couple of small formatting comments below, but otherwise consider it

Reviewed-by: Dave Chinner <dchinner@redhat.com>

> Index: xfs/fs/xfs/xfs_dfrag.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_dfrag.c	2011-12-02 19:39:31.437161062 +0100
> +++ xfs/fs/xfs/xfs_dfrag.c	2011-12-07 11:17:02.342984256 +0100
> @@ -163,12 +163,14 @@ xfs_swap_extents_check_format(
>  
>  	/* 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)
> +	    XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) >
> +	    XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
>  		return EINVAL;

I'd indent the XFS_IFORK_MAXEXT() so it's obvious it's part of a
conditional and not a new conditional expression. Maybe something
like:

+	    XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) >
+			XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))

Otherwise it's not exactly obvious how the logic flows here.

>  
>  	/* 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)
> +	    XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) >
> +	    XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
>  		return EINVAL;

Same here.

>  
>  	/*
> @@ -180,18 +182,25 @@ xfs_swap_extents_check_format(
>  	 * (a common defrag case) which will occur when the temp inode is in
>  	 * extent format...
>  	 */
> -	if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE &&
> -	    ((XFS_IFORK_BOFF(ip) &&
> -	      tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip)) ||
> -	     XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= ip->i_df.if_ext_max))
> +	if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
> +		if (XFS_IFORK_BOFF(ip) &&
> +		    tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip))
> +			return EINVAL;
> +		if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
> +		    XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
>  		return EINVAL;
                ^ needs another indent.
> +	}
>  
>  	/* Reciprocal target->temp btree format checks */
> -	if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE &&
> -	    ((XFS_IFORK_BOFF(tip) &&
> -	      ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip)) ||
> -	     XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= tip->i_df.if_ext_max))
> +	if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
> +		if (XFS_IFORK_BOFF(tip) &&
> +		    ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip))
> +			return EINVAL;
> +
> +		if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
> +		    XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
>  		return EINVAL;

Same here.


-- 
Dave Chinner
david@fromorbit.com

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

  reply	other threads:[~2011-12-13 22:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-08 15:57 [PATCH 00/11] inode shrink and misc updates Christoph Hellwig
2011-12-08 15:57 ` [PATCH 01/11] xfs: remove xfs_itruncate_data Christoph Hellwig
2011-12-13 21:23   ` Dave Chinner
2011-12-08 15:57 ` [PATCH 02/11] xfs: cleanup xfs_iomap_eof_align_last_fsb Christoph Hellwig
2011-12-13 21:25   ` Dave Chinner
2011-12-08 15:57 ` [PATCH 03/11] xfs: remove the unused dm_attrs structure Christoph Hellwig
2011-12-08 15:57 ` [PATCH 04/11] xfs: remove the if_ext_max field in struct xfs_ifork Christoph Hellwig
2011-12-13 21:59   ` Dave Chinner [this message]
2011-12-08 15:58 ` [PATCH 05/11] xfs: make i_flags an unsigned long Christoph Hellwig
2012-01-13 19:07   ` Ben Myers
2012-01-24 18:03     ` Christoph Hellwig
2011-12-08 15:58 ` [PATCH 06/11] xfs: replace i_flock with a sleeping bitlock Christoph Hellwig
2011-12-13 22:19   ` Dave Chinner
2011-12-18 18:11     ` Christoph Hellwig
2011-12-08 15:58 ` [PATCH 07/11] xfs: replace i_pin_wait with a bit waitqueue Christoph Hellwig
2011-12-13 22:21   ` Dave Chinner
2011-12-08 15:58 ` [PATCH 08/11] xfs: remove the i_size field in struct xfs_inode Christoph Hellwig
2011-12-13 22:58   ` Dave Chinner
2011-12-08 15:58 ` [PATCH 09/11] xfs: remove the i_new_size " Christoph Hellwig
2011-12-13 23:16   ` Dave Chinner
2011-12-14 13:30     ` Christoph Hellwig
2011-12-08 15:58 ` [PATCH 10/11] xfs: always return with the iolock held from xfs_file_aio_write_checks Christoph Hellwig
2011-12-13 23:20   ` Dave Chinner
2011-12-14 13:27     ` Christoph Hellwig
2011-12-08 15:58 ` [PATCH 11/11] xfs: cleanup xfs_file_aio_write Christoph Hellwig
2011-12-13 23:28   ` Dave Chinner
  -- strict thread matches above, loose matches on Subject: below --
2011-12-18 20:00 [PATCH 00/11] inode shrink and misc updates V2 Christoph Hellwig
2011-12-18 20:00 ` [PATCH 04/11] xfs: remove the if_ext_max field in struct xfs_ifork Christoph Hellwig
2012-01-06 16:58   ` Ben Myers
2012-01-16 22:45     ` Ben Myers
2012-01-17 15:16       ` Ben Myers
2012-01-17 17:04         ` Mark Tinguely

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=20111213215958.GC3179@dastard \
    --to=david@fromorbit.com \
    --cc=hch@infradead.org \
    --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.