diff mbox series

[12/18] btrfs-progs: add btrfs_readahead_node_child helper

Message ID 6bbffaa00e20aac133463f344979e73283c4f404.1681939316.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: more prep work for syncing ctree.c | expand

Commit Message

Josef Bacik April 19, 2023, 9:24 p.m. UTC
This exists in the kernel as a wrapper for readahead_tree_block, and is
used extensively in ctree.c in the kernel.  Sync this helper so that we
can easily sync ctree.c

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 kernel-shared/extent_io.c | 14 ++++++++++++++
 kernel-shared/extent_io.h |  1 +
 2 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/kernel-shared/extent_io.c b/kernel-shared/extent_io.c
index d6705e37..105b5ec8 100644
--- a/kernel-shared/extent_io.c
+++ b/kernel-shared/extent_io.c
@@ -651,3 +651,17 @@  void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *srcv)
 {
 	write_extent_buffer(eb, srcv, btrfs_header_fsid(), BTRFS_FSID_SIZE);
 }
+
+/*
+ * btrfs_readahead_node_child - readahead a node's child block
+ * @node:	parent node we're reading from
+ * @slot:	slot in the parent node for the child we want to read
+ *
+ * A helper for readahead_tree_block, we simply read the bytenr pointed at the
+ * slot in the node provided.
+ */
+void btrfs_readahead_node_child(struct extent_buffer *node, int slot)
+{
+	readahead_tree_block(node->fs_info, btrfs_node_blockptr(node, slot),
+			     btrfs_node_ptr_generation(node, slot));
+}
diff --git a/kernel-shared/extent_io.h b/kernel-shared/extent_io.h
index b4c2ac97..a1cda3a5 100644
--- a/kernel-shared/extent_io.h
+++ b/kernel-shared/extent_io.h
@@ -137,5 +137,6 @@  void extent_buffer_bitmap_set(struct extent_buffer *eb, unsigned long start,
 void extent_buffer_init_cache(struct btrfs_fs_info *fs_info);
 void extent_buffer_free_cache(struct btrfs_fs_info *fs_info);
 void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *srcv);
+void btrfs_readahead_node_child(struct extent_buffer *node, int slot);
 
 #endif