Ext4: wait for log to commit when putting super
PATCH 1/1 Ext4: wait for log to commit when putting super
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.
--- fs/ext4/super.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
fs/ext4/super.c +4 -0
@@ -593,6 +593,7 @@ static void ext4_put_super(struct super_block *sb) {struct ext4_sb_info *sbi =EXT4_SB (sb);struct ext4_super_block *es = sbi->s_es; +tid_t target;int i, err;flush_workqueue (sbi->dio_unwritten_wq);
@@ -603,6 +604,9 @@ static void ext4_put_super(struct super_block *sb)if (sb->s_dirt)ext4_commit_super (sb,1 ); +if (jbd2_journal_start_commit (EXT4_SB (sb)->s_journal, &target)) +jbd2_log_wait_commit (EXT4_SB (sb)->s_journal, target); +ext4_release_system_zone (sb);ext4_mb_release (sb);ext4_ext_release (sb);
Signature · 1 line
1.6.2.5
Quoted 7 lines · Josef Bacik
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 accesss_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.
Hm, doesn't jbd2_journal_destroy already do that, but we just call it -after- we've done ext4_mb_release which leads to freeing EXT4_SB(sb)->s_group_info ?
Can we just do jbd2_journal_destroy() earlier before we tear down things it may depend on?
-Eric
Quoted 27 lines
Signed-off-by Josef Bacik <[email protected]>--- fs/ext4/super.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)fs/ext4/super.c +4
-0@@ -593,6 +593,7 @@ static void ext4_put_super(struct super_block *sb) {struct ext4_sb_info *sbi =EXT4_SB (sb);struct ext4_super_block *es = sbi->s_es; +tid_t target;int i, err;flush_workqueue (sbi->dio_unwritten_wq);@@ -603,6 +604,9 @@ static void ext4_put_super(struct super_block *sb)if (sb->s_dirt)ext4_commit_super (sb,1 ); +if (jbd2_journal_start_commit (EXT4_SB (sb)->s_journal, &target)) +jbd2_log_wait_commit (EXT4_SB (sb)->s_journal, target); +ext4_release_system_zone (sb);ext4_mb_release (sb);ext4_ext_release (sb);
Quoted 9 lines · Eric Sandeen
Quoted 7 lines · Josef Bacik
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 accesss_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.
Quoted 7 lines
Hm, doesn't
jbd2_journal_destroyalready do that, but we just call it -after- we've doneext4_mb_releasewhich leads to freeing EXT4_SB(sb)->s_group_info ?Can we just do
jbd2_journal_destroy()earlier before we tear down things it may depend on?
That seems reasonable. We do
ext4_release_system_zone(sb);
ext4_mb_release(sb);
ext4_ext_release(sb);
ext4_xattr_put_super(sb);before the journal_destroy, and all thats doing is cleaning up our internal stuff. If we want to keep it close to what ext3 does we can just move
ext4_release_system_zone(sb);
ext4_mb_release(sb);
ext4_ext_release(sb);under the journal_destroy or just move the journal destroy above all of that stuff. Whichever you prefer. Thanks,
Josef
Quoted 27 lines · Josef Bacik
Quoted 8 lines · Eric Sandeen
Quoted 7 lines · Josef Bacik
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 accesss_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.Quoted 7 lines
Hm, doesn't
jbd2_journal_destroyalready do that, but we just call it -after- we've doneext4_mb_releasewhich leads to freeing EXT4_SB(sb)->s_group_info ?Can we just do
jbd2_journal_destroy()earlier before we tear down things it may depend on?That seems reasonable. We do
ext4_release_system_zone(sb); ext4_mb_release(sb); ext4_ext_release(sb); ext4_xattr_put_super(sb);before the
journal_destroy, and all thats doing is cleaning up our internal stuff. If we want to keep it close to what ext3 does we can just move
Quoted 6 lines
ext4_release_system_zone(sb); ext4_mb_release(sb); ext4_ext_release(sb);under the
journal_destroyor just move the journal destroy above all of that stuff. Whichever you prefer. Thanks,
I guess it doesn't matter much to me, I just preferred rearranging teardown order to adding more logic that I think is already taken care of in the jbd2_journal_destroy call ..
Thanks for finding this! :)
-Eric
Quoted 1 line
Josef
[email protected]
maintainerQuoted 4 lines · Eric Sandeen
I guess it doesn't matter much to me, I just preferred rearranging teardown order to adding more logic that I think is already taken care of in the
jbd2_journal_destroycall ..
Agreed.
Quoted 1 line
Thanks for finding this! :)
... and seconded! :-)
- Ted