diff options
Diffstat (limited to 'fs/xfs/xfs_btree.c')
-rw-r--r-- | fs/xfs/xfs_btree.c | 107 |
1 files changed, 4 insertions, 103 deletions
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index 31002093bfb7..074f7f6aa27c 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
@@ -387,16 +387,17 @@ xfs_btree_dup_cursor( | |||
387 | 387 | ||
388 | tp = cur->bc_tp; | 388 | tp = cur->bc_tp; |
389 | mp = cur->bc_mp; | 389 | mp = cur->bc_mp; |
390 | |||
390 | /* | 391 | /* |
391 | * Allocate a new cursor like the old one. | 392 | * Allocate a new cursor like the old one. |
392 | */ | 393 | */ |
393 | new = xfs_btree_init_cursor(mp, tp, cur->bc_private.a.agbp, | 394 | new = cur->bc_ops->dup_cursor(cur); |
394 | cur->bc_private.a.agno, cur->bc_btnum, cur->bc_private.b.ip, | 395 | |
395 | cur->bc_private.b.whichfork); | ||
396 | /* | 396 | /* |
397 | * Copy the record currently in the cursor. | 397 | * Copy the record currently in the cursor. |
398 | */ | 398 | */ |
399 | new->bc_rec = cur->bc_rec; | 399 | new->bc_rec = cur->bc_rec; |
400 | |||
400 | /* | 401 | /* |
401 | * For each level current, re-get the buffer and copy the ptr value. | 402 | * For each level current, re-get the buffer and copy the ptr value. |
402 | */ | 403 | */ |
@@ -416,15 +417,6 @@ xfs_btree_dup_cursor( | |||
416 | } else | 417 | } else |
417 | new->bc_bufs[i] = NULL; | 418 | new->bc_bufs[i] = NULL; |
418 | } | 419 | } |
419 | /* | ||
420 | * For bmap btrees, copy the firstblock, flist, and flags values, | ||
421 | * since init cursor doesn't get them. | ||
422 | */ | ||
423 | if (new->bc_btnum == XFS_BTNUM_BMAP) { | ||
424 | new->bc_private.b.firstblock = cur->bc_private.b.firstblock; | ||
425 | new->bc_private.b.flist = cur->bc_private.b.flist; | ||
426 | new->bc_private.b.flags = cur->bc_private.b.flags; | ||
427 | } | ||
428 | *ncur = new; | 420 | *ncur = new; |
429 | return 0; | 421 | return 0; |
430 | } | 422 | } |
@@ -505,97 +497,6 @@ xfs_btree_get_bufs( | |||
505 | } | 497 | } |
506 | 498 | ||
507 | /* | 499 | /* |
508 | * Allocate a new btree cursor. | ||
509 | * The cursor is either for allocation (A) or bmap (B) or inodes (I). | ||
510 | */ | ||
511 | xfs_btree_cur_t * /* new btree cursor */ | ||
512 | xfs_btree_init_cursor( | ||
513 | xfs_mount_t *mp, /* file system mount point */ | ||
514 | xfs_trans_t *tp, /* transaction pointer */ | ||
515 | xfs_buf_t *agbp, /* (A only) buffer for agf structure */ | ||
516 | /* (I only) buffer for agi structure */ | ||
517 | xfs_agnumber_t agno, /* (AI only) allocation group number */ | ||
518 | xfs_btnum_t btnum, /* btree identifier */ | ||
519 | xfs_inode_t *ip, /* (B only) inode owning the btree */ | ||
520 | int whichfork) /* (B only) data or attr fork */ | ||
521 | { | ||
522 | xfs_agf_t *agf; /* (A) allocation group freespace */ | ||
523 | xfs_agi_t *agi; /* (I) allocation group inodespace */ | ||
524 | xfs_btree_cur_t *cur; /* return value */ | ||
525 | xfs_ifork_t *ifp; /* (I) inode fork pointer */ | ||
526 | int nlevels=0; /* number of levels in the btree */ | ||
527 | |||
528 | ASSERT(xfs_btree_cur_zone != NULL); | ||
529 | /* | ||
530 | * Allocate a new cursor. | ||
531 | */ | ||
532 | cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_SLEEP); | ||
533 | /* | ||
534 | * Deduce the number of btree levels from the arguments. | ||
535 | */ | ||
536 | switch (btnum) { | ||
537 | case XFS_BTNUM_BNO: | ||
538 | case XFS_BTNUM_CNT: | ||
539 | agf = XFS_BUF_TO_AGF(agbp); | ||
540 | nlevels = be32_to_cpu(agf->agf_levels[btnum]); | ||
541 | break; | ||
542 | case XFS_BTNUM_BMAP: | ||
543 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
544 | nlevels = be16_to_cpu(ifp->if_broot->bb_level) + 1; | ||
545 | break; | ||
546 | case XFS_BTNUM_INO: | ||
547 | agi = XFS_BUF_TO_AGI(agbp); | ||
548 | nlevels = be32_to_cpu(agi->agi_level); | ||
549 | break; | ||
550 | default: | ||
551 | ASSERT(0); | ||
552 | } | ||
553 | /* | ||
554 | * Fill in the common fields. | ||
555 | */ | ||
556 | cur->bc_tp = tp; | ||
557 | cur->bc_mp = mp; | ||
558 | cur->bc_nlevels = nlevels; | ||
559 | cur->bc_btnum = btnum; | ||
560 | cur->bc_blocklog = mp->m_sb.sb_blocklog; | ||
561 | /* | ||
562 | * Fill in private fields. | ||
563 | */ | ||
564 | switch (btnum) { | ||
565 | case XFS_BTNUM_BNO: | ||
566 | case XFS_BTNUM_CNT: | ||
567 | /* | ||
568 | * Allocation btree fields. | ||
569 | */ | ||
570 | cur->bc_private.a.agbp = agbp; | ||
571 | cur->bc_private.a.agno = agno; | ||
572 | break; | ||
573 | case XFS_BTNUM_INO: | ||
574 | /* | ||
575 | * Inode allocation btree fields. | ||
576 | */ | ||
577 | cur->bc_private.a.agbp = agbp; | ||
578 | cur->bc_private.a.agno = agno; | ||
579 | break; | ||
580 | case XFS_BTNUM_BMAP: | ||
581 | /* | ||
582 | * Bmap btree fields. | ||
583 | */ | ||
584 | cur->bc_private.b.forksize = XFS_IFORK_SIZE(ip, whichfork); | ||
585 | cur->bc_private.b.ip = ip; | ||
586 | cur->bc_private.b.firstblock = NULLFSBLOCK; | ||
587 | cur->bc_private.b.flist = NULL; | ||
588 | cur->bc_private.b.allocated = 0; | ||
589 | cur->bc_private.b.flags = 0; | ||
590 | cur->bc_private.b.whichfork = whichfork; | ||
591 | break; | ||
592 | default: | ||
593 | ASSERT(0); | ||
594 | } | ||
595 | return cur; | ||
596 | } | ||
597 | |||
598 | /* | ||
599 | * Check for the cursor referring to the last block at the given level. | 500 | * Check for the cursor referring to the last block at the given level. |
600 | */ | 501 | */ |
601 | int /* 1=is last block, 0=not last block */ | 502 | int /* 1=is last block, 0=not last block */ |