Lines Matching refs:root
157 struct btrfs_root *root, *tmp; in switch_commit_roots() local
161 list_for_each_entry_safe(root, tmp, &cur_trans->switch_commits, in switch_commit_roots()
163 list_del_init(&root->dirty_list); in switch_commit_roots()
164 free_extent_buffer(root->commit_root); in switch_commit_roots()
165 root->commit_root = btrfs_root_node(root); in switch_commit_roots()
166 if (is_fstree(root->root_key.objectid)) in switch_commit_roots()
167 btrfs_unpin_free_ino(root); in switch_commit_roots()
168 extent_io_tree_release(&root->dirty_log_pages); in switch_commit_roots()
169 btrfs_qgroup_clean_swapped_blocks(root); in switch_commit_roots()
175 root = list_first_entry(&cur_trans->dropped_roots, in switch_commit_roots()
177 list_del_init(&root->root_list); in switch_commit_roots()
179 btrfs_free_log(trans, root); in switch_commit_roots()
180 btrfs_drop_and_free_fs_root(fs_info, root); in switch_commit_roots()
400 struct btrfs_root *root, in record_root_in_trans() argument
403 struct btrfs_fs_info *fs_info = root->fs_info; in record_root_in_trans()
405 if ((test_bit(BTRFS_ROOT_SHAREABLE, &root->state) && in record_root_in_trans()
406 root->last_trans < trans->transid) || force) { in record_root_in_trans()
407 WARN_ON(root == fs_info->extent_root); in record_root_in_trans()
408 WARN_ON(!force && root->commit_root != root->node); in record_root_in_trans()
415 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
423 if (root->last_trans == trans->transid && !force) { in record_root_in_trans()
428 (unsigned long)root->root_key.objectid, in record_root_in_trans()
431 root->last_trans = trans->transid; in record_root_in_trans()
452 btrfs_init_reloc_root(trans, root); in record_root_in_trans()
454 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
461 struct btrfs_root *root) in btrfs_add_dropped_root() argument
463 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dropped_root()
468 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
474 (unsigned long)root->root_key.objectid, in btrfs_add_dropped_root()
480 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
482 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_record_root_in_trans()
484 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) in btrfs_record_root_in_trans()
492 if (root->last_trans == trans->transid && in btrfs_record_root_in_trans()
493 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
497 record_root_in_trans(trans, root, 0); in btrfs_record_root_in_trans()
544 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
546 struct btrfs_fs_info *fs_info = root->fs_info; in need_reserve_reloc_root()
549 !test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || in need_reserve_reloc_root()
550 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
551 root->reloc_root) in need_reserve_reloc_root()
558 start_transaction(struct btrfs_root *root, unsigned int num_items, in start_transaction() argument
562 struct btrfs_fs_info *fs_info = root->fs_info; in start_transaction()
592 if (num_items && root != fs_info->chunk_root) { in start_transaction()
597 ret = btrfs_qgroup_reserve_meta_pertrans(root, qgroup_reserved, in start_transaction()
619 if (need_reserve_reloc_root(root)) { in start_transaction()
624 ret = btrfs_block_rsv_add(root, rsv, num_bytes, flush); in start_transaction()
688 h->root = root; in start_transaction()
690 h->fs_info = root->fs_info; in start_transaction()
737 btrfs_record_root_in_trans(h, root); in start_transaction()
750 btrfs_qgroup_free_meta_pertrans(root, qgroup_reserved); in start_transaction()
754 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
757 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
762 struct btrfs_root *root, in btrfs_start_transaction_fallback_global_rsv() argument
765 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_fallback_global_rsv()
769 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
771 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH, in btrfs_join_transaction()
775 struct btrfs_trans_handle *btrfs_join_transaction_spacecache(struct btrfs_root *root) in btrfs_join_transaction_spacecache() argument
777 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, in btrfs_join_transaction_spacecache()
785 struct btrfs_trans_handle *btrfs_join_transaction_nostart(struct btrfs_root *root) in btrfs_join_transaction_nostart() argument
787 return start_transaction(root, 0, TRANS_JOIN_NOSTART, in btrfs_join_transaction_nostart()
804 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
806 return start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction()
818 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
822 trans = start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction_barrier()
825 btrfs_wait_for_commit(root->fs_info, 0); in btrfs_attach_transaction_barrier()
1180 struct btrfs_root *root) in update_cowonly_root() argument
1185 struct btrfs_fs_info *fs_info = root->fs_info; in update_cowonly_root()
1188 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1191 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1192 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1193 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1196 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1198 &root->root_key, in update_cowonly_root()
1199 &root->root_item); in update_cowonly_root()
1203 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1258 struct btrfs_root *root; in commit_cowonly_roots() local
1261 root = list_entry(next, struct btrfs_root, dirty_list); in commit_cowonly_roots()
1262 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1264 if (root != fs_info->extent_root) in commit_cowonly_roots()
1265 list_add_tail(&root->dirty_list, in commit_cowonly_roots()
1267 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1302 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1304 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dead_root()
1307 if (list_empty(&root->root_list)) { in btrfs_add_dead_root()
1308 btrfs_grab_root(root); in btrfs_add_dead_root()
1309 list_add_tail(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1333 struct btrfs_root *root = gang[i]; in commit_fs_roots() local
1337 (unsigned long)root->root_key.objectid, in commit_fs_roots()
1341 btrfs_free_log(trans, root); in commit_fs_roots()
1342 btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1344 btrfs_save_ino_cache(root, trans); in commit_fs_roots()
1347 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1350 if (root->commit_root != root->node) { in commit_fs_roots()
1351 list_add_tail(&root->dirty_list, in commit_fs_roots()
1353 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1354 root->node); in commit_fs_roots()
1358 &root->root_key, in commit_fs_roots()
1359 &root->root_item); in commit_fs_roots()
1363 btrfs_qgroup_free_meta_all_pertrans(root); in commit_fs_roots()
1374 int btrfs_defrag_root(struct btrfs_root *root) in btrfs_defrag_root() argument
1376 struct btrfs_fs_info *info = root->fs_info; in btrfs_defrag_root()
1380 if (test_and_set_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state)) in btrfs_defrag_root()
1384 trans = btrfs_start_transaction(root, 0); in btrfs_defrag_root()
1390 ret = btrfs_defrag_leaves(trans, root); in btrfs_defrag_root()
1405 clear_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state); in btrfs_defrag_root()
1512 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1547 pending->error = btrfs_block_rsv_add(root, in create_pending_snapshot()
1567 parent_root = BTRFS_I(parent_inode)->root; in create_pending_snapshot()
1605 record_root_in_trans(trans, root, 0); in create_pending_snapshot()
1606 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1607 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1620 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1634 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1635 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old, in create_pending_snapshot()
1646 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1655 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1708 ret = qgroup_account_snapshot(trans, root, parent_root, in create_pending_snapshot()
1802 super->root = root_item->bytenr; in update_super_roots()
1901 ac->newtrans = btrfs_join_transaction(trans->root); in btrfs_commit_transaction_async()
1988 trace_btrfs_transaction_commit(trans->root); in cleanup_transaction()
2041 ret = btrfs_start_delalloc_snapshot(pending->root); in btrfs_start_delalloc_flush()
2066 btrfs_wait_ordered_extents(pending->root, in btrfs_wait_delalloc_flush()
2431 trace_btrfs_transaction_commit(trans->root); in btrfs_commit_transaction()
2471 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root) in btrfs_clean_one_deleted_snapshot() argument
2474 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_clean_one_deleted_snapshot()
2481 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2483 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2486 btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid); in btrfs_clean_one_deleted_snapshot()
2488 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2489 if (root->ino_cache_inode) { in btrfs_clean_one_deleted_snapshot()
2490 iput(root->ino_cache_inode); in btrfs_clean_one_deleted_snapshot()
2491 root->ino_cache_inode = NULL; in btrfs_clean_one_deleted_snapshot()
2494 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2496 ret = btrfs_drop_snapshot(root, 0, 0); in btrfs_clean_one_deleted_snapshot()
2498 ret = btrfs_drop_snapshot(root, 1, 0); in btrfs_clean_one_deleted_snapshot()
2500 btrfs_put_root(root); in btrfs_clean_one_deleted_snapshot()