Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269899
b: refs/heads/master
c: baf41a5
h: refs/heads/master
i:
  269897: 5e7564d
  269895: a62bff2
v: v3
  • Loading branch information
Dave Chinner authored and Alex Elder committed Oct 12, 2011
1 parent eba5ef9 commit cb18e5f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 51 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1b16447ba24ae39c7fe7133fcdcb4f174dec1901
refs/heads/master: baf41a52b9c62f9a825371806129ed12e2c1e2d8
93 changes: 45 additions & 48 deletions trunk/fs/xfs/xfs_bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2013,18 +2013,18 @@ xfs_bmap_adjacent(
* If allocating at eof, and there's a previous real block,
* try to use its last block as our starting point.
*/
if (ap->eof && ap->prevp->br_startoff != NULLFILEOFF &&
!isnullstartblock(ap->prevp->br_startblock) &&
ISVALID(ap->prevp->br_startblock + ap->prevp->br_blockcount,
ap->prevp->br_startblock)) {
ap->rval = ap->prevp->br_startblock + ap->prevp->br_blockcount;
if (ap->eof && ap->prev.br_startoff != NULLFILEOFF &&
!isnullstartblock(ap->prev.br_startblock) &&
ISVALID(ap->prev.br_startblock + ap->prev.br_blockcount,
ap->prev.br_startblock)) {
ap->rval = ap->prev.br_startblock + ap->prev.br_blockcount;
/*
* Adjust for the gap between prevp and us.
*/
adjust = ap->off -
(ap->prevp->br_startoff + ap->prevp->br_blockcount);
(ap->prev.br_startoff + ap->prev.br_blockcount);
if (adjust &&
ISVALID(ap->rval + adjust, ap->prevp->br_startblock))
ISVALID(ap->rval + adjust, ap->prev.br_startblock))
ap->rval += adjust;
}
/*
Expand All @@ -2042,17 +2042,17 @@ xfs_bmap_adjacent(
* If there's a previous (left) block, select a requested
* start block based on it.
*/
if (ap->prevp->br_startoff != NULLFILEOFF &&
!isnullstartblock(ap->prevp->br_startblock) &&
(prevbno = ap->prevp->br_startblock +
ap->prevp->br_blockcount) &&
ISVALID(prevbno, ap->prevp->br_startblock)) {
if (ap->prev.br_startoff != NULLFILEOFF &&
!isnullstartblock(ap->prev.br_startblock) &&
(prevbno = ap->prev.br_startblock +
ap->prev.br_blockcount) &&
ISVALID(prevbno, ap->prev.br_startblock)) {
/*
* Calculate gap to end of previous block.
*/
adjust = prevdiff = ap->off -
(ap->prevp->br_startoff +
ap->prevp->br_blockcount);
(ap->prev.br_startoff +
ap->prev.br_blockcount);
/*
* Figure the startblock based on the previous block's
* end and the gap size.
Expand All @@ -2063,7 +2063,7 @@ xfs_bmap_adjacent(
*/
if (prevdiff <= XFS_ALLOC_GAP_UNITS * ap->alen &&
ISVALID(prevbno + prevdiff,
ap->prevp->br_startblock))
ap->prev.br_startblock))
prevbno += adjust;
else
prevdiff += adjust;
Expand All @@ -2084,16 +2084,16 @@ xfs_bmap_adjacent(
* If there's a following (right) block, select a requested
* start block based on it.
*/
if (!isnullstartblock(ap->gotp->br_startblock)) {
if (!isnullstartblock(ap->got.br_startblock)) {
/*
* 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
* start and the gap size.
*/
gotbno = ap->gotp->br_startblock;
gotbno = ap->got.br_startblock;
/*
* Heuristic!
* If the gap is large relative to the piece we're
Expand Down Expand Up @@ -2151,7 +2151,7 @@ xfs_bmap_rtalloc(
mp = ap->ip->i_mount;
align = xfs_get_extsz_hint(ap->ip);
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,
ap->conv, &ap->off, &ap->alen);
if (error)
Expand Down Expand Up @@ -2374,7 +2374,7 @@ xfs_bmap_btalloc(
mp = ap->ip->i_mount;
align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0;
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,
&ap->off, &ap->alen);
ASSERT(!error);
Expand Down Expand Up @@ -4619,17 +4619,17 @@ xfs_bmapi_allocate(
* for in this bmap call but that wouldn't be as good.
*/
if (bma->wasdel) {
alen = (xfs_extlen_t)bma->gotp->br_blockcount;
aoff = bma->gotp->br_startoff;
alen = (xfs_extlen_t)bma->got.br_blockcount;
aoff = bma->got.br_startoff;
if (*lastx != NULLEXTNUM && *lastx) {
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1),
bma->prevp);
&bma->prev);
}
} else {
alen = (xfs_extlen_t)XFS_FILBLKS_MIN(bma->alen, MAXEXTLEN);
if (!bma->eof)
alen = (xfs_extlen_t)XFS_FILBLKS_MIN(alen,
bma->gotp->br_startoff - bma->off);
bma->got.br_startoff - bma->off);
aoff = bma->off;
}

Expand Down Expand Up @@ -4700,25 +4700,25 @@ xfs_bmapi_allocate(
(*cur)->bc_private.b.flags =
bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;

bma->gotp->br_startoff = aoff;
bma->gotp->br_startblock = abno;
bma->gotp->br_blockcount = alen;
bma->gotp->br_state = XFS_EXT_NORM;
bma->got.br_startoff = aoff;
bma->got.br_startblock = abno;
bma->got.br_blockcount = alen;
bma->got.br_state = XFS_EXT_NORM;

/*
* A wasdelay extent has been initialized, so shouldn't be flagged
* as unwritten.
*/
if (!bma->wasdel && (flags & XFS_BMAPI_PREALLOC) &&
xfs_sb_version_hasextflgbit(&mp->m_sb))
bma->gotp->br_state = XFS_EXT_UNWRITTEN;
bma->got.br_state = XFS_EXT_UNWRITTEN;

if (bma->wasdel) {
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 {
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);
}

Expand All @@ -4730,13 +4730,12 @@ xfs_bmapi_allocate(
* or xfs_bmap_add_extent_hole_real might have merged it into one 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);

ASSERT(bma->gotp->br_startoff <= aoff);
ASSERT(bma->gotp->br_startoff + bma->gotp->br_blockcount >=
aoff + alen);
ASSERT(bma->gotp->br_state == XFS_EXT_NORM ||
bma->gotp->br_state == XFS_EXT_UNWRITTEN);
ASSERT(bma->got.br_startoff <= aoff);
ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= aoff + alen);
ASSERT(bma->got.br_state == XFS_EXT_NORM ||
bma->got.br_state == XFS_EXT_UNWRITTEN);
return 0;
}

Expand Down Expand Up @@ -4793,7 +4792,7 @@ xfs_bmapi_convert_unwritten(
* xfs_bmap_add_extent_unwritten_real might have merged it into one
* 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,
Expand Down Expand Up @@ -4837,14 +4836,12 @@ xfs_bmapi_write(
xfs_fileoff_t end; /* end of mapped file region */
int eof; /* after the end of extents */
int error; /* error return */
struct xfs_bmbt_irec got; /* current file extent record */
xfs_extnum_t lastx; /* last useful extent number */
int logflags; /* flags for transaction logging */
xfs_extlen_t minleft; /* min blocks left after allocation */
int n; /* current extent index */
int nallocs; /* number of extents alloc'd */
xfs_fileoff_t obno; /* old block number (offset) */
struct xfs_bmbt_irec prev; /* previous file extent record */
int tmp_logflags; /* temp flags holder */
int whichfork; /* data or attr fork */
char inhole; /* current location is hole in file */
Expand Down Expand Up @@ -4916,21 +4913,20 @@ xfs_bmapi_write(
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;
end = bno + len;
obno = bno;

bma.tp = tp;
bma.ip = ip;
bma.prevp = &prev;
bma.gotp = &got;
bma.total = total;
bma.userdata = 0;

while (bno < end && n < *nmap) {
inhole = eof || got.br_startoff > bno;
wasdelay = !inhole && isnullstartblock(got.br_startblock);
inhole = eof || bma.got.br_startoff > bno;
wasdelay = !inhole && isnullstartblock(bma.got.br_startblock);

/*
* First, deal with the hole before the allocated space
Expand All @@ -4957,7 +4953,8 @@ xfs_bmapi_write(
}

/* 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 */
error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx,
Expand All @@ -4981,9 +4978,9 @@ xfs_bmapi_write(
break;

/* Else go on to the next record. */
prev = got;
bma.prev = bma.got;
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
eof = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/xfs/xfs_bmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ typedef struct xfs_bmalloca {
xfs_fileoff_t off; /* offset in file filling in */
struct xfs_trans *tp; /* transaction pointer */
struct xfs_inode *ip; /* incore inode pointer */
struct xfs_bmbt_irec *prevp; /* extent before the new one */
struct xfs_bmbt_irec *gotp; /* extent after, or delayed */
struct xfs_bmbt_irec prev; /* extent before the new one */
struct xfs_bmbt_irec got; /* extent after, or delayed */
xfs_extlen_t alen; /* i/o length asked/allocated */
xfs_extlen_t total; /* total blocks needed for xaction */
xfs_extlen_t minlen; /* minimum allocation size (blocks) */
Expand Down

0 comments on commit cb18e5f

Please sign in to comment.