aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2011-09-18 16:40:56 -0400
committerAlex Elder <aelder@sgi.com>2011-10-11 22:15:05 -0400
commitbaf41a52b9c62f9a825371806129ed12e2c1e2d8 (patch)
tree18779d98f2e82d24bdda9252d003960f474d4049 /fs/xfs
parent1b16447ba24ae39c7fe7133fcdcb4f174dec1901 (diff)
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_bmap.c93
-rw-r--r--fs/xfs/xfs_bmap.h4
2 files changed, 47 insertions, 50 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index e2eb3ba5b420..68edf99bfad6 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -2013,18 +2013,18 @@ xfs_bmap_adjacent(
2013 * If allocating at eof, and there's a previous real block, 2013 * If allocating at eof, and there's a previous real block,
2014 * try to use its last block as our starting point. 2014 * try to use its last block as our starting point.
2015 */ 2015 */
2016 if (ap->eof && ap->prevp->br_startoff != NULLFILEOFF && 2016 if (ap->eof && ap->prev.br_startoff != NULLFILEOFF &&
2017 !isnullstartblock(ap->prevp->br_startblock) && 2017 !isnullstartblock(ap->prev.br_startblock) &&
2018 ISVALID(ap->prevp->br_startblock + ap->prevp->br_blockcount, 2018 ISVALID(ap->prev.br_startblock + ap->prev.br_blockcount,
2019 ap->prevp->br_startblock)) { 2019 ap->prev.br_startblock)) {
2020 ap->rval = ap->prevp->br_startblock + ap->prevp->br_blockcount; 2020 ap->rval = ap->prev.br_startblock + ap->prev.br_blockcount;
2021 /* 2021 /*
2022 * Adjust for the gap between prevp and us. 2022 * Adjust for the gap between prevp and us.
2023 */ 2023 */
2024 adjust = ap->off - 2024 adjust = ap->off -
2025 (ap->prevp->br_startoff + ap->prevp->br_blockcount); 2025 (ap->prev.br_startoff + ap->prev.br_blockcount);
2026 if (adjust && 2026 if (adjust &&
2027 ISVALID(ap->rval + adjust, ap->prevp->br_startblock)) 2027 ISVALID(ap->rval + adjust, ap->prev.br_startblock))
2028 ap->rval += adjust; 2028 ap->rval += adjust;
2029 } 2029 }
2030 /* 2030 /*
@@ -2042,17 +2042,17 @@ xfs_bmap_adjacent(
2042 * If there's a previous (left) block, select a requested 2042 * If there's a previous (left) block, select a requested
2043 * start block based on it. 2043 * start block based on it.
2044 */ 2044 */
2045 if (ap->prevp->br_startoff != NULLFILEOFF && 2045 if (ap->prev.br_startoff != NULLFILEOFF &&
2046 !isnullstartblock(ap->prevp->br_startblock) && 2046 !isnullstartblock(ap->prev.br_startblock) &&
2047 (prevbno = ap->prevp->br_startblock + 2047 (prevbno = ap->prev.br_startblock +
2048 ap->prevp->br_blockcount) && 2048 ap->prev.br_blockcount) &&
2049 ISVALID(prevbno, ap->prevp->br_startblock)) { 2049 ISVALID(prevbno, ap->prev.br_startblock)) {
2050 /* 2050 /*
2051 * Calculate gap to end of previous block. 2051 * Calculate gap to end of previous block.
2052 */ 2052 */
2053 adjust = prevdiff = ap->off - 2053 adjust = prevdiff = ap->off -
2054 (ap->prevp->br_startoff + 2054 (ap->prev.br_startoff +
2055 ap->prevp->br_blockcount); 2055 ap->prev.br_blockcount);
2056 /* 2056 /*
2057 * Figure the startblock based on the previous block's 2057 * Figure the startblock based on the previous block's
2058 * end and the gap size. 2058 * end and the gap size.
@@ -2063,7 +2063,7 @@ xfs_bmap_adjacent(
2063 */ 2063 */
2064 if (prevdiff <= XFS_ALLOC_GAP_UNITS * ap->alen && 2064 if (prevdiff <= XFS_ALLOC_GAP_UNITS * ap->alen &&
2065 ISVALID(prevbno + prevdiff, 2065 ISVALID(prevbno + prevdiff,
2066 ap->prevp->br_startblock)) 2066 ap->prev.br_startblock))
2067 prevbno += adjust; 2067 prevbno += adjust;
2068 else 2068 else
2069 prevdiff += adjust; 2069 prevdiff += adjust;
@@ -2084,16 +2084,16 @@ xfs_bmap_adjacent(
2084 * If there's a following (right) block, select a requested 2084 * If there's a following (right) block, select a requested
2085 * start block based on it. 2085 * start block based on it.
2086 */ 2086 */
2087 if (!isnullstartblock(ap->gotp->br_startblock)) { 2087 if (!isnullstartblock(ap->got.br_startblock)) {
2088 /* 2088 /*
2089 * Calculate gap to start of next block. 2089 * Calculate gap to start of next block.
2090 */ 2090 */
2091 adjust = gotdiff = ap->gotp->br_startoff - ap->off; 2091 adjust = gotdiff = ap->got.br_startoff - ap->off;
2092 /* 2092 /*
2093 * Figure the startblock based on the next block's 2093 * Figure the startblock based on the next block's
2094 * start and the gap size. 2094 * start and the gap size.
2095 */ 2095 */
2096 gotbno = ap->gotp->br_startblock; 2096 gotbno = ap->got.br_startblock;
2097 /* 2097 /*
2098 * Heuristic! 2098 * Heuristic!
2099 * If the gap is large relative to the piece we're 2099 * If the gap is large relative to the piece we're
@@ -2151,7 +2151,7 @@ xfs_bmap_rtalloc(
2151 mp = ap->ip->i_mount; 2151 mp = ap->ip->i_mount;
2152 align = xfs_get_extsz_hint(ap->ip); 2152 align = xfs_get_extsz_hint(ap->ip);
2153 prod = align / mp->m_sb.sb_rextsize; 2153 prod = align / mp->m_sb.sb_rextsize;
2154 error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, 2154 error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
2155 align, 1, ap->eof, 0, 2155 align, 1, ap->eof, 0,
2156 ap->conv, &ap->off, &ap->alen); 2156 ap->conv, &ap->off, &ap->alen);
2157 if (error) 2157 if (error)
@@ -2374,7 +2374,7 @@ xfs_bmap_btalloc(
2374 mp = ap->ip->i_mount; 2374 mp = ap->ip->i_mount;
2375 align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0; 2375 align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0;
2376 if (unlikely(align)) { 2376 if (unlikely(align)) {
2377 error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, 2377 error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
2378 align, 0, ap->eof, 0, ap->conv, 2378 align, 0, ap->eof, 0, ap->conv,
2379 &ap->off, &ap->alen); 2379 &ap->off, &ap->alen);
2380 ASSERT(!error); 2380 ASSERT(!error);
@@ -4619,17 +4619,17 @@ xfs_bmapi_allocate(
4619 * for in this bmap call but that wouldn't be as good. 4619 * for in this bmap call but that wouldn't be as good.
4620 */ 4620 */
4621 if (bma->wasdel) { 4621 if (bma->wasdel) {
4622 alen = (xfs_extlen_t)bma->gotp->br_blockcount; 4622 alen = (xfs_extlen_t)bma->got.br_blockcount;
4623 aoff = bma->gotp->br_startoff; 4623 aoff = bma->got.br_startoff;
4624 if (*lastx != NULLEXTNUM && *lastx) { 4624 if (*lastx != NULLEXTNUM && *lastx) {
4625 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1), 4625 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1),
4626 bma->prevp); 4626 &bma->prev);
4627 } 4627 }
4628 } else { 4628 } else {
4629 alen = (xfs_extlen_t)XFS_FILBLKS_MIN(bma->alen, MAXEXTLEN); 4629 alen = (xfs_extlen_t)XFS_FILBLKS_MIN(bma->alen, MAXEXTLEN);
4630 if (!bma->eof) 4630 if (!bma->eof)
4631 alen = (xfs_extlen_t)XFS_FILBLKS_MIN(alen, 4631 alen = (xfs_extlen_t)XFS_FILBLKS_MIN(alen,
4632 bma->gotp->br_startoff - bma->off); 4632 bma->got.br_startoff - bma->off);
4633 aoff = bma->off; 4633 aoff = bma->off;
4634 } 4634 }
4635 4635
@@ -4700,10 +4700,10 @@ xfs_bmapi_allocate(
4700 (*cur)->bc_private.b.flags = 4700 (*cur)->bc_private.b.flags =
4701 bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0; 4701 bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
4702 4702
4703 bma->gotp->br_startoff = aoff; 4703 bma->got.br_startoff = aoff;
4704 bma->gotp->br_startblock = abno; 4704 bma->got.br_startblock = abno;
4705 bma->gotp->br_blockcount = alen; 4705 bma->got.br_blockcount = alen;
4706 bma->gotp->br_state = XFS_EXT_NORM; 4706 bma->got.br_state = XFS_EXT_NORM;
4707 4707
4708 /* 4708 /*
4709 * A wasdelay extent has been initialized, so shouldn't be flagged 4709 * A wasdelay extent has been initialized, so shouldn't be flagged
@@ -4711,14 +4711,14 @@ xfs_bmapi_allocate(
4711 */ 4711 */
4712 if (!bma->wasdel && (flags & XFS_BMAPI_PREALLOC) && 4712 if (!bma->wasdel && (flags & XFS_BMAPI_PREALLOC) &&
4713 xfs_sb_version_hasextflgbit(&mp->m_sb)) 4713 xfs_sb_version_hasextflgbit(&mp->m_sb))
4714 bma->gotp->br_state = XFS_EXT_UNWRITTEN; 4714 bma->got.br_state = XFS_EXT_UNWRITTEN;
4715 4715
4716 if (bma->wasdel) { 4716 if (bma->wasdel) {
4717 error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, lastx, 4717 error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, lastx,
4718 cur, bma->gotp, firstblock, flist, logflags); 4718 cur, &bma->got, firstblock, flist, logflags);
4719 } else { 4719 } else {
4720 error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, lastx, 4720 error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, lastx,
4721 cur, bma->gotp, firstblock, flist, logflags, 4721 cur, &bma->got, firstblock, flist, logflags,
4722 whichfork); 4722 whichfork);
4723 } 4723 }
4724 4724
@@ -4730,13 +4730,12 @@ xfs_bmapi_allocate(
4730 * or xfs_bmap_add_extent_hole_real might have merged it into one of 4730 * or xfs_bmap_add_extent_hole_real might have merged it into one of
4731 * the neighbouring ones. 4731 * the neighbouring ones.
4732 */ 4732 */
4733 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), bma->gotp); 4733 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got);
4734 4734
4735 ASSERT(bma->gotp->br_startoff <= aoff); 4735 ASSERT(bma->got.br_startoff <= aoff);
4736 ASSERT(bma->gotp->br_startoff + bma->gotp->br_blockcount >= 4736 ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= aoff + alen);
4737 aoff + alen); 4737 ASSERT(bma->got.br_state == XFS_EXT_NORM ||
4738 ASSERT(bma->gotp->br_state == XFS_EXT_NORM || 4738 bma->got.br_state == XFS_EXT_UNWRITTEN);
4739 bma->gotp->br_state == XFS_EXT_UNWRITTEN);
4740 return 0; 4739 return 0;
4741} 4740}
4742 4741
@@ -4793,7 +4792,7 @@ xfs_bmapi_convert_unwritten(
4793 * xfs_bmap_add_extent_unwritten_real might have merged it into one 4792 * xfs_bmap_add_extent_unwritten_real might have merged it into one
4794 * of the neighbouring ones. 4793 * of the neighbouring ones.
4795 */ 4794 */
4796 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), bma->gotp); 4795 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got);
4797 4796
4798 /* 4797 /*
4799 * We may have combined previously unwritten space with written space, 4798 * We may have combined previously unwritten space with written space,
@@ -4837,14 +4836,12 @@ xfs_bmapi_write(
4837 xfs_fileoff_t end; /* end of mapped file region */ 4836 xfs_fileoff_t end; /* end of mapped file region */
4838 int eof; /* after the end of extents */ 4837 int eof; /* after the end of extents */
4839 int error; /* error return */ 4838 int error; /* error return */
4840 struct xfs_bmbt_irec got; /* current file extent record */
4841 xfs_extnum_t lastx; /* last useful extent number */ 4839 xfs_extnum_t lastx; /* last useful extent number */
4842 int logflags; /* flags for transaction logging */ 4840 int logflags; /* flags for transaction logging */
4843 xfs_extlen_t minleft; /* min blocks left after allocation */ 4841 xfs_extlen_t minleft; /* min blocks left after allocation */
4844 int n; /* current extent index */ 4842 int n; /* current extent index */
4845 int nallocs; /* number of extents alloc'd */ 4843 int nallocs; /* number of extents alloc'd */
4846 xfs_fileoff_t obno; /* old block number (offset) */ 4844 xfs_fileoff_t obno; /* old block number (offset) */
4847 struct xfs_bmbt_irec prev; /* previous file extent record */
4848 int tmp_logflags; /* temp flags holder */ 4845 int tmp_logflags; /* temp flags holder */
4849 int whichfork; /* data or attr fork */ 4846 int whichfork; /* data or attr fork */
4850 char inhole; /* current location is hole in file */ 4847 char inhole; /* current location is hole in file */
@@ -4916,21 +4913,20 @@ xfs_bmapi_write(
4916 goto error0; 4913 goto error0;
4917 } 4914 }
4918 4915
4919 xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &got, &prev); 4916 xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &bma.got,
4917 &bma.prev);
4920 n = 0; 4918 n = 0;
4921 end = bno + len; 4919 end = bno + len;
4922 obno = bno; 4920 obno = bno;
4923 4921
4924 bma.tp = tp; 4922 bma.tp = tp;
4925 bma.ip = ip; 4923 bma.ip = ip;
4926 bma.prevp = &prev;
4927 bma.gotp = &got;
4928 bma.total = total; 4924 bma.total = total;
4929 bma.userdata = 0; 4925 bma.userdata = 0;
4930 4926
4931 while (bno < end && n < *nmap) { 4927 while (bno < end && n < *nmap) {
4932 inhole = eof || got.br_startoff > bno; 4928 inhole = eof || bma.got.br_startoff > bno;
4933 wasdelay = !inhole && isnullstartblock(got.br_startblock); 4929 wasdelay = !inhole && isnullstartblock(bma.got.br_startblock);
4934 4930
4935 /* 4931 /*
4936 * First, deal with the hole before the allocated space 4932 * First, deal with the hole before the allocated space
@@ -4957,7 +4953,8 @@ xfs_bmapi_write(
4957 } 4953 }
4958 4954
4959 /* Deal with the allocated space we found. */ 4955 /* Deal with the allocated space we found. */
4960 xfs_bmapi_trim_map(mval, &got, &bno, len, obno, end, n, flags); 4956 xfs_bmapi_trim_map(mval, &bma.got, &bno, len, obno,
4957 end, n, flags);
4961 4958
4962 /* Execute unwritten extent conversion if necessary */ 4959 /* Execute unwritten extent conversion if necessary */
4963 error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx, 4960 error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx,
@@ -4981,9 +4978,9 @@ xfs_bmapi_write(
4981 break; 4978 break;
4982 4979
4983 /* Else go on to the next record. */ 4980 /* Else go on to the next record. */
4984 prev = got; 4981 bma.prev = bma.got;
4985 if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t)) 4982 if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
4986 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got); 4983 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &bma.got);
4987 else 4984 else
4988 eof = 1; 4985 eof = 1;
4989 } 4986 }
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index be235f56d2a6..6e8f8aee7cdb 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -114,8 +114,8 @@ typedef struct xfs_bmalloca {
114 xfs_fileoff_t off; /* offset in file filling in */ 114 xfs_fileoff_t off; /* offset in file filling in */
115 struct xfs_trans *tp; /* transaction pointer */ 115 struct xfs_trans *tp; /* transaction pointer */
116 struct xfs_inode *ip; /* incore inode pointer */ 116 struct xfs_inode *ip; /* incore inode pointer */
117 struct xfs_bmbt_irec *prevp; /* extent before the new one */ 117 struct xfs_bmbt_irec prev; /* extent before the new one */
118 struct xfs_bmbt_irec *gotp; /* extent after, or delayed */ 118 struct xfs_bmbt_irec got; /* extent after, or delayed */
119 xfs_extlen_t alen; /* i/o length asked/allocated */ 119 xfs_extlen_t alen; /* i/o length asked/allocated */
120 xfs_extlen_t total; /* total blocks needed for xaction */ 120 xfs_extlen_t total; /* total blocks needed for xaction */
121 xfs_extlen_t minlen; /* minimum allocation size (blocks) */ 121 xfs_extlen_t minlen; /* minimum allocation size (blocks) */