Lines Matching refs:tp
69 struct xfs_trans *tp) in xfs_trans_free() argument
71 xfs_extent_busy_sort(&tp->t_busy); in xfs_trans_free()
72 xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false); in xfs_trans_free()
74 trace_xfs_trans_free(tp, _RET_IP_); in xfs_trans_free()
75 xfs_trans_clear_context(tp); in xfs_trans_free()
76 if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT)) in xfs_trans_free()
77 sb_end_intwrite(tp->t_mountp->m_super); in xfs_trans_free()
78 xfs_trans_free_dqinfo(tp); in xfs_trans_free()
79 kmem_cache_free(xfs_trans_cache, tp); in xfs_trans_free()
92 struct xfs_trans *tp) in xfs_trans_dup() argument
96 trace_xfs_trans_dup(tp, _RET_IP_); in xfs_trans_dup()
104 ntp->t_mountp = tp->t_mountp; in xfs_trans_dup()
110 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_dup()
111 ASSERT(tp->t_ticket != NULL); in xfs_trans_dup()
114 (tp->t_flags & XFS_TRANS_RESERVE) | in xfs_trans_dup()
115 (tp->t_flags & XFS_TRANS_NO_WRITECOUNT) | in xfs_trans_dup()
116 (tp->t_flags & XFS_TRANS_RES_FDBLKS); in xfs_trans_dup()
118 tp->t_flags |= XFS_TRANS_NO_WRITECOUNT; in xfs_trans_dup()
119 ntp->t_ticket = xfs_log_ticket_get(tp->t_ticket); in xfs_trans_dup()
121 ASSERT(tp->t_blk_res >= tp->t_blk_res_used); in xfs_trans_dup()
122 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; in xfs_trans_dup()
123 tp->t_blk_res = tp->t_blk_res_used; in xfs_trans_dup()
125 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; in xfs_trans_dup()
126 tp->t_rtx_res = tp->t_rtx_res_used; in xfs_trans_dup()
128 xfs_trans_switch_context(tp, ntp); in xfs_trans_dup()
131 xfs_defer_move(ntp, tp); in xfs_trans_dup()
133 xfs_trans_dup_dqinfo(tp, ntp); in xfs_trans_dup()
153 struct xfs_trans *tp, in xfs_trans_reserve() argument
158 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_reserve()
160 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_reserve()
171 tp->t_blk_res += blocks; in xfs_trans_reserve()
180 ASSERT(tp->t_log_res == 0 || in xfs_trans_reserve()
181 tp->t_log_res == resp->tr_logres); in xfs_trans_reserve()
182 ASSERT(tp->t_log_count == 0 || in xfs_trans_reserve()
183 tp->t_log_count == resp->tr_logcount); in xfs_trans_reserve()
186 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
189 ASSERT(tp->t_ticket == NULL); in xfs_trans_reserve()
190 ASSERT(!(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in xfs_trans_reserve()
193 if (tp->t_ticket != NULL) { in xfs_trans_reserve()
195 error = xfs_log_regrant(mp, tp->t_ticket); in xfs_trans_reserve()
200 &tp->t_ticket, XFS_TRANSACTION, in xfs_trans_reserve()
207 tp->t_log_res = resp->tr_logres; in xfs_trans_reserve()
208 tp->t_log_count = resp->tr_logcount; in xfs_trans_reserve()
222 tp->t_rtx_res += rtextents; in xfs_trans_reserve()
233 xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); in xfs_trans_reserve()
234 tp->t_ticket = NULL; in xfs_trans_reserve()
235 tp->t_log_res = 0; in xfs_trans_reserve()
236 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
242 tp->t_blk_res = 0; in xfs_trans_reserve()
256 struct xfs_trans *tp; in xfs_trans_alloc() local
266 tp = kmem_cache_zalloc(xfs_trans_cache, GFP_KERNEL | __GFP_NOFAIL); in xfs_trans_alloc()
269 xfs_trans_set_context(tp); in xfs_trans_alloc()
280 tp->t_magic = XFS_TRANS_HEADER_MAGIC; in xfs_trans_alloc()
281 tp->t_flags = flags; in xfs_trans_alloc()
282 tp->t_mountp = mp; in xfs_trans_alloc()
283 INIT_LIST_HEAD(&tp->t_items); in xfs_trans_alloc()
284 INIT_LIST_HEAD(&tp->t_busy); in xfs_trans_alloc()
285 INIT_LIST_HEAD(&tp->t_dfops); in xfs_trans_alloc()
286 tp->t_firstblock = NULLFSBLOCK; in xfs_trans_alloc()
288 error = xfs_trans_reserve(tp, resp, blocks, rtextents); in xfs_trans_alloc()
290 xfs_trans_cancel(tp); in xfs_trans_alloc()
303 xfs_trans_cancel(tp); in xfs_trans_alloc()
307 trace_xfs_trans_alloc(tp, _RET_IP_); in xfs_trans_alloc()
309 *tpp = tp; in xfs_trans_alloc()
357 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
362 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_sb()
366 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
371 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
382 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
383 if (tp->t_blk_res_used > tp->t_blk_res) in xfs_trans_mod_sb()
385 } else if (delta > 0 && (tp->t_flags & XFS_TRANS_RES_FDBLKS)) { in xfs_trans_mod_sb()
396 UINT_MAX - tp->t_blk_res); in xfs_trans_mod_sb()
397 tp->t_blk_res += blkres_delta; in xfs_trans_mod_sb()
400 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
410 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
421 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
422 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
424 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
433 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
436 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
440 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
443 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
446 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
449 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
452 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
455 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
458 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
465 tp->t_flags |= flags; in xfs_trans_mod_sb()
478 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
484 bp = xfs_trans_getsb(tp); in xfs_trans_apply_sb_deltas()
490 if (!xfs_has_lazysbcount((tp->t_mountp))) { in xfs_trans_apply_sb_deltas()
491 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
492 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
493 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
494 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
495 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
496 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
497 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
498 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
501 if (tp->t_frextents_delta) in xfs_trans_apply_sb_deltas()
502 be64_add_cpu(&sbp->sb_frextents, tp->t_frextents_delta); in xfs_trans_apply_sb_deltas()
503 if (tp->t_res_frextents_delta) in xfs_trans_apply_sb_deltas()
504 be64_add_cpu(&sbp->sb_frextents, tp->t_res_frextents_delta); in xfs_trans_apply_sb_deltas()
506 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
507 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
510 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
511 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
514 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
515 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
518 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
519 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
522 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
523 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
526 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
527 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
530 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
531 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
534 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
535 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
539 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); in xfs_trans_apply_sb_deltas()
544 xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1); in xfs_trans_apply_sb_deltas()
550 xfs_trans_log_buf(tp, bp, offsetof(struct xfs_dsb, sb_icount), in xfs_trans_apply_sb_deltas()
574 struct xfs_trans *tp) in xfs_trans_unreserve_and_mod_sb() argument
576 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_unreserve_and_mod_sb()
577 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_unreserve_and_mod_sb()
585 if (tp->t_blk_res > 0) in xfs_trans_unreserve_and_mod_sb()
586 blkdelta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
587 if ((tp->t_fdblocks_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
589 (tp->t_flags & XFS_TRANS_SB_DIRTY))) in xfs_trans_unreserve_and_mod_sb()
590 blkdelta += tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
592 if (tp->t_rtx_res > 0) in xfs_trans_unreserve_and_mod_sb()
593 rtxdelta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
594 if ((tp->t_frextents_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
595 (tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
596 rtxdelta += tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
599 (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
600 idelta = tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
601 ifreedelta = tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
617 if (rtxdelta == 0 && !(tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
622 mp->m_sb.sb_fdblocks += tp->t_fdblocks_delta + tp->t_res_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
626 mp->m_sb.sb_dblocks += tp->t_dblocks_delta; in xfs_trans_unreserve_and_mod_sb()
627 mp->m_sb.sb_agcount += tp->t_agcount_delta; in xfs_trans_unreserve_and_mod_sb()
628 mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_unreserve_and_mod_sb()
629 mp->m_sb.sb_rextsize += tp->t_rextsize_delta; in xfs_trans_unreserve_and_mod_sb()
630 mp->m_sb.sb_rbmblocks += tp->t_rbmblocks_delta; in xfs_trans_unreserve_and_mod_sb()
631 mp->m_sb.sb_rblocks += tp->t_rblocks_delta; in xfs_trans_unreserve_and_mod_sb()
632 mp->m_sb.sb_rextents += tp->t_rextents_delta; in xfs_trans_unreserve_and_mod_sb()
633 mp->m_sb.sb_rextslog += tp->t_rextslog_delta; in xfs_trans_unreserve_and_mod_sb()
648 struct xfs_trans *tp, in xfs_trans_add_item() argument
651 ASSERT(lip->li_mountp == tp->t_mountp); in xfs_trans_add_item()
652 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
656 list_add_tail(&lip->li_trans, &tp->t_items); in xfs_trans_add_item()
657 trace_xfs_trans_add_item(tp, _RET_IP_); in xfs_trans_add_item()
676 struct xfs_trans *tp, in xfs_trans_free_items() argument
681 trace_xfs_trans_free_items(tp, _RET_IP_); in xfs_trans_free_items()
683 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { in xfs_trans_free_items()
835 struct xfs_trans *tp, in __xfs_trans_commit() argument
838 struct xfs_mount *mp = tp->t_mountp; in __xfs_trans_commit()
841 int sync = tp->t_flags & XFS_TRANS_SYNC; in __xfs_trans_commit()
843 trace_xfs_trans_commit(tp, _RET_IP_); in __xfs_trans_commit()
849 WARN_ON_ONCE(!list_empty(&tp->t_dfops) && in __xfs_trans_commit()
850 !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in __xfs_trans_commit()
851 if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) { in __xfs_trans_commit()
852 error = xfs_defer_finish_noroll(&tp); in __xfs_trans_commit()
864 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in __xfs_trans_commit()
872 ASSERT(tp->t_ticket != NULL); in __xfs_trans_commit()
877 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in __xfs_trans_commit()
878 xfs_trans_apply_sb_deltas(tp); in __xfs_trans_commit()
879 xfs_trans_apply_dquot_deltas(tp); in __xfs_trans_commit()
881 xlog_cil_commit(mp->m_log, tp, &commit_seq, regrant); in __xfs_trans_commit()
883 xfs_trans_free(tp); in __xfs_trans_commit()
899 xfs_trans_unreserve_and_mod_sb(tp); in __xfs_trans_commit()
906 xfs_trans_unreserve_and_mod_dquots(tp); in __xfs_trans_commit()
907 if (tp->t_ticket) { in __xfs_trans_commit()
909 xfs_log_ticket_regrant(mp->m_log, tp->t_ticket); in __xfs_trans_commit()
911 xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); in __xfs_trans_commit()
912 tp->t_ticket = NULL; in __xfs_trans_commit()
914 xfs_trans_free_items(tp, !!error); in __xfs_trans_commit()
915 xfs_trans_free(tp); in __xfs_trans_commit()
923 struct xfs_trans *tp) in xfs_trans_commit() argument
925 return __xfs_trans_commit(tp, false); in xfs_trans_commit()
938 struct xfs_trans *tp) in xfs_trans_cancel() argument
940 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_cancel()
941 bool dirty = (tp->t_flags & XFS_TRANS_DIRTY); in xfs_trans_cancel()
943 trace_xfs_trans_cancel(tp, _RET_IP_); in xfs_trans_cancel()
945 if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) in xfs_trans_cancel()
946 xfs_defer_cancel(tp); in xfs_trans_cancel()
961 list_for_each_entry(lip, &tp->t_items, li_trans) in xfs_trans_cancel()
965 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
966 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
968 if (tp->t_ticket) { in xfs_trans_cancel()
969 xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); in xfs_trans_cancel()
970 tp->t_ticket = NULL; in xfs_trans_cancel()
973 xfs_trans_free_items(tp, dirty); in xfs_trans_cancel()
974 xfs_trans_free(tp); in xfs_trans_cancel()
1041 struct xfs_trans *tp; in xfs_trans_alloc_inode() local
1049 force ? XFS_TRANS_RESERVE : 0, &tp); in xfs_trans_alloc_inode()
1054 xfs_trans_ijoin(tp, ip, 0); in xfs_trans_alloc_inode()
1063 error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, force); in xfs_trans_alloc_inode()
1065 xfs_trans_cancel(tp); in xfs_trans_alloc_inode()
1074 *tpp = tp; in xfs_trans_alloc_inode()
1078 xfs_trans_cancel(tp); in xfs_trans_alloc_inode()
1097 struct xfs_trans *tp; in xfs_trans_alloc_icreate() local
1102 error = xfs_trans_alloc(mp, resv, dblocks, 0, 0, &tp); in xfs_trans_alloc_icreate()
1106 error = xfs_trans_reserve_quota_icreate(tp, udqp, gdqp, pdqp, dblocks); in xfs_trans_alloc_icreate()
1108 xfs_trans_cancel(tp); in xfs_trans_alloc_icreate()
1114 xfs_trans_cancel(tp); in xfs_trans_alloc_icreate()
1118 *tpp = tp; in xfs_trans_alloc_icreate()
1140 struct xfs_trans *tp; in xfs_trans_alloc_ichange() local
1149 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); in xfs_trans_alloc_ichange()
1154 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_trans_alloc_ichange()
1184 error = xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp, in xfs_trans_alloc_ichange()
1188 xfs_trans_cancel(tp); in xfs_trans_alloc_ichange()
1197 *tpp = tp; in xfs_trans_alloc_ichange()
1201 xfs_trans_cancel(tp); in xfs_trans_alloc_ichange()