diff options
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 | } | ||