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 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()
405 struct btrfs_root *root, in record_root_in_trans() argument
408 struct btrfs_fs_info *fs_info = root->fs_info; in record_root_in_trans()
411 if ((test_bit(BTRFS_ROOT_SHAREABLE, &root->state) && in record_root_in_trans()
412 root->last_trans < trans->transid) || force) { in record_root_in_trans()
413 WARN_ON(!force && root->commit_root != root->node); in record_root_in_trans()
420 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
428 if (root->last_trans == trans->transid && !force) { in record_root_in_trans()
433 (unsigned long)root->root_key.objectid, in record_root_in_trans()
436 root->last_trans = trans->transid; in record_root_in_trans()
457 ret = btrfs_init_reloc_root(trans, root); in record_root_in_trans()
459 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
466 struct btrfs_root *root) in btrfs_add_dropped_root() argument
468 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dropped_root()
473 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
479 (unsigned long)root->root_key.objectid, in btrfs_add_dropped_root()
485 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
487 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_record_root_in_trans()
490 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) in btrfs_record_root_in_trans()
498 if (root->last_trans == trans->transid && in btrfs_record_root_in_trans()
499 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
503 ret = record_root_in_trans(trans, root, 0); in btrfs_record_root_in_trans()
551 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
553 struct btrfs_fs_info *fs_info = root->fs_info; in need_reserve_reloc_root()
556 !test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || in need_reserve_reloc_root()
557 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
558 root->reloc_root) in need_reserve_reloc_root()
565 start_transaction(struct btrfs_root *root, unsigned int num_items, in start_transaction() argument
569 struct btrfs_fs_info *fs_info = root->fs_info; in start_transaction()
596 if (num_items && root != fs_info->chunk_root) { in start_transaction()
606 ret = btrfs_qgroup_reserve_meta_prealloc(root, qgroup_reserved, in start_transaction()
629 if (need_reserve_reloc_root(root)) { in start_transaction()
699 h->fs_info = root->fs_info; in start_transaction()
726 btrfs_qgroup_convert_reserved_meta(root, qgroup_reserved); in start_transaction()
753 ret = btrfs_record_root_in_trans(h, root); in start_transaction()
775 btrfs_qgroup_free_meta_prealloc(root, qgroup_reserved); in start_transaction()
779 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
782 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
787 struct btrfs_root *root, in btrfs_start_transaction_fallback_global_rsv() argument
790 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_fallback_global_rsv()
794 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
796 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH, in btrfs_join_transaction()
800 struct btrfs_trans_handle *btrfs_join_transaction_spacecache(struct btrfs_root *root) in btrfs_join_transaction_spacecache() argument
802 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, in btrfs_join_transaction_spacecache()
813 struct btrfs_trans_handle *btrfs_join_transaction_nostart(struct btrfs_root *root) in btrfs_join_transaction_nostart() argument
815 return start_transaction(root, 0, TRANS_JOIN_NOSTART, in btrfs_join_transaction_nostart()
832 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
834 return start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction()
846 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
850 trans = start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction_barrier()
855 ret = btrfs_wait_for_commit(root->fs_info, 0); in btrfs_attach_transaction_barrier()
1247 struct btrfs_root *root) in update_cowonly_root() argument
1252 struct btrfs_fs_info *fs_info = root->fs_info; in update_cowonly_root()
1255 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1258 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1259 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1260 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1263 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1265 &root->root_key, in update_cowonly_root()
1266 &root->root_item); in update_cowonly_root()
1270 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1323 struct btrfs_root *root; in commit_cowonly_roots() local
1326 root = list_entry(next, struct btrfs_root, dirty_list); in commit_cowonly_roots()
1327 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1329 list_add_tail(&root->dirty_list, in commit_cowonly_roots()
1331 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1380 struct btrfs_root *root = list_first_entry(&fs_info->dead_roots, in btrfs_maybe_wake_unfinished_drop() local
1383 if (test_bit(BTRFS_ROOT_UNFINISHED_DROP, &root->state)) { in btrfs_maybe_wake_unfinished_drop()
1398 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1400 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dead_root()
1403 if (list_empty(&root->root_list)) { in btrfs_add_dead_root()
1404 btrfs_grab_root(root); in btrfs_add_dead_root()
1407 if (test_bit(BTRFS_ROOT_UNFINISHED_DROP, &root->state)) in btrfs_add_dead_root()
1408 list_add(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1410 list_add_tail(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1441 struct btrfs_root *root = gang[i]; in commit_fs_roots() local
1448 ASSERT(atomic_read(&root->log_writers) == 0); in commit_fs_roots()
1449 ASSERT(atomic_read(&root->log_commit[0]) == 0); in commit_fs_roots()
1450 ASSERT(atomic_read(&root->log_commit[1]) == 0); in commit_fs_roots()
1453 (unsigned long)root->root_key.objectid, in commit_fs_roots()
1457 btrfs_free_log(trans, root); in commit_fs_roots()
1458 ret2 = btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1463 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1466 if (root->commit_root != root->node) { in commit_fs_roots()
1467 list_add_tail(&root->dirty_list, in commit_fs_roots()
1469 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1470 root->node); in commit_fs_roots()
1474 &root->root_key, in commit_fs_roots()
1475 &root->root_item); in commit_fs_roots()
1479 btrfs_qgroup_free_meta_all_pertrans(root); in commit_fs_roots()
1490 int btrfs_defrag_root(struct btrfs_root *root) in btrfs_defrag_root() argument
1492 struct btrfs_fs_info *info = root->fs_info; in btrfs_defrag_root()
1496 if (test_and_set_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state)) in btrfs_defrag_root()
1500 trans = btrfs_start_transaction(root, 0); in btrfs_defrag_root()
1506 ret = btrfs_defrag_leaves(trans, root); in btrfs_defrag_root()
1521 clear_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state); in btrfs_defrag_root()
1639 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1706 parent_root = BTRFS_I(parent_inode)->root; in create_pending_snapshot()
1747 ret = record_root_in_trans(trans, root, 0); in create_pending_snapshot()
1752 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1753 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1766 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1780 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1781 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old, in create_pending_snapshot()
1790 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1799 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1846 ret = qgroup_account_snapshot(trans, root, parent_root, in create_pending_snapshot()
1935 super->root = root_item->bytenr; in update_super_roots()
2615 struct btrfs_root *root; in btrfs_clean_one_deleted_snapshot() local
2623 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2625 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2628 btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid); in btrfs_clean_one_deleted_snapshot()
2630 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2632 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2634 ret = btrfs_drop_snapshot(root, 0, 0); in btrfs_clean_one_deleted_snapshot()
2636 ret = btrfs_drop_snapshot(root, 1, 0); in btrfs_clean_one_deleted_snapshot()
2638 btrfs_put_root(root); in btrfs_clean_one_deleted_snapshot()