~ubuntu-branches/ubuntu/precise/xfsprogs/precise

« back to all changes in this revision

Viewing changes to repair/dinode.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2009-12-10 09:19:37 UTC
  • mfrom: (8.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091210091937-22ll7dx6lsix3uec
Tags: 3.1.0
* New upstream release
* Merged German translation (closes: #521389)
* Merged German translation update (closes: #557100)
* Uptodate po file is provided now (closes: #538962)
* Fixed typos in xfs_quota man page (closes: #481715)
* Tighten permissions on temp fsr files (closes: #559490)

Show diffs side-by-side

added added

removed removed

Lines of Context:
524
524
 
525
525
        /*
526
526
         * set the appropriate number of extents
 
527
         * this iterates block by block, this can be optimised using extents
527
528
         */
528
529
        for (b = irec->br_startblock; b < irec->br_startblock +
529
530
                        irec->br_blockcount; b += mp->m_sb.sb_rextsize)  {
545
546
                        continue;
546
547
                }
547
548
 
548
 
                state = get_rtbno_state(mp, ext);
549
 
 
 
549
                state = get_rtbmap(ext);
550
550
                switch (state)  {
551
 
                        case XR_E_FREE:
552
 
                        case XR_E_UNKNOWN:
553
 
                                set_rtbno_state(mp, ext, XR_E_INUSE);
 
551
                case XR_E_FREE:
 
552
                case XR_E_UNKNOWN:
 
553
                        set_rtbmap(ext, XR_E_INUSE);
 
554
                        break;
 
555
                case XR_E_BAD_STATE:
 
556
                        do_error(_("bad state in rt block map %llu\n"), ext);
 
557
                case XR_E_FS_MAP:
 
558
                case XR_E_INO:
 
559
                case XR_E_INUSE_FS:
 
560
                        do_error(_("data fork in rt inode %llu found "
 
561
                                "metadata block %llu in rt bmap\n"),
 
562
                                ino, ext);
 
563
                case XR_E_INUSE:
 
564
                        if (pwe)
554
565
                                break;
555
 
 
556
 
                        case XR_E_BAD_STATE:
557
 
                                do_error(_("bad state in rt block map %llu\n"),
558
 
                                                ext);
559
 
 
560
 
                        case XR_E_FS_MAP:
561
 
                        case XR_E_INO:
562
 
                        case XR_E_INUSE_FS:
563
 
                                do_error(_("data fork in rt inode %llu found "
564
 
                                        "metadata block %llu in rt bmap\n"),
 
566
                case XR_E_MULT:
 
567
                        set_rtbmap(ext, XR_E_MULT);
 
568
                        do_warn(_("data fork in rt inode %llu claims "
 
569
                                        "used rt block %llu\n"),
565
570
                                        ino, ext);
566
 
 
567
 
                        case XR_E_INUSE:
568
 
                                if (pwe)
569
 
                                        break;
570
 
 
571
 
                        case XR_E_MULT:
572
 
                                set_rtbno_state(mp, ext, XR_E_MULT);
573
 
                                do_warn(_("data fork in rt inode %llu claims "
574
 
                                                "used rt block %llu\n"),
575
 
                                                ino, ext);
576
 
                                return 1;
577
 
 
578
 
                        case XR_E_FREE1:
579
 
                        default:
580
 
                                do_error(_("illegal state %d in rt block map "
581
 
                                                "%llu\n"), state, b);
 
571
                        return 1;
 
572
                case XR_E_FREE1:
 
573
                default:
 
574
                        do_error(_("illegal state %d in rt block map "
 
575
                                        "%llu\n"), state, b);
582
576
                }
583
577
        }
584
578
 
621
615
        char                    *forkname;
622
616
        int                     i;
623
617
        int                     state;
624
 
        xfs_dfsbno_t            e;
625
618
        xfs_agnumber_t          agno;
626
619
        xfs_agblock_t           agbno;
 
620
        xfs_agblock_t           ebno;
 
621
        xfs_extlen_t            blen;
627
622
        xfs_agnumber_t          locked_agno = -1;
628
623
        int                     error = 1;
629
624
 
725
720
                 */
726
721
                agno = XFS_FSB_TO_AGNO(mp, irec.br_startblock);
727
722
                agbno = XFS_FSB_TO_AGBNO(mp, irec.br_startblock);
728
 
                e = irec.br_startblock + irec.br_blockcount;
 
723
                ebno = agbno + irec.br_blockcount;
729
724
                if (agno != locked_agno) {
730
725
                        if (locked_agno != -1)
731
726
                                pthread_mutex_unlock(&ag_locks[locked_agno]);
740
735
                         * checking each entry without setting the
741
736
                         * block bitmap
742
737
                         */
743
 
                        for (b = irec.br_startblock; b < e; b++, agbno++)  {
744
 
                                if (search_dup_extent(mp, agno, agbno)) {
745
 
                                        do_warn(_("%s fork in ino %llu claims "
746
 
                                                "dup extent, off - %llu, "
747
 
                                                "start - %llu, cnt %llu\n"),
748
 
                                                forkname, ino, irec.br_startoff,
749
 
                                                irec.br_startblock,
750
 
                                                irec.br_blockcount);
751
 
                                        goto done;
752
 
                                }
 
738
                        if (search_dup_extent(agno, agbno, ebno)) {
 
739
                                do_warn(_("%s fork in ino %llu claims "
 
740
                                        "dup extent, off - %llu, "
 
741
                                        "start - %llu, cnt %llu\n"),
 
742
                                        forkname, ino, irec.br_startoff,
 
743
                                        irec.br_startblock,
 
744
                                        irec.br_blockcount);
 
745
                                goto done;
753
746
                        }
754
747
                        *tot += irec.br_blockcount;
755
748
                        continue;
756
749
                }
757
750
 
758
 
                for (b = irec.br_startblock; b < e; b++, agbno++)  {
759
 
                        /*
760
 
                         * Process in chunks of 16 (XR_BB_UNIT/XR_BB)
761
 
                         * for common XR_E_UNKNOWN to XR_E_INUSE transition
762
 
                         */
763
 
                        if (((agbno & XR_BB_MASK) == 0) && ((irec.br_startblock + irec.br_blockcount - b) >= (XR_BB_UNIT/XR_BB))) {
764
 
                                if (ba_bmap[agno][agbno>>XR_BB] == XR_E_UNKNOWN_LL) {
765
 
                                        ba_bmap[agno][agbno>>XR_BB] = XR_E_INUSE_LL;
766
 
                                        agbno += (XR_BB_UNIT/XR_BB) - 1;
767
 
                                        b += (XR_BB_UNIT/XR_BB) - 1;
768
 
                                        continue;
769
 
                                }
770
 
 
771
 
                        }
772
 
 
773
 
                        state = get_agbno_state(mp, agno, agbno);
774
 
 
 
751
                for (b = irec.br_startblock;
 
752
                     agbno < ebno;
 
753
                     b += blen, agbno += blen) {
 
754
                        state = get_bmap_ext(agno, agbno, ebno, &blen);
775
755
                        switch (state)  {
776
756
                        case XR_E_FREE:
777
757
                        case XR_E_FREE1:
780
760
                                        forkname, ino, (__uint64_t) b);
781
761
                                /* fall through ... */
782
762
                        case XR_E_UNKNOWN:
783
 
                                set_agbno_state(mp, agno, agbno, XR_E_INUSE);
 
763
                                set_bmap_ext(agno, agbno, blen, XR_E_INUSE);
784
764
                                break;
785
765
 
786
766
                        case XR_E_BAD_STATE:
796
776
 
797
777
                        case XR_E_INUSE:
798
778
                        case XR_E_MULT:
799
 
                                set_agbno_state(mp, agno, agbno, XR_E_MULT);
 
779
                                set_bmap_ext(agno, agbno, blen, XR_E_MULT);
800
780
                                do_warn(_("%s fork in %s inode %llu claims "
801
781
                                        "used block %llu\n"),
802
782
                                        forkname, ftype, ino, (__uint64_t) b);
2050
2030
                *nextents = 1;
2051
2031
 
2052
2032
        if (dinoc->di_format != XFS_DINODE_FMT_LOCAL && type != XR_INO_RTDATA)
2053
 
                *dblkmap = blkmap_alloc(*nextents);
 
2033
                *dblkmap = blkmap_alloc(*nextents, XFS_DATA_FORK);
2054
2034
        *nextents = 0;
2055
2035
 
2056
2036
        switch (dinoc->di_format) {
2172
2152
                err = process_lclinode(mp, agno, ino, dino, XFS_ATTR_FORK);
2173
2153
                break;
2174
2154
        case XFS_DINODE_FMT_EXTENTS:
2175
 
                ablkmap = blkmap_alloc(*anextents);
 
2155
                ablkmap = blkmap_alloc(*anextents, XFS_ATTR_FORK);
2176
2156
                *anextents = 0;
2177
2157
                err = process_exinode(mp, agno, ino, dino, type, dirty,
2178
2158
                                atotblocks, anextents, &ablkmap,
2179
2159
                                XFS_ATTR_FORK, check_dups);
2180
2160
                break;
2181
2161
        case XFS_DINODE_FMT_BTREE:
2182
 
                ablkmap = blkmap_alloc(*anextents);
 
2162
                ablkmap = blkmap_alloc(*anextents, XFS_ATTR_FORK);
2183
2163
                *anextents = 0;
2184
2164
                err = process_btinode(mp, agno, ino, dino, type, dirty,
2185
2165
                                atotblocks, anextents, &ablkmap,