blob: 6a1086e83ffc898ff3ab7f7b33d91c2c442019d7 [file] [log] [blame]
Chris Mason6cbd5572007-06-12 09:07:21 -04001/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
17 */
18
Chris Mason3768f362007-03-13 16:47:54 -040019#include "ctree.h"
Chris Mason5eda7b52007-06-22 14:16:25 -040020#include "transaction.h"
Chris Mason3768f362007-03-13 16:47:54 -040021#include "disk-io.h"
22#include "print-tree.h"
23
Chris Masonbf4ef672008-05-08 13:26:18 -040024/*
Chris Masond352ac62008-09-29 15:18:18 -040025 * search forward for a root, starting with objectid 'search_start'
26 * if a root key is found, the objectid we find is filled into 'found_objectid'
27 * and 0 is returned. < 0 is returned on error, 1 if there is nothing
28 * left in the tree.
Chris Masonbf4ef672008-05-08 13:26:18 -040029 */
30int btrfs_search_root(struct btrfs_root *root, u64 search_start,
31 u64 *found_objectid)
32{
33 struct btrfs_path *path;
34 struct btrfs_key search_key;
35 int ret;
36
37 root = root->fs_info->tree_root;
38 search_key.objectid = search_start;
39 search_key.type = (u8)-1;
40 search_key.offset = (u64)-1;
41
42 path = btrfs_alloc_path();
43 BUG_ON(!path);
44again:
45 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
46 if (ret < 0)
47 goto out;
48 if (ret == 0) {
49 ret = 1;
50 goto out;
51 }
52 if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {
53 ret = btrfs_next_leaf(root, path);
54 if (ret)
55 goto out;
56 }
57 btrfs_item_key_to_cpu(path->nodes[0], &search_key, path->slots[0]);
58 if (search_key.type != BTRFS_ROOT_ITEM_KEY) {
59 search_key.offset++;
60 btrfs_release_path(root, path);
61 goto again;
62 }
63 ret = 0;
64 *found_objectid = search_key.objectid;
65
66out:
67 btrfs_free_path(path);
68 return ret;
69}
70
Chris Masond352ac62008-09-29 15:18:18 -040071/*
72 * lookup the root with the highest offset for a given objectid. The key we do
73 * find is copied into 'key'. If we find something return 0, otherwise 1, < 0
74 * on error.
75 */
Chris Mason3768f362007-03-13 16:47:54 -040076int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
77 struct btrfs_root_item *item, struct btrfs_key *key)
78{
Chris Mason5caf2a02007-04-02 11:20:42 -040079 struct btrfs_path *path;
Chris Mason3768f362007-03-13 16:47:54 -040080 struct btrfs_key search_key;
Chris Mason5f39d392007-10-15 16:14:19 -040081 struct btrfs_key found_key;
82 struct extent_buffer *l;
Chris Mason3768f362007-03-13 16:47:54 -040083 int ret;
84 int slot;
85
86 search_key.objectid = objectid;
Chris Mason0660b5a2008-11-17 20:37:39 -050087 search_key.type = BTRFS_ROOT_ITEM_KEY;
Chris Mason5eda7b52007-06-22 14:16:25 -040088 search_key.offset = (u64)-1;
Chris Mason3768f362007-03-13 16:47:54 -040089
Chris Mason5caf2a02007-04-02 11:20:42 -040090 path = btrfs_alloc_path();
91 BUG_ON(!path);
Chris Mason5caf2a02007-04-02 11:20:42 -040092 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
Chris Mason3768f362007-03-13 16:47:54 -040093 if (ret < 0)
94 goto out;
Chris Mason5f39d392007-10-15 16:14:19 -040095
Chris Mason3768f362007-03-13 16:47:54 -040096 BUG_ON(ret == 0);
Yan, Zheng76dda932009-09-21 16:00:26 -040097 if (path->slots[0] == 0) {
Chris Mason3768f362007-03-13 16:47:54 -040098 ret = 1;
99 goto out;
100 }
Yan, Zheng76dda932009-09-21 16:00:26 -0400101 l = path->nodes[0];
102 slot = path->slots[0] - 1;
103 btrfs_item_key_to_cpu(l, &found_key, slot);
104 if (found_key.objectid != objectid ||
105 found_key.type != BTRFS_ROOT_ITEM_KEY) {
106 ret = 1;
107 goto out;
108 }
109 if (item)
110 read_extent_buffer(l, item, btrfs_item_ptr_offset(l, slot),
111 sizeof(*item));
112 if (key)
113 memcpy(key, &found_key, sizeof(found_key));
Chris Mason3768f362007-03-13 16:47:54 -0400114 ret = 0;
115out:
Chris Mason5caf2a02007-04-02 11:20:42 -0400116 btrfs_free_path(path);
Chris Mason3768f362007-03-13 16:47:54 -0400117 return ret;
118}
119
Yan Zheng5d4f98a2009-06-10 10:45:14 -0400120int btrfs_set_root_node(struct btrfs_root_item *item,
121 struct extent_buffer *node)
122{
123 btrfs_set_root_bytenr(item, node->start);
124 btrfs_set_root_level(item, btrfs_header_level(node));
125 btrfs_set_root_generation(item, btrfs_header_generation(node));
126 return 0;
127}
128
Chris Masond352ac62008-09-29 15:18:18 -0400129/*
130 * copy the data in 'item' into the btree
131 */
Chris Masone089f052007-03-16 16:20:31 -0400132int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
133 *root, struct btrfs_key *key, struct btrfs_root_item
134 *item)
Chris Mason3768f362007-03-13 16:47:54 -0400135{
Chris Mason5caf2a02007-04-02 11:20:42 -0400136 struct btrfs_path *path;
Chris Mason5f39d392007-10-15 16:14:19 -0400137 struct extent_buffer *l;
Chris Mason3768f362007-03-13 16:47:54 -0400138 int ret;
139 int slot;
Chris Mason5f39d392007-10-15 16:14:19 -0400140 unsigned long ptr;
Chris Mason3768f362007-03-13 16:47:54 -0400141
Chris Mason5caf2a02007-04-02 11:20:42 -0400142 path = btrfs_alloc_path();
143 BUG_ON(!path);
Chris Mason5caf2a02007-04-02 11:20:42 -0400144 ret = btrfs_search_slot(trans, root, key, path, 0, 1);
Chris Mason3768f362007-03-13 16:47:54 -0400145 if (ret < 0)
146 goto out;
Chris Masond6667462008-01-03 14:51:00 -0500147
148 if (ret != 0) {
149 btrfs_print_leaf(root, path->nodes[0]);
Chris Masond3977122009-01-05 21:25:51 -0500150 printk(KERN_CRIT "unable to update root key %llu %u %llu\n",
151 (unsigned long long)key->objectid, key->type,
152 (unsigned long long)key->offset);
Chris Masond6667462008-01-03 14:51:00 -0500153 BUG_ON(1);
154 }
155
Chris Mason5f39d392007-10-15 16:14:19 -0400156 l = path->nodes[0];
Chris Mason5caf2a02007-04-02 11:20:42 -0400157 slot = path->slots[0];
Chris Mason5f39d392007-10-15 16:14:19 -0400158 ptr = btrfs_item_ptr_offset(l, slot);
159 write_extent_buffer(l, item, ptr, sizeof(*item));
Chris Mason5caf2a02007-04-02 11:20:42 -0400160 btrfs_mark_buffer_dirty(path->nodes[0]);
Chris Mason3768f362007-03-13 16:47:54 -0400161out:
Chris Mason5caf2a02007-04-02 11:20:42 -0400162 btrfs_free_path(path);
Chris Mason3768f362007-03-13 16:47:54 -0400163 return ret;
164}
165
Chris Masone089f052007-03-16 16:20:31 -0400166int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
167 *root, struct btrfs_key *key, struct btrfs_root_item
168 *item)
Chris Mason3768f362007-03-13 16:47:54 -0400169{
170 int ret;
Chris Masone089f052007-03-16 16:20:31 -0400171 ret = btrfs_insert_item(trans, root, key, item, sizeof(*item));
Chris Mason3768f362007-03-13 16:47:54 -0400172 return ret;
173}
174
Chris Masond352ac62008-09-29 15:18:18 -0400175/*
176 * at mount time we want to find all the old transaction snapshots that were in
Chris Masond3977122009-01-05 21:25:51 -0500177 * the process of being deleted if we crashed. This is any root item with an
178 * offset lower than the latest root. They need to be queued for deletion to
179 * finish what was happening when we crashed.
Chris Masond352ac62008-09-29 15:18:18 -0400180 */
Yan Zheng5d4f98a2009-06-10 10:45:14 -0400181int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid)
Chris Mason5eda7b52007-06-22 14:16:25 -0400182{
183 struct btrfs_root *dead_root;
Chris Mason5eda7b52007-06-22 14:16:25 -0400184 struct btrfs_root_item *ri;
185 struct btrfs_key key;
Chris Masona7a16fd2008-06-26 10:34:20 -0400186 struct btrfs_key found_key;
Chris Mason5eda7b52007-06-22 14:16:25 -0400187 struct btrfs_path *path;
188 int ret;
189 u32 nritems;
Chris Mason5f39d392007-10-15 16:14:19 -0400190 struct extent_buffer *leaf;
Chris Mason5eda7b52007-06-22 14:16:25 -0400191 int slot;
192
Chris Mason5ce14bb2007-09-11 11:15:39 -0400193 key.objectid = objectid;
Chris Mason5eda7b52007-06-22 14:16:25 -0400194 btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
195 key.offset = 0;
196 path = btrfs_alloc_path();
197 if (!path)
198 return -ENOMEM;
Chris Masona7a16fd2008-06-26 10:34:20 -0400199
200again:
Chris Mason5eda7b52007-06-22 14:16:25 -0400201 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
202 if (ret < 0)
203 goto err;
Chris Masond3977122009-01-05 21:25:51 -0500204 while (1) {
Chris Mason5f39d392007-10-15 16:14:19 -0400205 leaf = path->nodes[0];
206 nritems = btrfs_header_nritems(leaf);
Chris Mason5eda7b52007-06-22 14:16:25 -0400207 slot = path->slots[0];
208 if (slot >= nritems) {
209 ret = btrfs_next_leaf(root, path);
210 if (ret)
211 break;
Chris Mason5f39d392007-10-15 16:14:19 -0400212 leaf = path->nodes[0];
213 nritems = btrfs_header_nritems(leaf);
Chris Mason5eda7b52007-06-22 14:16:25 -0400214 slot = path->slots[0];
215 }
Chris Mason5f39d392007-10-15 16:14:19 -0400216 btrfs_item_key_to_cpu(leaf, &key, slot);
Chris Mason5eda7b52007-06-22 14:16:25 -0400217 if (btrfs_key_type(&key) != BTRFS_ROOT_ITEM_KEY)
218 goto next;
Chris Mason5ce14bb2007-09-11 11:15:39 -0400219
220 if (key.objectid < objectid)
221 goto next;
222
223 if (key.objectid > objectid)
224 break;
225
Chris Mason5eda7b52007-06-22 14:16:25 -0400226 ri = btrfs_item_ptr(leaf, slot, struct btrfs_root_item);
Chris Mason5f39d392007-10-15 16:14:19 -0400227 if (btrfs_disk_root_refs(leaf, ri) != 0)
Chris Mason5eda7b52007-06-22 14:16:25 -0400228 goto next;
Chris Mason5ce14bb2007-09-11 11:15:39 -0400229
Chris Masona7a16fd2008-06-26 10:34:20 -0400230 memcpy(&found_key, &key, sizeof(key));
231 key.offset++;
232 btrfs_release_path(root, path);
Chris Masone02119d2008-09-05 16:13:11 -0400233 dead_root =
234 btrfs_read_fs_root_no_radix(root->fs_info->tree_root,
235 &found_key);
Aneesha1f39632007-07-11 10:03:27 -0400236 if (IS_ERR(dead_root)) {
237 ret = PTR_ERR(dead_root);
Chris Mason5eda7b52007-06-22 14:16:25 -0400238 goto err;
239 }
Chris Mason5ce14bb2007-09-11 11:15:39 -0400240
Yan Zheng5d4f98a2009-06-10 10:45:14 -0400241 ret = btrfs_add_dead_root(dead_root);
Chris Mason5eda7b52007-06-22 14:16:25 -0400242 if (ret)
243 goto err;
Chris Masona7a16fd2008-06-26 10:34:20 -0400244 goto again;
Chris Mason5eda7b52007-06-22 14:16:25 -0400245next:
246 slot++;
247 path->slots[0]++;
248 }
249 ret = 0;
250err:
251 btrfs_free_path(path);
252 return ret;
253}
254
Yan, Zheng76dda932009-09-21 16:00:26 -0400255int btrfs_find_orphan_roots(struct btrfs_root *tree_root)
256{
257 struct extent_buffer *leaf;
258 struct btrfs_path *path;
259 struct btrfs_key key;
Yan, Zhengd68fc572010-05-16 10:49:58 -0400260 struct btrfs_key root_key;
261 struct btrfs_root *root;
Yan, Zheng76dda932009-09-21 16:00:26 -0400262 int err = 0;
263 int ret;
264
265 path = btrfs_alloc_path();
266 if (!path)
267 return -ENOMEM;
268
269 key.objectid = BTRFS_ORPHAN_OBJECTID;
270 key.type = BTRFS_ORPHAN_ITEM_KEY;
271 key.offset = 0;
272
Yan, Zhengd68fc572010-05-16 10:49:58 -0400273 root_key.type = BTRFS_ROOT_ITEM_KEY;
274 root_key.offset = (u64)-1;
275
Yan, Zheng76dda932009-09-21 16:00:26 -0400276 while (1) {
277 ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0);
278 if (ret < 0) {
279 err = ret;
280 break;
281 }
282
283 leaf = path->nodes[0];
284 if (path->slots[0] >= btrfs_header_nritems(leaf)) {
285 ret = btrfs_next_leaf(tree_root, path);
286 if (ret < 0)
287 err = ret;
288 if (ret != 0)
289 break;
290 leaf = path->nodes[0];
291 }
292
293 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
294 btrfs_release_path(tree_root, path);
295
296 if (key.objectid != BTRFS_ORPHAN_OBJECTID ||
297 key.type != BTRFS_ORPHAN_ITEM_KEY)
298 break;
299
Yan, Zhengd68fc572010-05-16 10:49:58 -0400300 root_key.objectid = key.offset;
301 key.offset++;
302
303 root = btrfs_read_fs_root_no_name(tree_root->fs_info,
304 &root_key);
305 if (!IS_ERR(root))
306 continue;
307
308 ret = PTR_ERR(root);
309 if (ret != -ENOENT) {
Yan, Zheng76dda932009-09-21 16:00:26 -0400310 err = ret;
311 break;
312 }
313
Yan, Zhengd68fc572010-05-16 10:49:58 -0400314 ret = btrfs_find_dead_roots(tree_root, root_key.objectid);
315 if (ret) {
316 err = ret;
317 break;
318 }
Yan, Zheng76dda932009-09-21 16:00:26 -0400319 }
320
321 btrfs_free_path(path);
322 return err;
323}
324
Chris Masond352ac62008-09-29 15:18:18 -0400325/* drop the root item for 'key' from 'root' */
Chris Masone089f052007-03-16 16:20:31 -0400326int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
327 struct btrfs_key *key)
Chris Mason3768f362007-03-13 16:47:54 -0400328{
Chris Mason5caf2a02007-04-02 11:20:42 -0400329 struct btrfs_path *path;
Chris Mason3768f362007-03-13 16:47:54 -0400330 int ret;
Chris Masonc5739bb2007-04-10 09:27:04 -0400331 struct btrfs_root_item *ri;
Chris Mason5f39d392007-10-15 16:14:19 -0400332 struct extent_buffer *leaf;
Chris Mason3768f362007-03-13 16:47:54 -0400333
Chris Mason5caf2a02007-04-02 11:20:42 -0400334 path = btrfs_alloc_path();
335 BUG_ON(!path);
Chris Mason5caf2a02007-04-02 11:20:42 -0400336 ret = btrfs_search_slot(trans, root, key, path, -1, 1);
Chris Mason3768f362007-03-13 16:47:54 -0400337 if (ret < 0)
338 goto out;
Chris Masonedbd8d42007-12-21 16:27:24 -0500339
Chris Mason3768f362007-03-13 16:47:54 -0400340 BUG_ON(ret != 0);
Chris Mason5f39d392007-10-15 16:14:19 -0400341 leaf = path->nodes[0];
342 ri = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_item);
Chris Masonc5739bb2007-04-10 09:27:04 -0400343
Chris Mason5eda7b52007-06-22 14:16:25 -0400344 ret = btrfs_del_item(trans, root, path);
Chris Mason3768f362007-03-13 16:47:54 -0400345out:
Chris Mason5caf2a02007-04-02 11:20:42 -0400346 btrfs_free_path(path);
Chris Mason3768f362007-03-13 16:47:54 -0400347 return ret;
348}
Chris Mason0660b5a2008-11-17 20:37:39 -0500349
350int btrfs_del_root_ref(struct btrfs_trans_handle *trans,
351 struct btrfs_root *tree_root,
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400352 u64 root_id, u64 ref_id, u64 dirid, u64 *sequence,
353 const char *name, int name_len)
354
Chris Mason0660b5a2008-11-17 20:37:39 -0500355{
Chris Mason0660b5a2008-11-17 20:37:39 -0500356 struct btrfs_path *path;
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400357 struct btrfs_root_ref *ref;
358 struct extent_buffer *leaf;
359 struct btrfs_key key;
360 unsigned long ptr;
361 int err = 0;
362 int ret;
Chris Mason0660b5a2008-11-17 20:37:39 -0500363
364 path = btrfs_alloc_path();
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400365 if (!path)
366 return -ENOMEM;
Chris Mason0660b5a2008-11-17 20:37:39 -0500367
368 key.objectid = root_id;
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400369 key.type = BTRFS_ROOT_BACKREF_KEY;
Chris Mason0660b5a2008-11-17 20:37:39 -0500370 key.offset = ref_id;
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400371again:
Chris Mason0660b5a2008-11-17 20:37:39 -0500372 ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1);
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400373 BUG_ON(ret < 0);
374 if (ret == 0) {
375 leaf = path->nodes[0];
376 ref = btrfs_item_ptr(leaf, path->slots[0],
377 struct btrfs_root_ref);
Chris Mason0660b5a2008-11-17 20:37:39 -0500378
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400379 WARN_ON(btrfs_root_ref_dirid(leaf, ref) != dirid);
380 WARN_ON(btrfs_root_ref_name_len(leaf, ref) != name_len);
381 ptr = (unsigned long)(ref + 1);
382 WARN_ON(memcmp_extent_buffer(leaf, name, ptr, name_len));
383 *sequence = btrfs_root_ref_sequence(leaf, ref);
384
385 ret = btrfs_del_item(trans, tree_root, path);
386 BUG_ON(ret);
387 } else
388 err = -ENOENT;
389
390 if (key.type == BTRFS_ROOT_BACKREF_KEY) {
391 btrfs_release_path(tree_root, path);
392 key.objectid = ref_id;
393 key.type = BTRFS_ROOT_REF_KEY;
394 key.offset = root_id;
395 goto again;
396 }
Chris Mason0660b5a2008-11-17 20:37:39 -0500397
398 btrfs_free_path(path);
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400399 return err;
Chris Mason0660b5a2008-11-17 20:37:39 -0500400}
401
Chris Masonea9e8b12008-11-17 21:14:24 -0500402int btrfs_find_root_ref(struct btrfs_root *tree_root,
403 struct btrfs_path *path,
404 u64 root_id, u64 ref_id)
405{
406 struct btrfs_key key;
407 int ret;
408
409 key.objectid = root_id;
410 key.type = BTRFS_ROOT_REF_KEY;
411 key.offset = ref_id;
412
413 ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0);
414 return ret;
415}
416
Chris Mason0660b5a2008-11-17 20:37:39 -0500417/*
418 * add a btrfs_root_ref item. type is either BTRFS_ROOT_REF_KEY
419 * or BTRFS_ROOT_BACKREF_KEY.
420 *
421 * The dirid, sequence, name and name_len refer to the directory entry
422 * that is referencing the root.
423 *
424 * For a forward ref, the root_id is the id of the tree referencing
425 * the root and ref_id is the id of the subvol or snapshot.
426 *
427 * For a back ref the root_id is the id of the subvol or snapshot and
428 * ref_id is the id of the tree referencing it.
429 */
430int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
431 struct btrfs_root *tree_root,
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400432 u64 root_id, u64 ref_id, u64 dirid, u64 sequence,
Chris Mason0660b5a2008-11-17 20:37:39 -0500433 const char *name, int name_len)
434{
435 struct btrfs_key key;
436 int ret;
437 struct btrfs_path *path;
438 struct btrfs_root_ref *ref;
439 struct extent_buffer *leaf;
440 unsigned long ptr;
441
Chris Mason0660b5a2008-11-17 20:37:39 -0500442 path = btrfs_alloc_path();
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400443 if (!path)
444 return -ENOMEM;
Chris Mason0660b5a2008-11-17 20:37:39 -0500445
446 key.objectid = root_id;
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400447 key.type = BTRFS_ROOT_BACKREF_KEY;
Chris Mason0660b5a2008-11-17 20:37:39 -0500448 key.offset = ref_id;
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400449again:
Chris Mason0660b5a2008-11-17 20:37:39 -0500450 ret = btrfs_insert_empty_item(trans, tree_root, path, &key,
451 sizeof(*ref) + name_len);
452 BUG_ON(ret);
453
454 leaf = path->nodes[0];
455 ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref);
456 btrfs_set_root_ref_dirid(leaf, ref, dirid);
457 btrfs_set_root_ref_sequence(leaf, ref, sequence);
458 btrfs_set_root_ref_name_len(leaf, ref, name_len);
459 ptr = (unsigned long)(ref + 1);
460 write_extent_buffer(leaf, name, ptr, name_len);
461 btrfs_mark_buffer_dirty(leaf);
462
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400463 if (key.type == BTRFS_ROOT_BACKREF_KEY) {
464 btrfs_release_path(tree_root, path);
465 key.objectid = ref_id;
466 key.type = BTRFS_ROOT_REF_KEY;
467 key.offset = root_id;
468 goto again;
469 }
470
Chris Mason0660b5a2008-11-17 20:37:39 -0500471 btrfs_free_path(path);
Yan, Zheng4df27c4d2009-09-21 15:56:00 -0400472 return 0;
Chris Mason0660b5a2008-11-17 20:37:39 -0500473}