summaryrefslogtreecommitdiff
path: root/ctree.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2016-01-29 13:03:23 +0800
committerDavid Sterba <dsterba@suse.com>2016-06-07 18:15:19 +0200
commitf5e77e4c520aa46583f7dd0f1d264ed93714acb2 (patch)
tree57feb05cfc6ae6f4048e21dd8efba893ee9dd5b1 /ctree.c
parentf07c8149718e2b841b91269cc2c0d5ed92df1bca (diff)
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 <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'ctree.c')
-rw-r--r--ctree.c24
1 files changed, 24 insertions, 0 deletions
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;
+ }
+}