From 3c6b8977d44c66f0a50dd77c18a78b57b1022f8c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 10 Jul 2001 14:27:58 -0400 Subject: [PATCH] Speed up journal recovery in userspace by avoiding a pointless unconditional ext2_flush() call. Also made ext2_flush() more efficient when the superblock is modified after the filesystem has been flushed, and make it clear the superblock dirty flag after doing the superblock/block group descriptor flush. --- e2fsck/ChangeLog | 5 +++++ e2fsck/journal.c | 3 ++- lib/ext2fs/ChangeLog | 9 +++++++++ lib/ext2fs/closefs.c | 3 +++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 55b14c7..3432de9 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,8 @@ +2001-07-10 Theodore Tso + + * journal.c (e2fsck_run_ext3_journal): Only call ext3_flush() if + the superblock is dirty. + 2001-07-07 Theodore Tso * pass1b.c (pass1b, process_pass1b_block): Change the num_bad diff --git a/e2fsck/journal.c b/e2fsck/journal.c index dbfa118..96329df 100644 --- a/e2fsck/journal.c +++ b/e2fsck/journal.c @@ -716,7 +716,8 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx) return EXT2_ET_FILE_RO; } - ext2fs_flush(ctx->fs); /* Force out any modifications */ + if (fs->flags & EXT2_FLAG_DIRTY) + ext2fs_flush(ctx->fs); /* Force out any modifications */ recover_retval = recover_ext3_journal(ctx); diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 987b586..cd881e8 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,12 @@ +2001-07-10 Theodore Tso + + * closefs.c (write_primary_superblock): After writing changes to + the primary superblock, update the original superblock + copy so we don't have to re-write those changes in the + future. + (ext2fs_flush): Clear the superblock dirty flag after + we've flushed out changes to disk. + 2001-07-07 Theodore Tso * bitops.h (ext2fs_find_first_bit_set): Use %esi instead of %ebx diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 69a769f..f52c343 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -91,6 +91,7 @@ static errcode_t write_primary_superblock(ext2_filsys fs, if (retval) return retval; } + memcpy(fs->orig_super, super, SUPERBLOCK_SIZE); return 0; } @@ -251,6 +252,8 @@ errcode_t ext2fs_flush(ext2_filsys fs) goto errout; } + fs->flags &= ~EXT2_FLAG_DIRTY; + /* * Flush the blocks out to disk */ -- 1.8.3.1