public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <aelder@sgi.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs: fix extent format buffer allocation size
Date: Mon, 04 Apr 2011 15:09:09 -0500	[thread overview]
Message-ID: <1301947749.2630.75.camel@doink> (raw)
In-Reply-To: <1301453521-5614-1-git-send-email-david@fromorbit.com>

On Wed, 2011-03-30 at 13:52 +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> When formatting an inode item, we have to allocate a separate buffer
> to hold extents when there are delayed allocation extents on the
> inode and it is in extent format. The allocation size is derived
> from the in-core data fork representation, which accounts for
> delayed allocation extents, while the on-disk representation does
> not contain any delalloc extents.
> 
> As a result of this mismatch, the allocated buffer can be far larger
> than needed to hold the real extent list which, due to the fact the
> inode is in extent format, is limited to the size of the literal
> area of the inode. However, we can have thousands of delalloc
> extents, resulting in an allocation size orders of magnitude larger
> than is needed to hold all the real extents.
> 
> Fix this by limiting the size of the buffer being allocated to the
> size of the literal area of the inodes in the filesystem (i.e. the
> maximum size an inode fork can grow to).
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

I think one of your comments helps explain why you came about
the fix but it maybe distracts a bit from explaining what
the code is doing.  (See below.)  But the change looks good.

Reviewed-by: Alex Elder <aelder@sgi.com>

> ---
>  fs/xfs/xfs_inode_item.c |   69 ++++++++++++++++++++++++++++------------------
>  1 files changed, 42 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 46cc401..12cdc39 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -198,6 +198,43 @@ xfs_inode_item_size(
>  }
>  
>  /*
> + * xfs_inode_item_format_extents - convert in-core extents to on-disk form
> + *
> + * For either the data or attr fork in extent format, we need to endian convert
> + * the in-core extent as we place them into the on-disk inode. In this case, we
> + * ned to do this conversion before we write the extents into the log. Because
     need

> + * we don't have the disk inode to write into here, we allocate a buffer and
> + * format the extents into it via xfs_iextents_copy(). We free the buffer in
> + * the unlock routine after the copy for the log has been made.
> + *
> + * For the data fork, there can be delayed allocation extents
> + * in the inode as well, so the in-core data fork can be much larger than the
> + * on-disk data representation of real inodes. Hence we need to limit the size
> + * of the allocation to what will fit in the inode fork, otherwise we could be
> + * asking for excessively large allocation sizes.

I think the comment here is sort of oriented toward the old way
of looking at things.  I don't think there's any need to justify
the use of the max fork size rather than xfs_ifork->if_bytes.

Just say that any on-disk inode in extent format will fill
no more than that much space on disk, therefore the buffer
we allocate can be limited to that size.  (And perhaps as an
afterthought, delayed allocation extents are never recorded
to disk and therefore don't need space for endian-converting
them.)

> + */
> +STATIC void
> +xfs_inode_item_format_extents(
> +	struct xfs_inode	*ip,
> +	struct xfs_log_iovec	*vecp,
> +	int			whichfork,
> +	int			type)
> +{

. . .

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

      parent reply	other threads:[~2011-04-04 20:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-30  2:52 [PATCH] xfs: fix extent format buffer allocation size Dave Chinner
2011-03-30  9:33 ` Christoph Hellwig
2011-03-31  5:51   ` Dave Chinner
2011-03-31  6:29     ` Christoph Hellwig
2011-04-04 20:09 ` Alex Elder [this message]

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=1301947749.2630.75.camel@doink \
    --to=aelder@sgi.com \
    --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