Skip to content

Commit 0a31daa

Browse files
fdmananakdave
authored andcommitted
btrfs: add assertion for empty list of transactions at late stage of umount
Add an assertion to close_ctree(), after destroying all the work queues, to verify we do not have any transaction still open or committing at that at that point. If we have any, it means something is seriously wrong and that can cause memory leaks and use-after-free problems. This is motivated by the previous patches that fixed bugs where we ended up leaking an open transaction after unmounting the filesystem. Tested-by: Fabian Vogt <[email protected]> Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent a0a1db7 commit 0a31daa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/btrfs/disk-io.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4181,6 +4181,9 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
41814181
invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
41824182
btrfs_stop_all_workers(fs_info);
41834183

4184+
/* We shouldn't have any transaction open at this point */
4185+
ASSERT(list_empty(&fs_info->trans_list));
4186+
41844187
clear_bit(BTRFS_FS_OPEN, &fs_info->flags);
41854188
free_root_pointers(fs_info, true);
41864189
btrfs_free_fs_roots(fs_info);

0 commit comments

Comments
 (0)