Skip to content

Commit 48aa5c0

Browse files
adam900710kdave
authored andcommitted
btrfs: only invalidate btree inode pages after all ebs are released
In close_ctree(), we call invalidate_inode_pages2() to invalidate all pages from btree inode. But the problem is, it never returns 0, but always -EBUSY. The problem is that we are still holding all the essential tree root nodes, thus pages holding those tree blocks can not be invalidated thus invalidate_inode_pages2() always returns -EBUSY. This is also against the error cleanup path of open_ctree(), which properly frees all root pointers before calling invalidate_inode_pages(). So fix the order by delaying invalidate_inode_pages2() until we have freed all root pointers. Reviewed-by: Anand Jain <asj@kernel.org> Reviewed-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 7ae37b2 commit 48aa5c0

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

fs/btrfs/disk-io.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4434,20 +4434,20 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
44344434

44354435
btrfs_put_block_group_cache(fs_info);
44364436

4437-
/*
4438-
* we must make sure there is not any read request to
4439-
* submit after we stopping all workers.
4440-
*/
4441-
invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
4442-
btrfs_stop_all_workers(fs_info);
4443-
44444437
/* We shouldn't have any transaction open at this point */
44454438
warn_about_uncommitted_trans(fs_info);
44464439

44474440
clear_bit(BTRFS_FS_OPEN, &fs_info->flags);
44484441
free_root_pointers(fs_info, true);
44494442
btrfs_free_fs_roots(fs_info);
44504443

4444+
/*
4445+
* We must make sure there is not any read request to
4446+
* submit after we stop all workers.
4447+
*/
4448+
invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
4449+
btrfs_stop_all_workers(fs_info);
4450+
44514451
/*
44524452
* We must free the block groups after dropping the fs_roots as we could
44534453
* have had an IO error and have left over tree log blocks that aren't

0 commit comments

Comments
 (0)