From f5e77e4c520aa46583f7dd0f1d264ed93714acb2 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 29 Jan 2016 13:03:23 +0800 Subject: btrfs-progs: extent-tree: Introduce function to find the first overlapping extent Introduce a new function, btrfs_search_overlap_extent() to find the first overlapping extent. It's useful for later btrfs-convert rework. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- ctree.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ctree.c') diff --git a/ctree.c b/ctree.c index 6875bb48..a98ad185 100644 --- a/ctree.c +++ b/ctree.c @@ -2951,3 +2951,27 @@ int btrfs_previous_extent_item(struct btrfs_root *root, } return 1; } + +/* + * Search in extent tree to found next meta/data extent + * Caller needs to check for no-hole or skinny metadata features. + */ +int btrfs_next_extent_item(struct btrfs_root *root, + struct btrfs_path *path, u64 max_objectid) +{ + struct btrfs_key found_key; + int ret; + + while (1) { + ret = btrfs_next_item(root, path); + if (ret) + return ret; + btrfs_item_key_to_cpu(path->nodes[0], &found_key, + path->slots[0]); + if (found_key.objectid > max_objectid) + return 1; + if (found_key.type == BTRFS_EXTENT_ITEM_KEY || + found_key.type == BTRFS_METADATA_ITEM_KEY) + return 0; + } +} -- cgit v1.2.3