static errcode_t test_discard(io_channel channel, unsigned long long block, unsigned long long count) { struct test_private_data *data; errcode_t retval = 0; EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct test_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); if (data->real) retval = io_channel_discard(data->real, block, count); if (data->flags & TEST_FLAG_DISCARD) fprintf(data->outfile, "Test_io: discard(%llu, %llu) returned %s\n", block, count, retval ? error_message(retval) : "OK"); return retval; }
static void e2fsck_discard_blocks(e2fsck_t ctx, blk64_t start, blk64_t count) { ext2_filsys fs = ctx->fs; /* * If the filesystem has changed it means that there was an corruption * which should be repaired, but in some cases just one e2fsck run is * not enough to fix the problem, hence it is not safe to run discard * in this case. */ if (ext2fs_test_changed(fs)) ctx->options &= ~E2F_OPT_DISCARD; if ((ctx->options & E2F_OPT_DISCARD) && (io_channel_discard(fs->io, start, count))) ctx->options &= ~E2F_OPT_DISCARD; }