2009-12-07 21:00:41

by Josef Bacik

[permalink] [raw]
Subject: [PATCH] Ext4: wait for log to commit when putting super V2.

Update:
-Instead of adding new logic to wait for the journal to commit, just move the
cleanup code below the journal destruction which does the same thing. Thanks to
Eric Sandeen for the suggestion.

There is a problem where a transaction will be committing while we're unmounting
the filesystem and you will get a panic because EXT4_SB(sb)->s_group_info has
been kfree'ed in ext4_put_super. The commit code does the callback for the
mballoc stuff to release free'ed blocks in the transaction and panic's trying to
access s_group_info. The fix is to wait for the transaction to finish
committing before we start cleaning up the mballoc stuff. This patch hasn't
been tested yet, but its an obvious fix.

Signed-off-by: Josef Bacik <[email protected]>
---
fs/ext4/super.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d4ca92a..6721e10 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -603,10 +603,6 @@ static void ext4_put_super(struct super_block *sb)
if (sb->s_dirt)
ext4_commit_super(sb, 1);

- ext4_release_system_zone(sb);
- ext4_mb_release(sb);
- ext4_ext_release(sb);
- ext4_xattr_put_super(sb);
if (sbi->s_journal) {
err = jbd2_journal_destroy(sbi->s_journal);
sbi->s_journal = NULL;
@@ -614,6 +610,12 @@ static void ext4_put_super(struct super_block *sb)
ext4_abort(sb, __func__,
"Couldn't clean up the journal");
}
+
+ ext4_release_system_zone(sb);
+ ext4_mb_release(sb);
+ ext4_ext_release(sb);
+ ext4_xattr_put_super(sb);
+
if (!(sb->s_flags & MS_RDONLY)) {
EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
es->s_state = cpu_to_le16(sbi->s_mount_state);
--
1.6.2.5



2009-12-09 03:10:50

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] Ext4: wait for log to commit when putting super V2.

On Mon, Dec 07, 2009 at 04:00:44PM -0500, Josef Bacik wrote:
> Update:
> -Instead of adding new logic to wait for the journal to commit, just move the
> cleanup code below the journal destruction which does the same thing. Thanks to
> Eric Sandeen for the suggestion.
>
> There is a problem where a transaction will be committing while we're unmounting
> the filesystem and you will get a panic because EXT4_SB(sb)->s_group_info has
> been kfree'ed in ext4_put_super. The commit code does the callback for the
> mballoc stuff to release free'ed blocks in the transaction and panic's trying to
> access s_group_info. The fix is to wait for the transaction to finish
> committing before we start cleaning up the mballoc stuff. This patch hasn't
> been tested yet, but its an obvious fix.

Added to the ext4 patch queue, thanks.

- Ted