Skip to content

Commit af72273

Browse files
liubogithubkdave
authored andcommitted
Btrfs: clean up resources during umount after trans is aborted
Currently if some fatal errors occur, like all IO get -EIO, resources would be cleaned up when a) transaction is being committed or b) BTRFS_FS_STATE_ERROR is set However, in some rare cases, resources may be left alone after transaction gets aborted and umount may run into some ASSERT(), e.g. ASSERT(list_empty(&block_group->dirty_list)); For case a), in btrfs_commit_transaciton(), there're several places at the beginning where we just call btrfs_end_transaction() without cleaning up resources. For case b), it is possible that the trans handle doesn't have any dirty stuff, then only trans hanlde is marked as aborted while BTRFS_FS_STATE_ERROR is not set, so resources remain in memory. This makes btrfs also check BTRFS_FS_STATE_TRANS_ABORTED to make sure that all resources won't stay in memory after umount. Signed-off-by: Liu Bo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 1e1c50a commit af72273

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/disk-io.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3812,7 +3812,8 @@ void close_ctree(struct btrfs_fs_info *fs_info)
38123812
btrfs_err(fs_info, "commit super ret %d", ret);
38133813
}
38143814

3815-
if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state))
3815+
if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state) ||
3816+
test_bit(BTRFS_FS_STATE_TRANS_ABORTED, &fs_info->fs_state))
38163817
btrfs_error_commit_super(fs_info);
38173818

38183819
kthread_stop(fs_info->transaction_kthread);

0 commit comments

Comments
 (0)