Lines Matching full:transaction

18 #include "transaction.h"
39 * Transaction states and transitions
41 * No running transaction (fs tree blocks are not modified)
46 * Transaction N [[TRANS_STATE_RUNNING]]
48 * | New trans handles can be attached to transaction N by calling all
53 * | transaction N
55 * Transaction N [[TRANS_STATE_COMMIT_PREP]]
58 * | the race and the rest will wait for the winner to commit the transaction.
60 * | The winner will wait for previous running transaction to completely finish
63 * Transaction N [[TRANS_STATE_COMMIT_START]]
68 * | - Wait for current transaction to be committed by others.
72 * | to this running transaction.
74 * | transaction N+1.
77 * | Caller is chosen to commit transaction N, and all other trans handle
80 * Transaction N [[TRANS_STATE_COMMIT_DOING]]
82 * | The heavy lifting transaction work is started.
89 * | transaction to finish and attach to transaction N+1.
94 * Transaction N [[TRANS_STATE_UNBLOCKED]]
95 * | Transaction N+1
100 * | At this stage, new transaction is allowed to |
109 * Transaction N [[TRANS_STATE_COMPLETED]] V
110 * All tree blocks and super blocks are written. Transaction N+1
111 * This transaction is finished and all its [[TRANS_STATE_COMMIT_START]]
139 void btrfs_put_transaction(struct btrfs_transaction *transaction) in btrfs_put_transaction() argument
141 WARN_ON(refcount_read(&transaction->use_count) == 0); in btrfs_put_transaction()
142 if (refcount_dec_and_test(&transaction->use_count)) { in btrfs_put_transaction()
143 BUG_ON(!list_empty(&transaction->list)); in btrfs_put_transaction()
144 WARN_ON(!xa_empty(&transaction->delayed_refs.head_refs)); in btrfs_put_transaction()
145 WARN_ON(!xa_empty(&transaction->delayed_refs.dirty_extents)); in btrfs_put_transaction()
146 if (transaction->delayed_refs.pending_csums) in btrfs_put_transaction()
147 btrfs_err(transaction->fs_info, in btrfs_put_transaction()
149 transaction->delayed_refs.pending_csums); in btrfs_put_transaction()
152 * because the transaction was aborted and a commit did not in btrfs_put_transaction()
157 while (!list_empty(&transaction->deleted_bgs)) { in btrfs_put_transaction()
160 cache = list_first_entry(&transaction->deleted_bgs, in btrfs_put_transaction()
165 * block_group on the deleted_bgs list during a transaction abort. in btrfs_put_transaction()
167 spin_lock(&transaction->fs_info->unused_bgs_lock); in btrfs_put_transaction()
169 spin_unlock(&transaction->fs_info->unused_bgs_lock); in btrfs_put_transaction()
173 WARN_ON(!list_empty(&transaction->dev_update_list)); in btrfs_put_transaction()
174 kfree(transaction); in btrfs_put_transaction()
180 struct btrfs_transaction *cur_trans = trans->transaction; in switch_commit_roots()
185 * At this point no one can be using this transaction to modify any tree in switch_commit_roots()
186 * and no one can start another transaction to modify any tree either. in switch_commit_roots()
265 * either allocate a new transaction or hop into the existing one
304 * current transaction, and commit it. If there is no transaction, just in join_transaction()
311 * JOIN_NOLOCK only happens during the transaction commit, so in join_transaction()
326 * someone started a transaction after we unlocked. Make sure in join_transaction()
351 * commit the transaction. in join_transaction()
363 * although the tree mod log is per file system and not per transaction, in join_transaction()
364 * the log must never go across transaction boundaries. in join_transaction()
368 WARN(1, KERN_ERR "BTRFS: tree_mod_seq_list not empty when creating a fresh transaction\n"); in join_transaction()
370 WARN(1, KERN_ERR "BTRFS: tree_mod_log rb tree not empty when creating a fresh transaction\n"); in join_transaction()
401 * is properly recorded in a given transaction. This is required to make sure
402 * the old root from before we joined the transaction is deleted when the
403 * transaction commits.
442 * this transaction. in record_root_in_trans()
470 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_add_dropped_root()
472 /* Add ourselves to the transaction dropped list */ in btrfs_add_dropped_root()
517 /* wait for commit against the current transaction to become unblocked
518 * when this is done, it is safe to start a new transaction, but the current
519 * transaction might not be fully on disk.
576 * do 1 enospc flushing cycle per transaction start. in btrfs_reserve_trans_metadata()
625 * Do the reservation before we join the transaction so we can do all in start_transaction()
632 * transaction that could free this reserved space prematurely in start_transaction()
689 * If we are JOIN_NOLOCK we're already committing a transaction and in start_transaction()
696 * transaction and commit it, so we needn't do sb_start_intwrite(). in start_transaction()
720 h->transaction = cur_trans; in start_transaction()
737 trace_btrfs_space_reservation(fs_info, "transaction", in start_transaction()
773 * transaction. in start_transaction()
781 * The transaction handle is fully initialized and linked with in start_transaction()
789 * Now that we have found a transaction to be a part of, convert the in start_transaction()
790 * qgroup reservation from prealloc to pertrans. A different transaction in start_transaction()
840 * Similar to regular join but it never starts a transaction when none is
843 * happen if the transaction commit already started but it's not yet in the
853 * Catch the running transaction.
855 * It is used when we want to commit the current the transaction, but
859 * running transaction. But it is possible that the inactive transaction
861 * inactive transaction in the fs when -ENOENT is returned, you should
872 * Catch the running transaction.
896 /* Wait for a transaction commit to reach at least the given state. */
922 * A transaction isn't really completed until all of the in wait_for_commit()
925 * transaction. Wait for those. in wait_for_commit()
951 /* find specified transaction */ in btrfs_wait_for_commit()
968 * The specified transaction doesn't exist, or we in btrfs_wait_for_commit()
977 /* find newest transaction that is committing | committed */ in btrfs_wait_for_commit()
1008 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_should_end_transaction()
1037 trace_btrfs_space_reservation(fs_info, "transaction", in btrfs_trans_release_metadata()
1058 struct btrfs_transaction *cur_trans = trans->transaction; in __btrfs_end_transaction()
1149 * the transaction (through extent_io_tree_release()). in btrfs_write_marked_extents()
1172 * those extents are on disk for transaction or log commit. We wait
1188 * When committing the transaction, we'll remove any entries in __btrfs_wait_marked_extents()
1191 * concurrently - we do it only at transaction commit time when in __btrfs_wait_marked_extents()
1250 * This function ensures such extents are persisted on disk for transaction or
1253 * @trans: transaction whose dirty pages we'd like to write
1259 struct extent_io_tree *dirty_pages = &trans->transaction->dirty_pages; in btrfs_write_and_wait_transaction()
1268 extent_io_tree_release(&trans->transaction->dirty_pages); in btrfs_write_and_wait_transaction()
1328 struct list_head *dirty_bgs = &trans->transaction->dirty_bgs; in commit_cowonly_roots()
1329 struct list_head *io_bgs = &trans->transaction->io_bgs; in commit_cowonly_roots()
1335 * At this point no one can be using this transaction to modify any tree in commit_cowonly_roots()
1336 * and no one can start another transaction to modify any tree either. in commit_cowonly_roots()
1338 ASSERT(trans->transaction->state == TRANS_STATE_COMMIT_DOING); in commit_cowonly_roots()
1372 &trans->transaction->switch_commits); in commit_cowonly_roots()
1469 * At this point no one can be using this transaction to modify any tree in commit_fs_roots()
1470 * and no one can start another transaction to modify any tree either. in commit_fs_roots()
1472 ASSERT(trans->transaction->state == TRANS_STATE_COMMIT_DOING); in commit_fs_roots()
1511 &trans->transaction->switch_commits); in commit_fs_roots()
1532 * roots inside one transaction and write all btree into disk, to make
1592 * Now we do a simplified commit transaction, which will: in qgroup_account_snapshot()
1610 "Error while writing out transaction for qgroup"); in qgroup_account_snapshot()
1626 * transaction commit. This does the actual creation.
1629 * If the error which may affect the commitment of the current transaction
1665 * We're inside a transaction and must make sure that any potential in create_pending_snapshot()
1705 trace_btrfs_space_reservation(fs_info, "transaction", in create_pending_snapshot()
1750 if (ret) { /* Transaction aborted */ in create_pending_snapshot()
1921 struct list_head *head = &trans->transaction->pending_snapshots; in create_pending_snapshots()
1975 /* Kick the transaction kthread. */ in btrfs_commit_transaction_async()
1979 /* take transaction reference */ in btrfs_commit_transaction_async()
1980 cur_trans = trans->transaction; in btrfs_commit_transaction_async()
1986 * Wait for the current transaction commit to start and block in btrfs_commit_transaction_async()
1987 * subsequent transaction joins in btrfs_commit_transaction_async()
1997 * If there is a running transaction commit it or if it's already committing,
1998 * wait for its commit to complete. Does not start and commit a new transaction
2018 struct btrfs_transaction *cur_trans = trans->transaction; in cleanup_transaction()
2027 * If the transaction is removed from the list, it means this in cleanup_transaction()
2028 * transaction has been committed successfully, so it is impossible in cleanup_transaction()
2049 * Now that we know no one else is still using the transaction we can in cleanup_transaction()
2050 * remove the transaction from the list of transactions. This avoids in cleanup_transaction()
2051 * the transaction kthread from cleaning up the transaction while some in cleanup_transaction()
2053 * on things like log trees, as it forces the transaction kthread to in cleanup_transaction()
2054 * wait for this transaction to be cleaned up by us. in cleanup_transaction()
2060 btrfs_cleanup_one_transaction(trans->transaction); in cleanup_transaction()
2080 * pauses scrub, then starts and commits a transaction before unpausing in cleanup_transaction()
2081 * scrub. If the transaction commit is being done by the relocation in cleanup_transaction()
2096 * transaction and remove them from the list
2107 * block_group on the new_bgs list during a transaction abort. in btrfs_cleanup_pending_block_groups()
2123 * from already being in a transaction and our join_transaction doesn't in btrfs_start_delalloc_flush()
2146 * Add a pending snapshot associated with the given transaction handle to the
2147 * respective handle. This must be called after the transaction commit started
2155 struct btrfs_transaction *cur_trans = trans->transaction; in add_pending_snapshot()
2178 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_commit_transaction()
2199 * We only want one transaction commit doing the flushing so we do not in btrfs_commit_transaction()
2223 * will wait for the transaction to commit if it in btrfs_commit_transaction()
2296 * The previous transaction was aborted and was already removed in btrfs_commit_transaction()
2329 * The thread has started/joined the transaction thus it holds the in btrfs_commit_transaction()
2349 * transaction. Otherwise if this transaction commits before the ordered in btrfs_commit_transaction()
2359 * commit the transaction. We could have started a join before setting in btrfs_commit_transaction()
2368 * The thread has started/joined the transaction thus it holds the in btrfs_commit_transaction()
2389 * do an async commit but somebody else started before the transaction in btrfs_commit_transaction()
2439 WARN_ON(cur_trans != trans->transaction); in btrfs_commit_transaction()
2509 * Before changing the transaction state to TRANS_STATE_UNBLOCKED and in btrfs_commit_transaction()
2512 * start a new transaction and commit a log tree before we commit our in btrfs_commit_transaction()
2535 "Error while writing out transaction"); in btrfs_commit_transaction()
2608 btrfs_warn(fs_info, "Skipping commit of aborted transaction."); in btrfs_commit_transaction()
2666 * We only mark the transaction aborted and then set the file system read-only.
2672 * further cleanup. The transaction should complete as it normally would
2685 WRITE_ONCE(trans->transaction->aborted, error); in __btrfs_abort_transaction()
2688 /* Wake up anybody who may be waiting on this transaction */ in __btrfs_abort_transaction()