Lines Matching refs:tp
62 xfs_trans_t *tp; in xfs_trans_alloc() local
65 tp = _xfs_trans_alloc(mp, type, KM_SLEEP); in xfs_trans_alloc()
66 tp->t_flags |= XFS_TRANS_FREEZE_PROT; in xfs_trans_alloc()
67 return tp; in xfs_trans_alloc()
76 xfs_trans_t *tp; in _xfs_trans_alloc() local
81 tp = kmem_zone_zalloc(xfs_trans_zone, memflags); in _xfs_trans_alloc()
82 tp->t_magic = XFS_TRANS_HEADER_MAGIC; in _xfs_trans_alloc()
83 tp->t_type = type; in _xfs_trans_alloc()
84 tp->t_mountp = mp; in _xfs_trans_alloc()
85 INIT_LIST_HEAD(&tp->t_items); in _xfs_trans_alloc()
86 INIT_LIST_HEAD(&tp->t_busy); in _xfs_trans_alloc()
87 return tp; in _xfs_trans_alloc()
96 struct xfs_trans *tp) in xfs_trans_free() argument
98 xfs_extent_busy_sort(&tp->t_busy); in xfs_trans_free()
99 xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false); in xfs_trans_free()
101 atomic_dec(&tp->t_mountp->m_active_trans); in xfs_trans_free()
102 if (tp->t_flags & XFS_TRANS_FREEZE_PROT) in xfs_trans_free()
103 sb_end_intwrite(tp->t_mountp->m_super); in xfs_trans_free()
104 xfs_trans_free_dqinfo(tp); in xfs_trans_free()
105 kmem_zone_free(xfs_trans_zone, tp); in xfs_trans_free()
118 xfs_trans_t *tp) in xfs_trans_dup() argument
128 ntp->t_type = tp->t_type; in xfs_trans_dup()
129 ntp->t_mountp = tp->t_mountp; in xfs_trans_dup()
133 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_dup()
134 ASSERT(tp->t_ticket != NULL); in xfs_trans_dup()
137 (tp->t_flags & XFS_TRANS_RESERVE) | in xfs_trans_dup()
138 (tp->t_flags & XFS_TRANS_FREEZE_PROT); in xfs_trans_dup()
140 tp->t_flags &= ~XFS_TRANS_FREEZE_PROT; in xfs_trans_dup()
141 ntp->t_ticket = xfs_log_ticket_get(tp->t_ticket); in xfs_trans_dup()
142 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; in xfs_trans_dup()
143 tp->t_blk_res = tp->t_blk_res_used; in xfs_trans_dup()
144 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; in xfs_trans_dup()
145 tp->t_rtx_res = tp->t_rtx_res_used; in xfs_trans_dup()
146 ntp->t_pflags = tp->t_pflags; in xfs_trans_dup()
148 xfs_trans_dup_dqinfo(tp, ntp); in xfs_trans_dup()
150 atomic_inc(&tp->t_mountp->m_active_trans); in xfs_trans_dup()
170 struct xfs_trans *tp, in xfs_trans_reserve() argument
176 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_reserve()
179 current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_reserve()
187 error = xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), rsvd); in xfs_trans_reserve()
189 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_reserve()
192 tp->t_blk_res += blocks; in xfs_trans_reserve()
201 ASSERT(tp->t_log_res == 0 || in xfs_trans_reserve()
202 tp->t_log_res == resp->tr_logres); in xfs_trans_reserve()
203 ASSERT(tp->t_log_count == 0 || in xfs_trans_reserve()
204 tp->t_log_count == resp->tr_logcount); in xfs_trans_reserve()
207 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
210 ASSERT(tp->t_ticket == NULL); in xfs_trans_reserve()
211 ASSERT(!(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in xfs_trans_reserve()
214 if (tp->t_ticket != NULL) { in xfs_trans_reserve()
216 error = xfs_log_regrant(tp->t_mountp, tp->t_ticket); in xfs_trans_reserve()
218 error = xfs_log_reserve(tp->t_mountp, in xfs_trans_reserve()
221 &tp->t_ticket, XFS_TRANSACTION, in xfs_trans_reserve()
222 permanent, tp->t_type); in xfs_trans_reserve()
228 tp->t_log_res = resp->tr_logres; in xfs_trans_reserve()
229 tp->t_log_count = resp->tr_logcount; in xfs_trans_reserve()
238 error = xfs_mod_frextents(tp->t_mountp, -((int64_t)rtextents)); in xfs_trans_reserve()
243 tp->t_rtx_res += rtextents; in xfs_trans_reserve()
261 xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, log_flags); in xfs_trans_reserve()
262 tp->t_ticket = NULL; in xfs_trans_reserve()
263 tp->t_log_res = 0; in xfs_trans_reserve()
264 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
269 xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), rsvd); in xfs_trans_reserve()
270 tp->t_blk_res = 0; in xfs_trans_reserve()
273 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_reserve()
296 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
301 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_sb()
305 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
310 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
321 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
322 ASSERT(tp->t_blk_res_used <= tp->t_blk_res); in xfs_trans_mod_sb()
324 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
335 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
346 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
347 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
349 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
358 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
362 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
366 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
369 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
372 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
375 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
378 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
381 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
384 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
391 tp->t_flags |= flags; in xfs_trans_mod_sb()
404 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
410 bp = xfs_trans_getsb(tp, tp->t_mountp, 0); in xfs_trans_apply_sb_deltas()
416 ASSERT((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == in xfs_trans_apply_sb_deltas()
417 (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + in xfs_trans_apply_sb_deltas()
418 tp->t_ag_btree_delta)); in xfs_trans_apply_sb_deltas()
423 if (!xfs_sb_version_haslazysbcount(&(tp->t_mountp->m_sb))) { in xfs_trans_apply_sb_deltas()
424 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
425 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
426 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
427 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
428 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
429 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
430 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
431 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
434 if (tp->t_frextents_delta) in xfs_trans_apply_sb_deltas()
435 be64_add_cpu(&sbp->sb_frextents, tp->t_frextents_delta); in xfs_trans_apply_sb_deltas()
436 if (tp->t_res_frextents_delta) in xfs_trans_apply_sb_deltas()
437 be64_add_cpu(&sbp->sb_frextents, tp->t_res_frextents_delta); in xfs_trans_apply_sb_deltas()
439 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
440 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
443 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
444 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
447 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
448 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
451 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
452 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
455 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
456 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
459 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
460 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
463 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
464 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
467 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
468 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
472 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); in xfs_trans_apply_sb_deltas()
477 xfs_trans_log_buf(tp, bp, 0, sizeof(xfs_dsb_t) - 1); in xfs_trans_apply_sb_deltas()
483 xfs_trans_log_buf(tp, bp, offsetof(xfs_dsb_t, sb_icount), in xfs_trans_apply_sb_deltas()
550 struct xfs_trans *tp) in xfs_trans_unreserve_and_mod_sb() argument
552 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_unreserve_and_mod_sb()
553 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_unreserve_and_mod_sb()
561 if (tp->t_blk_res > 0) in xfs_trans_unreserve_and_mod_sb()
562 blkdelta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
563 if ((tp->t_fdblocks_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
565 (tp->t_flags & XFS_TRANS_SB_DIRTY))) in xfs_trans_unreserve_and_mod_sb()
566 blkdelta += tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
568 if (tp->t_rtx_res > 0) in xfs_trans_unreserve_and_mod_sb()
569 rtxdelta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
570 if ((tp->t_frextents_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
571 (tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
572 rtxdelta += tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
575 (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
576 idelta = tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
577 ifreedelta = tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
599 if (rtxdelta == 0 && !(tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
610 if (tp->t_dblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
611 error = xfs_sb_mod64(&mp->m_sb.sb_dblocks, tp->t_dblocks_delta); in xfs_trans_unreserve_and_mod_sb()
615 if (tp->t_agcount_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
616 error = xfs_sb_mod32(&mp->m_sb.sb_agcount, tp->t_agcount_delta); in xfs_trans_unreserve_and_mod_sb()
620 if (tp->t_imaxpct_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
621 error = xfs_sb_mod8(&mp->m_sb.sb_imax_pct, tp->t_imaxpct_delta); in xfs_trans_unreserve_and_mod_sb()
625 if (tp->t_rextsize_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
627 tp->t_rextsize_delta); in xfs_trans_unreserve_and_mod_sb()
631 if (tp->t_rbmblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
633 tp->t_rbmblocks_delta); in xfs_trans_unreserve_and_mod_sb()
637 if (tp->t_rblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
638 error = xfs_sb_mod64(&mp->m_sb.sb_rblocks, tp->t_rblocks_delta); in xfs_trans_unreserve_and_mod_sb()
642 if (tp->t_rextents_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
644 tp->t_rextents_delta); in xfs_trans_unreserve_and_mod_sb()
648 if (tp->t_rextslog_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
650 tp->t_rextslog_delta); in xfs_trans_unreserve_and_mod_sb()
658 if (tp->t_rextents_delta) in xfs_trans_unreserve_and_mod_sb()
659 xfs_sb_mod64(&mp->m_sb.sb_rextents, -tp->t_rextents_delta); in xfs_trans_unreserve_and_mod_sb()
661 if (tp->t_rblocks_delta) in xfs_trans_unreserve_and_mod_sb()
662 xfs_sb_mod64(&mp->m_sb.sb_rblocks, -tp->t_rblocks_delta); in xfs_trans_unreserve_and_mod_sb()
664 if (tp->t_rbmblocks_delta) in xfs_trans_unreserve_and_mod_sb()
665 xfs_sb_mod32(&mp->m_sb.sb_rbmblocks, -tp->t_rbmblocks_delta); in xfs_trans_unreserve_and_mod_sb()
667 if (tp->t_rextsize_delta) in xfs_trans_unreserve_and_mod_sb()
668 xfs_sb_mod32(&mp->m_sb.sb_rextsize, -tp->t_rextsize_delta); in xfs_trans_unreserve_and_mod_sb()
670 if (tp->t_rextsize_delta) in xfs_trans_unreserve_and_mod_sb()
671 xfs_sb_mod8(&mp->m_sb.sb_imax_pct, -tp->t_imaxpct_delta); in xfs_trans_unreserve_and_mod_sb()
673 if (tp->t_agcount_delta) in xfs_trans_unreserve_and_mod_sb()
674 xfs_sb_mod32(&mp->m_sb.sb_agcount, -tp->t_agcount_delta); in xfs_trans_unreserve_and_mod_sb()
676 if (tp->t_dblocks_delta) in xfs_trans_unreserve_and_mod_sb()
677 xfs_sb_mod64(&mp->m_sb.sb_dblocks, -tp->t_dblocks_delta); in xfs_trans_unreserve_and_mod_sb()
703 struct xfs_trans *tp, in xfs_trans_add_item() argument
708 ASSERT(lip->li_mountp == tp->t_mountp); in xfs_trans_add_item()
709 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
715 list_add_tail(&lidp->lid_trans, &tp->t_items); in xfs_trans_add_item()
745 struct xfs_trans *tp, in xfs_trans_free_items() argument
751 list_for_each_entry_safe(lidp, next, &tp->t_items, lid_trans) { in xfs_trans_free_items()
897 struct xfs_trans *tp, in xfs_trans_commit() argument
900 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_commit()
904 int sync = tp->t_flags & XFS_TRANS_SYNC; in xfs_trans_commit()
911 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_commit()
922 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in xfs_trans_commit()
930 ASSERT(tp->t_ticket != NULL); in xfs_trans_commit()
935 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in xfs_trans_commit()
936 xfs_trans_apply_sb_deltas(tp); in xfs_trans_commit()
937 xfs_trans_apply_dquot_deltas(tp); in xfs_trans_commit()
939 xfs_log_commit_cil(mp, tp, &commit_lsn, flags); in xfs_trans_commit()
941 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_commit()
942 xfs_trans_free(tp); in xfs_trans_commit()
958 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_commit()
965 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_commit()
966 if (tp->t_ticket) { in xfs_trans_commit()
967 commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, log_flags); in xfs_trans_commit()
971 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_commit()
972 xfs_trans_free_items(tp, NULLCOMMITLSN, error ? XFS_TRANS_ABORT : 0); in xfs_trans_commit()
973 xfs_trans_free(tp); in xfs_trans_commit()
989 xfs_trans_t *tp, in xfs_trans_cancel() argument
993 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_cancel()
999 if ((flags & XFS_TRANS_ABORT) && !(tp->t_flags & XFS_TRANS_DIRTY)) in xfs_trans_cancel()
1006 if ((tp->t_flags & XFS_TRANS_DIRTY) && !XFS_FORCED_SHUTDOWN(mp)) { in xfs_trans_cancel()
1014 list_for_each_entry(lidp, &tp->t_items, lid_trans) in xfs_trans_cancel()
1018 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
1019 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
1021 if (tp->t_ticket) { in xfs_trans_cancel()
1023 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_cancel()
1028 xfs_log_done(mp, tp->t_ticket, NULL, log_flags); in xfs_trans_cancel()
1032 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_cancel()
1034 xfs_trans_free_items(tp, NULLCOMMITLSN, flags); in xfs_trans_cancel()
1035 xfs_trans_free(tp); in xfs_trans_cancel()