Whamcloud - gitweb
config: update config.{guess,sub}
[tools/e2fsprogs.git] / e2fsck / pass1b.c
index 241669c..bca701c 100644 (file)
@@ -257,7 +257,7 @@ void e2fsck_pass1_dupblocks(e2fsck_t ctx, char *block_buf)
                        ctx->fs->super->s_first_data_block,
                        ext2fs_blocks_count(ctx->fs->super) - 1,
                        &next);
-               if (result == ENOENT) {
+               if (result == ENOENT && !(ctx->options & E2F_OPT_NO)) {
                        ext2fs_clear_feature_shared_blocks(ctx->fs->super);
                        ext2fs_mark_super_dirty(ctx->fs);
                }
@@ -705,6 +705,10 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
                fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
        if (ctx->inode_bad_map)
                ext2fs_unmark_inode_bitmap2(ctx->inode_bad_map, ino);
+       if (ctx->inode_reg_map)
+               ext2fs_unmark_inode_bitmap2(ctx->inode_reg_map, ino);
+       ext2fs_unmark_inode_bitmap2(ctx->inode_dir_map, ino);
+       ext2fs_unmark_inode_bitmap2(ctx->inode_used_map, ino);
        ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(dp->inode.i_mode));
        quota_data_sub(ctx->qctx, &dp->inode, ino,
                       pb.dup_blocks * fs->blocksize);
@@ -796,6 +800,7 @@ static int clone_file_block(ext2_filsys fs,
        e2fsck_t ctx;
        blk64_t c;
        int is_meta = 0;
+       int should_write = 1;
 
        ctx = cs->ctx;
        deferred_dec_badcount(cs);
@@ -803,6 +808,11 @@ static int clone_file_block(ext2_filsys fs,
        if (*block_nr == 0)
                return 0;
 
+       if (ext2fs_has_feature_shared_blocks(ctx->fs->super) &&
+           (ctx->options & E2F_OPT_UNSHARE_BLOCKS) &&
+           (ctx->options & E2F_OPT_NO))
+               should_write = 0;
+
        c = EXT2FS_B2C(fs, blockcnt);
        if (check_if_fs_cluster(ctx, EXT2FS_B2C(fs, *block_nr)))
                is_meta = 1;
@@ -875,16 +885,25 @@ cluster_alloc_ok:
                        cs->errcode = retval;
                        return BLOCK_ABORT;
                }
-               retval = io_channel_write_blk64(fs->io, new_block, 1, cs->buf);
-               if (retval) {
-                       cs->errcode = retval;
-                       return BLOCK_ABORT;
+               if (should_write) {
+                       retval = io_channel_write_blk64(fs->io, new_block, 1, cs->buf);
+                       if (retval) {
+                               cs->errcode = retval;
+                               return BLOCK_ABORT;
+                       }
                }
                cs->save_dup_cluster = (is_meta ? NULL : p);
                cs->save_blocknr = *block_nr;
                *block_nr = new_block;
                ext2fs_mark_block_bitmap2(ctx->block_found_map, new_block);
                ext2fs_mark_block_bitmap2(fs->block_map, new_block);
+
+               if (!should_write) {
+                       /* Don't try to change extent information; we want e2fsck to
+                        * return success.
+                        */
+                       return 0;
+               }
                return BLOCK_CHANGED;
        }
        return 0;