Lines Matching refs:tp
65 struct xfs_trans *tp) in xfs_trans_free() argument
67 xfs_extent_busy_sort(&tp->t_busy); in xfs_trans_free()
68 xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false); in xfs_trans_free()
70 trace_xfs_trans_free(tp, _RET_IP_); in xfs_trans_free()
71 xfs_trans_clear_context(tp); in xfs_trans_free()
72 if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT)) in xfs_trans_free()
73 sb_end_intwrite(tp->t_mountp->m_super); in xfs_trans_free()
74 xfs_trans_free_dqinfo(tp); in xfs_trans_free()
75 kmem_cache_free(xfs_trans_zone, tp); in xfs_trans_free()
88 struct xfs_trans *tp) in xfs_trans_dup() argument
92 trace_xfs_trans_dup(tp, _RET_IP_); in xfs_trans_dup()
100 ntp->t_mountp = tp->t_mountp; in xfs_trans_dup()
106 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_dup()
107 ASSERT(tp->t_ticket != NULL); in xfs_trans_dup()
110 (tp->t_flags & XFS_TRANS_RESERVE) | in xfs_trans_dup()
111 (tp->t_flags & XFS_TRANS_NO_WRITECOUNT) | in xfs_trans_dup()
112 (tp->t_flags & XFS_TRANS_RES_FDBLKS); in xfs_trans_dup()
114 tp->t_flags |= XFS_TRANS_NO_WRITECOUNT; in xfs_trans_dup()
115 ntp->t_ticket = xfs_log_ticket_get(tp->t_ticket); in xfs_trans_dup()
117 ASSERT(tp->t_blk_res >= tp->t_blk_res_used); in xfs_trans_dup()
118 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; in xfs_trans_dup()
119 tp->t_blk_res = tp->t_blk_res_used; in xfs_trans_dup()
121 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; in xfs_trans_dup()
122 tp->t_rtx_res = tp->t_rtx_res_used; in xfs_trans_dup()
124 xfs_trans_switch_context(tp, ntp); in xfs_trans_dup()
127 xfs_defer_move(ntp, tp); in xfs_trans_dup()
129 xfs_trans_dup_dqinfo(tp, ntp); in xfs_trans_dup()
149 struct xfs_trans *tp, in xfs_trans_reserve() argument
154 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_reserve()
156 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_reserve()
167 tp->t_blk_res += blocks; in xfs_trans_reserve()
176 ASSERT(tp->t_log_res == 0 || in xfs_trans_reserve()
177 tp->t_log_res == resp->tr_logres); in xfs_trans_reserve()
178 ASSERT(tp->t_log_count == 0 || in xfs_trans_reserve()
179 tp->t_log_count == resp->tr_logcount); in xfs_trans_reserve()
182 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
185 ASSERT(tp->t_ticket == NULL); in xfs_trans_reserve()
186 ASSERT(!(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in xfs_trans_reserve()
189 if (tp->t_ticket != NULL) { in xfs_trans_reserve()
191 error = xfs_log_regrant(mp, tp->t_ticket); in xfs_trans_reserve()
196 &tp->t_ticket, XFS_TRANSACTION, in xfs_trans_reserve()
203 tp->t_log_res = resp->tr_logres; in xfs_trans_reserve()
204 tp->t_log_count = resp->tr_logcount; in xfs_trans_reserve()
218 tp->t_rtx_res += rtextents; in xfs_trans_reserve()
229 xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); in xfs_trans_reserve()
230 tp->t_ticket = NULL; in xfs_trans_reserve()
231 tp->t_log_res = 0; in xfs_trans_reserve()
232 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
238 tp->t_blk_res = 0; in xfs_trans_reserve()
252 struct xfs_trans *tp; in xfs_trans_alloc() local
260 tp = kmem_cache_zalloc(xfs_trans_zone, GFP_KERNEL | __GFP_NOFAIL); in xfs_trans_alloc()
263 xfs_trans_set_context(tp); in xfs_trans_alloc()
274 tp->t_magic = XFS_TRANS_HEADER_MAGIC; in xfs_trans_alloc()
275 tp->t_flags = flags; in xfs_trans_alloc()
276 tp->t_mountp = mp; in xfs_trans_alloc()
277 INIT_LIST_HEAD(&tp->t_items); in xfs_trans_alloc()
278 INIT_LIST_HEAD(&tp->t_busy); in xfs_trans_alloc()
279 INIT_LIST_HEAD(&tp->t_dfops); in xfs_trans_alloc()
280 tp->t_firstblock = NULLFSBLOCK; in xfs_trans_alloc()
282 error = xfs_trans_reserve(tp, resp, blocks, rtextents); in xfs_trans_alloc()
284 xfs_trans_cancel(tp); in xfs_trans_alloc()
288 trace_xfs_trans_alloc(tp, _RET_IP_); in xfs_trans_alloc()
290 *tpp = tp; in xfs_trans_alloc()
338 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
343 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_sb()
347 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
352 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
363 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
364 if (tp->t_blk_res_used > tp->t_blk_res) in xfs_trans_mod_sb()
366 } else if (delta > 0 && (tp->t_flags & XFS_TRANS_RES_FDBLKS)) { in xfs_trans_mod_sb()
377 UINT_MAX - tp->t_blk_res); in xfs_trans_mod_sb()
378 tp->t_blk_res += blkres_delta; in xfs_trans_mod_sb()
381 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
391 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
402 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
403 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
405 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
414 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
418 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
422 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
425 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
428 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
431 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
434 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
437 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
440 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
447 tp->t_flags |= flags; in xfs_trans_mod_sb()
460 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
466 bp = xfs_trans_getsb(tp); in xfs_trans_apply_sb_deltas()
472 ASSERT((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == in xfs_trans_apply_sb_deltas()
473 (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + in xfs_trans_apply_sb_deltas()
474 tp->t_ag_btree_delta)); in xfs_trans_apply_sb_deltas()
479 if (!xfs_sb_version_haslazysbcount(&(tp->t_mountp->m_sb))) { in xfs_trans_apply_sb_deltas()
480 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
481 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
482 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
483 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
484 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
485 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
486 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
487 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
490 if (tp->t_frextents_delta) in xfs_trans_apply_sb_deltas()
491 be64_add_cpu(&sbp->sb_frextents, tp->t_frextents_delta); in xfs_trans_apply_sb_deltas()
492 if (tp->t_res_frextents_delta) in xfs_trans_apply_sb_deltas()
493 be64_add_cpu(&sbp->sb_frextents, tp->t_res_frextents_delta); in xfs_trans_apply_sb_deltas()
495 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
496 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
499 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
500 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
503 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
504 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
507 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
508 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
511 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
512 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
515 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
516 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
519 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
520 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
523 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
524 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
528 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); in xfs_trans_apply_sb_deltas()
533 xfs_trans_log_buf(tp, bp, 0, sizeof(xfs_dsb_t) - 1); in xfs_trans_apply_sb_deltas()
539 xfs_trans_log_buf(tp, bp, offsetof(xfs_dsb_t, sb_icount), in xfs_trans_apply_sb_deltas()
563 struct xfs_trans *tp) in xfs_trans_unreserve_and_mod_sb() argument
565 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_unreserve_and_mod_sb()
566 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_unreserve_and_mod_sb()
574 if (tp->t_blk_res > 0) in xfs_trans_unreserve_and_mod_sb()
575 blkdelta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
576 if ((tp->t_fdblocks_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
578 (tp->t_flags & XFS_TRANS_SB_DIRTY))) in xfs_trans_unreserve_and_mod_sb()
579 blkdelta += tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
581 if (tp->t_rtx_res > 0) in xfs_trans_unreserve_and_mod_sb()
582 rtxdelta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
583 if ((tp->t_frextents_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
584 (tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
585 rtxdelta += tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
588 (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
589 idelta = tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
590 ifreedelta = tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
613 if (rtxdelta == 0 && !(tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
618 mp->m_sb.sb_fdblocks += tp->t_fdblocks_delta + tp->t_res_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
622 mp->m_sb.sb_dblocks += tp->t_dblocks_delta; in xfs_trans_unreserve_and_mod_sb()
623 mp->m_sb.sb_agcount += tp->t_agcount_delta; in xfs_trans_unreserve_and_mod_sb()
624 mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_unreserve_and_mod_sb()
625 mp->m_sb.sb_rextsize += tp->t_rextsize_delta; in xfs_trans_unreserve_and_mod_sb()
626 mp->m_sb.sb_rbmblocks += tp->t_rbmblocks_delta; in xfs_trans_unreserve_and_mod_sb()
627 mp->m_sb.sb_rblocks += tp->t_rblocks_delta; in xfs_trans_unreserve_and_mod_sb()
628 mp->m_sb.sb_rextents += tp->t_rextents_delta; in xfs_trans_unreserve_and_mod_sb()
629 mp->m_sb.sb_rextslog += tp->t_rextslog_delta; in xfs_trans_unreserve_and_mod_sb()
644 struct xfs_trans *tp, in xfs_trans_add_item() argument
647 ASSERT(lip->li_mountp == tp->t_mountp); in xfs_trans_add_item()
648 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
652 list_add_tail(&lip->li_trans, &tp->t_items); in xfs_trans_add_item()
653 trace_xfs_trans_add_item(tp, _RET_IP_); in xfs_trans_add_item()
672 struct xfs_trans *tp, in xfs_trans_free_items() argument
677 trace_xfs_trans_free_items(tp, _RET_IP_); in xfs_trans_free_items()
679 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { in xfs_trans_free_items()
831 struct xfs_trans *tp, in __xfs_trans_commit() argument
834 struct xfs_mount *mp = tp->t_mountp; in __xfs_trans_commit()
837 int sync = tp->t_flags & XFS_TRANS_SYNC; in __xfs_trans_commit()
839 trace_xfs_trans_commit(tp, _RET_IP_); in __xfs_trans_commit()
845 WARN_ON_ONCE(!list_empty(&tp->t_dfops) && in __xfs_trans_commit()
846 !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in __xfs_trans_commit()
847 if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) { in __xfs_trans_commit()
848 error = xfs_defer_finish_noroll(&tp); in __xfs_trans_commit()
860 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in __xfs_trans_commit()
868 ASSERT(tp->t_ticket != NULL); in __xfs_trans_commit()
873 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in __xfs_trans_commit()
874 xfs_trans_apply_sb_deltas(tp); in __xfs_trans_commit()
875 xfs_trans_apply_dquot_deltas(tp); in __xfs_trans_commit()
877 xlog_cil_commit(mp->m_log, tp, &commit_seq, regrant); in __xfs_trans_commit()
879 xfs_trans_free(tp); in __xfs_trans_commit()
895 xfs_trans_unreserve_and_mod_sb(tp); in __xfs_trans_commit()
902 xfs_trans_unreserve_and_mod_dquots(tp); in __xfs_trans_commit()
903 if (tp->t_ticket) { in __xfs_trans_commit()
905 xfs_log_ticket_regrant(mp->m_log, tp->t_ticket); in __xfs_trans_commit()
907 xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); in __xfs_trans_commit()
908 tp->t_ticket = NULL; in __xfs_trans_commit()
910 xfs_trans_free_items(tp, !!error); in __xfs_trans_commit()
911 xfs_trans_free(tp); in __xfs_trans_commit()
919 struct xfs_trans *tp) in xfs_trans_commit() argument
921 return __xfs_trans_commit(tp, false); in xfs_trans_commit()
934 struct xfs_trans *tp) in xfs_trans_cancel() argument
936 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_cancel()
937 bool dirty = (tp->t_flags & XFS_TRANS_DIRTY); in xfs_trans_cancel()
939 trace_xfs_trans_cancel(tp, _RET_IP_); in xfs_trans_cancel()
941 if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) in xfs_trans_cancel()
942 xfs_defer_cancel(tp); in xfs_trans_cancel()
957 list_for_each_entry(lip, &tp->t_items, li_trans) in xfs_trans_cancel()
961 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
962 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
964 if (tp->t_ticket) { in xfs_trans_cancel()
965 xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); in xfs_trans_cancel()
966 tp->t_ticket = NULL; in xfs_trans_cancel()
969 xfs_trans_free_items(tp, dirty); in xfs_trans_cancel()
970 xfs_trans_free(tp); in xfs_trans_cancel()