diff options
author | Dave Chinner <dchinner@redhat.com> | 2011-09-18 16:41:00 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2011-10-11 22:15:06 -0400 |
commit | 29c8d17a8938be88e36b93522753f3519aefd05d (patch) | |
tree | e54ac344f5228cd22d447a9759682f73ce3d4c6e /fs/xfs | |
parent | 963c30cf45e8c832ae11438ff9d99c954b9d0114 (diff) |
xfs: move btree cursor 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')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 56 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap.h | 2 |
2 files changed, 28 insertions, 30 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 6a7832d3540e..a54326bf9aa0 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -4608,7 +4608,6 @@ STATIC int | |||
4608 | xfs_bmapi_allocate( | 4608 | xfs_bmapi_allocate( |
4609 | struct xfs_bmalloca *bma, | 4609 | struct xfs_bmalloca *bma, |
4610 | xfs_extnum_t *lastx, | 4610 | xfs_extnum_t *lastx, |
4611 | struct xfs_btree_cur **cur, | ||
4612 | int flags, | 4611 | int flags, |
4613 | int *nallocs, | 4612 | int *nallocs, |
4614 | int *logflags) | 4613 | int *logflags) |
@@ -4668,14 +4667,14 @@ xfs_bmapi_allocate( | |||
4668 | 4667 | ||
4669 | if (bma->flist->xbf_low) | 4668 | if (bma->flist->xbf_low) |
4670 | bma->minleft = 0; | 4669 | bma->minleft = 0; |
4671 | if (*cur) | 4670 | if (bma->cur) |
4672 | (*cur)->bc_private.b.firstblock = *bma->firstblock; | 4671 | bma->cur->bc_private.b.firstblock = *bma->firstblock; |
4673 | if (bma->blkno == NULLFSBLOCK) | 4672 | if (bma->blkno == NULLFSBLOCK) |
4674 | return 0; | 4673 | return 0; |
4675 | if ((ifp->if_flags & XFS_IFBROOT) && !*cur) { | 4674 | if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) { |
4676 | (*cur) = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork); | 4675 | bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork); |
4677 | (*cur)->bc_private.b.firstblock = *bma->firstblock; | 4676 | bma->cur->bc_private.b.firstblock = *bma->firstblock; |
4678 | (*cur)->bc_private.b.flist = bma->flist; | 4677 | bma->cur->bc_private.b.flist = bma->flist; |
4679 | } | 4678 | } |
4680 | /* | 4679 | /* |
4681 | * Bump the number of extents we've allocated | 4680 | * Bump the number of extents we've allocated |
@@ -4683,8 +4682,8 @@ xfs_bmapi_allocate( | |||
4683 | */ | 4682 | */ |
4684 | (*nallocs)++; | 4683 | (*nallocs)++; |
4685 | 4684 | ||
4686 | if (*cur) | 4685 | if (bma->cur) |
4687 | (*cur)->bc_private.b.flags = | 4686 | bma->cur->bc_private.b.flags = |
4688 | bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0; | 4687 | bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0; |
4689 | 4688 | ||
4690 | bma->got.br_startoff = bma->offset; | 4689 | bma->got.br_startoff = bma->offset; |
@@ -4702,12 +4701,12 @@ xfs_bmapi_allocate( | |||
4702 | 4701 | ||
4703 | if (bma->wasdel) { | 4702 | if (bma->wasdel) { |
4704 | error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, lastx, | 4703 | error = xfs_bmap_add_extent_delay_real(bma->tp, bma->ip, lastx, |
4705 | cur, &bma->got, bma->firstblock, bma->flist, | 4704 | &bma->cur, &bma->got, bma->firstblock, |
4706 | logflags); | 4705 | bma->flist, logflags); |
4707 | } else { | 4706 | } else { |
4708 | error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, lastx, | 4707 | error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, lastx, |
4709 | cur, &bma->got, bma->firstblock, bma->flist, | 4708 | &bma->cur, &bma->got, bma->firstblock, |
4710 | logflags, whichfork); | 4709 | bma->flist, logflags, whichfork); |
4711 | } | 4710 | } |
4712 | 4711 | ||
4713 | if (error) | 4712 | if (error) |
@@ -4734,7 +4733,6 @@ xfs_bmapi_convert_unwritten( | |||
4734 | struct xfs_bmbt_irec *mval, | 4733 | struct xfs_bmbt_irec *mval, |
4735 | xfs_filblks_t len, | 4734 | xfs_filblks_t len, |
4736 | xfs_extnum_t *lastx, | 4735 | xfs_extnum_t *lastx, |
4737 | struct xfs_btree_cur **cur, | ||
4738 | int flags, | 4736 | int flags, |
4739 | int *logflags) | 4737 | int *logflags) |
4740 | { | 4738 | { |
@@ -4760,17 +4758,17 @@ xfs_bmapi_convert_unwritten( | |||
4760 | * Modify (by adding) the state flag, if writing. | 4758 | * Modify (by adding) the state flag, if writing. |
4761 | */ | 4759 | */ |
4762 | ASSERT(mval->br_blockcount <= len); | 4760 | ASSERT(mval->br_blockcount <= len); |
4763 | if ((ifp->if_flags & XFS_IFBROOT) && !*cur) { | 4761 | if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) { |
4764 | *cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp, | 4762 | bma->cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp, |
4765 | bma->ip, whichfork); | 4763 | bma->ip, whichfork); |
4766 | (*cur)->bc_private.b.firstblock = *bma->firstblock; | 4764 | bma->cur->bc_private.b.firstblock = *bma->firstblock; |
4767 | (*cur)->bc_private.b.flist = bma->flist; | 4765 | bma->cur->bc_private.b.flist = bma->flist; |
4768 | } | 4766 | } |
4769 | mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) | 4767 | mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) |
4770 | ? XFS_EXT_NORM : XFS_EXT_UNWRITTEN; | 4768 | ? XFS_EXT_NORM : XFS_EXT_UNWRITTEN; |
4771 | 4769 | ||
4772 | error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, lastx, | 4770 | error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, lastx, |
4773 | cur, mval, bma->firstblock, bma->flist, logflags); | 4771 | &bma->cur, mval, bma->firstblock, bma->flist, logflags); |
4774 | if (error) | 4772 | if (error) |
4775 | return error; | 4773 | return error; |
4776 | 4774 | ||
@@ -4819,7 +4817,6 @@ xfs_bmapi_write( | |||
4819 | struct xfs_mount *mp = ip->i_mount; | 4817 | struct xfs_mount *mp = ip->i_mount; |
4820 | struct xfs_ifork *ifp; | 4818 | struct xfs_ifork *ifp; |
4821 | struct xfs_bmalloca bma = { 0 }; /* args for xfs_bmap_alloc */ | 4819 | struct xfs_bmalloca bma = { 0 }; /* args for xfs_bmap_alloc */ |
4822 | struct xfs_btree_cur *cur; /* bmap btree cursor */ | ||
4823 | xfs_fileoff_t end; /* end of mapped file region */ | 4820 | xfs_fileoff_t end; /* end of mapped file region */ |
4824 | int eof; /* after the end of extents */ | 4821 | int eof; /* after the end of extents */ |
4825 | int error; /* error return */ | 4822 | int error; /* error return */ |
@@ -4875,7 +4872,6 @@ xfs_bmapi_write( | |||
4875 | 4872 | ||
4876 | logflags = 0; | 4873 | logflags = 0; |
4877 | nallocs = 0; | 4874 | nallocs = 0; |
4878 | cur = NULL; | ||
4879 | 4875 | ||
4880 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { | 4876 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { |
4881 | error = xfs_bmap_local_to_extents(tp, ip, firstblock, total, | 4877 | error = xfs_bmap_local_to_extents(tp, ip, firstblock, total, |
@@ -4927,7 +4923,7 @@ xfs_bmapi_write( | |||
4927 | bma.length = len; | 4923 | bma.length = len; |
4928 | bma.offset = bno; | 4924 | bma.offset = bno; |
4929 | 4925 | ||
4930 | error = xfs_bmapi_allocate(&bma, &lastx, &cur, flags, | 4926 | error = xfs_bmapi_allocate(&bma, &lastx, flags, |
4931 | &nallocs, &tmp_logflags); | 4927 | &nallocs, &tmp_logflags); |
4932 | logflags |= tmp_logflags; | 4928 | logflags |= tmp_logflags; |
4933 | if (error) | 4929 | if (error) |
@@ -4942,7 +4938,7 @@ xfs_bmapi_write( | |||
4942 | 4938 | ||
4943 | /* Execute unwritten extent conversion if necessary */ | 4939 | /* Execute unwritten extent conversion if necessary */ |
4944 | error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx, | 4940 | error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx, |
4945 | &cur, flags, &tmp_logflags); | 4941 | flags, &tmp_logflags); |
4946 | logflags |= tmp_logflags; | 4942 | logflags |= tmp_logflags; |
4947 | if (error == EAGAIN) | 4943 | if (error == EAGAIN) |
4948 | continue; | 4944 | continue; |
@@ -4974,8 +4970,8 @@ xfs_bmapi_write( | |||
4974 | */ | 4970 | */ |
4975 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE && | 4971 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE && |
4976 | XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max) { | 4972 | XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max) { |
4977 | ASSERT(cur); | 4973 | ASSERT(bma.cur); |
4978 | error = xfs_bmap_btree_to_extents(tp, ip, cur, | 4974 | error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, |
4979 | &tmp_logflags, whichfork); | 4975 | &tmp_logflags, whichfork); |
4980 | logflags |= tmp_logflags; | 4976 | logflags |= tmp_logflags; |
4981 | if (error) | 4977 | if (error) |
@@ -5005,19 +5001,19 @@ error0: | |||
5005 | if (logflags) | 5001 | if (logflags) |
5006 | xfs_trans_log_inode(tp, ip, logflags); | 5002 | xfs_trans_log_inode(tp, ip, logflags); |
5007 | 5003 | ||
5008 | if (cur) { | 5004 | if (bma.cur) { |
5009 | if (!error) { | 5005 | if (!error) { |
5010 | ASSERT(*firstblock == NULLFSBLOCK || | 5006 | ASSERT(*firstblock == NULLFSBLOCK || |
5011 | XFS_FSB_TO_AGNO(mp, *firstblock) == | 5007 | XFS_FSB_TO_AGNO(mp, *firstblock) == |
5012 | XFS_FSB_TO_AGNO(mp, | 5008 | XFS_FSB_TO_AGNO(mp, |
5013 | cur->bc_private.b.firstblock) || | 5009 | bma.cur->bc_private.b.firstblock) || |
5014 | (flist->xbf_low && | 5010 | (flist->xbf_low && |
5015 | XFS_FSB_TO_AGNO(mp, *firstblock) < | 5011 | XFS_FSB_TO_AGNO(mp, *firstblock) < |
5016 | XFS_FSB_TO_AGNO(mp, | 5012 | XFS_FSB_TO_AGNO(mp, |
5017 | cur->bc_private.b.firstblock))); | 5013 | bma.cur->bc_private.b.firstblock))); |
5018 | *firstblock = cur->bc_private.b.firstblock; | 5014 | *firstblock = bma.cur->bc_private.b.firstblock; |
5019 | } | 5015 | } |
5020 | xfs_btree_del_cursor(cur, | 5016 | xfs_btree_del_cursor(bma.cur, |
5021 | error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR); | 5017 | error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR); |
5022 | } | 5018 | } |
5023 | if (!error) | 5019 | if (!error) |
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h index 5f398b1ac70c..858d9d509989 100644 --- a/fs/xfs/xfs_bmap.h +++ b/fs/xfs/xfs_bmap.h | |||
@@ -120,6 +120,8 @@ typedef struct xfs_bmalloca { | |||
120 | xfs_extlen_t length; /* i/o length asked/allocated */ | 120 | xfs_extlen_t length; /* i/o length asked/allocated */ |
121 | xfs_fsblock_t blkno; /* starting block of new extent */ | 121 | xfs_fsblock_t blkno; /* starting block of new extent */ |
122 | 122 | ||
123 | struct xfs_btree_cur *cur; /* btree cursor */ | ||
124 | |||
123 | xfs_extlen_t total; /* total blocks needed for xaction */ | 125 | xfs_extlen_t total; /* total blocks needed for xaction */ |
124 | xfs_extlen_t minlen; /* minimum allocation size (blocks) */ | 126 | xfs_extlen_t minlen; /* minimum allocation size (blocks) */ |
125 | xfs_extlen_t minleft; /* amount must be left after alloc */ | 127 | xfs_extlen_t minleft; /* amount must be left after alloc */ |