On Tue, Mar 27, 2012 at 03:50:48PM -0500, Eric Sandeen wrote:
> 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.
>
> Hm, as usually happens right after finalizing this I stumbled
> on something else. xfs_iroot_realloc() does essentially the same
> test, but uses a funky macro to resolve the incore/ondisk size
> difference:
>
> ASSERT(ifp->if_broot_bytes <=
> XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ);
>
> so dfrag.c could be fixed up the same way, I suppose, using
> XFS_BROOT_SIZE_ADJ if desired (though I have no real love for that
> undocumented macro!)
I much prefer the addition of a XFS_BMAP_BMDR_SPACE() macro. Perhaps
it might be worthwhile to convert those uses of XFS_BROOT_SIZE_ADJ
to use your new macro, and get rid of the XFS_BROOT_SIZE_ADJ grot
altogether?
Anyway, consider your patch:
Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
Cheers,
Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx
|