]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Btrfs: clean up resources during umount after trans is aborted
authorLiu Bo <bo.liu@linux.alibaba.com>
Fri, 30 Mar 2018 22:11:56 +0000 (06:11 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 May 2018 05:52:22 +0000 (07:52 +0200)
commitf2924e32dcf27b2267f2fd5f10482685386d47f6
treeff54a8d196fd1a50fc9505132fc9a602a32d1165
parent1908ca222b3656f7607e5bde4fe350c6051791f0
Btrfs: clean up resources during umount after trans is aborted

[ Upstream commit af7227338135d2f1b1552bf9a6d43e02dcba10b9 ]

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 <bo.liu@linux.alibaba.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/disk-io.c