aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Schmidt <list.btrfs@jan-o-sch.net>2012-06-11 02:29:29 -0400
committerJan Schmidt <list.btrfs@jan-o-sch.net>2012-06-14 12:52:09 -0400
commit3d7806eca43e73a9721d2e09369200ed93036bd0 (patch)
tree339d940a7cb3522169f9e2a8b14edf8b8ae15880
parenta95236d99fa56766f11056903439f55fe5038bcf (diff)
Btrfs: add btrfs_next_old_leaf
To make sense of the tree mod log, the backref walker not only needs btrfs_search_old_slot, but it also called btrfs_next_leaf, which in turn was calling btrfs_search_slot. This obviously didn't give the correct result. This commit adds btrfs_next_old_leaf, a drop-in replacement for btrfs_next_leaf with a time_seq parameter. If it is zero, it behaves exactly like btrfs_next_leaf. If it is non-zero, it will use btrfs_search_old_slot with this time_seq parameter. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
-rw-r--r--fs/btrfs/backref.c7
-rw-r--r--fs/btrfs/ctree.c11
-rw-r--r--fs/btrfs/ctree.h2
3 files changed, 16 insertions, 4 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 579131de1b3b..8f7d1237b7a0 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -179,7 +179,8 @@ static int __add_prelim_ref(struct list_head *head, u64 root_id,
179 179
180static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path, 180static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
181 struct ulist *parents, int level, 181 struct ulist *parents, int level,
182 struct btrfs_key *key, u64 wanted_disk_byte, 182 struct btrfs_key *key, u64 time_seq,
183 u64 wanted_disk_byte,
183 const u64 *extent_item_pos) 184 const u64 *extent_item_pos)
184{ 185{
185 int ret; 186 int ret;
@@ -212,7 +213,7 @@ add_parent:
212 */ 213 */
213 while (1) { 214 while (1) {
214 eie = NULL; 215 eie = NULL;
215 ret = btrfs_next_leaf(root, path); 216 ret = btrfs_next_old_leaf(root, path, time_seq);
216 if (ret < 0) 217 if (ret < 0)
217 return ret; 218 return ret;
218 if (ret) 219 if (ret)
@@ -297,7 +298,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
297 if (level == 0) 298 if (level == 0)
298 btrfs_item_key_to_cpu(eb, &key, path->slots[0]); 299 btrfs_item_key_to_cpu(eb, &key, path->slots[0]);
299 300
300 ret = add_all_parents(root, path, parents, level, &key, 301 ret = add_all_parents(root, path, parents, level, &key, time_seq,
301 ref->wanted_disk_byte, extent_item_pos); 302 ref->wanted_disk_byte, extent_item_pos);
302out: 303out:
303 btrfs_free_path(path); 304 btrfs_free_path(path);
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 50d7c99ddce7..cb76b2a1b908 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -5017,6 +5017,12 @@ next:
5017 */ 5017 */
5018int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path) 5018int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
5019{ 5019{
5020 return btrfs_next_old_leaf(root, path, 0);
5021}
5022
5023int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
5024 u64 time_seq)
5025{
5020 int slot; 5026 int slot;
5021 int level; 5027 int level;
5022 struct extent_buffer *c; 5028 struct extent_buffer *c;
@@ -5041,7 +5047,10 @@ again:
5041 path->keep_locks = 1; 5047 path->keep_locks = 1;
5042 path->leave_spinning = 1; 5048 path->leave_spinning = 1;
5043 5049
5044 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 5050 if (time_seq)
5051 ret = btrfs_search_old_slot(root, &key, path, time_seq);
5052 else
5053 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
5045 path->keep_locks = 0; 5054 path->keep_locks = 0;
5046 5055
5047 if (ret < 0) 5056 if (ret < 0)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0151ca1ac657..db15e9e7b91c 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2753,6 +2753,8 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans,
2753} 2753}
2754 2754
2755int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); 2755int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
2756int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
2757 u64 time_seq);
2756static inline int btrfs_next_item(struct btrfs_root *root, struct btrfs_path *p) 2758static inline int btrfs_next_item(struct btrfs_root *root, struct btrfs_path *p)
2757{ 2759{
2758 ++p->slots[0]; 2760 ++p->slots[0];