Skip to contentSkip to conversation

Btrfs-progs: just return -ENOENT if we don't find the root item

PATCH New Josef Bacik 1 participant 1 message Oct 23, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs-progs: just return -ENOENT if we don't find the root item

We were bug_on(slot == 0), but that's just obnoxious, return -ENOENT so we can handle the situation properly. Thanks,

---
 root-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
root-tree.c +2 -1
index bdc8504..858fe2f 100644
@@ -40,10 +40,11 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
 	ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
 	if (ret < 0)
 		goto out;
+	if (path->slots[0] == 0)
+		return -ENOENT;
 
 	BUG_ON(ret == 0);
 	l = path->nodes[0];
-	BUG_ON(path->slots[0] == 0);
 	slot = path->slots[0] - 1;
 	btrfs_item_key_to_cpu(l, &found_key, slot);
 	if (found_key.objectid != objectid) {
Signature · 1 line
1.8.3.1