xfs: move extent records into bmalloca structure
Rather that putting extent records on the stack and then pointing to them in the bmalloca structure which is in the same stack frame, put the extent records directly in the bmalloca structure. This reduces the number of args that need to be passed around. Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
This commit is contained in:
parent
1b16447ba2
commit
baf41a52b9
@ -2013,18 +2013,18 @@ xfs_bmap_adjacent(
|
|||||||
* If allocating at eof, and there's a previous real block,
|
* If allocating at eof, and there's a previous real block,
|
||||||
* try to use its last block as our starting point.
|
* try to use its last block as our starting point.
|
||||||
*/
|
*/
|
||||||
if (ap->eof && ap->prevp->br_startoff != NULLFILEOFF &&
|
if (ap->eof && ap->prev.br_startoff != NULLFILEOFF &&
|
||||||
!isnullstartblock(ap->prevp->br_startblock) &&
|
!isnullstartblock(ap->prev.br_startblock) &&
|
||||||
ISVALID(ap->prevp->br_startblock + ap->prevp->br_blockcount,
|
ISVALID(ap->prev.br_startblock + ap->prev.br_blockcount,
|
||||||
ap->prevp->br_startblock)) {
|
ap->prev.br_startblock)) {
|
||||||
ap->rval = ap->prevp->br_startblock + ap->prevp->br_blockcount;
|
ap->rval = ap->prev.br_startblock + ap->prev.br_blockcount;
|
||||||
/*
|
/*
|
||||||
* Adjust for the gap between prevp and us.
|
* Adjust for the gap between prevp and us.
|
||||||
*/
|
*/
|
||||||
adjust = ap->off -
|
adjust = ap->off -
|
||||||
(ap->prevp->br_startoff + ap->prevp->br_blockcount);
|
(ap->prev.br_startoff + ap->prev.br_blockcount);
|
||||||
if (adjust &&
|
if (adjust &&
|
||||||
ISVALID(ap->rval + adjust, ap->prevp->br_startblock))
|
ISVALID(ap->rval + adjust, ap->prev.br_startblock))
|
||||||
ap->rval += adjust;
|
ap->rval += adjust;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -2042,17 +2042,17 @@ xfs_bmap_adjacent(
|
|||||||
* If there's a previous (left) block, select a requested
|
* If there's a previous (left) block, select a requested
|
||||||
* start block based on it.
|
* start block based on it.
|
||||||
*/
|
*/
|
||||||
if (ap->prevp->br_startoff != NULLFILEOFF &&
|
if (ap->prev.br_startoff != NULLFILEOFF &&
|
||||||
!isnullstartblock(ap->prevp->br_startblock) &&
|
!isnullstartblock(ap->prev.br_startblock) &&
|
||||||
(prevbno = ap->prevp->br_startblock +
|
(prevbno = ap->prev.br_startblock +
|
||||||
ap->prevp->br_blockcount) &&
|
ap->prev.br_blockcount) &&
|
||||||
ISVALID(prevbno, ap->prevp->br_startblock)) {
|
ISVALID(prevbno, ap->prev.br_startblock)) {
|
||||||
/*
|
/*
|
||||||
* Calculate gap to end of previous block.
|
* Calculate gap to end of previous block.
|
||||||
*/
|
*/
|
||||||
adjust = prevdiff = ap->off -
|
adjust = prevdiff = ap->off -
|
||||||
(ap->prevp->br_startoff +
|
(ap->prev.br_startoff +
|
||||||
ap->prevp->br_blockcount);
|
ap->prev.br_blockcount);
|
||||||
/*
|
/*
|
||||||
* Figure the startblock based on the previous block's
|
* Figure the startblock based on the previous block's
|
||||||
* end and the gap size.
|
* end and the gap size.
|
||||||
@ -2063,7 +2063,7 @@ xfs_bmap_adjacent(
|
|||||||
*/
|
*/
|
||||||
if (prevdiff <= XFS_ALLOC_GAP_UNITS * ap->alen &&
|
if (prevdiff <= XFS_ALLOC_GAP_UNITS * ap->alen &&
|
||||||
ISVALID(prevbno + prevdiff,
|
ISVALID(prevbno + prevdiff,
|
||||||
ap->prevp->br_startblock))
|
ap->prev.br_startblock))
|
||||||
prevbno += adjust;
|
prevbno += adjust;
|
||||||
else
|
else
|
||||||
prevdiff += adjust;
|
prevdiff += adjust;
|
||||||
@ -2084,16 +2084,16 @@ xfs_bmap_adjacent(
|
|||||||
* If there's a following (right) block, select a requested
|
* If there's a following (right) block, select a requested
|
||||||
* start block based on it.
|
* start block based on it.
|
||||||
*/
|
*/
|
||||||
if (!isnullstartblock(ap->gotp->br_startblock)) {
|
if (!isnullstartblock(ap->got.br_startblock)) {
|
||||||
/*
|
/*
|
||||||
* Calculate gap to start of next block.
|
* Calculate gap to start of next block.
|
||||||
*/
|
*/
|
||||||
adjust = gotdiff = ap->gotp->br_startoff - ap->off;
|
adjust = gotdiff = ap->got.br_startoff - ap->off;
|
||||||
/*
|
/*
|
||||||
* Figure the startblock based on the next block's
|
* Figure the startblock based on the next block's
|
||||||
* start and the gap size.
|
* start and the gap size.
|
||||||
*/
|
*/
|
||||||
gotbno = ap->gotp->br_startblock;
|
gotbno = ap->got.br_startblock;
|
||||||
/*
|
/*
|
||||||
* Heuristic!
|
* Heuristic!
|
||||||
* If the gap is large relative to the piece we're
|
* If the gap is large relative to the piece we're
|
||||||
@ -2151,7 +2151,7 @@ xfs_bmap_rtalloc(
|
|||||||
mp = ap->ip->i_mount;
|
mp = ap->ip->i_mount;
|
||||||
align = xfs_get_extsz_hint(ap->ip);
|
align = xfs_get_extsz_hint(ap->ip);
|
||||||
prod = align / mp->m_sb.sb_rextsize;
|
prod = align / mp->m_sb.sb_rextsize;
|
||||||
error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
|
error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
|
||||||
align, 1, ap->eof, 0,
|
align, 1, ap->eof, 0,
|
||||||
ap->conv, &ap->off, &ap->alen);
|
ap->conv, &ap->off, &ap->alen);
|
||||||
if (error)
|
if (error)
|
||||||
@ -2374,7 +2374,7 @@ xfs_bmap_btalloc(
|
|||||||
mp = ap->ip->i_mount;
|
mp = ap->ip->i_mount;
|
||||||
align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0;
|
align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0;
|
||||||
if (unlikely(align)) {
|
if (unlikely(align)) {
|
||||||
error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
|
error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
|
||||||
align, 0, ap->eof, 0, ap->conv,
|
align, 0, ap->eof, 0, ap->conv,
|
||||||
&ap->off, &ap->alen);
|
&ap->off, &ap->alen);
|
||||||
ASSERT(!error);
|
ASSERT(!error);
|
||||||
@ -4619,17 +4619,17 @@ xfs_bmapi_allocate(
|
|||||||
* for in this bmap call but that wouldn't be as good.
|
* for in this bmap call but that wouldn't be as good.
|
||||||
*/
|
*/
|
||||||
if (bma->wasdel) {
|
if (bma->wasdel) {
|
||||||
alen = (xfs_extlen_t)bma->gotp->br_blockcount;
|
alen = (xfs_extlen_t)bma->got.br_blockcount;
|
||||||
aoff = bma->gotp->br_startoff;
|
aoff = bma->got.br_startoff;
|
||||||
if (*lastx != NULLEXTNUM && *lastx) {
|
if (*lastx != NULLEXTNUM && *lastx) {
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1),
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1),
|
||||||
bma->prevp);
|
&bma->prev);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alen = (xfs_extlen_t)XFS_FILBLKS_MIN(bma->alen, MAXEXTLEN);
|
alen = (xfs_extlen_t)XFS_FILBLKS_MIN(bma->alen, MAXEXTLEN);
|
||||||
if (!bma->eof)
|
if (!bma->eof)
|
||||||
alen = (xfs_extlen_t)XFS_FILBLKS_MIN(alen,
|
alen = (xfs_extlen_t)XFS_FILBLKS_MIN(alen,
|
||||||
bma->gotp->br_startoff - bma->off);
|
bma->got.br_startoff - bma->off);
|
||||||
aoff = bma->off;
|
aoff = bma->off;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4700,10 +4700,10 @@ xfs_bmapi_allocate(
|
|||||||
(*cur)->bc_private.b.flags =
|
(*cur)->bc_private.b.flags =
|
||||||
bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
|
bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
|
||||||
|
|
||||||
bma->gotp->br_startoff = aoff;
|
bma->got.br_startoff = aoff;
|
||||||
bma->gotp->br_startblock = abno;
|
bma->got.br_startblock = abno;
|
||||||
bma->gotp->br_blockcount = alen;
|
bma->got.br_blockcount = alen;
|
||||||
bma->gotp->br_state = XFS_EXT_NORM;
|
bma->got.br_state = XFS_EXT_NORM;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A wasdelay extent has been initialized, so shouldn't be flagged
|
* A wasdelay extent has been initialized, so shouldn't be flagged
|
||||||
@ -4711,14 +4711,14 @@ xfs_bmapi_allocate(
|
|||||||
*/
|
*/
|
||||||
if (!bma->wasdel && (flags & XFS_BMAPI_PREALLOC) &&
|
if (!bma->wasdel && (flags & XFS_BMAPI_PREALLOC) &&
|
||||||
xfs_sb_version_hasextflgbit(&mp->m_sb))
|
xfs_sb_version_hasextflgbit(&mp->m_sb))
|
||||||
bma->gotp->br_state = XFS_EXT_UNWRITTEN;
|
bma->got.br_state = XFS_EXT_UNWRITTEN;
|
||||||
|
|
||||||
if (bma->wasdel) {
|
if (bma->wasdel) {
|
||||||
error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, lastx,
|
error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, lastx,
|
||||||
cur, bma->gotp, firstblock, flist, logflags);
|
cur, &bma->got, firstblock, flist, logflags);
|
||||||
} else {
|
} else {
|
||||||
error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, lastx,
|
error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, lastx,
|
||||||
cur, bma->gotp, firstblock, flist, logflags,
|
cur, &bma->got, firstblock, flist, logflags,
|
||||||
whichfork);
|
whichfork);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4730,13 +4730,12 @@ xfs_bmapi_allocate(
|
|||||||
* or xfs_bmap_add_extent_hole_real might have merged it into one of
|
* or xfs_bmap_add_extent_hole_real might have merged it into one of
|
||||||
* the neighbouring ones.
|
* the neighbouring ones.
|
||||||
*/
|
*/
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), bma->gotp);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got);
|
||||||
|
|
||||||
ASSERT(bma->gotp->br_startoff <= aoff);
|
ASSERT(bma->got.br_startoff <= aoff);
|
||||||
ASSERT(bma->gotp->br_startoff + bma->gotp->br_blockcount >=
|
ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= aoff + alen);
|
||||||
aoff + alen);
|
ASSERT(bma->got.br_state == XFS_EXT_NORM ||
|
||||||
ASSERT(bma->gotp->br_state == XFS_EXT_NORM ||
|
bma->got.br_state == XFS_EXT_UNWRITTEN);
|
||||||
bma->gotp->br_state == XFS_EXT_UNWRITTEN);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4793,7 +4792,7 @@ xfs_bmapi_convert_unwritten(
|
|||||||
* xfs_bmap_add_extent_unwritten_real might have merged it into one
|
* xfs_bmap_add_extent_unwritten_real might have merged it into one
|
||||||
* of the neighbouring ones.
|
* of the neighbouring ones.
|
||||||
*/
|
*/
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), bma->gotp);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We may have combined previously unwritten space with written space,
|
* We may have combined previously unwritten space with written space,
|
||||||
@ -4837,14 +4836,12 @@ xfs_bmapi_write(
|
|||||||
xfs_fileoff_t end; /* end of mapped file region */
|
xfs_fileoff_t end; /* end of mapped file region */
|
||||||
int eof; /* after the end of extents */
|
int eof; /* after the end of extents */
|
||||||
int error; /* error return */
|
int error; /* error return */
|
||||||
struct xfs_bmbt_irec got; /* current file extent record */
|
|
||||||
xfs_extnum_t lastx; /* last useful extent number */
|
xfs_extnum_t lastx; /* last useful extent number */
|
||||||
int logflags; /* flags for transaction logging */
|
int logflags; /* flags for transaction logging */
|
||||||
xfs_extlen_t minleft; /* min blocks left after allocation */
|
xfs_extlen_t minleft; /* min blocks left after allocation */
|
||||||
int n; /* current extent index */
|
int n; /* current extent index */
|
||||||
int nallocs; /* number of extents alloc'd */
|
int nallocs; /* number of extents alloc'd */
|
||||||
xfs_fileoff_t obno; /* old block number (offset) */
|
xfs_fileoff_t obno; /* old block number (offset) */
|
||||||
struct xfs_bmbt_irec prev; /* previous file extent record */
|
|
||||||
int tmp_logflags; /* temp flags holder */
|
int tmp_logflags; /* temp flags holder */
|
||||||
int whichfork; /* data or attr fork */
|
int whichfork; /* data or attr fork */
|
||||||
char inhole; /* current location is hole in file */
|
char inhole; /* current location is hole in file */
|
||||||
@ -4916,21 +4913,20 @@ xfs_bmapi_write(
|
|||||||
goto error0;
|
goto error0;
|
||||||
}
|
}
|
||||||
|
|
||||||
xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &got, &prev);
|
xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &bma.got,
|
||||||
|
&bma.prev);
|
||||||
n = 0;
|
n = 0;
|
||||||
end = bno + len;
|
end = bno + len;
|
||||||
obno = bno;
|
obno = bno;
|
||||||
|
|
||||||
bma.tp = tp;
|
bma.tp = tp;
|
||||||
bma.ip = ip;
|
bma.ip = ip;
|
||||||
bma.prevp = &prev;
|
|
||||||
bma.gotp = &got;
|
|
||||||
bma.total = total;
|
bma.total = total;
|
||||||
bma.userdata = 0;
|
bma.userdata = 0;
|
||||||
|
|
||||||
while (bno < end && n < *nmap) {
|
while (bno < end && n < *nmap) {
|
||||||
inhole = eof || got.br_startoff > bno;
|
inhole = eof || bma.got.br_startoff > bno;
|
||||||
wasdelay = !inhole && isnullstartblock(got.br_startblock);
|
wasdelay = !inhole && isnullstartblock(bma.got.br_startblock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First, deal with the hole before the allocated space
|
* First, deal with the hole before the allocated space
|
||||||
@ -4957,7 +4953,8 @@ xfs_bmapi_write(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Deal with the allocated space we found. */
|
/* Deal with the allocated space we found. */
|
||||||
xfs_bmapi_trim_map(mval, &got, &bno, len, obno, end, n, flags);
|
xfs_bmapi_trim_map(mval, &bma.got, &bno, len, obno,
|
||||||
|
end, n, flags);
|
||||||
|
|
||||||
/* Execute unwritten extent conversion if necessary */
|
/* Execute unwritten extent conversion if necessary */
|
||||||
error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx,
|
error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx,
|
||||||
@ -4981,9 +4978,9 @@ xfs_bmapi_write(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* Else go on to the next record. */
|
/* Else go on to the next record. */
|
||||||
prev = got;
|
bma.prev = bma.got;
|
||||||
if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
|
if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
|
||||||
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got);
|
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &bma.got);
|
||||||
else
|
else
|
||||||
eof = 1;
|
eof = 1;
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,8 @@ typedef struct xfs_bmalloca {
|
|||||||
xfs_fileoff_t off; /* offset in file filling in */
|
xfs_fileoff_t off; /* offset in file filling in */
|
||||||
struct xfs_trans *tp; /* transaction pointer */
|
struct xfs_trans *tp; /* transaction pointer */
|
||||||
struct xfs_inode *ip; /* incore inode pointer */
|
struct xfs_inode *ip; /* incore inode pointer */
|
||||||
struct xfs_bmbt_irec *prevp; /* extent before the new one */
|
struct xfs_bmbt_irec prev; /* extent before the new one */
|
||||||
struct xfs_bmbt_irec *gotp; /* extent after, or delayed */
|
struct xfs_bmbt_irec got; /* extent after, or delayed */
|
||||||
xfs_extlen_t alen; /* i/o length asked/allocated */
|
xfs_extlen_t alen; /* i/o length asked/allocated */
|
||||||
xfs_extlen_t total; /* total blocks needed for xaction */
|
xfs_extlen_t total; /* total blocks needed for xaction */
|
||||||
xfs_extlen_t minlen; /* minimum allocation size (blocks) */
|
xfs_extlen_t minlen; /* minimum allocation size (blocks) */
|
||||||
|
Loading…
Reference in New Issue
Block a user