diff mbox

Btrfs: make sure there are not any read requests before stopping workers

Message ID 1397042602-23205-1-git-send-email-wangsl.fnst@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Wang Shilong April 9, 2014, 11:23 a.m. UTC
In close_ctree(), after we have stopped all workers,there maybe still
some read requests(for example readahead) to submit and this *maybe* trigger
an oops that user reported before:

kernel BUG at fs/btrfs/async-thread.c:619!

By hacking codes, i can reproduce this problem with one cpu available.
We fix this potential problem by invalidating all btree inode pages before
stopping all workers.

Thanks to Miao for pointing out this problem.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
---
 fs/btrfs/disk-io.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

David Sterba April 14, 2014, 4:47 p.m. UTC | #1
On Wed, Apr 09, 2014 at 07:23:22PM +0800, Wang Shilong wrote:
> In close_ctree(), after we have stopped all workers,there maybe still
> some read requests(for example readahead) to submit and this *maybe* trigger
> an oops that user reported before:
> 
> kernel BUG at fs/btrfs/async-thread.c:619!
> 
> By hacking codes, i can reproduce this problem with one cpu available.
> We fix this potential problem by invalidating all btree inode pages before
> stopping all workers.
> 
> Thanks to Miao for pointing out this problem.
> 
> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.cz>

This is for 3.15-rc

> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3619,6 +3619,11 @@ int close_ctree(struct btrfs_root *root)
>  
>  	btrfs_free_block_groups(fs_info);
>  
> +	/*
> +	 * we must make sure there is not any read request to
> +	 * submit after we stopping all workers.
> +	 */
> +	invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
>  	btrfs_stop_all_workers(fs_info);
>  
>  	free_root_pointers(fs_info, 1);

Now this shutdown sequence almost matches the one from open_ctree.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index d9698fd..8a49823 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3619,6 +3619,11 @@  int close_ctree(struct btrfs_root *root)
 
 	btrfs_free_block_groups(fs_info);
 
+	/*
+	 * we must make sure there is not any read request to
+	 * submit after we stopping all workers.
+	 */
+	invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
 	btrfs_stop_all_workers(fs_info);
 
 	free_root_pointers(fs_info, 1);