aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorArne Jansen <sensille@gmx.net>2011-05-23 08:33:49 -0400
committerArne Jansen <sensille@gmx.net>2011-10-02 02:48:44 -0400
commit7414a03fbf9e75fbbf2a3c16828cd862e572aa44 (patch)
treecc5fe98478b73281055a471fbce242b40a253490 /fs/btrfs/ctree.h
parent90519d66abbccc251d14719ac76f191f70826e40 (diff)
btrfs: initial readahead code and prototypes
This is the implementation for the generic read ahead framework. To trigger a readahead, btrfs_reada_add must be called. It will start a read ahead for the given range [start, end) on tree root. The returned handle can either be used to wait on the readahead to finish (btrfs_reada_wait), or to send it to the background (btrfs_reada_detach). The read ahead works as follows: On btrfs_reada_add, the root of the tree is inserted into a radix_tree. reada_start_machine will then search for extents to prefetch and trigger some reads. When a read finishes for a node, all contained node/leaf pointers that lie in the given range will also be enqueued. The reads will be triggered in sequential order, thus giving a big win over a naive enumeration. It will also make use of multi-device layouts. Each disk will have its on read pointer and all disks will by utilized in parallel. Also will no two disks read both sides of a mirror simultaneously, as this would waste seeking capacity. Instead both disks will read different parts of the filesystem. Any number of readaheads can be started in parallel. The read order will be determined globally, i.e. 2 parallel readaheads will normally finish faster than the 2 started one after another. Changes v2: - protect root->node by transaction instead of node_lock - fix missed branches: The readahead had a too simple check to determine if a branch from a node should be checked or not. It now also records the upper bound of each node to see if the requested RA range lies within. - use KERN_CONT to debug output, to avoid line breaks - defer reada_start_machine to worker to avoid deadlock Changes v3: - protect root->node by rcu Changes v5: - changed EIO-semantics of reada_tree_block_flagged - remove spin_lock from reada_control and make elems an atomic_t - remove unused read_total from reada_control - kill reada_key_cmp, use btrfs_comp_cpu_keys instead - use kref-style release functions where possible - return struct reada_control * instead of void * from btrfs_reada_add Signed-off-by: Arne Jansen <sensille@gmx.net>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index f71fd24cc152..370af767440d 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2702,4 +2702,20 @@ int btrfs_scrub_cancel_devid(struct btrfs_root *root, u64 devid);
2702int btrfs_scrub_progress(struct btrfs_root *root, u64 devid, 2702int btrfs_scrub_progress(struct btrfs_root *root, u64 devid,
2703 struct btrfs_scrub_progress *progress); 2703 struct btrfs_scrub_progress *progress);
2704 2704
2705/* reada.c */
2706struct reada_control {
2707 struct btrfs_root *root; /* tree to prefetch */
2708 struct btrfs_key key_start;
2709 struct btrfs_key key_end; /* exclusive */
2710 atomic_t elems;
2711 struct kref refcnt;
2712 wait_queue_head_t wait;
2713};
2714struct reada_control *btrfs_reada_add(struct btrfs_root *root,
2715 struct btrfs_key *start, struct btrfs_key *end);
2716int btrfs_reada_wait(void *handle);
2717void btrfs_reada_detach(void *handle);
2718int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb,
2719 u64 start, int err);
2720
2705#endif 2721#endif