Lines Matching refs:root

162 	struct btrfs_root *root, *tmp;  in switch_commit_roots()  local
166 list_for_each_entry_safe(root, tmp, &cur_trans->switch_commits, in switch_commit_roots()
168 list_del_init(&root->dirty_list); in switch_commit_roots()
169 free_extent_buffer(root->commit_root); in switch_commit_roots()
170 root->commit_root = btrfs_root_node(root); in switch_commit_roots()
171 extent_io_tree_release(&root->dirty_log_pages); in switch_commit_roots()
172 btrfs_qgroup_clean_swapped_blocks(root); in switch_commit_roots()
178 root = list_first_entry(&cur_trans->dropped_roots, in switch_commit_roots()
180 list_del_init(&root->root_list); in switch_commit_roots()
182 btrfs_free_log(trans, root); in switch_commit_roots()
183 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 root->last_trans < trans->transid) || force) { in record_root_in_trans()
416 WARN_ON(root == fs_info->extent_root); in record_root_in_trans()
417 WARN_ON(!force && root->commit_root != root->node); in record_root_in_trans()
424 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
432 if (root->last_trans == trans->transid && !force) { in record_root_in_trans()
437 (unsigned long)root->root_key.objectid, in record_root_in_trans()
440 root->last_trans = trans->transid; in record_root_in_trans()
461 ret = btrfs_init_reloc_root(trans, root); in record_root_in_trans()
463 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
470 struct btrfs_root *root) in btrfs_add_dropped_root() argument
472 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dropped_root()
477 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
483 (unsigned long)root->root_key.objectid, in btrfs_add_dropped_root()
489 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
491 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_record_root_in_trans()
494 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) in btrfs_record_root_in_trans()
502 if (root->last_trans == trans->transid && in btrfs_record_root_in_trans()
503 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
507 ret = record_root_in_trans(trans, root, 0); in btrfs_record_root_in_trans()
554 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
556 struct btrfs_fs_info *fs_info = root->fs_info; in need_reserve_reloc_root()
559 !test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || in need_reserve_reloc_root()
560 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
561 root->reloc_root) in need_reserve_reloc_root()
568 start_transaction(struct btrfs_root *root, unsigned int num_items, in start_transaction() argument
572 struct btrfs_fs_info *fs_info = root->fs_info; in start_transaction()
599 if (num_items && root != fs_info->chunk_root) { in start_transaction()
604 ret = btrfs_qgroup_reserve_meta_pertrans(root, qgroup_reserved, in start_transaction()
626 if (need_reserve_reloc_root(root)) { in start_transaction()
631 ret = btrfs_block_rsv_add(root, rsv, num_bytes, flush); in start_transaction()
695 h->root = root; in start_transaction()
697 h->fs_info = root->fs_info; in start_transaction()
743 ret = btrfs_record_root_in_trans(h, root); in start_transaction()
765 btrfs_qgroup_free_meta_pertrans(root, qgroup_reserved); in start_transaction()
769 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
772 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
777 struct btrfs_root *root, in btrfs_start_transaction_fallback_global_rsv() argument
780 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_fallback_global_rsv()
784 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
786 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH, in btrfs_join_transaction()
790 struct btrfs_trans_handle *btrfs_join_transaction_spacecache(struct btrfs_root *root) in btrfs_join_transaction_spacecache() argument
792 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, in btrfs_join_transaction_spacecache()
800 struct btrfs_trans_handle *btrfs_join_transaction_nostart(struct btrfs_root *root) in btrfs_join_transaction_nostart() argument
802 return start_transaction(root, 0, TRANS_JOIN_NOSTART, in btrfs_join_transaction_nostart()
819 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
821 return start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction()
833 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
837 trans = start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction_barrier()
840 btrfs_wait_for_commit(root->fs_info, 0); in btrfs_attach_transaction_barrier()
1194 struct btrfs_root *root) in update_cowonly_root() argument
1199 struct btrfs_fs_info *fs_info = root->fs_info; in update_cowonly_root()
1202 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1205 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1206 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1207 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1210 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1212 &root->root_key, in update_cowonly_root()
1213 &root->root_item); in update_cowonly_root()
1217 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1264 struct btrfs_root *root; in commit_cowonly_roots() local
1267 root = list_entry(next, struct btrfs_root, dirty_list); in commit_cowonly_roots()
1268 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1270 if (root != fs_info->extent_root) in commit_cowonly_roots()
1271 list_add_tail(&root->dirty_list, in commit_cowonly_roots()
1273 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1317 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1319 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dead_root()
1322 if (list_empty(&root->root_list)) { in btrfs_add_dead_root()
1323 btrfs_grab_root(root); in btrfs_add_dead_root()
1324 list_add_tail(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1348 struct btrfs_root *root = gang[i]; in commit_fs_roots() local
1352 (unsigned long)root->root_key.objectid, in commit_fs_roots()
1356 btrfs_free_log(trans, root); in commit_fs_roots()
1357 ret2 = btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1362 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1365 if (root->commit_root != root->node) { in commit_fs_roots()
1366 list_add_tail(&root->dirty_list, in commit_fs_roots()
1368 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1369 root->node); in commit_fs_roots()
1373 &root->root_key, in commit_fs_roots()
1374 &root->root_item); in commit_fs_roots()
1378 btrfs_qgroup_free_meta_all_pertrans(root); in commit_fs_roots()
1389 int btrfs_defrag_root(struct btrfs_root *root) in btrfs_defrag_root() argument
1391 struct btrfs_fs_info *info = root->fs_info; in btrfs_defrag_root()
1395 if (test_and_set_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state)) in btrfs_defrag_root()
1399 trans = btrfs_start_transaction(root, 0); in btrfs_defrag_root()
1405 ret = btrfs_defrag_leaves(trans, root); in btrfs_defrag_root()
1420 clear_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state); in btrfs_defrag_root()
1546 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1581 pending->error = btrfs_block_rsv_add(root, in create_pending_snapshot()
1601 parent_root = BTRFS_I(parent_inode)->root; in create_pending_snapshot()
1640 ret = record_root_in_trans(trans, root, 0); in create_pending_snapshot()
1645 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1646 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1659 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1673 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1674 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old, in create_pending_snapshot()
1683 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1692 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1739 ret = qgroup_account_snapshot(trans, root, parent_root, in create_pending_snapshot()
1827 super->root = root_item->bytenr; in update_super_roots()
1902 ac->newtrans = btrfs_join_transaction(trans->root); in btrfs_commit_transaction_async()
1989 trace_btrfs_transaction_commit(trans->root); in cleanup_transaction()
2396 trace_btrfs_transaction_commit(trans->root); in btrfs_commit_transaction()
2436 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root) in btrfs_clean_one_deleted_snapshot() argument
2439 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_clean_one_deleted_snapshot()
2446 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2448 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2451 btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid); in btrfs_clean_one_deleted_snapshot()
2453 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2455 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2457 ret = btrfs_drop_snapshot(root, 0, 0); in btrfs_clean_one_deleted_snapshot()
2459 ret = btrfs_drop_snapshot(root, 1, 0); in btrfs_clean_one_deleted_snapshot()
2461 btrfs_put_root(root); in btrfs_clean_one_deleted_snapshot()