aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2011-09-18 16:40:59 -0400
committerAlex Elder <aelder@sgi.com>2011-10-11 22:15:06 -0400
commit963c30cf45e8c832ae11438ff9d99c954b9d0114 (patch)
tree0d6c7ea97c4b4acaea918d6e158a3aa09dc37ca6 /fs/xfs/xfs_bmap.c
parent3a75667e902dbdb87718b1ee2b3b745b344a8163 (diff)
xfs: do not keep local copies of allocation ranges in xfs_bmapi_allocate
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.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index b47555cfbd8f..6a7832d3540e 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -4617,9 +4617,6 @@ xfs_bmapi_allocate(
4617 int whichfork = (flags & XFS_BMAPI_ATTRFORK) ? 4617 int whichfork = (flags & XFS_BMAPI_ATTRFORK) ?
4618 XFS_ATTR_FORK : XFS_DATA_FORK; 4618 XFS_ATTR_FORK : XFS_DATA_FORK;
4619 struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); 4619 struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork);
4620 xfs_fsblock_t abno;
4621 xfs_extlen_t alen;
4622 xfs_fileoff_t aoff;
4623 int error; 4620 int error;
4624 int rt; 4621 int rt;
4625 4622
@@ -4630,18 +4627,17 @@ xfs_bmapi_allocate(
4630 * for in this bmap call but that wouldn't be as good. 4627 * for in this bmap call but that wouldn't be as good.
4631 */ 4628 */
4632 if (bma->wasdel) { 4629 if (bma->wasdel) {
4633 alen = (xfs_extlen_t)bma->got.br_blockcount; 4630 bma->length = (xfs_extlen_t)bma->got.br_blockcount;
4634 aoff = bma->got.br_startoff; 4631 bma->offset = bma->got.br_startoff;
4635 if (*lastx != NULLEXTNUM && *lastx) { 4632 if (*lastx != NULLEXTNUM && *lastx) {
4636 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1), 4633 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1),
4637 &bma->prev); 4634 &bma->prev);
4638 } 4635 }
4639 } else { 4636 } else {
4640 alen = (xfs_extlen_t)XFS_FILBLKS_MIN(bma->length, MAXEXTLEN); 4637 bma->length = XFS_FILBLKS_MIN(bma->length, MAXEXTLEN);
4641 if (!bma->eof) 4638 if (!bma->eof)
4642 alen = (xfs_extlen_t)XFS_FILBLKS_MIN(alen, 4639 bma->length = XFS_FILBLKS_MIN(bma->length,
4643 bma->got.br_startoff - bma->offset); 4640 bma->got.br_startoff - bma->offset);
4644 aoff = bma->offset;
4645 } 4641 }
4646 4642
4647 /* 4643 /*
@@ -4649,23 +4645,17 @@ xfs_bmapi_allocate(
4649 * user data. 4645 * user data.
4650 */ 4646 */
4651 if (!(flags & XFS_BMAPI_METADATA)) { 4647 if (!(flags & XFS_BMAPI_METADATA)) {
4652 bma->userdata = (aoff == 0) ? 4648 bma->userdata = (bma->offset == 0) ?
4653 XFS_ALLOC_INITIAL_USER_DATA : XFS_ALLOC_USERDATA; 4649 XFS_ALLOC_INITIAL_USER_DATA : XFS_ALLOC_USERDATA;
4654 } 4650 }
4655 4651
4656 /* 4652 bma->minlen = (flags & XFS_BMAPI_CONTIG) ? bma->length : 1;
4657 * Fill in changeable bma fields.
4658 */
4659 bma->length = alen;
4660 bma->offset = aoff;
4661 bma->minlen = (flags & XFS_BMAPI_CONTIG) ? alen : 1;
4662 bma->aeof = 0;
4663 4653
4664 /* 4654 /*
4665 * Only want to do the alignment at the eof if it is userdata and 4655 * Only want to do the alignment at the eof if it is userdata and
4666 * allocation length is larger than a stripe unit. 4656 * allocation length is larger than a stripe unit.
4667 */ 4657 */
4668 if (mp->m_dalign && alen >= mp->m_dalign && 4658 if (mp->m_dalign && bma->length >= mp->m_dalign &&
4669 !(flags & XFS_BMAPI_METADATA) && whichfork == XFS_DATA_FORK) { 4659 !(flags & XFS_BMAPI_METADATA) && whichfork == XFS_DATA_FORK) {
4670 error = xfs_bmap_isaeof(bma, whichfork); 4660 error = xfs_bmap_isaeof(bma, whichfork);
4671 if (error) 4661 if (error)
@@ -4676,17 +4666,11 @@ xfs_bmapi_allocate(
4676 if (error) 4666 if (error)
4677 return error; 4667 return error;
4678 4668
4679 /*
4680 * Copy out result fields.
4681 */
4682 abno = bma->blkno;
4683 alen = bma->length;
4684 aoff = bma->offset;
4685 if (bma->flist->xbf_low) 4669 if (bma->flist->xbf_low)
4686 bma->minleft = 0; 4670 bma->minleft = 0;
4687 if (*cur) 4671 if (*cur)
4688 (*cur)->bc_private.b.firstblock = *bma->firstblock; 4672 (*cur)->bc_private.b.firstblock = *bma->firstblock;
4689 if (abno == NULLFSBLOCK) 4673 if (bma->blkno == NULLFSBLOCK)
4690 return 0; 4674 return 0;
4691 if ((ifp->if_flags & XFS_IFBROOT) && !*cur) { 4675 if ((ifp->if_flags & XFS_IFBROOT) && !*cur) {
4692 (*cur) = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork); 4676 (*cur) = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork);
@@ -4703,9 +4687,9 @@ xfs_bmapi_allocate(
4703 (*cur)->bc_private.b.flags = 4687 (*cur)->bc_private.b.flags =
4704 bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0; 4688 bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
4705 4689
4706 bma->got.br_startoff = aoff; 4690 bma->got.br_startoff = bma->offset;
4707 bma->got.br_startblock = abno; 4691 bma->got.br_startblock = bma->blkno;
4708 bma->got.br_blockcount = alen; 4692 bma->got.br_blockcount = bma->length;
4709 bma->got.br_state = XFS_EXT_NORM; 4693 bma->got.br_state = XFS_EXT_NORM;
4710 4694
4711 /* 4695 /*
@@ -4736,8 +4720,9 @@ xfs_bmapi_allocate(
4736 */ 4720 */
4737 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got); 4721 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got);
4738 4722
4739 ASSERT(bma->got.br_startoff <= aoff); 4723 ASSERT(bma->got.br_startoff <= bma->offset);
4740 ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= aoff + alen); 4724 ASSERT(bma->got.br_startoff + bma->got.br_blockcount >=
4725 bma->offset + bma->length);
4741 ASSERT(bma->got.br_state == XFS_EXT_NORM || 4726 ASSERT(bma->got.br_state == XFS_EXT_NORM ||
4742 bma->got.br_state == XFS_EXT_UNWRITTEN); 4727 bma->got.br_state == XFS_EXT_UNWRITTEN);
4743 return 0; 4728 return 0;