extent_io.c (478ef8868ff80372e29d1c5283f360cf49ab0a8b) extent_io.c (bfb484d922a317183d77b3b6db77a2ff659384cc)
1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/bitops.h>
4#include <linux/slab.h>
5#include <linux/bio.h>
6#include <linux/mm.h>
7#include <linux/pagemap.h>
8#include <linux/page-flags.h>

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

6118 */
6119 if (!test_and_clear_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags)) {
6120 spin_unlock(&eb->refs_lock);
6121 return 0;
6122 }
6123
6124 return release_extent_buffer(eb);
6125}
1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/bitops.h>
4#include <linux/slab.h>
5#include <linux/bio.h>
6#include <linux/mm.h>
7#include <linux/pagemap.h>
8#include <linux/page-flags.h>

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

6118 */
6119 if (!test_and_clear_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags)) {
6120 spin_unlock(&eb->refs_lock);
6121 return 0;
6122 }
6123
6124 return release_extent_buffer(eb);
6125}
6126
6127/*
6128 * btrfs_readahead_tree_block - attempt to readahead a child block
6129 * @fs_info: the fs_info
6130 * @bytenr: bytenr to read
6131 * @gen: generation for the uptodate check, can be 0
6132 *
6133 * Attempt to readahead a tree block at @bytenr. If @gen is 0 then we do a
6134 * normal uptodate check of the eb, without checking the generation. If we have
6135 * to read the block we will not block on anything.
6136 */
6137void btrfs_readahead_tree_block(struct btrfs_fs_info *fs_info,
6138 u64 bytenr, u64 gen)
6139{
6140 struct extent_buffer *eb;
6141 int ret;
6142
6143 eb = btrfs_find_create_tree_block(fs_info, bytenr);
6144 if (IS_ERR(eb))
6145 return;
6146
6147 if (btrfs_buffer_uptodate(eb, gen, 1)) {
6148 free_extent_buffer(eb);
6149 return;
6150 }
6151
6152 ret = read_extent_buffer_pages(eb, WAIT_NONE, 0);
6153 if (ret < 0)
6154 free_extent_buffer_stale(eb);
6155 else
6156 free_extent_buffer(eb);
6157}
6158
6159/*
6160 * btrfs_readahead_node_child - readahead a node's child block
6161 * @node: parent node we're reading from
6162 * @slot: slot in the parent node for the child we want to read
6163 *
6164 * A helper for btrfs_readahead_tree_block, we simply read the bytenr pointed at
6165 * the slot in the node provided.
6166 */
6167void btrfs_readahead_node_child(struct extent_buffer *node, int slot)
6168{
6169 btrfs_readahead_tree_block(node->fs_info,
6170 btrfs_node_blockptr(node, slot),
6171 btrfs_node_ptr_generation(node, slot));
6172}