Lines Matching refs:root

83 	struct btrfs_root *root, *tmp;  in switch_commit_roots()  local
86 list_for_each_entry_safe(root, tmp, &trans->switch_commits, in switch_commit_roots()
88 list_del_init(&root->dirty_list); in switch_commit_roots()
89 free_extent_buffer(root->commit_root); in switch_commit_roots()
90 root->commit_root = btrfs_root_node(root); in switch_commit_roots()
91 if (is_fstree(root->root_key.objectid)) in switch_commit_roots()
92 btrfs_unpin_free_ino(root); in switch_commit_roots()
93 extent_io_tree_release(&root->dirty_log_pages); in switch_commit_roots()
94 btrfs_qgroup_clean_swapped_blocks(root); in switch_commit_roots()
100 root = list_first_entry(&trans->dropped_roots, in switch_commit_roots()
102 list_del_init(&root->root_list); in switch_commit_roots()
104 btrfs_drop_and_free_fs_root(fs_info, root); in switch_commit_roots()
281 struct btrfs_root *root, in record_root_in_trans() argument
284 struct btrfs_fs_info *fs_info = root->fs_info; in record_root_in_trans()
286 if ((test_bit(BTRFS_ROOT_REF_COWS, &root->state) && in record_root_in_trans()
287 root->last_trans < trans->transid) || force) { in record_root_in_trans()
288 WARN_ON(root == fs_info->extent_root); in record_root_in_trans()
289 WARN_ON(!force && root->commit_root != root->node); in record_root_in_trans()
296 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
304 if (root->last_trans == trans->transid && !force) { in record_root_in_trans()
309 (unsigned long)root->root_key.objectid, in record_root_in_trans()
312 root->last_trans = trans->transid; in record_root_in_trans()
333 btrfs_init_reloc_root(trans, root); in record_root_in_trans()
335 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
342 struct btrfs_root *root) in btrfs_add_dropped_root() argument
344 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dropped_root()
349 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
355 (unsigned long)root->root_key.objectid, in btrfs_add_dropped_root()
361 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
363 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_record_root_in_trans()
365 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in btrfs_record_root_in_trans()
373 if (root->last_trans == trans->transid && in btrfs_record_root_in_trans()
374 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
378 record_root_in_trans(trans, root, 0); in btrfs_record_root_in_trans()
425 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
427 struct btrfs_fs_info *fs_info = root->fs_info; in need_reserve_reloc_root()
430 !test_bit(BTRFS_ROOT_REF_COWS, &root->state) || in need_reserve_reloc_root()
431 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
432 root->reloc_root) in need_reserve_reloc_root()
439 start_transaction(struct btrfs_root *root, unsigned int num_items, in start_transaction() argument
443 struct btrfs_fs_info *fs_info = root->fs_info; in start_transaction()
472 if (num_items && root != fs_info->chunk_root) { in start_transaction()
477 ret = btrfs_qgroup_reserve_meta_pertrans(root, qgroup_reserved, in start_transaction()
498 if (need_reserve_reloc_root(root)) { in start_transaction()
503 ret = btrfs_block_rsv_add(root, rsv, num_bytes, flush); in start_transaction()
564 h->root = root; in start_transaction()
566 h->fs_info = root->fs_info; in start_transaction()
589 btrfs_record_root_in_trans(h, root); in start_transaction()
604 btrfs_qgroup_free_meta_pertrans(root, qgroup_reserved); in start_transaction()
608 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
611 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
616 struct btrfs_root *root, in btrfs_start_transaction_fallback_global_rsv() argument
620 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_start_transaction_fallback_global_rsv()
631 trans = start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_fallback_global_rsv()
636 trans = btrfs_start_transaction(root, 0); in btrfs_start_transaction_fallback_global_rsv()
656 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
658 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH, in btrfs_join_transaction()
662 struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) in btrfs_join_transaction_nolock() argument
664 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, in btrfs_join_transaction_nolock()
672 struct btrfs_trans_handle *btrfs_join_transaction_nostart(struct btrfs_root *root) in btrfs_join_transaction_nostart() argument
674 return start_transaction(root, 0, TRANS_JOIN_NOSTART, in btrfs_join_transaction_nostart()
691 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
693 return start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction()
705 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
709 trans = start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction_barrier()
712 btrfs_wait_for_commit(root->fs_info, 0); in btrfs_attach_transaction_barrier()
1072 struct btrfs_root *root) in update_cowonly_root() argument
1077 struct btrfs_fs_info *fs_info = root->fs_info; in update_cowonly_root()
1080 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1083 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1084 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1085 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1088 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1090 &root->root_key, in update_cowonly_root()
1091 &root->root_item); in update_cowonly_root()
1095 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1150 struct btrfs_root *root; in commit_cowonly_roots() local
1153 root = list_entry(next, struct btrfs_root, dirty_list); in commit_cowonly_roots()
1154 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1156 if (root != fs_info->extent_root) in commit_cowonly_roots()
1157 list_add_tail(&root->dirty_list, in commit_cowonly_roots()
1159 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1194 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1196 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dead_root()
1199 if (list_empty(&root->root_list)) in btrfs_add_dead_root()
1200 list_add_tail(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1224 struct btrfs_root *root = gang[i]; in commit_fs_roots() local
1226 (unsigned long)root->root_key.objectid, in commit_fs_roots()
1230 btrfs_free_log(trans, root); in commit_fs_roots()
1231 btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1233 btrfs_save_ino_cache(root, trans); in commit_fs_roots()
1236 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1239 if (root->commit_root != root->node) { in commit_fs_roots()
1240 list_add_tail(&root->dirty_list, in commit_fs_roots()
1242 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1243 root->node); in commit_fs_roots()
1247 &root->root_key, in commit_fs_roots()
1248 &root->root_item); in commit_fs_roots()
1252 btrfs_qgroup_free_meta_all_pertrans(root); in commit_fs_roots()
1263 int btrfs_defrag_root(struct btrfs_root *root) in btrfs_defrag_root() argument
1265 struct btrfs_fs_info *info = root->fs_info; in btrfs_defrag_root()
1269 if (test_and_set_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state)) in btrfs_defrag_root()
1273 trans = btrfs_start_transaction(root, 0); in btrfs_defrag_root()
1277 ret = btrfs_defrag_leaves(trans, root); in btrfs_defrag_root()
1292 clear_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state); in btrfs_defrag_root()
1399 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1435 pending->error = btrfs_block_rsv_add(root, in create_pending_snapshot()
1455 parent_root = BTRFS_I(parent_inode)->root; in create_pending_snapshot()
1493 record_root_in_trans(trans, root, 0); in create_pending_snapshot()
1494 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1495 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1509 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1523 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1524 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old); in create_pending_snapshot()
1534 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1543 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1595 ret = qgroup_account_snapshot(trans, root, parent_root, in create_pending_snapshot()
1688 super->root = root_item->bytenr; in update_super_roots()
1785 ac->newtrans = btrfs_join_transaction(trans->root); in btrfs_commit_transaction_async()
1862 trace_btrfs_transaction_commit(trans->root); in cleanup_transaction()
1915 ret = btrfs_start_delalloc_snapshot(pending->root); in btrfs_start_delalloc_flush()
1940 btrfs_wait_ordered_extents(pending->root, in btrfs_wait_delalloc_flush()
2307 trace_btrfs_transaction_commit(trans->root); in btrfs_commit_transaction()
2343 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root) in btrfs_clean_one_deleted_snapshot() argument
2346 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_clean_one_deleted_snapshot()
2353 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2355 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2358 btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid); in btrfs_clean_one_deleted_snapshot()
2360 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2362 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2364 ret = btrfs_drop_snapshot(root, NULL, 0, 0); in btrfs_clean_one_deleted_snapshot()
2366 ret = btrfs_drop_snapshot(root, NULL, 1, 0); in btrfs_clean_one_deleted_snapshot()