When argument '-n' was specified and should run in read-only mode, we
should not attempt to discard anything. In order to do that we have to
check for E2F_OPT_NO flag and clear E2F_OPT_DISCARD flag if E2F_OPT_NO
is set.
This commit fixes the problem when we would mark inode tables as zeroed
(EXT2_BG_INODE_ZEROED) even when e2fsck is running in read-only mode. We
also move the check for E2F_OPT_NO so we can clear E2F_OPT_DISCARD as
early as possible.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
if (ext2fs_test_changed(fs))
ctx->options &= ~E2F_OPT_DISCARD;
- if (!(ctx->options & E2F_OPT_NO) &&
- (ctx->options & E2F_OPT_DISCARD) &&
+ if ((ctx->options & E2F_OPT_DISCARD) &&
(io_channel_discard(fs->io, start, count)))
ctx->options &= ~E2F_OPT_DISCARD;
}
ctx->options &= ~E2F_OPT_DISCARD;
}
- if ((ctx->options & E2F_OPT_NO) || !(ctx->options & E2F_OPT_DISCARD))
+ if (!(ctx->options & E2F_OPT_DISCARD))
return;
/*
profile_set_syntax_err_cb(syntax_err_report);
profile_init(config_fn, &ctx->profile);
+ /* Turn off discard in read-only mode */
+ if ((ctx->options & E2F_OPT_NO) &&
+ (ctx->options & E2F_OPT_DISCARD))
+ ctx->options &= ~E2F_OPT_DISCARD;
+
if (flush) {
fd = open(ctx->filesystem_name, O_RDONLY, 0);
if (fd < 0) {