diff options
-rw-r--r-- | fs/btrfs/backref.c | 4 | ||||
-rw-r--r-- | fs/btrfs/ctree.c | 17 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 1 |
3 files changed, 19 insertions, 3 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index f3187938e081..65608fbf2232 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -283,9 +283,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, | |||
283 | goto out; | 283 | goto out; |
284 | } | 284 | } |
285 | 285 | ||
286 | rcu_read_lock(); | 286 | root_level = btrfs_old_root_level(root, time_seq); |
287 | root_level = btrfs_header_level(root->node); | ||
288 | rcu_read_unlock(); | ||
289 | 287 | ||
290 | if (root_level + 1 == level) | 288 | if (root_level + 1 == level) |
291 | goto out; | 289 | goto out; |
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index d9308c38a8f2..ef68c33eefd9 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -1297,6 +1297,23 @@ get_old_root(struct btrfs_root *root, u64 time_seq) | |||
1297 | return eb; | 1297 | return eb; |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | int btrfs_old_root_level(struct btrfs_root *root, u64 time_seq) | ||
1301 | { | ||
1302 | struct tree_mod_elem *tm; | ||
1303 | int level; | ||
1304 | |||
1305 | tm = __tree_mod_log_oldest_root(root->fs_info, root, time_seq); | ||
1306 | if (tm && tm->op == MOD_LOG_ROOT_REPLACE) { | ||
1307 | level = tm->old_root.level; | ||
1308 | } else { | ||
1309 | rcu_read_lock(); | ||
1310 | level = btrfs_header_level(root->node); | ||
1311 | rcu_read_unlock(); | ||
1312 | } | ||
1313 | |||
1314 | return level; | ||
1315 | } | ||
1316 | |||
1300 | static inline int should_cow_block(struct btrfs_trans_handle *trans, | 1317 | static inline int should_cow_block(struct btrfs_trans_handle *trans, |
1301 | struct btrfs_root *root, | 1318 | struct btrfs_root *root, |
1302 | struct extent_buffer *buf) | 1319 | struct extent_buffer *buf) |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 1630be831210..34c5a442dd33 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -3120,6 +3120,7 @@ static inline u64 btrfs_inc_tree_mod_seq(struct btrfs_fs_info *fs_info) | |||
3120 | { | 3120 | { |
3121 | return atomic_inc_return(&fs_info->tree_mod_seq); | 3121 | return atomic_inc_return(&fs_info->tree_mod_seq); |
3122 | } | 3122 | } |
3123 | int btrfs_old_root_level(struct btrfs_root *root, u64 time_seq); | ||
3123 | 3124 | ||
3124 | /* root-item.c */ | 3125 | /* root-item.c */ |
3125 | int btrfs_find_root_ref(struct btrfs_root *tree_root, | 3126 | int btrfs_find_root_ref(struct btrfs_root *tree_root, |