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()
909 struct btrfs_transaction *cur_trans = NULL, *t; in btrfs_wait_for_commit() local
920 cur_trans = t; in btrfs_wait_for_commit()
921 refcount_inc(&cur_trans->use_count); in btrfs_wait_for_commit()
936 if (!cur_trans) { in btrfs_wait_for_commit()
949 cur_trans = t; in btrfs_wait_for_commit()
950 refcount_inc(&cur_trans->use_count); in btrfs_wait_for_commit()
955 if (!cur_trans) in btrfs_wait_for_commit()
959 wait_for_commit(cur_trans, TRANS_STATE_COMPLETED); in btrfs_wait_for_commit()
960 ret = cur_trans->aborted; in btrfs_wait_for_commit()
961 btrfs_put_transaction(cur_trans); in btrfs_wait_for_commit()
973 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_should_end_transaction() local
975 if (cur_trans->state >= TRANS_STATE_COMMIT_START || in btrfs_should_end_transaction()
976 test_bit(BTRFS_DELAYED_REFS_FLUSHING, &cur_trans->delayed_refs.flags)) in btrfs_should_end_transaction()
1010 struct btrfs_transaction *cur_trans = trans->transaction; in __btrfs_end_transaction() local
1029 WARN_ON(cur_trans != info->running_transaction); in __btrfs_end_transaction()
1030 WARN_ON(atomic_read(&cur_trans->num_writers) < 1); in __btrfs_end_transaction()
1031 atomic_dec(&cur_trans->num_writers); in __btrfs_end_transaction()
1032 extwriter_counter_dec(cur_trans, trans->type); in __btrfs_end_transaction()
1034 cond_wake_up(&cur_trans->writer_wait); in __btrfs_end_transaction()
1039 btrfs_put_transaction(cur_trans); in __btrfs_end_transaction()
1973 struct btrfs_transaction *cur_trans; in btrfs_commit_transaction_async() local
1980 cur_trans = trans->transaction; in btrfs_commit_transaction_async()
1981 refcount_inc(&cur_trans->use_count); in btrfs_commit_transaction_async()
1991 cur_trans->state >= TRANS_STATE_COMMIT_START || in btrfs_commit_transaction_async()
1992 TRANS_ABORTED(cur_trans)); in btrfs_commit_transaction_async()
1993 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction_async()
1999 struct btrfs_transaction *cur_trans = trans->transaction; in cleanup_transaction() local
2012 BUG_ON(list_empty(&cur_trans->list)); in cleanup_transaction()
2014 if (cur_trans == fs_info->running_transaction) { in cleanup_transaction()
2015 cur_trans->state = TRANS_STATE_COMMIT_DOING; in cleanup_transaction()
2023 wait_event(cur_trans->writer_wait, in cleanup_transaction()
2024 atomic_read(&cur_trans->num_writers) == 1); in cleanup_transaction()
2037 list_del_init(&cur_trans->list); in cleanup_transaction()
2044 if (cur_trans == fs_info->running_transaction) in cleanup_transaction()
2050 btrfs_put_transaction(cur_trans); in cleanup_transaction()
2051 btrfs_put_transaction(cur_trans); in cleanup_transaction()
2130 struct btrfs_transaction *cur_trans = trans->transaction; in add_pending_snapshot() local
2136 ASSERT(cur_trans->state >= TRANS_STATE_COMMIT_PREP); in add_pending_snapshot()
2138 list_add(&trans->pending_snapshot->list, &cur_trans->pending_snapshots); in add_pending_snapshot()
2153 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_commit_transaction() local
2165 if (TRANS_ABORTED(cur_trans)) { in btrfs_commit_transaction()
2166 ret = cur_trans->aborted; in btrfs_commit_transaction()
2178 &cur_trans->delayed_refs.flags)) { in btrfs_commit_transaction()
2190 if (!test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &cur_trans->flags)) { in btrfs_commit_transaction()
2208 &cur_trans->flags)) in btrfs_commit_transaction()
2220 if (cur_trans->state >= TRANS_STATE_COMMIT_PREP) { in btrfs_commit_transaction()
2226 refcount_inc(&cur_trans->use_count); in btrfs_commit_transaction()
2234 wait_for_commit(cur_trans, want_state); in btrfs_commit_transaction()
2236 if (TRANS_ABORTED(cur_trans)) in btrfs_commit_transaction()
2237 ret = cur_trans->aborted; in btrfs_commit_transaction()
2239 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()
2244 cur_trans->state = TRANS_STATE_COMMIT_PREP; in btrfs_commit_transaction()
2248 if (cur_trans->list.prev != &fs_info->trans_list) { in btrfs_commit_transaction()
2254 prev_trans = list_entry(cur_trans->list.prev, in btrfs_commit_transaction()
2283 cur_trans->state = TRANS_STATE_COMMIT_START; in btrfs_commit_transaction()
2293 extwriter_counter_dec(cur_trans, trans->type); in btrfs_commit_transaction()
2310 wait_event(cur_trans->writer_wait, in btrfs_commit_transaction()
2311 extwriter_counter_read(cur_trans) == 0); in btrfs_commit_transaction()
2328 wait_event(cur_trans->pending_wait, in btrfs_commit_transaction()
2329 atomic_read(&cur_trans->pending_ordered) == 0); in btrfs_commit_transaction()
2339 cur_trans->state = TRANS_STATE_COMMIT_DOING; in btrfs_commit_transaction()
2349 wait_event(cur_trans->writer_wait, in btrfs_commit_transaction()
2350 atomic_read(&cur_trans->num_writers) == 1); in btrfs_commit_transaction()
2369 if (TRANS_ABORTED(cur_trans)) { in btrfs_commit_transaction()
2370 ret = cur_trans->aborted; in btrfs_commit_transaction()
2414 WARN_ON(cur_trans != trans->transaction); in btrfs_commit_transaction()
2441 if (TRANS_ABORTED(cur_trans)) { in btrfs_commit_transaction()
2442 ret = cur_trans->aborted; in btrfs_commit_transaction()
2446 cur_trans = fs_info->running_transaction; in btrfs_commit_transaction()
2451 &cur_trans->switch_commits); in btrfs_commit_transaction()
2456 &cur_trans->switch_commits); in btrfs_commit_transaction()
2462 &cur_trans->switch_commits); in btrfs_commit_transaction()
2467 ASSERT(list_empty(&cur_trans->dirty_bgs)); in btrfs_commit_transaction()
2468 ASSERT(list_empty(&cur_trans->io_bgs)); in btrfs_commit_transaction()
2476 btrfs_commit_device_sizes(cur_trans); in btrfs_commit_transaction()
2494 cur_trans->state = TRANS_STATE_UNBLOCKED; in btrfs_commit_transaction()
2528 cur_trans->state = TRANS_STATE_SUPER_COMMITTED; in btrfs_commit_transaction()
2529 wake_up(&cur_trans->commit_wait); in btrfs_commit_transaction()
2534 if (test_bit(BTRFS_TRANS_HAVE_FREE_BGS, &cur_trans->flags)) in btrfs_commit_transaction()
2537 fs_info->last_trans_committed = cur_trans->transid; in btrfs_commit_transaction()
2542 cur_trans->state = TRANS_STATE_COMPLETED; in btrfs_commit_transaction()
2543 wake_up(&cur_trans->commit_wait); in btrfs_commit_transaction()
2547 list_del_init(&cur_trans->list); in btrfs_commit_transaction()
2550 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()
2551 btrfs_put_transaction(cur_trans); in btrfs_commit_transaction()