• Home
  • Raw
  • Download

Lines Matching refs:root

132 	struct btrfs_root *root, *tmp;  in switch_commit_roots()  local
135 list_for_each_entry_safe(root, tmp, &trans->switch_commits, in switch_commit_roots()
137 list_del_init(&root->dirty_list); in switch_commit_roots()
138 free_extent_buffer(root->commit_root); in switch_commit_roots()
139 root->commit_root = btrfs_root_node(root); in switch_commit_roots()
140 if (is_fstree(root->objectid)) in switch_commit_roots()
141 btrfs_unpin_free_ino(root); in switch_commit_roots()
142 clear_btree_io_tree(&root->dirty_log_pages); in switch_commit_roots()
148 root = list_first_entry(&trans->dropped_roots, in switch_commit_roots()
150 list_del_init(&root->root_list); in switch_commit_roots()
152 btrfs_drop_and_free_fs_root(fs_info, root); in switch_commit_roots()
314 struct btrfs_root *root, in record_root_in_trans() argument
317 struct btrfs_fs_info *fs_info = root->fs_info; in record_root_in_trans()
319 if ((test_bit(BTRFS_ROOT_REF_COWS, &root->state) && in record_root_in_trans()
320 root->last_trans < trans->transid) || force) { in record_root_in_trans()
321 WARN_ON(root == fs_info->extent_root); in record_root_in_trans()
322 WARN_ON(!force && root->commit_root != root->node); in record_root_in_trans()
329 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
337 if (root->last_trans == trans->transid && !force) { in record_root_in_trans()
342 (unsigned long)root->root_key.objectid, in record_root_in_trans()
345 root->last_trans = trans->transid; in record_root_in_trans()
366 btrfs_init_reloc_root(trans, root); in record_root_in_trans()
368 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
375 struct btrfs_root *root) in btrfs_add_dropped_root() argument
377 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dropped_root()
382 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
388 (unsigned long)root->root_key.objectid, in btrfs_add_dropped_root()
394 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
396 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_record_root_in_trans()
398 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in btrfs_record_root_in_trans()
406 if (root->last_trans == trans->transid && in btrfs_record_root_in_trans()
407 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
411 record_root_in_trans(trans, root, 0); in btrfs_record_root_in_trans()
462 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
464 struct btrfs_fs_info *fs_info = root->fs_info; in need_reserve_reloc_root()
467 !test_bit(BTRFS_ROOT_REF_COWS, &root->state) || in need_reserve_reloc_root()
468 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
469 root->reloc_root) in need_reserve_reloc_root()
476 start_transaction(struct btrfs_root *root, unsigned int num_items, in start_transaction() argument
480 struct btrfs_fs_info *fs_info = root->fs_info; in start_transaction()
509 if (num_items && root != fs_info->chunk_root) { in start_transaction()
511 ret = btrfs_qgroup_reserve_meta(root, qgroup_reserved, in start_transaction()
520 if (need_reserve_reloc_root(root)) { in start_transaction()
525 ret = btrfs_block_rsv_add(root, &fs_info->trans_block_rsv, in start_transaction()
569 h->root = root; in start_transaction()
571 h->fs_info = root->fs_info; in start_transaction()
594 btrfs_record_root_in_trans(h, root); in start_transaction()
609 btrfs_qgroup_free_meta(root, qgroup_reserved); in start_transaction()
613 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
616 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
621 struct btrfs_root *root, in btrfs_start_transaction_fallback_global_rsv() argument
625 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_start_transaction_fallback_global_rsv()
636 trans = start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_fallback_global_rsv()
641 trans = btrfs_start_transaction(root, 0); in btrfs_start_transaction_fallback_global_rsv()
662 struct btrfs_root *root, in btrfs_start_transaction_lflush() argument
665 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_lflush()
669 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
671 return start_transaction(root, 0, TRANS_JOIN, BTRFS_RESERVE_NO_FLUSH, in btrfs_join_transaction()
675 struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) in btrfs_join_transaction_nolock() argument
677 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, in btrfs_join_transaction_nolock()
681 struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root) in btrfs_start_ioctl_transaction() argument
683 return start_transaction(root, 0, TRANS_USERSPACE, in btrfs_start_ioctl_transaction()
700 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
702 return start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction()
714 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
718 trans = start_transaction(root, 0, TRANS_ATTACH, in btrfs_attach_transaction_barrier()
721 btrfs_wait_for_commit(root->fs_info, 0); in btrfs_attach_transaction_barrier()
1122 struct btrfs_root *root) in update_cowonly_root() argument
1127 struct btrfs_fs_info *fs_info = root->fs_info; in update_cowonly_root()
1130 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1133 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1134 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1135 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1138 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1140 &root->root_key, in update_cowonly_root()
1141 &root->root_item); in update_cowonly_root()
1145 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1200 struct btrfs_root *root; in commit_cowonly_roots() local
1203 root = list_entry(next, struct btrfs_root, dirty_list); in commit_cowonly_roots()
1204 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1206 if (root != fs_info->extent_root) in commit_cowonly_roots()
1207 list_add_tail(&root->dirty_list, in commit_cowonly_roots()
1209 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1241 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1243 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_dead_root()
1246 if (list_empty(&root->root_list)) in btrfs_add_dead_root()
1247 list_add_tail(&root->root_list, &fs_info->dead_roots); in btrfs_add_dead_root()
1271 struct btrfs_root *root = gang[i]; in commit_fs_roots() local
1273 (unsigned long)root->root_key.objectid, in commit_fs_roots()
1277 btrfs_free_log(trans, root); in commit_fs_roots()
1278 btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1279 btrfs_orphan_commit_root(trans, root); in commit_fs_roots()
1281 btrfs_save_ino_cache(root, trans); in commit_fs_roots()
1284 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1287 if (root->commit_root != root->node) { in commit_fs_roots()
1288 list_add_tail(&root->dirty_list, in commit_fs_roots()
1290 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1291 root->node); in commit_fs_roots()
1295 &root->root_key, in commit_fs_roots()
1296 &root->root_item); in commit_fs_roots()
1300 btrfs_qgroup_free_meta_all(root); in commit_fs_roots()
1311 int btrfs_defrag_root(struct btrfs_root *root) in btrfs_defrag_root() argument
1313 struct btrfs_fs_info *info = root->fs_info; in btrfs_defrag_root()
1317 if (test_and_set_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state)) in btrfs_defrag_root()
1321 trans = btrfs_start_transaction(root, 0); in btrfs_defrag_root()
1325 ret = btrfs_defrag_leaves(trans, root); in btrfs_defrag_root()
1340 clear_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state); in btrfs_defrag_root()
1447 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1483 pending->error = btrfs_block_rsv_add(root, in create_pending_snapshot()
1503 parent_root = BTRFS_I(parent_inode)->root; in create_pending_snapshot()
1541 record_root_in_trans(trans, root, 0); in create_pending_snapshot()
1542 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1543 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1557 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1571 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1572 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old); in create_pending_snapshot()
1582 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1591 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1643 ret = qgroup_account_snapshot(trans, root, parent_root, in create_pending_snapshot()
1739 super->root = root_item->bytenr; in update_super_roots()
1836 ac->newtrans = btrfs_join_transaction(trans->root); in btrfs_commit_transaction_async()
1873 struct btrfs_root *root, int err) in cleanup_transaction() argument
1875 struct btrfs_fs_info *fs_info = root->fs_info; in cleanup_transaction()
1915 trace_btrfs_transaction_commit(root); in cleanup_transaction()
2319 trace_btrfs_transaction_commit(trans->root); in btrfs_commit_transaction()
2339 cleanup_transaction(trans, trans->root, ret); in btrfs_commit_transaction()
2354 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root) in btrfs_clean_one_deleted_snapshot() argument
2357 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_clean_one_deleted_snapshot()
2364 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2366 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2369 btrfs_debug(fs_info, "cleaner removing %llu", root->objectid); in btrfs_clean_one_deleted_snapshot()
2371 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2373 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2375 ret = btrfs_drop_snapshot(root, NULL, 0, 0); in btrfs_clean_one_deleted_snapshot()
2377 ret = btrfs_drop_snapshot(root, NULL, 1, 0); in btrfs_clean_one_deleted_snapshot()