diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-10-30 01:53:59 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@sgi.com> | 2008-10-30 01:53:59 -0400 |
commit | 561f7d17390d00444e6cd0b02b7516c91528082e (patch) | |
tree | 59359b995320bf79a55c2f23305960b5ffe74d8f /fs/xfs/xfs_bmap_btree.c | |
parent | f2277f06e626d694e61bb356524ff536ced24acf (diff) |
[XFS] split up xfs_btree_init_cursor
xfs_btree_init_cursor contains close to little shared code for the
different btrees and will get even more non-common code in the future.
Split it up into one routine per btree type.
Because xfs_btree_dup_cursor needs to call the init routine for a generic
btree cursor add a new btree operation vector that contains a dup_cursor
method that initializes a new cursor based on an existing one.
The btree operations vector is based on an idea and code from Dave Chinner
and will grow more entries later during this series.
SGI-PV: 985583
SGI-Modid: xfs-linux-melb:xfs-kern:32176a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: Bill O'Donnell <billodo@sgi.com>
Signed-off-by: David Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_bmap_btree.c')
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 23efad29a5cd..cfbdd00045cf 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -2608,3 +2608,62 @@ xfs_check_nostate_extents( | |||
2608 | } | 2608 | } |
2609 | return 0; | 2609 | return 0; |
2610 | } | 2610 | } |
2611 | |||
2612 | |||
2613 | STATIC struct xfs_btree_cur * | ||
2614 | xfs_bmbt_dup_cursor( | ||
2615 | struct xfs_btree_cur *cur) | ||
2616 | { | ||
2617 | struct xfs_btree_cur *new; | ||
2618 | |||
2619 | new = xfs_bmbt_init_cursor(cur->bc_mp, cur->bc_tp, | ||
2620 | cur->bc_private.b.ip, cur->bc_private.b.whichfork); | ||
2621 | |||
2622 | /* | ||
2623 | * Copy the firstblock, flist, and flags values, | ||
2624 | * since init cursor doesn't get them. | ||
2625 | */ | ||
2626 | new->bc_private.b.firstblock = cur->bc_private.b.firstblock; | ||
2627 | new->bc_private.b.flist = cur->bc_private.b.flist; | ||
2628 | new->bc_private.b.flags = cur->bc_private.b.flags; | ||
2629 | |||
2630 | return new; | ||
2631 | } | ||
2632 | |||
2633 | static const struct xfs_btree_ops xfs_bmbt_ops = { | ||
2634 | .dup_cursor = xfs_bmbt_dup_cursor, | ||
2635 | }; | ||
2636 | |||
2637 | /* | ||
2638 | * Allocate a new bmap btree cursor. | ||
2639 | */ | ||
2640 | struct xfs_btree_cur * /* new bmap btree cursor */ | ||
2641 | xfs_bmbt_init_cursor( | ||
2642 | struct xfs_mount *mp, /* file system mount point */ | ||
2643 | struct xfs_trans *tp, /* transaction pointer */ | ||
2644 | struct xfs_inode *ip, /* inode owning the btree */ | ||
2645 | int whichfork) /* data or attr fork */ | ||
2646 | { | ||
2647 | struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); | ||
2648 | struct xfs_btree_cur *cur; | ||
2649 | |||
2650 | cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_SLEEP); | ||
2651 | |||
2652 | cur->bc_tp = tp; | ||
2653 | cur->bc_mp = mp; | ||
2654 | cur->bc_nlevels = be16_to_cpu(ifp->if_broot->bb_level) + 1; | ||
2655 | cur->bc_btnum = XFS_BTNUM_BMAP; | ||
2656 | cur->bc_blocklog = mp->m_sb.sb_blocklog; | ||
2657 | |||
2658 | cur->bc_ops = &xfs_bmbt_ops; | ||
2659 | |||
2660 | cur->bc_private.b.forksize = XFS_IFORK_SIZE(ip, whichfork); | ||
2661 | cur->bc_private.b.ip = ip; | ||
2662 | cur->bc_private.b.firstblock = NULLFSBLOCK; | ||
2663 | cur->bc_private.b.flist = NULL; | ||
2664 | cur->bc_private.b.allocated = 0; | ||
2665 | cur->bc_private.b.flags = 0; | ||
2666 | cur->bc_private.b.whichfork = whichfork; | ||
2667 | |||
2668 | return cur; | ||
2669 | } | ||