btrfs: fix race in btrfs_free_dummy_fs_info()
authorMatthew Wilcox <[email protected]>
Wed, 14 Dec 2016 23:08:46 +0000 (15:08 -0800)
committerLinus Torvalds <[email protected]>
Thu, 15 Dec 2016 00:04:10 +0000 (16:04 -0800)
We drop the lock which protects the radix tree, so we must call
radix_tree_iter_next() in order to avoid a modification to the tree
invalidating the iterator state.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox <[email protected]>
Tested-by: Kirill A. Shutemov <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: Ross Zwisler <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/btrfs/tests/btrfs-tests.c

index bf62ad919a95db4725483000b6110b6e20890214..73076a0ea6a91b00977d8f884adb2f04d54c3d61 100644 (file)
@@ -162,6 +162,7 @@ void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info)
                                slot = radix_tree_iter_retry(&iter);
                        continue;
                }
+               slot = radix_tree_iter_next(&iter);
                spin_unlock(&fs_info->buffer_lock);
                free_extent_buffer_stale(eb);
                spin_lock(&fs_info->buffer_lock);