Merge tag 'for-5.11/drivers-2020-12-14' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / fs / btrfs / qgroup.c
index 87bd37b..fe30460 100644 (file)
@@ -894,8 +894,6 @@ static int btrfs_clean_quota_tree(struct btrfs_trans_handle *trans,
        if (!path)
                return -ENOMEM;
 
-       path->leave_spinning = 1;
-
        key.objectid = 0;
        key.offset = 0;
        key.type = 0;
@@ -1944,34 +1942,22 @@ static int qgroup_trace_extent_swap(struct btrfs_trans_handle* trans,
                struct btrfs_key dst_key;
 
                if (src_path->nodes[cur_level] == NULL) {
-                       struct btrfs_key first_key;
                        struct extent_buffer *eb;
                        int parent_slot;
-                       u64 child_gen;
-                       u64 child_bytenr;
 
                        eb = src_path->nodes[cur_level + 1];
                        parent_slot = src_path->slots[cur_level + 1];
-                       child_bytenr = btrfs_node_blockptr(eb, parent_slot);
-                       child_gen = btrfs_node_ptr_generation(eb, parent_slot);
-                       btrfs_node_key_to_cpu(eb, &first_key, parent_slot);
 
-                       eb = read_tree_block(fs_info, child_bytenr, child_gen,
-                                            cur_level, &first_key);
+                       eb = btrfs_read_node_slot(eb, parent_slot);
                        if (IS_ERR(eb)) {
                                ret = PTR_ERR(eb);
                                goto out;
-                       } else if (!extent_buffer_uptodate(eb)) {
-                               free_extent_buffer(eb);
-                               ret = -EIO;
-                               goto out;
                        }
 
                        src_path->nodes[cur_level] = eb;
 
                        btrfs_tree_read_lock(eb);
-                       btrfs_set_lock_blocking_read(eb);
-                       src_path->locks[cur_level] = BTRFS_READ_LOCK_BLOCKING;
+                       src_path->locks[cur_level] = BTRFS_READ_LOCK;
                }
 
                src_path->slots[cur_level] = dst_path->slots[cur_level];
@@ -2066,10 +2052,8 @@ static int qgroup_trace_new_subtree_blocks(struct btrfs_trans_handle* trans,
 
        /* Read the tree block if needed */
        if (dst_path->nodes[cur_level] == NULL) {
-               struct btrfs_key first_key;
                int parent_slot;
                u64 child_gen;
-               u64 child_bytenr;
 
                /*
                 * dst_path->nodes[root_level] must be initialized before
@@ -2088,31 +2072,23 @@ static int qgroup_trace_new_subtree_blocks(struct btrfs_trans_handle* trans,
                  */
                eb = dst_path->nodes[cur_level + 1];
                parent_slot = dst_path->slots[cur_level + 1];
-               child_bytenr = btrfs_node_blockptr(eb, parent_slot);
                child_gen = btrfs_node_ptr_generation(eb, parent_slot);
-               btrfs_node_key_to_cpu(eb, &first_key, parent_slot);
 
                /* This node is old, no need to trace */
                if (child_gen < last_snapshot)
                        goto out;
 
-               eb = read_tree_block(fs_info, child_bytenr, child_gen,
-                                    cur_level, &first_key);
+               eb = btrfs_read_node_slot(eb, parent_slot);
                if (IS_ERR(eb)) {
                        ret = PTR_ERR(eb);
                        goto out;
-               } else if (!extent_buffer_uptodate(eb)) {
-                       free_extent_buffer(eb);
-                       ret = -EIO;
-                       goto out;
                }
 
                dst_path->nodes[cur_level] = eb;
                dst_path->slots[cur_level] = 0;
 
                btrfs_tree_read_lock(eb);
-               btrfs_set_lock_blocking_read(eb);
-               dst_path->locks[cur_level] = BTRFS_READ_LOCK_BLOCKING;
+               dst_path->locks[cur_level] = BTRFS_READ_LOCK;
                need_cleanup = true;
        }
 
@@ -2256,38 +2232,28 @@ walk_down:
        level = root_level;
        while (level >= 0) {
                if (path->nodes[level] == NULL) {
-                       struct btrfs_key first_key;
                        int parent_slot;
-                       u64 child_gen;
                        u64 child_bytenr;
 
                        /*
-                        * We need to get child blockptr/gen from parent before
-                        * we can read it.
+                        * We need to get child blockptr from parent before we
+                        * can read it.
                          */
                        eb = path->nodes[level + 1];
                        parent_slot = path->slots[level + 1];
                        child_bytenr = btrfs_node_blockptr(eb, parent_slot);
-                       child_gen = btrfs_node_ptr_generation(eb, parent_slot);
-                       btrfs_node_key_to_cpu(eb, &first_key, parent_slot);
 
-                       eb = read_tree_block(fs_info, child_bytenr, child_gen,
-                                            level, &first_key);
+                       eb = btrfs_read_node_slot(eb, parent_slot);
                        if (IS_ERR(eb)) {
                                ret = PTR_ERR(eb);
                                goto out;
-                       } else if (!extent_buffer_uptodate(eb)) {
-                               free_extent_buffer(eb);
-                               ret = -EIO;
-                               goto out;
                        }
 
                        path->nodes[level] = eb;
                        path->slots[level] = 0;
 
                        btrfs_tree_read_lock(eb);
-                       btrfs_set_lock_blocking_read(eb);
-                       path->locks[level] = BTRFS_READ_LOCK_BLOCKING;
+                       path->locks[level] = BTRFS_READ_LOCK;
 
                        ret = btrfs_qgroup_trace_extent(trans, child_bytenr,
                                                        fs_info->nodesize,
@@ -4242,7 +4208,7 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,
        spin_unlock(&blocks->lock);
 
        /* Read out reloc subtree root */
-       reloc_eb = read_tree_block(fs_info, block->reloc_bytenr,
+       reloc_eb = read_tree_block(fs_info, block->reloc_bytenr, 0,
                                   block->reloc_generation, block->level,
                                   &block->first_key);
        if (IS_ERR(reloc_eb)) {