Lines Matching refs:cur_trans

178 	struct btrfs_transaction *cur_trans = trans->transaction;  in switch_commit_roots()  local
186 ASSERT(cur_trans->state == TRANS_STATE_COMMIT_DOING); in switch_commit_roots()
193 list_for_each_entry_safe(root, tmp, &cur_trans->switch_commits, in switch_commit_roots()
203 spin_lock(&cur_trans->dropped_roots_lock); in switch_commit_roots()
204 while (!list_empty(&cur_trans->dropped_roots)) { in switch_commit_roots()
205 root = list_first_entry(&cur_trans->dropped_roots, in switch_commit_roots()
208 spin_unlock(&cur_trans->dropped_roots_lock); in switch_commit_roots()
211 spin_lock(&cur_trans->dropped_roots_lock); in switch_commit_roots()
213 spin_unlock(&cur_trans->dropped_roots_lock); in switch_commit_roots()
268 struct btrfs_transaction *cur_trans; in join_transaction() local
278 cur_trans = fs_info->running_transaction; in join_transaction()
279 if (cur_trans) { in join_transaction()
280 if (TRANS_ABORTED(cur_trans)) { in join_transaction()
282 return cur_trans->aborted; in join_transaction()
284 if (btrfs_blocked_trans_types[cur_trans->state] & type) { in join_transaction()
288 refcount_inc(&cur_trans->use_count); in join_transaction()
289 atomic_inc(&cur_trans->num_writers); in join_transaction()
290 extwriter_counter_inc(cur_trans, type); in join_transaction()
312 cur_trans = kmalloc(sizeof(*cur_trans), GFP_NOFS); in join_transaction()
313 if (!cur_trans) in join_transaction()
327 kfree(cur_trans); in join_transaction()
333 kfree(cur_trans); in join_transaction()
337 cur_trans->fs_info = fs_info; in join_transaction()
338 atomic_set(&cur_trans->pending_ordered, 0); in join_transaction()
339 init_waitqueue_head(&cur_trans->pending_wait); in join_transaction()
340 atomic_set(&cur_trans->num_writers, 1); in join_transaction()
341 extwriter_counter_init(cur_trans, type); in join_transaction()
342 init_waitqueue_head(&cur_trans->writer_wait); in join_transaction()
343 init_waitqueue_head(&cur_trans->commit_wait); in join_transaction()
344 cur_trans->state = TRANS_STATE_RUNNING; in join_transaction()
349 refcount_set(&cur_trans->use_count, 2); in join_transaction()
350 cur_trans->flags = 0; in join_transaction()
351 cur_trans->start_time = ktime_get_seconds(); in join_transaction()
353 memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs)); in join_transaction()
355 cur_trans->delayed_refs.href_root = RB_ROOT_CACHED; in join_transaction()
356 cur_trans->delayed_refs.dirty_extent_root = RB_ROOT; in join_transaction()
357 atomic_set(&cur_trans->delayed_refs.num_entries, 0); in join_transaction()
370 spin_lock_init(&cur_trans->delayed_refs.lock); in join_transaction()
372 INIT_LIST_HEAD(&cur_trans->pending_snapshots); in join_transaction()
373 INIT_LIST_HEAD(&cur_trans->dev_update_list); in join_transaction()
374 INIT_LIST_HEAD(&cur_trans->switch_commits); in join_transaction()
375 INIT_LIST_HEAD(&cur_trans->dirty_bgs); in join_transaction()
376 INIT_LIST_HEAD(&cur_trans->io_bgs); in join_transaction()
377 INIT_LIST_HEAD(&cur_trans->dropped_roots); in join_transaction()
378 mutex_init(&cur_trans->cache_write_mutex); in join_transaction()
379 spin_lock_init(&cur_trans->dirty_bgs_lock); in join_transaction()
380 INIT_LIST_HEAD(&cur_trans->deleted_bgs); in join_transaction()
381 spin_lock_init(&cur_trans->dropped_roots_lock); in join_transaction()
382 list_add_tail(&cur_trans->list, &fs_info->trans_list); in join_transaction()
383 extent_io_tree_init(fs_info, &cur_trans->dirty_pages, in join_transaction()
385 extent_io_tree_init(fs_info, &cur_trans->pinned_extents, in join_transaction()
388 cur_trans->transid = fs_info->generation; in join_transaction()
389 fs_info->running_transaction = cur_trans; in join_transaction()
390 cur_trans->aborted = 0; in join_transaction()
467 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_add_dropped_root() local
470 spin_lock(&cur_trans->dropped_roots_lock); in btrfs_add_dropped_root()
471 list_add_tail(&root->root_list, &cur_trans->dropped_roots); in btrfs_add_dropped_root()
472 spin_unlock(&cur_trans->dropped_roots_lock); in btrfs_add_dropped_root()
520 struct btrfs_transaction *cur_trans; in wait_current_trans() local
523 cur_trans = fs_info->running_transaction; in wait_current_trans()
524 if (cur_trans && is_transaction_blocked(cur_trans)) { in wait_current_trans()
525 refcount_inc(&cur_trans->use_count); in wait_current_trans()
530 cur_trans->state >= TRANS_STATE_UNBLOCKED || in wait_current_trans()
531 TRANS_ABORTED(cur_trans)); in wait_current_trans()
532 btrfs_put_transaction(cur_trans); in wait_current_trans()
570 struct btrfs_transaction *cur_trans; in start_transaction() local
692 cur_trans = fs_info->running_transaction; in start_transaction()
694 h->transid = cur_trans->transid; in start_transaction()
695 h->transaction = cur_trans; in start_transaction()
703 if (cur_trans->state >= TRANS_STATE_COMMIT_START && in start_transaction()
908 struct btrfs_transaction *cur_trans = NULL, *t; in btrfs_wait_for_commit() local
919 cur_trans = t; in btrfs_wait_for_commit()
920 refcount_inc(&cur_trans->use_count); in btrfs_wait_for_commit()
935 if (!cur_trans) { in btrfs_wait_for_commit()
948 cur_trans = t; in btrfs_wait_for_commit()
949 refcount_inc(&cur_trans->use_count); in btrfs_wait_for_commit()
954 if (!cur_trans) in btrfs_wait_for_commit()
958 wait_for_commit(cur_trans, TRANS_STATE_COMPLETED); in btrfs_wait_for_commit()
959 ret = cur_trans->aborted; in btrfs_wait_for_commit()
960 btrfs_put_transaction(cur_trans); in btrfs_wait_for_commit()
972 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_should_end_transaction() local
974 if (cur_trans->state >= TRANS_STATE_COMMIT_START || in btrfs_should_end_transaction()
975 test_bit(BTRFS_DELAYED_REFS_FLUSHING, &cur_trans->delayed_refs.flags)) in btrfs_should_end_transaction()
1009 struct btrfs_transaction *cur_trans = trans->transaction; in __btrfs_end_transaction() local
1028 WARN_ON(cur_trans != info->running_transaction); in __btrfs_end_transaction()
1029 WARN_ON(atomic_read(&cur_trans->num_writers) < 1); in __btrfs_end_transaction()
1030 atomic_dec(&cur_trans->num_writers); in __btrfs_end_transaction()
1031 extwriter_counter_dec(cur_trans, trans->type); in __btrfs_end_transaction()
1033 cond_wake_up(&cur_trans->writer_wait); in __btrfs_end_transaction()
1038 btrfs_put_transaction(cur_trans); in __btrfs_end_transaction()
1972 struct btrfs_transaction *cur_trans; in btrfs_commit_transaction_async() local
1979 cur_trans = trans->transaction; in btrfs_commit_transaction_async()
1980 refcount_inc(&cur_trans->use_count); in btrfs_commit_transaction_async()
1990 cur_trans->state >= TRANS_STATE_COMMIT_START || in btrfs_commit_transaction_async()
1991 TRANS_ABORTED(cur_trans)); in btrfs_commit_transaction_async()
1992 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction_async()
1998 struct btrfs_transaction *cur_trans = trans->transaction; in cleanup_transaction() local
2011 BUG_ON(list_empty(&cur_trans->list)); in cleanup_transaction()
2013 if (cur_trans == fs_info->running_transaction) { in cleanup_transaction()
2014 cur_trans->state = TRANS_STATE_COMMIT_DOING; in cleanup_transaction()
2022 wait_event(cur_trans->writer_wait, in cleanup_transaction()
2023 atomic_read(&cur_trans->num_writers) == 1); in cleanup_transaction()
2036 list_del_init(&cur_trans->list); in cleanup_transaction()
2043 if (cur_trans == fs_info->running_transaction) in cleanup_transaction()
2049 btrfs_put_transaction(cur_trans); in cleanup_transaction()
2050 btrfs_put_transaction(cur_trans); in cleanup_transaction()
2129 struct btrfs_transaction *cur_trans = trans->transaction; in add_pending_snapshot() local
2135 ASSERT(cur_trans->state >= TRANS_STATE_COMMIT_PREP); in add_pending_snapshot()
2137 list_add(&trans->pending_snapshot->list, &cur_trans->pending_snapshots); in add_pending_snapshot()
2152 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_commit_transaction() local
2164 if (TRANS_ABORTED(cur_trans)) { in btrfs_commit_transaction()
2165 ret = cur_trans->aborted; in btrfs_commit_transaction()
2177 &cur_trans->delayed_refs.flags)) { in btrfs_commit_transaction()
2189 if (!test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &cur_trans->flags)) { in btrfs_commit_transaction()
2207 &cur_trans->flags)) in btrfs_commit_transaction()
2219 if (cur_trans->state >= TRANS_STATE_COMMIT_PREP) { in btrfs_commit_transaction()
2225 refcount_inc(&cur_trans->use_count); in btrfs_commit_transaction()
2233 wait_for_commit(cur_trans, want_state); in btrfs_commit_transaction()
2235 if (TRANS_ABORTED(cur_trans)) in btrfs_commit_transaction()
2236 ret = cur_trans->aborted; in btrfs_commit_transaction()
2238 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()
2243 cur_trans->state = TRANS_STATE_COMMIT_PREP; in btrfs_commit_transaction()
2247 if (cur_trans->list.prev != &fs_info->trans_list) { in btrfs_commit_transaction()
2253 prev_trans = list_entry(cur_trans->list.prev, in btrfs_commit_transaction()
2282 cur_trans->state = TRANS_STATE_COMMIT_START; in btrfs_commit_transaction()
2292 extwriter_counter_dec(cur_trans, trans->type); in btrfs_commit_transaction()
2309 wait_event(cur_trans->writer_wait, in btrfs_commit_transaction()
2310 extwriter_counter_read(cur_trans) == 0); in btrfs_commit_transaction()
2327 wait_event(cur_trans->pending_wait, in btrfs_commit_transaction()
2328 atomic_read(&cur_trans->pending_ordered) == 0); in btrfs_commit_transaction()
2338 cur_trans->state = TRANS_STATE_COMMIT_DOING; in btrfs_commit_transaction()
2348 wait_event(cur_trans->writer_wait, in btrfs_commit_transaction()
2349 atomic_read(&cur_trans->num_writers) == 1); in btrfs_commit_transaction()
2368 if (TRANS_ABORTED(cur_trans)) { in btrfs_commit_transaction()
2369 ret = cur_trans->aborted; in btrfs_commit_transaction()
2413 WARN_ON(cur_trans != trans->transaction); in btrfs_commit_transaction()
2440 if (TRANS_ABORTED(cur_trans)) { in btrfs_commit_transaction()
2441 ret = cur_trans->aborted; in btrfs_commit_transaction()
2445 cur_trans = fs_info->running_transaction; in btrfs_commit_transaction()
2450 &cur_trans->switch_commits); in btrfs_commit_transaction()
2455 &cur_trans->switch_commits); in btrfs_commit_transaction()
2461 &cur_trans->switch_commits); in btrfs_commit_transaction()
2466 ASSERT(list_empty(&cur_trans->dirty_bgs)); in btrfs_commit_transaction()
2467 ASSERT(list_empty(&cur_trans->io_bgs)); in btrfs_commit_transaction()
2475 btrfs_commit_device_sizes(cur_trans); in btrfs_commit_transaction()
2493 cur_trans->state = TRANS_STATE_UNBLOCKED; in btrfs_commit_transaction()
2527 cur_trans->state = TRANS_STATE_SUPER_COMMITTED; in btrfs_commit_transaction()
2528 wake_up(&cur_trans->commit_wait); in btrfs_commit_transaction()
2533 if (test_bit(BTRFS_TRANS_HAVE_FREE_BGS, &cur_trans->flags)) in btrfs_commit_transaction()
2536 fs_info->last_trans_committed = cur_trans->transid; in btrfs_commit_transaction()
2541 cur_trans->state = TRANS_STATE_COMPLETED; in btrfs_commit_transaction()
2542 wake_up(&cur_trans->commit_wait); in btrfs_commit_transaction()
2546 list_del_init(&cur_trans->list); in btrfs_commit_transaction()
2549 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()
2550 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()