Commit 1fd044d9 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Alex Elder

xfs: do not use xfs_bmap_add_extent for adding delalloc extents

We can just call xfs_bmap_add_extent_hole_delay directly to add a
delayed allocated regions to the extent tree, instead of going
through all the complexities of xfs_bmap_add_extent that aren't
needed for this simple case.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent 4403280a
...@@ -100,17 +100,6 @@ xfs_bmap_add_extent_delay_real( ...@@ -100,17 +100,6 @@ xfs_bmap_add_extent_delay_real(
xfs_bmap_free_t *flist, /* list of extents to be freed */ xfs_bmap_free_t *flist, /* list of extents to be freed */
int *logflagsp); /* inode logging flags */ int *logflagsp); /* inode logging flags */
/*
* Called by xfs_bmap_add_extent to handle cases converting a hole
* to a delayed allocation.
*/
STATIC int /* error */
xfs_bmap_add_extent_hole_delay(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t *idx, /* extent number to update/insert */
xfs_bmbt_irec_t *new, /* new data to add to file extents */
int *logflagsp); /* inode logging flags */
/* /*
* Called by xfs_bmap_add_extent to handle cases converting a hole * Called by xfs_bmap_add_extent to handle cases converting a hole
* to a real allocation. * to a real allocation.
...@@ -431,8 +420,7 @@ xfs_bmap_add_attrfork_local( ...@@ -431,8 +420,7 @@ xfs_bmap_add_attrfork_local(
} }
/* /*
* Called by xfs_bmapi to update file extent records and the btree * Update file extent records and the btree after allocating space.
* after allocating space (or doing a delayed allocation).
*/ */
STATIC int /* error */ STATIC int /* error */
xfs_bmap_add_extent( xfs_bmap_add_extent(
...@@ -464,21 +452,12 @@ xfs_bmap_add_extent( ...@@ -464,21 +452,12 @@ xfs_bmap_add_extent(
ASSERT(*idx >= 0); ASSERT(*idx >= 0);
ASSERT(*idx <= nextents); ASSERT(*idx <= nextents);
ASSERT(!isnullstartblock(new->br_startblock));
/*
* Any kind of new delayed allocation goes here.
*/
if (isnullstartblock(new->br_startblock)) {
if (cur)
ASSERT((cur->bc_private.b.flags &
XFS_BTCUR_BPRV_WASDEL) == 0);
error = xfs_bmap_add_extent_hole_delay(ip, idx, new,
&logflags);
}
/* /*
* Real allocation off the end of the file. * Real allocation off the end of the file.
*/ */
else if (*idx == nextents) { if (*idx == nextents) {
if (cur) if (cur)
ASSERT((cur->bc_private.b.flags & ASSERT((cur->bc_private.b.flags &
XFS_BTCUR_BPRV_WASDEL) == 0); XFS_BTCUR_BPRV_WASDEL) == 0);
...@@ -1581,16 +1560,13 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -1581,16 +1560,13 @@ xfs_bmap_add_extent_unwritten_real(
} }
/* /*
* Called by xfs_bmap_add_extent to handle cases converting a hole * Convert a hole to a delayed allocation.
* to a delayed allocation.
*/ */
/*ARGSUSED*/ STATIC void
STATIC int /* error */
xfs_bmap_add_extent_hole_delay( xfs_bmap_add_extent_hole_delay(
xfs_inode_t *ip, /* incore inode pointer */ xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t *idx, /* extent number to update/insert */ xfs_extnum_t *idx, /* extent number to update/insert */
xfs_bmbt_irec_t *new, /* new data to add to file extents */ xfs_bmbt_irec_t *new) /* new data to add to file extents */
int *logflagsp) /* inode logging flags */
{ {
xfs_ifork_t *ifp; /* inode fork pointer */ xfs_ifork_t *ifp; /* inode fork pointer */
xfs_bmbt_irec_t left; /* left neighbor extent entry */ xfs_bmbt_irec_t left; /* left neighbor extent entry */
...@@ -1725,8 +1701,6 @@ xfs_bmap_add_extent_hole_delay( ...@@ -1725,8 +1701,6 @@ xfs_bmap_add_extent_hole_delay(
* Nothing to do for disk quota accounting here. * Nothing to do for disk quota accounting here.
*/ */
} }
*logflagsp = 0;
return 0;
} }
/* /*
...@@ -4455,9 +4429,6 @@ xfs_bmapi_reserve_delalloc( ...@@ -4455,9 +4429,6 @@ xfs_bmapi_reserve_delalloc(
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
xfs_extlen_t alen; xfs_extlen_t alen;
xfs_extlen_t indlen; xfs_extlen_t indlen;
xfs_fsblock_t firstblock = NULLFSBLOCK;
struct xfs_btree_cur *cur = NULL;
int tmp_logflags = 0;
char rt = XFS_IS_REALTIME_INODE(ip); char rt = XFS_IS_REALTIME_INODE(ip);
xfs_extlen_t extsz; xfs_extlen_t extsz;
int error; int error;
...@@ -4524,16 +4495,11 @@ xfs_bmapi_reserve_delalloc( ...@@ -4524,16 +4495,11 @@ xfs_bmapi_reserve_delalloc(
got->br_startblock = nullstartblock(indlen); got->br_startblock = nullstartblock(indlen);
got->br_blockcount = alen; got->br_blockcount = alen;
got->br_state = XFS_EXT_NORM; got->br_state = XFS_EXT_NORM;
xfs_bmap_add_extent_hole_delay(ip, lastx, got);
error = xfs_bmap_add_extent(NULL, ip, lastx, &cur, got, &firstblock,
NULL, &tmp_logflags, XFS_DATA_FORK);
ASSERT(!error);
ASSERT(!tmp_logflags);
ASSERT(!cur);
/* /*
* Update our extent pointer, given that xfs_bmap_add_extent might * Update our extent pointer, given that xfs_bmap_add_extent_hole_delay
* have merged it into one of the neighbouring ones. * might have merged it into one of the neighbouring ones.
*/ */
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), got); xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), got);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment