~daniel-mehrmann/e2fsprogs/master

« back to all changes in this revision

Viewing changes to e2fsck/pass1b.c

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2014-10-27 09:44:27 UTC
  • mfrom: (8.4.29 sid)
  • Revision ID: package-import@ubuntu.com-20141027094427-g56dce6sg7pasdgm
Tags: 1.42.12-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/rules:
      Block pkg-create-dbgsym from operating on this package.
      Build without dietlibc-dev, which is in universe 
      Use the autotools-dev dh addon to update config.guess/config.sub for new
      ports.
  - debian/control:
      Regenerate with ./debian/rules debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
261
261
        e2fsck_t        ctx;
262
262
        ext2_ino_t      ino;
263
263
        int             dup_blocks;
264
 
        blk64_t         cur_cluster;
 
264
        blk64_t         cur_cluster, phys_cluster;
265
265
        struct ext2_inode *inode;
266
266
        struct problem_context *pctx;
267
267
};
299
299
                if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
300
300
                        continue;
301
301
                if (pctx.errcode) {
 
302
                        pctx.ino = ino;
302
303
                        fix_problem(ctx, PR_1B_ISCAN_ERROR, &pctx);
303
304
                        ctx->flags |= E2F_FLAG_ABORT;
304
305
                        return;
314
315
                pb.dup_blocks = 0;
315
316
                pb.inode = &inode;
316
317
                pb.cur_cluster = ~0;
 
318
                pb.phys_cluster = ~0;
317
319
 
318
320
                if (ext2fs_inode_has_valid_blocks2(fs, &inode) ||
319
321
                    (ino == EXT2_BAD_INO))
350
352
{
351
353
        struct process_block_struct *p;
352
354
        e2fsck_t ctx;
353
 
        blk64_t lc;
 
355
        blk64_t lc, pc;
354
356
 
355
357
        if (HOLE_BLKADDR(*block_nr))
356
358
                return 0;
357
359
        p = (struct process_block_struct *) priv_data;
358
360
        ctx = p->ctx;
359
361
        lc = EXT2FS_B2C(fs, blockcnt);
 
362
        pc = EXT2FS_B2C(fs, *block_nr);
360
363
 
361
364
        if (!ext2fs_test_block_bitmap2(ctx->block_dup_map, *block_nr))
362
365
                goto finish;
369
372
        p->dup_blocks++;
370
373
        ext2fs_mark_inode_bitmap2(inode_dup_map, p->ino);
371
374
 
372
 
        if (lc != p->cur_cluster)
 
375
        /*
 
376
         * Qualifications for submitting a block for duplicate processing:
 
377
         * It's an extent/indirect block (and has a negative logical offset);
 
378
         * we've crossed a logical cluster boundary; or the physical cluster
 
379
         * suddenly changed, which indicates that blocks in a logical cluster
 
380
         * are mapped to multiple physical clusters.
 
381
         */
 
382
        if (blockcnt < 0 || lc != p->cur_cluster || pc != p->phys_cluster)
373
383
                add_dupe(ctx, p->ino, EXT2FS_B2C(fs, *block_nr), p->inode);
374
384
 
375
385
finish:
376
386
        p->cur_cluster = lc;
 
387
        p->phys_cluster = pc;
377
388
        return 0;
378
389
}
379
390
 
543
554
                        pctx.dir = t->dir;
544
555
                        fix_problem(ctx, PR_1D_DUP_FILE_LIST, &pctx);
545
556
                }
546
 
                if (file_ok) {
 
557
                /*
 
558
                 * Even if the file shares blocks with itself, we still need to
 
559
                 * clone the blocks.
 
560
                 */
 
561
                if (file_ok && (meta_data ? shared_len+1 : shared_len) != 0) {
547
562
                        fix_problem(ctx, PR_1D_DUP_BLOCKS_DEALT, &pctx);
548
563
                        continue;
549
564
                }
610
625
                            _("internal error: can't find dup_blk for %llu\n"),
611
626
                                *block_nr);
612
627
        } else {
613
 
                ext2fs_unmark_block_bitmap2(ctx->block_found_map, *block_nr);
614
 
                ext2fs_block_alloc_stats2(fs, *block_nr, -1);
 
628
                if ((*block_nr % EXT2FS_CLUSTER_RATIO(ctx->fs)) == 0)
 
629
                        ext2fs_block_alloc_stats2(fs, *block_nr, -1);
615
630
                pb->dup_blocks++;
616
631
        }
617
632
        pb->cur_cluster = lc;
687
702
        errcode_t       errcode;
688
703
        blk64_t         dup_cluster;
689
704
        blk64_t         alloc_block;
690
 
        ext2_ino_t      dir;
 
705
        ext2_ino_t      dir, ino;
691
706
        char    *buf;
692
707
        e2fsck_t ctx;
 
708
        struct ext2_inode       *inode;
693
709
};
694
710
 
695
711
static int clone_file_block(ext2_filsys fs,
737
753
                        decrement_badcount(ctx, *block_nr, p);
738
754
 
739
755
                cs->dup_cluster = c;
740
 
 
 
756
                /*
 
757
                 * Let's try an implied cluster allocation.  If we get the same
 
758
                 * cluster back, then we need to find a new block; otherwise,
 
759
                 * we're merely fixing the problem of one logical cluster being
 
760
                 * mapped to multiple physical clusters.
 
761
                 */
 
762
                new_block = 0;
 
763
                retval = ext2fs_map_cluster_block(fs, cs->ino, cs->inode,
 
764
                                                  blockcnt, &new_block);
 
765
                if (retval == 0 && new_block != 0 &&
 
766
                    EXT2FS_B2C(ctx->fs, new_block) !=
 
767
                    EXT2FS_B2C(ctx->fs, *block_nr))
 
768
                        goto cluster_alloc_ok;
741
769
                retval = ext2fs_new_block2(fs, 0, ctx->block_found_map,
742
770
                                           &new_block);
743
771
                if (retval) {
744
772
                        cs->errcode = retval;
745
773
                        return BLOCK_ABORT;
746
774
                }
 
775
cluster_alloc_ok:
747
776
                cs->alloc_block = new_block;
748
777
 
749
778
        got_block:
798
827
        cs.dup_cluster = ~0;
799
828
        cs.alloc_block = 0;
800
829
        cs.ctx = ctx;
 
830
        cs.ino = ino;
 
831
        cs.inode = &dp->inode;
801
832
        retval = ext2fs_get_mem(fs->blocksize, &cs.buf);
802
833
        if (retval)
803
834
                return retval;