aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/root-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/root-tree.c')
-rw-r--r--fs/btrfs/root-tree.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index 0091c01abb06..eb7f7655e9d5 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -22,8 +22,10 @@
22#include "print-tree.h" 22#include "print-tree.h"
23 23
24/* 24/*
25 * returns 0 on finding something, 1 if no more roots are there 25 * search forward for a root, starting with objectid 'search_start'
26 * and < 0 on error 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.
27 */ 29 */
28int btrfs_search_root(struct btrfs_root *root, u64 search_start, 30int btrfs_search_root(struct btrfs_root *root, u64 search_start,
29 u64 *found_objectid) 31 u64 *found_objectid)
@@ -66,6 +68,11 @@ out:
66 return ret; 68 return ret;
67} 69}
68 70
71/*
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 */
69int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, 76int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
70 struct btrfs_root_item *item, struct btrfs_key *key) 77 struct btrfs_root_item *item, struct btrfs_key *key)
71{ 78{
@@ -104,6 +111,9 @@ out:
104 return ret; 111 return ret;
105} 112}
106 113
114/*
115 * copy the data in 'item' into the btree
116 */
107int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root 117int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
108 *root, struct btrfs_key *key, struct btrfs_root_item 118 *root, struct btrfs_key *key, struct btrfs_root_item
109 *item) 119 *item)
@@ -147,6 +157,12 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
147 return ret; 157 return ret;
148} 158}
149 159
160/*
161 * at mount time we want to find all the old transaction snapshots that were in
162 * the process of being deleted if we crashed. This is any root item with an offset
163 * lower than the latest root. They need to be queued for deletion to finish
164 * what was happening when we crashed.
165 */
150int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid, 166int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid,
151 struct btrfs_root *latest) 167 struct btrfs_root *latest)
152{ 168{
@@ -227,6 +243,7 @@ err:
227 return ret; 243 return ret;
228} 244}
229 245
246/* drop the root item for 'key' from 'root' */
230int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, 247int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
231 struct btrfs_key *key) 248 struct btrfs_key *key)
232{ 249{