Lines Matching refs:cur_trans

174 	struct btrfs_transaction *cur_trans;  in join_transaction()  local
184 cur_trans = fs_info->running_transaction; in join_transaction()
185 if (cur_trans) { in join_transaction()
186 if (cur_trans->aborted) { in join_transaction()
188 return cur_trans->aborted; in join_transaction()
190 if (btrfs_blocked_trans_types[cur_trans->state] & type) { in join_transaction()
194 refcount_inc(&cur_trans->use_count); in join_transaction()
195 atomic_inc(&cur_trans->num_writers); in join_transaction()
196 extwriter_counter_inc(cur_trans, type); in join_transaction()
216 cur_trans = kmalloc(sizeof(*cur_trans), GFP_NOFS); in join_transaction()
217 if (!cur_trans) in join_transaction()
226 kfree(cur_trans); in join_transaction()
230 kfree(cur_trans); in join_transaction()
234 cur_trans->fs_info = fs_info; in join_transaction()
235 atomic_set(&cur_trans->num_writers, 1); in join_transaction()
236 extwriter_counter_init(cur_trans, type); in join_transaction()
237 init_waitqueue_head(&cur_trans->writer_wait); in join_transaction()
238 init_waitqueue_head(&cur_trans->commit_wait); in join_transaction()
239 init_waitqueue_head(&cur_trans->pending_wait); in join_transaction()
240 cur_trans->state = TRANS_STATE_RUNNING; in join_transaction()
245 refcount_set(&cur_trans->use_count, 2); in join_transaction()
246 atomic_set(&cur_trans->pending_ordered, 0); in join_transaction()
247 cur_trans->flags = 0; in join_transaction()
248 cur_trans->start_time = ktime_get_seconds(); in join_transaction()
250 memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs)); in join_transaction()
252 cur_trans->delayed_refs.href_root = RB_ROOT; in join_transaction()
253 cur_trans->delayed_refs.dirty_extent_root = RB_ROOT; in join_transaction()
254 atomic_set(&cur_trans->delayed_refs.num_entries, 0); in join_transaction()
267 spin_lock_init(&cur_trans->delayed_refs.lock); in join_transaction()
269 INIT_LIST_HEAD(&cur_trans->pending_snapshots); in join_transaction()
270 INIT_LIST_HEAD(&cur_trans->pending_chunks); in join_transaction()
271 INIT_LIST_HEAD(&cur_trans->switch_commits); in join_transaction()
272 INIT_LIST_HEAD(&cur_trans->dirty_bgs); in join_transaction()
273 INIT_LIST_HEAD(&cur_trans->io_bgs); in join_transaction()
274 INIT_LIST_HEAD(&cur_trans->dropped_roots); in join_transaction()
275 mutex_init(&cur_trans->cache_write_mutex); in join_transaction()
276 cur_trans->num_dirty_bgs = 0; in join_transaction()
277 spin_lock_init(&cur_trans->dirty_bgs_lock); in join_transaction()
278 INIT_LIST_HEAD(&cur_trans->deleted_bgs); in join_transaction()
279 spin_lock_init(&cur_trans->dropped_roots_lock); in join_transaction()
280 list_add_tail(&cur_trans->list, &fs_info->trans_list); in join_transaction()
281 extent_io_tree_init(&cur_trans->dirty_pages, in join_transaction()
284 cur_trans->transid = fs_info->generation; in join_transaction()
285 fs_info->running_transaction = cur_trans; in join_transaction()
286 cur_trans->aborted = 0; in join_transaction()
363 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_add_dropped_root() local
366 spin_lock(&cur_trans->dropped_roots_lock); in btrfs_add_dropped_root()
367 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
368 spin_unlock(&cur_trans->dropped_roots_lock); in btrfs_add_dropped_root()
415 struct btrfs_transaction *cur_trans; in wait_current_trans() local
418 cur_trans = fs_info->running_transaction; in wait_current_trans()
419 if (cur_trans && is_transaction_blocked(cur_trans)) { in wait_current_trans()
420 refcount_inc(&cur_trans->use_count); in wait_current_trans()
424 cur_trans->state >= TRANS_STATE_UNBLOCKED || in wait_current_trans()
425 cur_trans->aborted); in wait_current_trans()
426 btrfs_put_transaction(cur_trans); in wait_current_trans()
464 struct btrfs_transaction *cur_trans; in start_transaction() local
547 cur_trans = fs_info->running_transaction; in start_transaction()
549 h->transid = cur_trans->transid; in start_transaction()
550 h->transaction = cur_trans; in start_transaction()
560 if (cur_trans->state >= TRANS_STATE_BLOCKED && in start_transaction()
726 struct btrfs_transaction *cur_trans = NULL, *t; in btrfs_wait_for_commit() local
737 cur_trans = t; in btrfs_wait_for_commit()
738 refcount_inc(&cur_trans->use_count); in btrfs_wait_for_commit()
753 if (!cur_trans) { in btrfs_wait_for_commit()
766 cur_trans = t; in btrfs_wait_for_commit()
767 refcount_inc(&cur_trans->use_count); in btrfs_wait_for_commit()
772 if (!cur_trans) in btrfs_wait_for_commit()
776 wait_for_commit(cur_trans); in btrfs_wait_for_commit()
777 btrfs_put_transaction(cur_trans); in btrfs_wait_for_commit()
799 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_should_end_transaction() local
804 if (cur_trans->state >= TRANS_STATE_BLOCKED || in btrfs_should_end_transaction()
805 cur_trans->delayed_refs.flushing) in btrfs_should_end_transaction()
844 struct btrfs_transaction *cur_trans = trans->transaction; in __btrfs_end_transaction() local
887 READ_ONCE(cur_trans->state) == TRANS_STATE_RUNNING) { in __btrfs_end_transaction()
889 if (cur_trans->state == TRANS_STATE_RUNNING) in __btrfs_end_transaction()
890 cur_trans->state = TRANS_STATE_BLOCKED; in __btrfs_end_transaction()
894 if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) { in __btrfs_end_transaction()
904 WARN_ON(cur_trans != info->running_transaction); in __btrfs_end_transaction()
905 WARN_ON(atomic_read(&cur_trans->num_writers) < 1); in __btrfs_end_transaction()
906 atomic_dec(&cur_trans->num_writers); in __btrfs_end_transaction()
907 extwriter_counter_dec(cur_trans, trans->type); in __btrfs_end_transaction()
909 cond_wake_up(&cur_trans->writer_wait); in __btrfs_end_transaction()
910 btrfs_put_transaction(cur_trans); in __btrfs_end_transaction()
1827 struct btrfs_transaction *cur_trans; in btrfs_commit_transaction_async() local
1842 cur_trans = trans->transaction; in btrfs_commit_transaction_async()
1843 refcount_inc(&cur_trans->use_count); in btrfs_commit_transaction_async()
1858 wait_current_trans_commit_start_and_unblock(fs_info, cur_trans); in btrfs_commit_transaction_async()
1860 wait_current_trans_commit_start(fs_info, cur_trans); in btrfs_commit_transaction_async()
1865 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction_async()
1873 struct btrfs_transaction *cur_trans = trans->transaction; in cleanup_transaction() local
1887 BUG_ON(list_empty(&cur_trans->list)); in cleanup_transaction()
1889 list_del_init(&cur_trans->list); in cleanup_transaction()
1890 if (cur_trans == fs_info->running_transaction) { in cleanup_transaction()
1891 cur_trans->state = TRANS_STATE_COMMIT_DOING; in cleanup_transaction()
1893 wait_event(cur_trans->writer_wait, in cleanup_transaction()
1894 atomic_read(&cur_trans->num_writers) == 1); in cleanup_transaction()
1903 if (cur_trans == fs_info->running_transaction) in cleanup_transaction()
1909 btrfs_put_transaction(cur_trans); in cleanup_transaction()
1910 btrfs_put_transaction(cur_trans); in cleanup_transaction()
1944 btrfs_wait_pending_ordered(struct btrfs_transaction *cur_trans) in btrfs_wait_pending_ordered() argument
1946 wait_event(cur_trans->pending_wait, in btrfs_wait_pending_ordered()
1947 atomic_read(&cur_trans->pending_ordered) == 0); in btrfs_wait_pending_ordered()
1953 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_commit_transaction() local
1966 if (unlikely(READ_ONCE(cur_trans->aborted))) { in btrfs_commit_transaction()
1967 ret = cur_trans->aborted; in btrfs_commit_transaction()
1984 cur_trans = trans->transaction; in btrfs_commit_transaction()
1990 cur_trans->delayed_refs.flushing = 1; in btrfs_commit_transaction()
2002 if (!test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &cur_trans->flags)) { in btrfs_commit_transaction()
2020 &cur_trans->flags)) in btrfs_commit_transaction()
2034 if (cur_trans->state >= TRANS_STATE_COMMIT_START) { in btrfs_commit_transaction()
2036 refcount_inc(&cur_trans->use_count); in btrfs_commit_transaction()
2039 wait_for_commit(cur_trans); in btrfs_commit_transaction()
2041 if (unlikely(cur_trans->aborted)) in btrfs_commit_transaction()
2042 ret = cur_trans->aborted; in btrfs_commit_transaction()
2044 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()
2049 cur_trans->state = TRANS_STATE_COMMIT_START; in btrfs_commit_transaction()
2052 if (cur_trans->list.prev != &fs_info->trans_list) { in btrfs_commit_transaction()
2053 prev_trans = list_entry(cur_trans->list.prev, in btrfs_commit_transaction()
2082 extwriter_counter_dec(cur_trans, trans->type); in btrfs_commit_transaction()
2092 wait_event(cur_trans->writer_wait, in btrfs_commit_transaction()
2093 extwriter_counter_read(cur_trans) == 0); in btrfs_commit_transaction()
2102 btrfs_wait_pending_ordered(cur_trans); in btrfs_commit_transaction()
2111 cur_trans->state = TRANS_STATE_COMMIT_DOING; in btrfs_commit_transaction()
2113 wait_event(cur_trans->writer_wait, in btrfs_commit_transaction()
2114 atomic_read(&cur_trans->num_writers) == 1); in btrfs_commit_transaction()
2117 if (unlikely(READ_ONCE(cur_trans->aborted))) { in btrfs_commit_transaction()
2118 ret = cur_trans->aborted; in btrfs_commit_transaction()
2167 WARN_ON(cur_trans != trans->transaction); in btrfs_commit_transaction()
2235 if (unlikely(READ_ONCE(cur_trans->aborted))) { in btrfs_commit_transaction()
2236 ret = cur_trans->aborted; in btrfs_commit_transaction()
2244 cur_trans = fs_info->running_transaction; in btrfs_commit_transaction()
2249 &cur_trans->switch_commits); in btrfs_commit_transaction()
2254 &cur_trans->switch_commits); in btrfs_commit_transaction()
2256 switch_commit_roots(cur_trans); in btrfs_commit_transaction()
2258 ASSERT(list_empty(&cur_trans->dirty_bgs)); in btrfs_commit_transaction()
2259 ASSERT(list_empty(&cur_trans->io_bgs)); in btrfs_commit_transaction()
2268 btrfs_update_commit_device_bytes_used(cur_trans); in btrfs_commit_transaction()
2276 cur_trans->state = TRANS_STATE_UNBLOCKED; in btrfs_commit_transaction()
2302 if (test_bit(BTRFS_TRANS_HAVE_FREE_BGS, &cur_trans->flags)) in btrfs_commit_transaction()
2305 fs_info->last_trans_committed = cur_trans->transid; in btrfs_commit_transaction()
2310 cur_trans->state = TRANS_STATE_COMPLETED; in btrfs_commit_transaction()
2311 wake_up(&cur_trans->commit_wait); in btrfs_commit_transaction()
2315 list_del_init(&cur_trans->list); in btrfs_commit_transaction()
2318 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()
2319 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()