Update backrefs during dropping snapshot
PATCH 1/1 Update backrefs during dropping snapshot
The new backref format has restriction on type of backref item. If a tree block isn't referenced by its owner tree, full backrefs must be used for the pointers in it. When a tree block loses its owner tree's reference, backrefs for the pointers in it should be updated to full backrefs. Current btrfs_drop_snapshot misses the code that updates backrefs, so it's unsafe for general use.
This patch adds backrefs update code to btrfs_drop_snapshot.
Signed-off-by Yan Zheng <[email protected]>
---
fs/btrfs/ctree.h +1 -2
@@ -2076,8 +2076,7 @@ static inline int btrfs_insert_empty_iteint btrfs_next_leaf (struct btrfs_root *root,struct btrfs_path *path);int btrfs_prev_leaf (struct btrfs_root *root,struct btrfs_path *path);int btrfs_leaf_free_space (struct btrfs_root *root,struct extent_buffer *leaf); -int btrfs_drop_snapshot (struct btrfs_trans_handle *trans,struct btrfs_root - *root); +int btrfs_drop_snapshot (struct btrfs_root *root,int update_ref); int btrfs_drop_subtree(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *node,
fs/btrfs/extent-tree.c +390 -174
712 lines not on this page · raw message
fs/btrfs/relocation.c +1 -4
@@ -1788,7 +1788,7 @@ static void merge_func(struct btrfs_workbtrfs_end_transaction (trans, root); } -btrfs_drop_dead_root (reloc_root); +btrfs_drop_snapshot (reloc_root,0 );if (atomic_dec_and_test (async->num_pending))complete (async->done);
@@ -2075,9 +2075,6 @@ static int do_relocation(struct btrfs_tr ret =btrfs_drop_subtree (trans, root, eb, upper->eb);BUG_ON (ret); - -btrfs_tree_unlock (eb); -free_extent_buffer (eb); }if (!lowest) {btrfs_tree_unlock (upper->eb);
fs/btrfs/transaction.c +3 -1
@@ -593,6 +593,7 @@ int btrfs_defrag_root(struct btrfs_rootreturn 0 ; } +#if 0 /* * when dropping snapshots, we generate a ton of delayed refs, and it makes * sense not to join the transaction while it is trying to flush the current
@@ -681,6 +682,7 @@ int btrfs_drop_dead_root(struct btrfs_robtrfs_btree_balance_dirty (tree_root, nr); return ret; } +#endif /* * new snapshots need to be created at a very specific time in the
@@ -1081,7 +1083,7 @@ int btrfs_clean_old_snapshots(struct btrwhile (!list_empty (&list)) { root = list_entry(list.next, struct btrfs_root, root_list);list_del_init (&root->root_list); -btrfs_drop_dead_root (root); +btrfs_drop_snapshot (root,0 ); }return 0 ; }