From: Eric Sandeen <sandeen@sandeen.net>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfs: check on-disk (not incore) btree root size in dfrag.c
Date: Wed, 19 Jun 2013 16:51:41 -0500 [thread overview]
Message-ID: <51C227ED.5010108@sandeen.net> (raw)
In-Reply-To: <4F7225BA.40200@redhat.com>
On 3/27/12 3:40 PM, Eric Sandeen wrote:
> xfs_swap_extents_check_format() contains checks to make sure that
> original and the temporary files during defrag are compatible;
> Gabriel VLASIU ran into a case where xfs_fsr returned EINVAL
> because the tests found the btree root to be of size 120,
> while the fork offset was only 104; IOW, they overlapped.
>
> However, this is just due to an error in the
> xfs_swap_extents_check_format() tests, because it is checking
> the in-memory btree root size against the on-disk fork offset.
> We should be checking the on-disk sizes in both cases.
>
> This patch adds a new macro to calculate this size, and uses
> it in the tests.
>
> With this change, the filesystem image provided by Gabriel
> allows for proper file degragmentation.
I think this and the followup patch 2/1 got lost.
Ben, any idea?
Thanks,
-Eric
> Reported-by: Gabriel VLASIU <gabriel@vlasiu.net>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
> index 0e66c4e..d9eeb64 100644
> --- a/fs/xfs/xfs_bmap_btree.h
> +++ b/fs/xfs/xfs_bmap_btree.h
> @@ -189,12 +189,14 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;
> #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \
> (int)(XFS_BTREE_LBLOCK_LEN + \
> ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
> -
> #define XFS_BMAP_BROOT_SPACE(bb) \
> (XFS_BMAP_BROOT_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs)))
> +
> #define XFS_BMDR_SPACE_CALC(nrecs) \
> (int)(sizeof(xfs_bmdr_block_t) + \
> ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
> +#define XFS_BMAP_BMDR_SPACE(bb) \
> + (XFS_BMDR_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs)))
>
> /*
> * Maximum number of bmap btree levels.
> diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
> index dd974a5..2707d86 100644
> --- a/fs/xfs/xfs_dfrag.c
> +++ b/fs/xfs/xfs_dfrag.c
> @@ -26,6 +26,9 @@
> #include "xfs_ag.h"
> #include "xfs_mount.h"
> #include "xfs_bmap_btree.h"
> +#include "xfs_alloc_btree.h"
> +#include "xfs_ialloc_btree.h"
> +#include "xfs_btree.h"
> #include "xfs_dinode.h"
> #include "xfs_inode.h"
> #include "xfs_inode_item.h"
> @@ -184,7 +187,7 @@ xfs_swap_extents_check_format(
> */
> 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))
> + XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip))
> return EINVAL;
> if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
> XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
> @@ -194,9 +197,8 @@ xfs_swap_extents_check_format(
> /* Reciprocal target->temp btree format checks */
> 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))
> + XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip))
> return EINVAL;
> -
> if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
> XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
> return EINVAL;
>
> _______________________________________________
> 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
next prev parent reply other threads:[~2013-06-19 21:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-27 20:40 [PATCH] xfs: check on-disk (not incore) btree root size in dfrag.c Eric Sandeen
2012-03-27 20:50 ` Eric Sandeen
2012-03-27 21:16 ` Dave Chinner
2012-03-28 17:21 ` [PATCH 2/1] xfs: use XFS_BMAP_BMDR_SPACE vs. XFS_BROOT_SIZE_ADJ Eric Sandeen
2012-03-29 0:55 ` Dave Chinner
2013-06-19 21:51 ` Eric Sandeen [this message]
2013-06-20 17:09 ` [PATCH] xfs: check on-disk (not incore) btree root size in dfrag.c Ben Myers
2013-07-09 16:26 ` Eric Sandeen
2013-07-09 18:22 ` Ben Myers
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=51C227ED.5010108@sandeen.net \
--to=sandeen@sandeen.net \
--cc=sandeen@redhat.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