Lines Matching refs:root
183 struct btrfs_root *root, *tmp; in switch_commit_roots() local
197 list_for_each_entry_safe(root, tmp, &cur_trans->switch_commits, in switch_commit_roots()
199 list_del_init(&root->dirty_list); in switch_commit_roots()
200 free_extent_buffer(root->commit_root); in switch_commit_roots()
201 root->commit_root = btrfs_root_node(root); in switch_commit_roots()
202 btrfs_extent_io_tree_release(&root->dirty_log_pages); in switch_commit_roots()
203 btrfs_qgroup_clean_swapped_blocks(root); in switch_commit_roots()
209 root = list_first_entry(&cur_trans->dropped_roots, in switch_commit_roots()
211 list_del_init(&root->root_list); in switch_commit_roots()
213 btrfs_free_log(trans, root); in switch_commit_roots()
214 btrfs_drop_and_free_fs_root(fs_info, root); in switch_commit_roots()
408 struct btrfs_root *root, in record_root_in_trans() argument
411 struct btrfs_fs_info *fs_info = root->fs_info; in record_root_in_trans()
414 if ((test_bit(BTRFS_ROOT_SHAREABLE, &root->state) && in record_root_in_trans()
415 btrfs_get_root_last_trans(root) < trans->transid) || force) { in record_root_in_trans()
416 WARN_ON(!force && root->commit_root != root->node); in record_root_in_trans()
423 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
431 if (btrfs_get_root_last_trans(root) == trans->transid && !force) { in record_root_in_trans()
436 (unsigned long)btrfs_root_id(root), in record_root_in_trans()
439 btrfs_set_root_last_trans(root, trans->transid); in record_root_in_trans()
460 ret = btrfs_init_reloc_root(trans, root); in record_root_in_trans()
462 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
469 struct btrfs_root *root) in btrfs_add_dropped_root() argument
471 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dropped_root()
476 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
482 (unsigned long)btrfs_root_id(root), in btrfs_add_dropped_root()
488 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
490 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_record_root_in_trans()
493 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) in btrfs_record_root_in_trans()
501 if (btrfs_get_root_last_trans(root) == trans->transid && in btrfs_record_root_in_trans()
502 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
506 ret = record_root_in_trans(trans, root, 0); in btrfs_record_root_in_trans()
555 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
557 struct btrfs_fs_info *fs_info = root->fs_info; in need_reserve_reloc_root()
560 !test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || in need_reserve_reloc_root()
561 btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
562 root->reloc_root) in need_reserve_reloc_root()
598 start_transaction(struct btrfs_root *root, unsigned int num_items, in start_transaction() argument
602 struct btrfs_fs_info *fs_info = root->fs_info; in start_transaction()
631 if (num_items && root != fs_info->chunk_root) { in start_transaction()
638 ret = btrfs_qgroup_reserve_meta_prealloc(root, qgroup_reserved, in start_transaction()
657 if (need_reserve_reloc_root(root)) { in start_transaction()
725 h->fs_info = root->fs_info; in start_transaction()
782 ret = btrfs_record_root_in_trans(h, root); in start_transaction()
798 btrfs_qgroup_convert_reserved_meta(root, qgroup_reserved); in start_transaction()
812 btrfs_qgroup_free_meta_prealloc(root, qgroup_reserved); in start_transaction()
816 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
819 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
824 struct btrfs_root *root, in btrfs_start_transaction_fallback_global_rsv() argument
827 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_fallback_global_rsv()
831 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
833 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH, in btrfs_join_transaction()
837 struct btrfs_trans_handle *btrfs_join_transaction_spacecache(struct btrfs_root *root) in btrfs_join_transaction_spacecache() argument
839 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, in btrfs_join_transaction_spacecache()
850 struct btrfs_trans_handle *btrfs_join_transaction_nostart(struct btrfs_root *root) in btrfs_join_transaction_nostart() argument
852 return start_transaction(root, 0, TRANS_JOIN_NOSTART, in btrfs_join_transaction_nostart()
869 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
871 return start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction()
883 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
887 trans = start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction_barrier()
892 ret = btrfs_wait_for_commit(root->fs_info, 0); in btrfs_attach_transaction_barrier()
1299 struct btrfs_root *root) in update_cowonly_root() argument
1304 struct btrfs_fs_info *fs_info = root->fs_info; in update_cowonly_root()
1307 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1310 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1311 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1312 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1315 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1317 &root->root_key, in update_cowonly_root()
1318 &root->root_item); in update_cowonly_root()
1322 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1375 struct btrfs_root *root; in commit_cowonly_roots() local
1377 root = list_first_entry(&fs_info->dirty_cowonly_roots, in commit_cowonly_roots()
1379 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1380 list_move_tail(&root->dirty_list, in commit_cowonly_roots()
1383 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1432 struct btrfs_root *root = list_first_entry(&fs_info->dead_roots, in btrfs_maybe_wake_unfinished_drop() local
1435 if (test_bit(BTRFS_ROOT_UNFINISHED_DROP, &root->state)) { in btrfs_maybe_wake_unfinished_drop()
1450 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1452 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dead_root()
1455 if (list_empty(&root->root_list)) { in btrfs_add_dead_root()
1456 btrfs_grab_root(root); in btrfs_add_dead_root()
1459 if (test_bit(BTRFS_ROOT_UNFINISHED_DROP, &root->state)) in btrfs_add_dead_root()
1460 list_add(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1462 list_add_tail(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1494 struct btrfs_root *root = gang[i]; in commit_fs_roots() local
1501 ASSERT(atomic_read(&root->log_writers) == 0, in commit_fs_roots()
1503 atomic_read(&root->log_writers)); in commit_fs_roots()
1504 ASSERT(atomic_read(&root->log_commit[0]) == 0, in commit_fs_roots()
1506 atomic_read(&root->log_commit[0])); in commit_fs_roots()
1507 ASSERT(atomic_read(&root->log_commit[1]) == 0, in commit_fs_roots()
1509 atomic_read(&root->log_commit[1])); in commit_fs_roots()
1512 (unsigned long)btrfs_root_id(root), in commit_fs_roots()
1514 btrfs_qgroup_free_meta_all_pertrans(root); in commit_fs_roots()
1517 btrfs_free_log(trans, root); in commit_fs_roots()
1518 ret2 = btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1523 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1526 if (root->commit_root != root->node) { in commit_fs_roots()
1527 list_add_tail(&root->dirty_list, in commit_fs_roots()
1529 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1530 root->node); in commit_fs_roots()
1534 &root->root_key, in commit_fs_roots()
1535 &root->root_item); in commit_fs_roots()
1658 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1721 parent_root = parent_inode->root; in create_pending_snapshot()
1770 ret = record_root_in_trans(trans, root, 0); in create_pending_snapshot()
1775 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1776 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1789 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1803 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1804 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old, in create_pending_snapshot()
1813 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1822 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1872 ret = qgroup_account_snapshot(trans, root, parent_root, in create_pending_snapshot()
1875 ret = btrfs_qgroup_inherit(trans, btrfs_root_id(root), objectid, in create_pending_snapshot()
1978 super->root = root_item->bytenr; in update_super_roots()
2040 int btrfs_commit_current_transaction(struct btrfs_root *root) in btrfs_commit_current_transaction() argument
2044 trans = btrfs_attach_transaction_barrier(root); in btrfs_commit_current_transaction()
2673 struct btrfs_root *root; in btrfs_clean_one_deleted_snapshot() local
2681 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2683 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2686 btrfs_debug(fs_info, "cleaner removing %llu", btrfs_root_id(root)); in btrfs_clean_one_deleted_snapshot()
2688 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2690 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2692 ret = btrfs_drop_snapshot(root, false, false); in btrfs_clean_one_deleted_snapshot()
2694 ret = btrfs_drop_snapshot(root, true, false); in btrfs_clean_one_deleted_snapshot()
2696 btrfs_put_root(root); in btrfs_clean_one_deleted_snapshot()