summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorNikolay Borisov2019-03-25 13:31:24 +0100
committerDavid Sterba2019-04-29 19:02:36 +0200
commit41e7acd38c1ae82f24f51d302bbdecdb4675b6b2 (patch)
tree50f7d2fb844c9b8959df72b86ca879e85c2ede08 /fs/btrfs/extent_io.c
parentbtrfs: Handle pending/pinned chunks before blockgroup relocation during devic... (diff)
downloadkernel-qcow2-linux-41e7acd38c1ae82f24f51d302bbdecdb4675b6b2.tar.gz
kernel-qcow2-linux-41e7acd38c1ae82f24f51d302bbdecdb4675b6b2.tar.xz
kernel-qcow2-linux-41e7acd38c1ae82f24f51d302bbdecdb4675b6b2.zip
btrfs: Rename and export clear_btree_io_tree
This function is going to be used to clear out the device extent allocation information. Give it a more generic name and export it. This is in preparation to replacing the pending/pinned chunk lists with an extent tree. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a3e3e95c632e..26d7b6a5d567 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -266,6 +266,35 @@ void extent_io_tree_init(struct btrfs_fs_info *fs_info,
tree->owner = owner;
}
+void extent_io_tree_release(struct extent_io_tree *tree)
+{
+ spin_lock(&tree->lock);
+ /*
+ * Do a single barrier for the waitqueue_active check here, the state
+ * of the waitqueue should not change once extent_io_tree_release is
+ * called.
+ */
+ smp_mb();
+ while (!RB_EMPTY_ROOT(&tree->state)) {
+ struct rb_node *node;
+ struct extent_state *state;
+
+ node = rb_first(&tree->state);
+ state = rb_entry(node, struct extent_state, rb_node);
+ rb_erase(&state->rb_node, &tree->state);
+ RB_CLEAR_NODE(&state->rb_node);
+ /*
+ * btree io trees aren't supposed to have tasks waiting for
+ * changes in the flags of extent states ever.
+ */
+ ASSERT(!waitqueue_active(&state->wq));
+ free_extent_state(state);
+
+ cond_resched_lock(&tree->lock);
+ }
+ spin_unlock(&tree->lock);
+}
+
static struct extent_state *alloc_extent_state(gfp_t mask)
{
struct extent_state *state;