blocks anyway, then this option will have no effect. Note when using this
option, if there is no free space to clone blocks, there is no prompt to
delete files and instead the operation will fail.
+.IP
+Note that unshare_blocks requires the "-f" option to ensure that all passes
+are run. Additionally, if "-n" is also specified, e2fsck will simulate trying
+to allocate enough space to deduplicate. If this fails, the exit code will
+be non-zero.
.RE
.TP
.B \-f
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);
}
e2fsck_t ctx;
blk64_t c;
int is_meta = 0;
+ int should_write = 1;
ctx = cs->ctx;
deferred_dec_badcount(cs);
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;
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;
ext2fs_mark_super_dirty(fs);
}
+ if (ext2fs_has_feature_shared_blocks(ctx->fs->super) &&
+ (ctx->options & E2F_OPT_UNSHARE_BLOCKS) &&
+ (ctx->options & E2F_OPT_NO))
+ /* Don't try to write or flush I/O, we just wanted to know whether or
+ * not there were enough free blocks to undo deduplication.
+ */
+ goto skip_write;
+
if (!(ctx->options & E2F_OPT_READONLY)) {
e2fsck_write_bitmaps(ctx);
if (fs->flags & EXT2_FLAG_DIRTY) {
exit_value |= FSCK_REBOOT;
}
}
+
+skip_write:
if (!ext2fs_test_valid(fs) ||
((exit_value & FSCK_CANCELED) &&
(sb->s_state & EXT2_ERROR_FS))) {