aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2011-09-18 16:41:01 -0400
committerAlex Elder <aelder@sgi.com>2011-10-11 22:15:06 -0400
commite0c3da5d89dc1aeef2275a8b751231e147603f0f (patch)
tree4409337fb70fba9979d8160d5055e402daa3a692 /fs/xfs/xfs_bmap.c
parent29c8d17a8938be88e36b93522753f3519aefd05d (diff)
xfs: move lastx and nallocs into bmalloca
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/xfs_bmap.c')
-rw-r--r--fs/xfs/xfs_bmap.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index a54326bf9aa0..3ef145307274 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -4607,9 +4607,7 @@ xfs_bmapi_delay(
4607STATIC int 4607STATIC int
4608xfs_bmapi_allocate( 4608xfs_bmapi_allocate(
4609 struct xfs_bmalloca *bma, 4609 struct xfs_bmalloca *bma,
4610 xfs_extnum_t *lastx,
4611 int flags, 4610 int flags,
4612 int *nallocs,
4613 int *logflags) 4611 int *logflags)
4614{ 4612{
4615 struct xfs_mount *mp = bma->ip->i_mount; 4613 struct xfs_mount *mp = bma->ip->i_mount;
@@ -4628,8 +4626,8 @@ xfs_bmapi_allocate(
4628 if (bma->wasdel) { 4626 if (bma->wasdel) {
4629 bma->length = (xfs_extlen_t)bma->got.br_blockcount; 4627 bma->length = (xfs_extlen_t)bma->got.br_blockcount;
4630 bma->offset = bma->got.br_startoff; 4628 bma->offset = bma->got.br_startoff;
4631 if (*lastx != NULLEXTNUM && *lastx) { 4629 if (bma->idx != NULLEXTNUM && bma->idx) {
4632 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1), 4630 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx - 1),
4633 &bma->prev); 4631 &bma->prev);
4634 } 4632 }
4635 } else { 4633 } else {
@@ -4680,7 +4678,7 @@ xfs_bmapi_allocate(
4680 * Bump the number of extents we've allocated 4678 * Bump the number of extents we've allocated
4681 * in this call. 4679 * in this call.
4682 */ 4680 */
4683 (*nallocs)++; 4681 bma->nallocs++;
4684 4682
4685 if (bma->cur) 4683 if (bma->cur)
4686 bma->cur->bc_private.b.flags = 4684 bma->cur->bc_private.b.flags =
@@ -4700,13 +4698,14 @@ xfs_bmapi_allocate(
4700 bma->got.br_state = XFS_EXT_UNWRITTEN; 4698 bma->got.br_state = XFS_EXT_UNWRITTEN;
4701 4699
4702 if (bma->wasdel) { 4700 if (bma->wasdel) {
4703 error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, lastx, 4701 error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip,
4704 &bma->cur, &bma->got, bma->firstblock, 4702 &bma->idx, &bma->cur, &bma->got,
4705 bma->flist, logflags); 4703 bma->firstblock, bma->flist, logflags);
4706 } else { 4704 } else {
4707 error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, lastx, 4705 error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
4708 &bma->cur, &bma->got, bma->firstblock, 4706 &bma->idx, &bma->cur, &bma->got,
4709 bma->flist, logflags, whichfork); 4707 bma->firstblock, bma->flist, logflags,
4708 whichfork);
4710 } 4709 }
4711 4710
4712 if (error) 4711 if (error)
@@ -4717,7 +4716,7 @@ xfs_bmapi_allocate(
4717 * or xfs_bmap_add_extent_hole_real might have merged it into one of 4716 * or xfs_bmap_add_extent_hole_real might have merged it into one of
4718 * the neighbouring ones. 4717 * the neighbouring ones.
4719 */ 4718 */
4720 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got); 4719 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx), &bma->got);
4721 4720
4722 ASSERT(bma->got.br_startoff <= bma->offset); 4721 ASSERT(bma->got.br_startoff <= bma->offset);
4723 ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= 4722 ASSERT(bma->got.br_startoff + bma->got.br_blockcount >=
@@ -4732,7 +4731,6 @@ xfs_bmapi_convert_unwritten(
4732 struct xfs_bmalloca *bma, 4731 struct xfs_bmalloca *bma,
4733 struct xfs_bmbt_irec *mval, 4732 struct xfs_bmbt_irec *mval,
4734 xfs_filblks_t len, 4733 xfs_filblks_t len,
4735 xfs_extnum_t *lastx,
4736 int flags, 4734 int flags,
4737 int *logflags) 4735 int *logflags)
4738{ 4736{
@@ -4767,7 +4765,7 @@ xfs_bmapi_convert_unwritten(
4767 mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) 4765 mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN)
4768 ? XFS_EXT_NORM : XFS_EXT_UNWRITTEN; 4766 ? XFS_EXT_NORM : XFS_EXT_UNWRITTEN;
4769 4767
4770 error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, lastx, 4768 error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, &bma->idx,
4771 &bma->cur, mval, bma->firstblock, bma->flist, logflags); 4769 &bma->cur, mval, bma->firstblock, bma->flist, logflags);
4772 if (error) 4770 if (error)
4773 return error; 4771 return error;
@@ -4777,7 +4775,7 @@ xfs_bmapi_convert_unwritten(
4777 * xfs_bmap_add_extent_unwritten_real might have merged it into one 4775 * xfs_bmap_add_extent_unwritten_real might have merged it into one
4778 * of the neighbouring ones. 4776 * of the neighbouring ones.
4779 */ 4777 */
4780 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got); 4778 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx), &bma->got);
4781 4779
4782 /* 4780 /*
4783 * We may have combined previously unwritten space with written space, 4781 * We may have combined previously unwritten space with written space,
@@ -4820,10 +4818,8 @@ xfs_bmapi_write(
4820 xfs_fileoff_t end; /* end of mapped file region */ 4818 xfs_fileoff_t end; /* end of mapped file region */
4821 int eof; /* after the end of extents */ 4819 int eof; /* after the end of extents */
4822 int error; /* error return */ 4820 int error; /* error return */
4823 xfs_extnum_t lastx; /* last useful extent number */
4824 int logflags; /* flags for transaction logging */ 4821 int logflags; /* flags for transaction logging */
4825 int n; /* current extent index */ 4822 int n; /* current extent index */
4826 int nallocs; /* number of extents alloc'd */
4827 xfs_fileoff_t obno; /* old block number (offset) */ 4823 xfs_fileoff_t obno; /* old block number (offset) */
4828 int tmp_logflags; /* temp flags holder */ 4824 int tmp_logflags; /* temp flags holder */
4829 int whichfork; /* data or attr fork */ 4825 int whichfork; /* data or attr fork */
@@ -4871,7 +4867,6 @@ xfs_bmapi_write(
4871 XFS_STATS_INC(xs_blk_mapw); 4867 XFS_STATS_INC(xs_blk_mapw);
4872 4868
4873 logflags = 0; 4869 logflags = 0;
4874 nallocs = 0;
4875 4870
4876 if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { 4871 if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) {
4877 error = xfs_bmap_local_to_extents(tp, ip, firstblock, total, 4872 error = xfs_bmap_local_to_extents(tp, ip, firstblock, total,
@@ -4895,7 +4890,7 @@ xfs_bmapi_write(
4895 goto error0; 4890 goto error0;
4896 } 4891 }
4897 4892
4898 xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &bma.got, 4893 xfs_bmap_search_extents(ip, bno, whichfork, &eof, &bma.idx, &bma.got,
4899 &bma.prev); 4894 &bma.prev);
4900 n = 0; 4895 n = 0;
4901 end = bno + len; 4896 end = bno + len;
@@ -4923,8 +4918,7 @@ xfs_bmapi_write(
4923 bma.length = len; 4918 bma.length = len;
4924 bma.offset = bno; 4919 bma.offset = bno;
4925 4920
4926 error = xfs_bmapi_allocate(&bma, &lastx, flags, 4921 error = xfs_bmapi_allocate(&bma, flags, &tmp_logflags);
4927 &nallocs, &tmp_logflags);
4928 logflags |= tmp_logflags; 4922 logflags |= tmp_logflags;
4929 if (error) 4923 if (error)
4930 goto error0; 4924 goto error0;
@@ -4937,7 +4931,7 @@ xfs_bmapi_write(
4937 end, n, flags); 4931 end, n, flags);
4938 4932
4939 /* Execute unwritten extent conversion if necessary */ 4933 /* Execute unwritten extent conversion if necessary */
4940 error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx, 4934 error = xfs_bmapi_convert_unwritten(&bma, mval, len,
4941 flags, &tmp_logflags); 4935 flags, &tmp_logflags);
4942 logflags |= tmp_logflags; 4936 logflags |= tmp_logflags;
4943 if (error == EAGAIN) 4937 if (error == EAGAIN)
@@ -4953,14 +4947,15 @@ xfs_bmapi_write(
4953 * XFS_BMAP_MAX_NMAP extents no matter what. Otherwise 4947 * XFS_BMAP_MAX_NMAP extents no matter what. Otherwise
4954 * the transaction may get too big. 4948 * the transaction may get too big.
4955 */ 4949 */
4956 if (bno >= end || n >= *nmap || nallocs >= *nmap) 4950 if (bno >= end || n >= *nmap || bma.nallocs >= *nmap)
4957 break; 4951 break;
4958 4952
4959 /* Else go on to the next record. */ 4953 /* Else go on to the next record. */
4960 bma.prev = bma.got; 4954 bma.prev = bma.got;
4961 if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t)) 4955 if (++bma.idx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t)) {
4962 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &bma.got); 4956 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma.idx),
4963 else 4957 &bma.got);
4958 } else
4964 eof = 1; 4959 eof = 1;
4965 } 4960 }
4966 *nmap = n; 4961 *nmap = n;