From 27a407df546eafa54f3f50c470e3a0a4c788fae5 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 25 May 2009 20:14:04 -0400 Subject: [PATCH] e2fsck: Fix journal replay bug which reverts changes to the bg descriptors Fix a regression in e2fsprogs 1.41.5 which would undo updates to the block group descriptors after a journal replay, caused by commit b7c5b403. We now use ext2fs_free() instead of ext2fs_close() to make sure we the library will never try to write out superblock or block group descriptors. Signed-off-by: "Theodore Ts'o" --- e2fsck/journal.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/e2fsck/journal.c b/e2fsck/journal.c index adbd3db..155857d 100644 --- a/e2fsck/journal.c +++ b/e2fsck/journal.c @@ -854,6 +854,8 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx) io_manager io_ptr = ctx->fs->io->manager; int blocksize = ctx->fs->blocksize; errcode_t retval, recover_retval; + io_stats stats = 0; + unsigned long long kbytes_written = 0; printf(_("%s: recovering journal\n"), ctx->device_name); if (ctx->options & E2F_OPT_READONLY) { @@ -871,11 +873,15 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx) * Reload the filesystem context to get up-to-date data from disk * because journal recovery will change the filesystem under us. */ - ext2fs_close(ctx->fs); + if (ctx->fs->super->s_kbytes_written && + ctx->fs->io->manager->get_stats) + ctx->fs->io->manager->get_stats(ctx->fs->io, &stats); + if (stats && stats->bytes_written) + kbytes_written = stats->bytes_written >> 10; + ext2fs_free(ctx->fs); retval = ext2fs_open(ctx->filesystem_name, EXT2_FLAG_RW, ctx->superblock, blocksize, io_ptr, &ctx->fs); - if (retval) { com_err(ctx->program_name, retval, _("while trying to re-open %s"), @@ -885,6 +891,7 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx) ctx->fs->priv_data = ctx; ctx->fs->now = ctx->now; ctx->fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; + ctx->fs->super->s_kbytes_written += kbytes_written; /* Set the superblock flags */ e2fsck_clear_recover(ctx, recover_retval); -- 1.8.3.1