Lines Matching refs:root

182 	struct btrfs_root *root, *tmp;  in switch_commit_roots()  local
195 list_for_each_entry_safe(root, tmp, &cur_trans->switch_commits, in switch_commit_roots()
197 list_del_init(&root->dirty_list); in switch_commit_roots()
198 free_extent_buffer(root->commit_root); in switch_commit_roots()
199 root->commit_root = btrfs_root_node(root); in switch_commit_roots()
200 btrfs_extent_io_tree_release(&root->dirty_log_pages); in switch_commit_roots()
201 btrfs_qgroup_clean_swapped_blocks(root); in switch_commit_roots()
207 root = list_first_entry(&cur_trans->dropped_roots, in switch_commit_roots()
209 list_del_init(&root->root_list); in switch_commit_roots()
211 btrfs_free_log(trans, root); in switch_commit_roots()
212 btrfs_drop_and_free_fs_root(fs_info, root); in switch_commit_roots()
406 struct btrfs_root *root, in record_root_in_trans() argument
409 struct btrfs_fs_info *fs_info = root->fs_info; in record_root_in_trans()
412 if ((test_bit(BTRFS_ROOT_SHAREABLE, &root->state) && in record_root_in_trans()
413 btrfs_get_root_last_trans(root) < trans->transid) || force) { in record_root_in_trans()
414 WARN_ON(!force && root->commit_root != root->node); in record_root_in_trans()
421 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
429 if (btrfs_get_root_last_trans(root) == trans->transid && !force) { in record_root_in_trans()
434 (unsigned long)btrfs_root_id(root), in record_root_in_trans()
437 btrfs_set_root_last_trans(root, trans->transid); in record_root_in_trans()
458 ret = btrfs_init_reloc_root(trans, root); in record_root_in_trans()
460 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
467 struct btrfs_root *root) in btrfs_add_dropped_root() argument
469 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dropped_root()
474 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
480 (unsigned long)btrfs_root_id(root), in btrfs_add_dropped_root()
486 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
488 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_record_root_in_trans()
491 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) in btrfs_record_root_in_trans()
499 if (btrfs_get_root_last_trans(root) == trans->transid && in btrfs_record_root_in_trans()
500 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
504 ret = record_root_in_trans(trans, root, 0); in btrfs_record_root_in_trans()
552 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
554 struct btrfs_fs_info *fs_info = root->fs_info; in need_reserve_reloc_root()
557 !test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || in need_reserve_reloc_root()
558 btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
559 root->reloc_root) in need_reserve_reloc_root()
595 start_transaction(struct btrfs_root *root, unsigned int num_items, in start_transaction() argument
599 struct btrfs_fs_info *fs_info = root->fs_info; in start_transaction()
628 if (num_items && root != fs_info->chunk_root) { in start_transaction()
635 ret = btrfs_qgroup_reserve_meta_prealloc(root, qgroup_reserved, in start_transaction()
654 if (need_reserve_reloc_root(root)) { in start_transaction()
722 h->fs_info = root->fs_info; in start_transaction()
779 ret = btrfs_record_root_in_trans(h, root); in start_transaction()
795 btrfs_qgroup_convert_reserved_meta(root, qgroup_reserved); in start_transaction()
809 btrfs_qgroup_free_meta_prealloc(root, qgroup_reserved); in start_transaction()
813 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
816 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
821 struct btrfs_root *root, in btrfs_start_transaction_fallback_global_rsv() argument
824 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_fallback_global_rsv()
828 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
830 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH, in btrfs_join_transaction()
834 struct btrfs_trans_handle *btrfs_join_transaction_spacecache(struct btrfs_root *root) in btrfs_join_transaction_spacecache() argument
836 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, in btrfs_join_transaction_spacecache()
847 struct btrfs_trans_handle *btrfs_join_transaction_nostart(struct btrfs_root *root) in btrfs_join_transaction_nostart() argument
849 return start_transaction(root, 0, TRANS_JOIN_NOSTART, in btrfs_join_transaction_nostart()
866 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
868 return start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction()
880 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
884 trans = start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction_barrier()
889 ret = btrfs_wait_for_commit(root->fs_info, 0); in btrfs_attach_transaction_barrier()
1289 struct btrfs_root *root) in update_cowonly_root() argument
1294 struct btrfs_fs_info *fs_info = root->fs_info; in update_cowonly_root()
1297 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1300 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1301 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1302 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1305 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1307 &root->root_key, in update_cowonly_root()
1308 &root->root_item); in update_cowonly_root()
1312 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1364 struct btrfs_root *root; in commit_cowonly_roots() local
1366 root = list_first_entry(&fs_info->dirty_cowonly_roots, in commit_cowonly_roots()
1368 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1369 list_move_tail(&root->dirty_list, in commit_cowonly_roots()
1372 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1421 struct btrfs_root *root = list_first_entry(&fs_info->dead_roots, in btrfs_maybe_wake_unfinished_drop() local
1424 if (test_bit(BTRFS_ROOT_UNFINISHED_DROP, &root->state)) { in btrfs_maybe_wake_unfinished_drop()
1439 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1441 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dead_root()
1444 if (list_empty(&root->root_list)) { in btrfs_add_dead_root()
1445 btrfs_grab_root(root); in btrfs_add_dead_root()
1448 if (test_bit(BTRFS_ROOT_UNFINISHED_DROP, &root->state)) in btrfs_add_dead_root()
1449 list_add(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1451 list_add_tail(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1482 struct btrfs_root *root = gang[i]; in commit_fs_roots() local
1489 ASSERT(atomic_read(&root->log_writers) == 0); in commit_fs_roots()
1490 ASSERT(atomic_read(&root->log_commit[0]) == 0); in commit_fs_roots()
1491 ASSERT(atomic_read(&root->log_commit[1]) == 0); in commit_fs_roots()
1494 (unsigned long)btrfs_root_id(root), in commit_fs_roots()
1496 btrfs_qgroup_free_meta_all_pertrans(root); in commit_fs_roots()
1499 btrfs_free_log(trans, root); in commit_fs_roots()
1500 ret2 = btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1505 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1508 if (root->commit_root != root->node) { in commit_fs_roots()
1509 list_add_tail(&root->dirty_list, in commit_fs_roots()
1511 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1512 root->node); in commit_fs_roots()
1516 &root->root_key, in commit_fs_roots()
1517 &root->root_item); in commit_fs_roots()
1640 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1707 parent_root = parent_inode->root; in create_pending_snapshot()
1756 ret = record_root_in_trans(trans, root, 0); in create_pending_snapshot()
1761 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1762 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1775 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1789 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1790 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old, in create_pending_snapshot()
1799 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1808 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1856 ret = qgroup_account_snapshot(trans, root, parent_root, in create_pending_snapshot()
1859 ret = btrfs_qgroup_inherit(trans, btrfs_root_id(root), objectid, in create_pending_snapshot()
1947 super->root = root_item->bytenr; in update_super_roots()
2002 int btrfs_commit_current_transaction(struct btrfs_root *root) in btrfs_commit_current_transaction() argument
2006 trans = btrfs_attach_transaction_barrier(root); in btrfs_commit_current_transaction()
2641 struct btrfs_root *root; in btrfs_clean_one_deleted_snapshot() local
2649 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2651 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2654 btrfs_debug(fs_info, "cleaner removing %llu", btrfs_root_id(root)); in btrfs_clean_one_deleted_snapshot()
2656 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2658 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2660 ret = btrfs_drop_snapshot(root, 0, 0); in btrfs_clean_one_deleted_snapshot()
2662 ret = btrfs_drop_snapshot(root, 1, 0); in btrfs_clean_one_deleted_snapshot()
2664 btrfs_put_root(root); in btrfs_clean_one_deleted_snapshot()