Lines Matching refs:root

108 	struct btrfs_root *root, *tmp;  in switch_commit_roots()  local
111 list_for_each_entry_safe(root, tmp, &trans->switch_commits, in switch_commit_roots()
113 list_del_init(&root->dirty_list); in switch_commit_roots()
114 free_extent_buffer(root->commit_root); in switch_commit_roots()
115 root->commit_root = btrfs_root_node(root); in switch_commit_roots()
116 if (is_fstree(root->objectid)) in switch_commit_roots()
117 btrfs_unpin_free_ino(root); in switch_commit_roots()
118 clear_btree_io_tree(&root->dirty_log_pages); in switch_commit_roots()
151 static noinline int join_transaction(struct btrfs_root *root, unsigned int type) in join_transaction() argument
154 struct btrfs_fs_info *fs_info = root->fs_info; in join_transaction()
278 struct btrfs_root *root) in record_root_in_trans() argument
280 if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) && in record_root_in_trans()
281 root->last_trans < trans->transid) { in record_root_in_trans()
282 WARN_ON(root == root->fs_info->extent_root); in record_root_in_trans()
283 WARN_ON(root->commit_root != root->node); in record_root_in_trans()
290 set_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
297 spin_lock(&root->fs_info->fs_roots_radix_lock); in record_root_in_trans()
298 if (root->last_trans == trans->transid) { in record_root_in_trans()
299 spin_unlock(&root->fs_info->fs_roots_radix_lock); in record_root_in_trans()
302 radix_tree_tag_set(&root->fs_info->fs_roots_radix, in record_root_in_trans()
303 (unsigned long)root->root_key.objectid, in record_root_in_trans()
305 spin_unlock(&root->fs_info->fs_roots_radix_lock); in record_root_in_trans()
306 root->last_trans = trans->transid; in record_root_in_trans()
327 btrfs_init_reloc_root(trans, root); in record_root_in_trans()
329 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state); in record_root_in_trans()
336 struct btrfs_root *root) in btrfs_record_root_in_trans() argument
338 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in btrfs_record_root_in_trans()
346 if (root->last_trans == trans->transid && in btrfs_record_root_in_trans()
347 !test_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state)) in btrfs_record_root_in_trans()
350 mutex_lock(&root->fs_info->reloc_mutex); in btrfs_record_root_in_trans()
351 record_root_in_trans(trans, root); in btrfs_record_root_in_trans()
352 mutex_unlock(&root->fs_info->reloc_mutex); in btrfs_record_root_in_trans()
368 static void wait_current_trans(struct btrfs_root *root) in wait_current_trans() argument
372 spin_lock(&root->fs_info->trans_lock); in wait_current_trans()
373 cur_trans = root->fs_info->running_transaction; in wait_current_trans()
376 spin_unlock(&root->fs_info->trans_lock); in wait_current_trans()
378 wait_event(root->fs_info->transaction_wait, in wait_current_trans()
383 spin_unlock(&root->fs_info->trans_lock); in wait_current_trans()
387 static int may_wait_transaction(struct btrfs_root *root, int type) in may_wait_transaction() argument
389 if (root->fs_info->log_root_recovering) in may_wait_transaction()
396 !atomic_read(&root->fs_info->open_ioctl_trans)) in may_wait_transaction()
402 static inline bool need_reserve_reloc_root(struct btrfs_root *root) in need_reserve_reloc_root() argument
404 if (!root->fs_info->reloc_ctl || in need_reserve_reloc_root()
405 !test_bit(BTRFS_ROOT_REF_COWS, &root->state) || in need_reserve_reloc_root()
406 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || in need_reserve_reloc_root()
407 root->reloc_root) in need_reserve_reloc_root()
414 start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type, in start_transaction() argument
427 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) in start_transaction()
444 if (num_items > 0 && root != root->fs_info->chunk_root) { in start_transaction()
445 if (root->fs_info->quota_enabled && in start_transaction()
446 is_fstree(root->root_key.objectid)) { in start_transaction()
447 qgroup_reserved = num_items * root->nodesize; in start_transaction()
448 ret = btrfs_qgroup_reserve(root, qgroup_reserved); in start_transaction()
453 num_bytes = btrfs_calc_trans_metadata_size(root, num_items); in start_transaction()
457 if (need_reserve_reloc_root(root)) { in start_transaction()
458 num_bytes += root->nodesize; in start_transaction()
462 ret = btrfs_block_rsv_add(root, in start_transaction()
463 &root->fs_info->trans_block_rsv, in start_transaction()
486 sb_start_intwrite(root->fs_info->sb); in start_transaction()
488 if (may_wait_transaction(root, type)) in start_transaction()
489 wait_current_trans(root); in start_transaction()
492 ret = join_transaction(root, type); in start_transaction()
494 wait_current_trans(root); in start_transaction()
506 cur_trans = root->fs_info->running_transaction; in start_transaction()
512 h->root = root; in start_transaction()
531 may_wait_transaction(root, type)) { in start_transaction()
533 btrfs_commit_transaction(h, root); in start_transaction()
538 trace_btrfs_space_reservation(root->fs_info, "transaction", in start_transaction()
540 h->block_rsv = &root->fs_info->trans_block_rsv; in start_transaction()
547 btrfs_record_root_in_trans(h, root); in start_transaction()
555 sb_end_intwrite(root->fs_info->sb); in start_transaction()
559 btrfs_block_rsv_release(root, &root->fs_info->trans_block_rsv, in start_transaction()
563 btrfs_qgroup_free(root, qgroup_reserved); in start_transaction()
567 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, in btrfs_start_transaction() argument
570 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction()
575 struct btrfs_root *root, int num_items) in btrfs_start_transaction_lflush() argument
577 return start_transaction(root, num_items, TRANS_START, in btrfs_start_transaction_lflush()
581 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) in btrfs_join_transaction() argument
583 return start_transaction(root, 0, TRANS_JOIN, 0); in btrfs_join_transaction()
586 struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) in btrfs_join_transaction_nolock() argument
588 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, 0); in btrfs_join_transaction_nolock()
591 struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root) in btrfs_start_ioctl_transaction() argument
593 return start_transaction(root, 0, TRANS_USERSPACE, 0); in btrfs_start_ioctl_transaction()
609 struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) in btrfs_attach_transaction() argument
611 return start_transaction(root, 0, TRANS_ATTACH, 0); in btrfs_attach_transaction()
622 btrfs_attach_transaction_barrier(struct btrfs_root *root) in btrfs_attach_transaction_barrier() argument
626 trans = start_transaction(root, 0, TRANS_ATTACH, 0); in btrfs_attach_transaction_barrier()
628 btrfs_wait_for_commit(root, 0); in btrfs_attach_transaction_barrier()
634 static noinline void wait_for_commit(struct btrfs_root *root, in wait_for_commit() argument
640 int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid) in btrfs_wait_for_commit() argument
646 if (transid <= root->fs_info->last_trans_committed) in btrfs_wait_for_commit()
650 spin_lock(&root->fs_info->trans_lock); in btrfs_wait_for_commit()
651 list_for_each_entry(t, &root->fs_info->trans_list, list) { in btrfs_wait_for_commit()
663 spin_unlock(&root->fs_info->trans_lock); in btrfs_wait_for_commit()
670 if (transid > root->fs_info->last_trans_committed) in btrfs_wait_for_commit()
676 spin_lock(&root->fs_info->trans_lock); in btrfs_wait_for_commit()
677 list_for_each_entry_reverse(t, &root->fs_info->trans_list, in btrfs_wait_for_commit()
687 spin_unlock(&root->fs_info->trans_lock); in btrfs_wait_for_commit()
692 wait_for_commit(root, cur_trans); in btrfs_wait_for_commit()
698 void btrfs_throttle(struct btrfs_root *root) in btrfs_throttle() argument
700 if (!atomic_read(&root->fs_info->open_ioctl_trans)) in btrfs_throttle()
701 wait_current_trans(root); in btrfs_throttle()
705 struct btrfs_root *root) in should_end_transaction() argument
707 if (root->fs_info->global_block_rsv.space_info->full && in should_end_transaction()
708 btrfs_check_space_for_delayed_refs(trans, root)) in should_end_transaction()
711 return !!btrfs_block_rsv_check(root, &root->fs_info->global_block_rsv, 5); in should_end_transaction()
715 struct btrfs_root *root) in btrfs_should_end_transaction() argument
729 err = btrfs_run_delayed_refs(trans, root, updates * 2); in btrfs_should_end_transaction()
734 return should_end_transaction(trans, root); in btrfs_should_end_transaction()
738 struct btrfs_root *root, int throttle) in __btrfs_end_transaction() argument
741 struct btrfs_fs_info *info = root->fs_info; in __btrfs_end_transaction()
753 btrfs_trans_release_metadata(trans, root); in __btrfs_end_transaction()
757 btrfs_create_pending_block_groups(trans, root); in __btrfs_end_transaction()
768 btrfs_should_throttle_delayed_refs(trans, root); in __btrfs_end_transaction()
785 btrfs_qgroup_free(trans->root, trans->qgroup_reserved); in __btrfs_end_transaction()
789 btrfs_trans_release_metadata(trans, root); in __btrfs_end_transaction()
793 btrfs_create_pending_block_groups(trans, root); in __btrfs_end_transaction()
795 if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) && in __btrfs_end_transaction()
796 should_end_transaction(trans, root) && in __btrfs_end_transaction()
806 return btrfs_commit_transaction(trans, root); in __btrfs_end_transaction()
812 sb_end_intwrite(root->fs_info->sb); in __btrfs_end_transaction()
828 btrfs_run_delayed_iputs(root); in __btrfs_end_transaction()
831 test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) { in __btrfs_end_transaction()
839 btrfs_async_run_delayed_refs(root, cur, in __btrfs_end_transaction()
846 struct btrfs_root *root) in btrfs_end_transaction() argument
848 return __btrfs_end_transaction(trans, root, 0); in btrfs_end_transaction()
852 struct btrfs_root *root) in btrfs_end_transaction_throttle() argument
854 return __btrfs_end_transaction(trans, root, 1); in btrfs_end_transaction_throttle()
862 int btrfs_write_marked_extents(struct btrfs_root *root, in btrfs_write_marked_extents() argument
867 struct address_space *mapping = root->fs_info->btree_inode->i_mapping; in btrfs_write_marked_extents()
916 int btrfs_wait_marked_extents(struct btrfs_root *root, in btrfs_wait_marked_extents() argument
921 struct address_space *mapping = root->fs_info->btree_inode->i_mapping; in btrfs_wait_marked_extents()
925 struct btrfs_inode *btree_ino = BTRFS_I(root->fs_info->btree_inode); in btrfs_wait_marked_extents()
955 if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { in btrfs_wait_marked_extents()
982 static int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, in btrfs_write_and_wait_marked_extents() argument
990 ret = btrfs_write_marked_extents(root, dirty_pages, mark); in btrfs_write_and_wait_marked_extents()
992 ret2 = btrfs_wait_marked_extents(root, dirty_pages, mark); in btrfs_write_and_wait_marked_extents()
1002 struct btrfs_root *root) in btrfs_write_and_wait_transaction() argument
1006 ret = btrfs_write_and_wait_marked_extents(root, in btrfs_write_and_wait_transaction()
1025 struct btrfs_root *root) in update_cowonly_root() argument
1030 struct btrfs_root *tree_root = root->fs_info->tree_root; in update_cowonly_root()
1032 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1035 old_root_bytenr = btrfs_root_bytenr(&root->root_item); in update_cowonly_root()
1036 if (old_root_bytenr == root->node->start && in update_cowonly_root()
1037 old_root_used == btrfs_root_used(&root->root_item)) in update_cowonly_root()
1040 btrfs_set_root_node(&root->root_item, root->node); in update_cowonly_root()
1042 &root->root_key, in update_cowonly_root()
1043 &root->root_item); in update_cowonly_root()
1047 old_root_used = btrfs_root_used(&root->root_item); in update_cowonly_root()
1061 struct btrfs_root *root) in commit_cowonly_roots() argument
1063 struct btrfs_fs_info *fs_info = root->fs_info; in commit_cowonly_roots()
1079 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); in commit_cowonly_roots()
1083 ret = btrfs_run_dev_stats(trans, root->fs_info); in commit_cowonly_roots()
1086 ret = btrfs_run_dev_replace(trans, root->fs_info); in commit_cowonly_roots()
1089 ret = btrfs_run_qgroups(trans, root->fs_info); in commit_cowonly_roots()
1093 ret = btrfs_setup_space_cache(trans, root); in commit_cowonly_roots()
1098 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); in commit_cowonly_roots()
1105 root = list_entry(next, struct btrfs_root, dirty_list); in commit_cowonly_roots()
1106 clear_bit(BTRFS_ROOT_DIRTY, &root->state); in commit_cowonly_roots()
1108 if (root != fs_info->extent_root) in commit_cowonly_roots()
1109 list_add_tail(&root->dirty_list, in commit_cowonly_roots()
1111 ret = update_cowonly_root(trans, root); in commit_cowonly_roots()
1114 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); in commit_cowonly_roots()
1120 ret = btrfs_write_dirty_block_groups(trans, root); in commit_cowonly_roots()
1123 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); in commit_cowonly_roots()
1143 void btrfs_add_dead_root(struct btrfs_root *root) in btrfs_add_dead_root() argument
1145 spin_lock(&root->fs_info->trans_lock); in btrfs_add_dead_root()
1146 if (list_empty(&root->root_list)) in btrfs_add_dead_root()
1147 list_add_tail(&root->root_list, &root->fs_info->dead_roots); in btrfs_add_dead_root()
1148 spin_unlock(&root->fs_info->trans_lock); in btrfs_add_dead_root()
1155 struct btrfs_root *root) in commit_fs_roots() argument
1158 struct btrfs_fs_info *fs_info = root->fs_info; in commit_fs_roots()
1172 root = gang[i]; in commit_fs_roots()
1174 (unsigned long)root->root_key.objectid, in commit_fs_roots()
1178 btrfs_free_log(trans, root); in commit_fs_roots()
1179 btrfs_update_reloc_root(trans, root); in commit_fs_roots()
1180 btrfs_orphan_commit_root(trans, root); in commit_fs_roots()
1182 btrfs_save_ino_cache(root, trans); in commit_fs_roots()
1185 clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); in commit_fs_roots()
1188 if (root->commit_root != root->node) { in commit_fs_roots()
1189 list_add_tail(&root->dirty_list, in commit_fs_roots()
1191 btrfs_set_root_node(&root->root_item, in commit_fs_roots()
1192 root->node); in commit_fs_roots()
1196 &root->root_key, in commit_fs_roots()
1197 &root->root_item); in commit_fs_roots()
1211 int btrfs_defrag_root(struct btrfs_root *root) in btrfs_defrag_root() argument
1213 struct btrfs_fs_info *info = root->fs_info; in btrfs_defrag_root()
1217 if (test_and_set_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state)) in btrfs_defrag_root()
1221 trans = btrfs_start_transaction(root, 0); in btrfs_defrag_root()
1225 ret = btrfs_defrag_leaves(trans, root); in btrfs_defrag_root()
1227 btrfs_end_transaction(trans, root); in btrfs_defrag_root()
1231 if (btrfs_fs_closing(root->fs_info) || ret != -EAGAIN) in btrfs_defrag_root()
1234 if (btrfs_defrag_cancelled(root->fs_info)) { in btrfs_defrag_root()
1240 clear_bit(BTRFS_ROOT_DEFRAG_RUNNING, &root->state); in btrfs_defrag_root()
1260 struct btrfs_root *root = pending->root; in create_pending_snapshot() local
1296 pending->error = btrfs_block_rsv_add(root, in create_pending_snapshot()
1314 parent_root = BTRFS_I(parent_inode)->root; in create_pending_snapshot()
1333 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1344 ret = btrfs_run_delayed_items(trans, root); in create_pending_snapshot()
1346 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1350 record_root_in_trans(trans, root); in create_pending_snapshot()
1351 btrfs_set_root_last_snapshot(&root->root_item, trans->transid); in create_pending_snapshot()
1352 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); in create_pending_snapshot()
1366 memcpy(new_root_item->parent_uuid, root->root_item.uuid, in create_pending_snapshot()
1380 old = btrfs_lock_root_node(root); in create_pending_snapshot()
1381 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old); in create_pending_snapshot()
1385 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1391 ret = btrfs_copy_root(trans, root, old, &tmp, objectid); in create_pending_snapshot()
1396 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1404 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); in create_pending_snapshot()
1406 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1411 root->root_key.objectid, in create_pending_snapshot()
1414 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1419 set_bit(BTRFS_ROOT_FORCE_COW, &root->state); in create_pending_snapshot()
1429 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1441 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1446 pending->snap = btrfs_read_fs_root_no_name(root->fs_info, &key); in create_pending_snapshot()
1449 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1455 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1459 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); in create_pending_snapshot()
1461 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1472 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1481 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1487 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1496 btrfs_abort_transaction(trans, root, ret); in create_pending_snapshot()
1531 static void update_super_roots(struct btrfs_root *root) in update_super_roots() argument
1536 super = root->fs_info->super_copy; in update_super_roots()
1538 root_item = &root->fs_info->chunk_root->root_item; in update_super_roots()
1543 root_item = &root->fs_info->tree_root->root_item; in update_super_roots()
1544 super->root = root_item->bytenr; in update_super_roots()
1547 if (btrfs_test_opt(root, SPACE_CACHE)) in update_super_roots()
1549 if (root->fs_info->update_uuid_tree_gen) in update_super_roots()
1583 static void wait_current_trans_commit_start(struct btrfs_root *root, in wait_current_trans_commit_start() argument
1586 wait_event(root->fs_info->transaction_blocked_wait, in wait_current_trans_commit_start()
1595 static void wait_current_trans_commit_start_and_unblock(struct btrfs_root *root, in wait_current_trans_commit_start_and_unblock() argument
1598 wait_event(root->fs_info->transaction_wait, in wait_current_trans_commit_start_and_unblock()
1609 struct btrfs_root *root; member
1624 &ac->root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1], in do_async_commit()
1629 btrfs_commit_transaction(ac->newtrans, ac->root); in do_async_commit()
1634 struct btrfs_root *root, in btrfs_commit_transaction_async() argument
1645 ac->root = root; in btrfs_commit_transaction_async()
1646 ac->newtrans = btrfs_join_transaction(root); in btrfs_commit_transaction_async()
1657 btrfs_end_transaction(trans, root); in btrfs_commit_transaction_async()
1665 &root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1], in btrfs_commit_transaction_async()
1672 wait_current_trans_commit_start_and_unblock(root, cur_trans); in btrfs_commit_transaction_async()
1674 wait_current_trans_commit_start(root, cur_trans); in btrfs_commit_transaction_async()
1685 struct btrfs_root *root, int err) in cleanup_transaction() argument
1692 btrfs_abort_transaction(trans, root, err); in cleanup_transaction()
1694 spin_lock(&root->fs_info->trans_lock); in cleanup_transaction()
1704 if (cur_trans == root->fs_info->running_transaction) { in cleanup_transaction()
1706 spin_unlock(&root->fs_info->trans_lock); in cleanup_transaction()
1710 spin_lock(&root->fs_info->trans_lock); in cleanup_transaction()
1712 spin_unlock(&root->fs_info->trans_lock); in cleanup_transaction()
1714 btrfs_cleanup_one_transaction(trans->transaction, root); in cleanup_transaction()
1716 spin_lock(&root->fs_info->trans_lock); in cleanup_transaction()
1717 if (cur_trans == root->fs_info->running_transaction) in cleanup_transaction()
1718 root->fs_info->running_transaction = NULL; in cleanup_transaction()
1719 spin_unlock(&root->fs_info->trans_lock); in cleanup_transaction()
1722 sb_end_intwrite(root->fs_info->sb); in cleanup_transaction()
1726 trace_btrfs_transaction_commit(root); in cleanup_transaction()
1730 btrfs_scrub_cancel(root->fs_info); in cleanup_transaction()
1771 struct btrfs_root *root) in btrfs_commit_transaction() argument
1775 struct btrfs_inode *btree_ino = BTRFS_I(root->fs_info->btree_inode); in btrfs_commit_transaction()
1781 btrfs_end_transaction(trans, root); in btrfs_commit_transaction()
1788 ret = btrfs_run_delayed_refs(trans, root, 0); in btrfs_commit_transaction()
1790 btrfs_end_transaction(trans, root); in btrfs_commit_transaction()
1794 btrfs_trans_release_metadata(trans, root); in btrfs_commit_transaction()
1797 btrfs_qgroup_free(root, trans->qgroup_reserved); in btrfs_commit_transaction()
1811 btrfs_create_pending_block_groups(trans, root); in btrfs_commit_transaction()
1813 ret = btrfs_run_delayed_refs(trans, root, 0); in btrfs_commit_transaction()
1815 btrfs_end_transaction(trans, root); in btrfs_commit_transaction()
1835 mutex_lock(&root->fs_info->ro_block_group_mutex); in btrfs_commit_transaction()
1840 mutex_unlock(&root->fs_info->ro_block_group_mutex); in btrfs_commit_transaction()
1843 ret = btrfs_start_dirty_block_groups(trans, root); in btrfs_commit_transaction()
1846 btrfs_end_transaction(trans, root); in btrfs_commit_transaction()
1850 spin_lock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
1853 spin_unlock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
1855 ret = btrfs_end_transaction(trans, root); in btrfs_commit_transaction()
1857 wait_for_commit(root, cur_trans); in btrfs_commit_transaction()
1868 wake_up(&root->fs_info->transaction_blocked_wait); in btrfs_commit_transaction()
1870 if (cur_trans->list.prev != &root->fs_info->trans_list) { in btrfs_commit_transaction()
1875 spin_unlock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
1877 wait_for_commit(root, prev_trans); in btrfs_commit_transaction()
1884 spin_unlock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
1887 spin_unlock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
1892 ret = btrfs_start_delalloc_flush(root->fs_info); in btrfs_commit_transaction()
1896 ret = btrfs_run_delayed_items(trans, root); in btrfs_commit_transaction()
1904 ret = btrfs_run_delayed_items(trans, root); in btrfs_commit_transaction()
1908 btrfs_wait_delalloc_flush(root->fs_info); in btrfs_commit_transaction()
1910 btrfs_wait_pending_ordered(cur_trans, root->fs_info); in btrfs_commit_transaction()
1912 btrfs_scrub_pause(root); in btrfs_commit_transaction()
1918 spin_lock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
1920 spin_unlock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
1934 mutex_lock(&root->fs_info->reloc_mutex); in btrfs_commit_transaction()
1941 ret = create_pending_snapshots(trans, root->fs_info); in btrfs_commit_transaction()
1943 mutex_unlock(&root->fs_info->reloc_mutex); in btrfs_commit_transaction()
1957 ret = btrfs_run_delayed_items(trans, root); in btrfs_commit_transaction()
1959 mutex_unlock(&root->fs_info->reloc_mutex); in btrfs_commit_transaction()
1963 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); in btrfs_commit_transaction()
1965 mutex_unlock(&root->fs_info->reloc_mutex); in btrfs_commit_transaction()
1973 btrfs_assert_delayed_root_empty(root); in btrfs_commit_transaction()
1990 mutex_lock(&root->fs_info->tree_log_mutex); in btrfs_commit_transaction()
1992 ret = commit_fs_roots(trans, root); in btrfs_commit_transaction()
1994 mutex_unlock(&root->fs_info->tree_log_mutex); in btrfs_commit_transaction()
1995 mutex_unlock(&root->fs_info->reloc_mutex); in btrfs_commit_transaction()
2003 btrfs_apply_pending_changes(root->fs_info); in btrfs_commit_transaction()
2008 btrfs_free_log_root_tree(trans, root->fs_info); in btrfs_commit_transaction()
2010 ret = commit_cowonly_roots(trans, root); in btrfs_commit_transaction()
2012 mutex_unlock(&root->fs_info->tree_log_mutex); in btrfs_commit_transaction()
2013 mutex_unlock(&root->fs_info->reloc_mutex); in btrfs_commit_transaction()
2023 mutex_unlock(&root->fs_info->tree_log_mutex); in btrfs_commit_transaction()
2024 mutex_unlock(&root->fs_info->reloc_mutex); in btrfs_commit_transaction()
2028 btrfs_prepare_extent_commit(trans, root); in btrfs_commit_transaction()
2030 cur_trans = root->fs_info->running_transaction; in btrfs_commit_transaction()
2032 btrfs_set_root_node(&root->fs_info->tree_root->root_item, in btrfs_commit_transaction()
2033 root->fs_info->tree_root->node); in btrfs_commit_transaction()
2034 list_add_tail(&root->fs_info->tree_root->dirty_list, in btrfs_commit_transaction()
2037 btrfs_set_root_node(&root->fs_info->chunk_root->root_item, in btrfs_commit_transaction()
2038 root->fs_info->chunk_root->node); in btrfs_commit_transaction()
2039 list_add_tail(&root->fs_info->chunk_root->dirty_list, in btrfs_commit_transaction()
2042 switch_commit_roots(cur_trans, root->fs_info); in btrfs_commit_transaction()
2047 update_super_roots(root); in btrfs_commit_transaction()
2049 btrfs_set_super_log_root(root->fs_info->super_copy, 0); in btrfs_commit_transaction()
2050 btrfs_set_super_log_root_level(root->fs_info->super_copy, 0); in btrfs_commit_transaction()
2051 memcpy(root->fs_info->super_for_commit, root->fs_info->super_copy, in btrfs_commit_transaction()
2052 sizeof(*root->fs_info->super_copy)); in btrfs_commit_transaction()
2054 btrfs_update_commit_device_size(root->fs_info); in btrfs_commit_transaction()
2055 btrfs_update_commit_device_bytes_used(root, cur_trans); in btrfs_commit_transaction()
2060 spin_lock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
2062 root->fs_info->running_transaction = NULL; in btrfs_commit_transaction()
2063 spin_unlock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
2064 mutex_unlock(&root->fs_info->reloc_mutex); in btrfs_commit_transaction()
2066 wake_up(&root->fs_info->transaction_wait); in btrfs_commit_transaction()
2068 ret = btrfs_write_and_wait_transaction(trans, root); in btrfs_commit_transaction()
2070 btrfs_error(root->fs_info, ret, in btrfs_commit_transaction()
2072 mutex_unlock(&root->fs_info->tree_log_mutex); in btrfs_commit_transaction()
2076 ret = write_ctree_super(trans, root, 0); in btrfs_commit_transaction()
2078 mutex_unlock(&root->fs_info->tree_log_mutex); in btrfs_commit_transaction()
2086 mutex_unlock(&root->fs_info->tree_log_mutex); in btrfs_commit_transaction()
2088 btrfs_finish_extent_commit(trans, root); in btrfs_commit_transaction()
2091 btrfs_clear_space_info_full(root->fs_info); in btrfs_commit_transaction()
2093 root->fs_info->last_trans_committed = cur_trans->transid; in btrfs_commit_transaction()
2101 spin_lock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
2103 spin_unlock(&root->fs_info->trans_lock); in btrfs_commit_transaction()
2109 sb_end_intwrite(root->fs_info->sb); in btrfs_commit_transaction()
2111 trace_btrfs_transaction_commit(root); in btrfs_commit_transaction()
2113 btrfs_scrub_continue(root); in btrfs_commit_transaction()
2120 if (current != root->fs_info->transaction_kthread) in btrfs_commit_transaction()
2121 btrfs_run_delayed_iputs(root); in btrfs_commit_transaction()
2126 btrfs_scrub_continue(root); in btrfs_commit_transaction()
2128 btrfs_trans_release_metadata(trans, root); in btrfs_commit_transaction()
2131 btrfs_qgroup_free(root, trans->qgroup_reserved); in btrfs_commit_transaction()
2134 btrfs_warn(root->fs_info, "Skipping commit of aborted transaction."); in btrfs_commit_transaction()
2137 cleanup_transaction(trans, root, ret); in btrfs_commit_transaction()
2152 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root) in btrfs_clean_one_deleted_snapshot() argument
2155 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_clean_one_deleted_snapshot()
2162 root = list_first_entry(&fs_info->dead_roots, in btrfs_clean_one_deleted_snapshot()
2164 list_del_init(&root->root_list); in btrfs_clean_one_deleted_snapshot()
2167 pr_debug("BTRFS: cleaner removing %llu\n", root->objectid); in btrfs_clean_one_deleted_snapshot()
2169 btrfs_kill_all_delayed_nodes(root); in btrfs_clean_one_deleted_snapshot()
2171 if (btrfs_header_backref_rev(root->node) < in btrfs_clean_one_deleted_snapshot()
2173 ret = btrfs_drop_snapshot(root, NULL, 0, 0); in btrfs_clean_one_deleted_snapshot()
2175 ret = btrfs_drop_snapshot(root, NULL, 1, 0); in btrfs_clean_one_deleted_snapshot()