Lines Matching refs:root

113 	struct btrfs_root *root, *tmp;  in switch_commit_roots()  local
116 list_for_each_entry_safe(root, tmp, &trans->switch_commits, in switch_commit_roots()
118 list_del_init(&root->dirty_list); in switch_commit_roots()
119 free_extent_buffer(root->commit_root); in switch_commit_roots()
120 root->commit_root = btrfs_root_node(root); in switch_commit_roots()
121 if (is_fstree(root->objectid)) in switch_commit_roots()
122 btrfs_unpin_free_ino(root); in switch_commit_roots()
123 clear_btree_io_tree(&root->dirty_log_pages); in switch_commit_roots()
129 root = list_first_entry(&trans->dropped_roots, in switch_commit_roots()
131 list_del_init(&root->root_list); in switch_commit_roots()
133 btrfs_drop_and_free_fs_root(fs_info, root); in switch_commit_roots()
295 struct btrfs_root *root, in record_root_in_trans() argument
298 struct btrfs_fs_info *fs_info = root->fs_info; in record_root_in_trans()
300 if ((test_bit(BTRFS_ROOT_REF_COWS, &root->state) && in record_root_in_trans()
301 root->last_trans < trans->transid) || force) { in record_root_in_trans()
302 WARN_ON(root == fs_info->extent_root); in record_root_in_trans()
303 WARN_ON(!force && root->commit_root != root->node); in record_root_in_trans()
310 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
318 if (root->last_trans == trans->transid && !force) { in record_root_in_trans()
323 (unsigned long)root->root_key.objectid, in record_root_in_trans()
326 root->last_trans = trans->transid; in record_root_in_trans()
347 btrfs_init_reloc_root(trans, root); in record_root_in_trans()
349 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
356 struct btrfs_root *root) in btrfs_add_dropped_root() argument
358 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dropped_root()
363 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
369 (unsigned long)root->root_key.objectid, in btrfs_add_dropped_root()
375 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
377 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_record_root_in_trans()
379 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in btrfs_record_root_in_trans()
387 if (root->last_trans == trans->transid && in btrfs_record_root_in_trans()
388 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
392 record_root_in_trans(trans, root, 0); in btrfs_record_root_in_trans()
439 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
441 struct btrfs_fs_info *fs_info = root->fs_info; in need_reserve_reloc_root()
444 !test_bit(BTRFS_ROOT_REF_COWS, &root->state) || in need_reserve_reloc_root()
445 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
446 root->reloc_root) in need_reserve_reloc_root()
453 start_transaction(struct btrfs_root *root, unsigned int num_items, in start_transaction() argument
457 struct btrfs_fs_info *fs_info = root->fs_info; in start_transaction()
486 if (num_items && root != fs_info->chunk_root) { in start_transaction()
488 ret = btrfs_qgroup_reserve_meta_pertrans(root, qgroup_reserved, in start_transaction()
497 if (need_reserve_reloc_root(root)) { in start_transaction()
502 ret = btrfs_block_rsv_add(root, &fs_info->trans_block_rsv, in start_transaction()
546 h->root = root; in start_transaction()
548 h->fs_info = root->fs_info; in start_transaction()
571 btrfs_record_root_in_trans(h, root); in start_transaction()
586 btrfs_qgroup_free_meta_pertrans(root, qgroup_reserved); in start_transaction()
590 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
593 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
598 struct btrfs_root *root, in btrfs_start_transaction_fallback_global_rsv() argument
602 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_start_transaction_fallback_global_rsv()
613 trans = start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_fallback_global_rsv()
618 trans = btrfs_start_transaction(root, 0); in btrfs_start_transaction_fallback_global_rsv()
638 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
640 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH, in btrfs_join_transaction()
644 struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) in btrfs_join_transaction_nolock() argument
646 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, in btrfs_join_transaction_nolock()
663 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
665 return start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction()
677 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
681 trans = start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction_barrier()
684 btrfs_wait_for_commit(root->fs_info, 0); in btrfs_attach_transaction_barrier()
1091 struct btrfs_root *root) in update_cowonly_root() argument
1096 struct btrfs_fs_info *fs_info = root->fs_info; in update_cowonly_root()
1099 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1102 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1103 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1104 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1107 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1109 &root->root_key, in update_cowonly_root()
1110 &root->root_item); in update_cowonly_root()
1114 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1169 struct btrfs_root *root; in commit_cowonly_roots() local
1172 root = list_entry(next, struct btrfs_root, dirty_list); in commit_cowonly_roots()
1173 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1175 if (root != fs_info->extent_root) in commit_cowonly_roots()
1176 list_add_tail(&root->dirty_list, in commit_cowonly_roots()
1178 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1210 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1212 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dead_root()
1215 if (list_empty(&root->root_list)) in btrfs_add_dead_root()
1216 list_add_tail(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1240 struct btrfs_root *root = gang[i]; in commit_fs_roots() local
1242 (unsigned long)root->root_key.objectid, in commit_fs_roots()
1246 btrfs_free_log(trans, root); in commit_fs_roots()
1247 btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1249 btrfs_save_ino_cache(root, trans); in commit_fs_roots()
1252 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1255 if (root->commit_root != root->node) { in commit_fs_roots()
1256 list_add_tail(&root->dirty_list, in commit_fs_roots()
1258 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1259 root->node); in commit_fs_roots()
1263 &root->root_key, in commit_fs_roots()
1264 &root->root_item); in commit_fs_roots()
1268 btrfs_qgroup_free_meta_all_pertrans(root); in commit_fs_roots()
1279 int btrfs_defrag_root(struct btrfs_root *root) in btrfs_defrag_root() argument
1281 struct btrfs_fs_info *info = root->fs_info; in btrfs_defrag_root()
1285 if (test_and_set_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state)) in btrfs_defrag_root()
1289 trans = btrfs_start_transaction(root, 0); in btrfs_defrag_root()
1293 ret = btrfs_defrag_leaves(trans, root); in btrfs_defrag_root()
1308 clear_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state); in btrfs_defrag_root()
1415 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1451 pending->error = btrfs_block_rsv_add(root, in create_pending_snapshot()
1471 parent_root = BTRFS_I(parent_inode)->root; in create_pending_snapshot()
1509 record_root_in_trans(trans, root, 0); in create_pending_snapshot()
1510 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1511 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1525 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1539 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1540 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old); in create_pending_snapshot()
1550 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1559 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1611 ret = qgroup_account_snapshot(trans, root, parent_root, in create_pending_snapshot()
1705 super->root = root_item->bytenr; in update_super_roots()
1802 ac->newtrans = btrfs_join_transaction(trans->root); in btrfs_commit_transaction_async()
1880 trace_btrfs_transaction_commit(trans->root); in cleanup_transaction()
2274 trace_btrfs_transaction_commit(trans->root); in btrfs_commit_transaction()
2318 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root) in btrfs_clean_one_deleted_snapshot() argument
2321 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_clean_one_deleted_snapshot()
2328 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2330 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2333 btrfs_debug(fs_info, "cleaner removing %llu", root->objectid); in btrfs_clean_one_deleted_snapshot()
2335 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2337 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2339 ret = btrfs_drop_snapshot(root, NULL, 0, 0); in btrfs_clean_one_deleted_snapshot()
2341 ret = btrfs_drop_snapshot(root, NULL, 1, 0); in btrfs_clean_one_deleted_snapshot()