extent-tree.c (1136fa0c07de570dc17858745af8be169d1440ba) extent-tree.c (b4be6aefa73c9a6899ef3ba9c5faaa8a66e333ef)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
4 */
5
6#include <linux/sched.h>
7#include <linux/sched/signal.h>
8#include <linux/pagemap.h>

--- 5608 unchanged lines hidden (view full) ---

5617 struct btrfs_root *tree_root = fs_info->tree_root;
5618 struct btrfs_root_item *root_item = &root->root_item;
5619 struct walk_control *wc;
5620 struct btrfs_key key;
5621 int err = 0;
5622 int ret;
5623 int level;
5624 bool root_dropped = false;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
4 */
5
6#include <linux/sched.h>
7#include <linux/sched/signal.h>
8#include <linux/pagemap.h>

--- 5608 unchanged lines hidden (view full) ---

5617 struct btrfs_root *tree_root = fs_info->tree_root;
5618 struct btrfs_root_item *root_item = &root->root_item;
5619 struct walk_control *wc;
5620 struct btrfs_key key;
5621 int err = 0;
5622 int ret;
5623 int level;
5624 bool root_dropped = false;
5625 bool unfinished_drop = false;
5625
5626 btrfs_debug(fs_info, "Drop subvolume %llu", root->root_key.objectid);
5627
5628 path = btrfs_alloc_path();
5629 if (!path) {
5630 err = -ENOMEM;
5631 goto out;
5632 }

--- 26 unchanged lines hidden (view full) ---

5659 * This will help us catch people modifying the fs tree while we're
5660 * dropping it. It is unsafe to mess with the fs tree while it's being
5661 * dropped as we unlock the root node and parent nodes as we walk down
5662 * the tree, assuming nothing will change. If something does change
5663 * then we'll have stale information and drop references to blocks we've
5664 * already dropped.
5665 */
5666 set_bit(BTRFS_ROOT_DELETING, &root->state);
5626
5627 btrfs_debug(fs_info, "Drop subvolume %llu", root->root_key.objectid);
5628
5629 path = btrfs_alloc_path();
5630 if (!path) {
5631 err = -ENOMEM;
5632 goto out;
5633 }

--- 26 unchanged lines hidden (view full) ---

5660 * This will help us catch people modifying the fs tree while we're
5661 * dropping it. It is unsafe to mess with the fs tree while it's being
5662 * dropped as we unlock the root node and parent nodes as we walk down
5663 * the tree, assuming nothing will change. If something does change
5664 * then we'll have stale information and drop references to blocks we've
5665 * already dropped.
5666 */
5667 set_bit(BTRFS_ROOT_DELETING, &root->state);
5668 unfinished_drop = test_bit(BTRFS_ROOT_UNFINISHED_DROP, &root->state);
5669
5667 if (btrfs_disk_key_objectid(&root_item->drop_progress) == 0) {
5668 level = btrfs_header_level(root->node);
5669 path->nodes[level] = btrfs_lock_root_node(root);
5670 path->slots[level] = 0;
5671 path->locks[level] = BTRFS_WRITE_LOCK;
5672 memset(&wc->update_progress, 0,
5673 sizeof(wc->update_progress));
5674 } else {

--- 159 unchanged lines hidden (view full) ---

5834 root_dropped = true;
5835out_end_trans:
5836 btrfs_end_transaction_throttle(trans);
5837out_free:
5838 kfree(wc);
5839 btrfs_free_path(path);
5840out:
5841 /*
5670 if (btrfs_disk_key_objectid(&root_item->drop_progress) == 0) {
5671 level = btrfs_header_level(root->node);
5672 path->nodes[level] = btrfs_lock_root_node(root);
5673 path->slots[level] = 0;
5674 path->locks[level] = BTRFS_WRITE_LOCK;
5675 memset(&wc->update_progress, 0,
5676 sizeof(wc->update_progress));
5677 } else {

--- 159 unchanged lines hidden (view full) ---

5837 root_dropped = true;
5838out_end_trans:
5839 btrfs_end_transaction_throttle(trans);
5840out_free:
5841 kfree(wc);
5842 btrfs_free_path(path);
5843out:
5844 /*
5845 * We were an unfinished drop root, check to see if there are any
5846 * pending, and if not clear and wake up any waiters.
5847 */
5848 if (!err && unfinished_drop)
5849 btrfs_maybe_wake_unfinished_drop(fs_info);
5850
5851 /*
5842 * So if we need to stop dropping the snapshot for whatever reason we
5843 * need to make sure to add it back to the dead root list so that we
5844 * keep trying to do the work later. This also cleans up roots if we
5845 * don't have it in the radix (like when we recover after a power fail
5846 * or unmount) so we don't leak memory.
5847 */
5848 if (!for_reloc && !root_dropped)
5849 btrfs_add_dead_root(root);

--- 330 unchanged lines hidden ---
5852 * So if we need to stop dropping the snapshot for whatever reason we
5853 * need to make sure to add it back to the dead root list so that we
5854 * keep trying to do the work later. This also cleans up roots if we
5855 * don't have it in the radix (like when we recover after a power fail
5856 * or unmount) so we don't leak memory.
5857 */
5858 if (!for_reloc && !root_dropped)
5859 btrfs_add_dead_root(root);

--- 330 unchanged lines hidden ---