~wb-munzinger/+junk/ocfs2-tools

« back to all changes in this revision

Viewing changes to libocfs2/extents.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2011-01-14 12:46:49 UTC
  • mfrom: (1.1.10 upstream) (0.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110114124649-vbe5qz211f3zxwuf
Tags: 1.6.3-1ubuntu1
* Merge from debian unstable (LP: #703008).  Remaining changes:
  - Fix configure tests for ld --as-needed.
  - Fix build failure with ld --no-add-needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
        eb->h_fs_generation = bswap_32(eb->h_fs_generation);
91
91
        eb->h_blkno         = bswap_64(eb->h_blkno);
92
92
        eb->h_next_leaf_blk = bswap_64(eb->h_next_leaf_blk);
 
93
        eb->h_suballoc_loc  = bswap_64(eb->h_suballoc_loc);
93
94
}
94
95
 
95
96
void ocfs2_swap_extent_block_from_cpu(ocfs2_filesys *fs,
464
465
                                     int flags,
465
466
                                     char *block_buf,
466
467
                                     int (*func)(ocfs2_filesys *fs,
467
 
                                                 struct ocfs2_extent_rec *rec,
468
 
                                                 int tree_depth,
469
 
                                                 uint32_t ccount,
470
 
                                                 uint64_t ref_blkno,
471
 
                                                 int ref_recno,
472
 
                                                 void *priv_data),
473
 
                                                 void *priv_data)
 
468
                                                 struct ocfs2_extent_rec *rec,
 
469
                                                 int tree_depth,
 
470
                                                 uint32_t ccount,
 
471
                                                 uint64_t ref_blkno,
 
472
                                                 int ref_recno,
 
473
                                                 void *priv_data),
 
474
                                     void *priv_data)
474
475
{
475
476
        int i;
476
477
        int iret = 0;
550
551
        return ret;
551
552
}
552
553
 
 
554
errcode_t ocfs2_extent_iterate_dx_root(ocfs2_filesys *fs,
 
555
                                       struct ocfs2_dx_root_block *dx_root,
 
556
                                       int flags,
 
557
                                       char *block_buf,
 
558
                                       int (*func)(ocfs2_filesys *fs,
 
559
                                                   struct ocfs2_extent_rec *rec,
 
560
                                                   int tree_depth,
 
561
                                                   uint32_t ccount,
 
562
                                                   uint64_t ref_blkno,
 
563
                                                   int ref_recno,
 
564
                                                   void *priv_data),
 
565
                                       void *priv_data)
 
566
{
 
567
        int i;
 
568
        int iret = 0;
 
569
        struct ocfs2_extent_list *el;
 
570
        errcode_t ret;
 
571
        struct extent_context ctxt;
 
572
 
 
573
        if (dx_root->dr_flags & OCFS2_DX_FLAG_INLINE)
 
574
                return OCFS2_ET_INODE_CANNOT_BE_ITERATED;
 
575
 
 
576
        el = &dx_root->dr_list;
 
577
        if (el->l_tree_depth) {
 
578
                ret = ocfs2_malloc0(sizeof(char *) * el->l_tree_depth,
 
579
                                    &ctxt.eb_bufs);
 
580
                if (ret)
 
581
                        goto out;
 
582
 
 
583
                if (block_buf) {
 
584
                        ctxt.eb_bufs[0] = block_buf;
 
585
                } else {
 
586
                        ret = ocfs2_malloc0(fs->fs_blocksize *
 
587
                                            el->l_tree_depth,
 
588
                                            &ctxt.eb_bufs[0]);
 
589
                        if (ret)
 
590
                                goto out_eb_bufs;
 
591
                }
 
592
 
 
593
                for (i = 1; i < el->l_tree_depth; i++) {
 
594
                        ctxt.eb_bufs[i] = ctxt.eb_bufs[0] +
 
595
                                i * fs->fs_blocksize;
 
596
                }
 
597
        }
 
598
        else
 
599
                ctxt.eb_bufs = NULL;
 
600
 
 
601
        ctxt.fs = fs;
 
602
        ctxt.func = func;
 
603
        ctxt.priv_data = priv_data;
 
604
        ctxt.flags = flags;
 
605
        ctxt.ccount = 0;
 
606
        ctxt.last_eb_blkno = 0;
 
607
        ctxt.last_eb_cpos = 0;
 
608
 
 
609
        ret = 0;
 
610
        iret |= extent_iterate_el(el, 0, &ctxt);
 
611
        if (iret & OCFS2_EXTENT_ERROR)
 
612
                ret = ctxt.errcode;
 
613
 
 
614
        if (iret & OCFS2_EXTENT_ABORT)
 
615
                goto out_abort;
 
616
 
 
617
        /* we can only trust ctxt.last_eb_blkno if we walked the whole tree */
 
618
        if (dx_root->dr_last_eb_blk != ctxt.last_eb_blkno) {
 
619
                dx_root->dr_last_eb_blk = ctxt.last_eb_blkno;
 
620
                iret |= OCFS2_EXTENT_CHANGED;
 
621
        }
 
622
 
 
623
out_abort:
 
624
#if 0
 
625
        /*
 
626
         * This block needs to be fixed up for write support.
 
627
         */
 
628
        if (!ret && (iret & OCFS2_EXTENT_CHANGED))
 
629
                ret = ocfs2_write_inode(fs, inode->i_blkno, (char *)inode);
 
630
#endif
 
631
 
 
632
out_eb_bufs:
 
633
        if (ctxt.eb_bufs) {
 
634
                if (!block_buf && ctxt.eb_bufs[0])
 
635
                        ocfs2_free(&ctxt.eb_bufs[0]);
 
636
                ocfs2_free(&ctxt.eb_bufs);
 
637
        }
 
638
 
 
639
out:
 
640
        return ret;
 
641
}
 
642
 
553
643
errcode_t ocfs2_extent_iterate(ocfs2_filesys *fs,
554
644
                               uint64_t blkno,
555
645
                               int flags,