Lines Matching defs:root

157 	struct btrfs_root *root, *tmp;
161 list_for_each_entry_safe(root, tmp, &cur_trans->switch_commits,
163 list_del_init(&root->dirty_list);
164 free_extent_buffer(root->commit_root);
165 root->commit_root = btrfs_root_node(root);
166 if (is_fstree(root->root_key.objectid))
167 btrfs_unpin_free_ino(root);
168 extent_io_tree_release(&root->dirty_log_pages);
169 btrfs_qgroup_clean_swapped_blocks(root);
175 root = list_first_entry(&cur_trans->dropped_roots,
177 list_del_init(&root->root_list);
179 btrfs_free_log(trans, root);
180 btrfs_drop_and_free_fs_root(fs_info, root);
193 * commit root
199 * new commit root
395 * This does all the record keeping required to make sure that a shareable root
397 * the old root from before we joined the transaction is deleted when the
401 struct btrfs_root *root,
404 struct btrfs_fs_info *fs_info = root->fs_info;
406 if ((test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
407 root->last_trans < trans->transid) || force) {
408 WARN_ON(root == fs_info->extent_root);
409 WARN_ON(!force && root->commit_root != root->node);
416 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state);
419 * they find our root->last_trans update
424 if (root->last_trans == trans->transid && !force) {
429 (unsigned long)root->root_key.objectid,
432 root->last_trans = trans->transid;
436 * unless we're really doing the first setup for this root in
439 * Normally we'd use root->last_trans as a flag to decide
442 * But, we have to set root->last_trans before we
443 * init the relocation root, otherwise, we trip over warnings
445 * with root IN_TRANS_SETUP. When this is 1, we're still
448 * When this is zero, they can trust root->last_trans and fly
453 btrfs_init_reloc_root(trans, root);
455 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state);
462 struct btrfs_root *root)
464 struct btrfs_fs_info *fs_info = root->fs_info;
469 list_add_tail(&root->root_list, &cur_trans->dropped_roots);
472 /* Make sure we don't try to update the root at commit time */
475 (unsigned long)root->root_key.objectid,
481 struct btrfs_root *root)
483 struct btrfs_fs_info *fs_info = root->fs_info;
485 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
493 if (root->last_trans == trans->transid &&
494 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state))
498 record_root_in_trans(trans, root, 0);
545 static inline bool need_reserve_reloc_root(struct btrfs_root *root)
547 struct btrfs_fs_info *fs_info = root->fs_info;
550 !test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
551 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID ||
552 root->reloc_root)
559 start_transaction(struct btrfs_root *root, unsigned int num_items,
563 struct btrfs_fs_info *fs_info = root->fs_info;
593 if (num_items && root != fs_info->chunk_root) {
598 ret = btrfs_qgroup_reserve_meta_pertrans(root, qgroup_reserved,
618 * Do the reservation for the relocation root creation
620 if (need_reserve_reloc_root(root)) {
625 ret = btrfs_block_rsv_add(root, rsv, num_bytes, flush);
639 * Some people call with btrfs_start_transaction(root, 0)
689 h->root = root;
691 h->fs_info = root->fs_info;
738 btrfs_record_root_in_trans(h, root);
751 btrfs_qgroup_free_meta_pertrans(root, qgroup_reserved);
755 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
758 return start_transaction(root, num_items, TRANS_START,
763 struct btrfs_root *root,
766 return start_transaction(root, num_items, TRANS_START,
770 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root)
772 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH,
776 struct btrfs_trans_handle *btrfs_join_transaction_spacecache(struct btrfs_root *root)
778 return start_transaction(root, 0, TRANS_JOIN_NOLOCK,
786 struct btrfs_trans_handle *btrfs_join_transaction_nostart(struct btrfs_root *root)
788 return start_transaction(root, 0, TRANS_JOIN_NOSTART,
805 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root)
807 return start_transaction(root, 0, TRANS_ATTACH,
819 btrfs_attach_transaction_barrier(struct btrfs_root *root)
823 trans = start_transaction(root, 0, TRANS_ATTACH,
828 ret = btrfs_wait_for_commit(root->fs_info, 0);
1177 * this is used to update the root pointer in the tree of tree roots.
1179 * But, in the case of the extent allocation tree, updating the root
1180 * pointer may allocate blocks which may change the root of the extent
1183 * So, this loops and repeats and makes sure the cowonly root didn't
1184 * change while the root pointer was being updated in the metadata.
1187 struct btrfs_root *root)
1192 struct btrfs_fs_info *fs_info = root->fs_info;
1195 old_root_used = btrfs_root_used(&root->root_item);
1198 old_root_bytenr = btrfs_root_bytenr(&root->root_item);
1199 if (old_root_bytenr == root->node->start &&
1200 old_root_used == btrfs_root_used(&root->root_item))
1203 btrfs_set_root_node(&root->root_item, root->node);
1205 &root->root_key,
1206 &root->root_item);
1210 old_root_used = btrfs_root_used(&root->root_item);
1265 struct btrfs_root *root;
1268 root = list_entry(next, struct btrfs_root, dirty_list);
1269 clear_bit(BTRFS_ROOT_DIRTY, &root->state);
1271 if (root != fs_info->extent_root)
1272 list_add_tail(&root->dirty_list,
1274 ret = update_cowonly_root(trans, root);
1306 * a dirty root struct and adds it into the list of dead roots that need to
1309 void btrfs_add_dead_root(struct btrfs_root *root)
1311 struct btrfs_fs_info *fs_info = root->fs_info;
1314 if (list_empty(&root->root_list)) {
1315 btrfs_grab_root(root);
1316 list_add_tail(&root->root_list, &fs_info->dead_roots);
1340 struct btrfs_root *root = gang[i];
1344 (unsigned long)root->root_key.objectid,
1348 btrfs_free_log(trans, root);
1349 btrfs_update_reloc_root(trans, root);
1351 btrfs_save_ino_cache(root, trans);
1354 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state);
1357 if (root->commit_root != root->node) {
1358 list_add_tail(&root->dirty_list,
1360 btrfs_set_root_node(&root->root_item,
1361 root->node);
1365 &root->root_key,
1366 &root->root_item);
1370 btrfs_qgroup_free_meta_all_pertrans(root);
1381 int btrfs_defrag_root(struct btrfs_root *root)
1383 struct btrfs_fs_info *info = root->fs_info;
1387 if (test_and_set_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state))
1391 trans = btrfs_start_transaction(root, 0);
1397 ret = btrfs_defrag_leaves(trans, root);
1412 clear_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state);
1443 * recorded root will never be updated again, causing an outdated root
1476 * like chunk and root tree, as they won't affect qgroup.
1492 * Force parent root to be updated, as we recorded it before so its
1519 struct btrfs_root *root = pending->root;
1554 pending->error = btrfs_block_rsv_add(root,
1574 parent_root = BTRFS_I(parent_inode)->root;
1612 record_root_in_trans(trans, root, 0);
1613 btrfs_set_root_last_snapshot(&root->root_item, trans->transid);
1614 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item));
1627 memcpy(new_root_item->parent_uuid, root->root_item.uuid,
1641 old = btrfs_lock_root_node(root);
1642 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old,
1653 ret = btrfs_copy_root(trans, root, old, &tmp, objectid);
1662 set_bit(BTRFS_ROOT_FORCE_COW, &root->state);
1677 * insert root back/forward references
1715 ret = qgroup_account_snapshot(trans, root, parent_root,
1809 super->root = root_item->bytenr;
1908 ac->newtrans = btrfs_join_transaction(trans->root);
1995 trace_btrfs_transaction_commit(trans->root);
2039 * Flush dellaloc for any root that is going to be snapshotted.
2048 ret = btrfs_start_delalloc_snapshot(pending->root);
2073 btrfs_wait_ordered_extents(pending->root,
2300 * root for every subvolume and other tree. So, we have to keep
2323 * safe to free the root of tree log roots
2438 trace_btrfs_transaction_commit(trans->root);
2478 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
2481 struct btrfs_fs_info *fs_info = root->fs_info;
2488 root = list_first_entry(&fs_info->dead_roots,
2490 list_del_init(&root->root_list);
2493 btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid);
2495 btrfs_kill_all_delayed_nodes(root);
2496 if (root->ino_cache_inode) {
2497 iput(root->ino_cache_inode);
2498 root->ino_cache_inode = NULL;
2501 if (btrfs_header_backref_rev(root->node) <
2503 ret = btrfs_drop_snapshot(root, 0, 0);
2505 ret = btrfs_drop_snapshot(root, 1, 0);
2507 btrfs_put_root(root);