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()
254 xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, false); in xfs_trans_reserve()
255 tp->t_ticket = NULL; in xfs_trans_reserve()
256 tp->t_log_res = 0; in xfs_trans_reserve()
257 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
262 xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), rsvd); in xfs_trans_reserve()
263 tp->t_blk_res = 0; in xfs_trans_reserve()
266 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_reserve()
289 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
294 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_sb()
298 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
303 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
314 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
315 ASSERT(tp->t_blk_res_used <= tp->t_blk_res); in xfs_trans_mod_sb()
317 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
328 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
339 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
340 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
342 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
351 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
355 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
359 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
362 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
365 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
368 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
371 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
374 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
377 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
384 tp->t_flags |= flags; in xfs_trans_mod_sb()
397 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
403 bp = xfs_trans_getsb(tp, tp->t_mountp, 0); in xfs_trans_apply_sb_deltas()
409 ASSERT((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == in xfs_trans_apply_sb_deltas()
410 (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + in xfs_trans_apply_sb_deltas()
411 tp->t_ag_btree_delta)); in xfs_trans_apply_sb_deltas()
416 if (!xfs_sb_version_haslazysbcount(&(tp->t_mountp->m_sb))) { in xfs_trans_apply_sb_deltas()
417 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
418 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
419 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
420 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
421 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
422 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
423 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
424 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
427 if (tp->t_frextents_delta) in xfs_trans_apply_sb_deltas()
428 be64_add_cpu(&sbp->sb_frextents, tp->t_frextents_delta); in xfs_trans_apply_sb_deltas()
429 if (tp->t_res_frextents_delta) in xfs_trans_apply_sb_deltas()
430 be64_add_cpu(&sbp->sb_frextents, tp->t_res_frextents_delta); in xfs_trans_apply_sb_deltas()
432 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
433 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
436 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
437 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
440 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
441 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
444 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
445 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
448 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
449 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
452 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
453 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
456 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
457 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
460 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
461 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
465 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); in xfs_trans_apply_sb_deltas()
470 xfs_trans_log_buf(tp, bp, 0, sizeof(xfs_dsb_t) - 1); in xfs_trans_apply_sb_deltas()
476 xfs_trans_log_buf(tp, bp, offsetof(xfs_dsb_t, sb_icount), in xfs_trans_apply_sb_deltas()
543 struct xfs_trans *tp) in xfs_trans_unreserve_and_mod_sb() argument
545 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_unreserve_and_mod_sb()
546 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_unreserve_and_mod_sb()
554 if (tp->t_blk_res > 0) in xfs_trans_unreserve_and_mod_sb()
555 blkdelta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
556 if ((tp->t_fdblocks_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
558 (tp->t_flags & XFS_TRANS_SB_DIRTY))) in xfs_trans_unreserve_and_mod_sb()
559 blkdelta += tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
561 if (tp->t_rtx_res > 0) in xfs_trans_unreserve_and_mod_sb()
562 rtxdelta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
563 if ((tp->t_frextents_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
564 (tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
565 rtxdelta += tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
568 (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
569 idelta = tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
570 ifreedelta = tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
592 if (rtxdelta == 0 && !(tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
603 if (tp->t_dblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
604 error = xfs_sb_mod64(&mp->m_sb.sb_dblocks, tp->t_dblocks_delta); in xfs_trans_unreserve_and_mod_sb()
608 if (tp->t_agcount_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
609 error = xfs_sb_mod32(&mp->m_sb.sb_agcount, tp->t_agcount_delta); in xfs_trans_unreserve_and_mod_sb()
613 if (tp->t_imaxpct_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
614 error = xfs_sb_mod8(&mp->m_sb.sb_imax_pct, tp->t_imaxpct_delta); in xfs_trans_unreserve_and_mod_sb()
618 if (tp->t_rextsize_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
620 tp->t_rextsize_delta); in xfs_trans_unreserve_and_mod_sb()
624 if (tp->t_rbmblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
626 tp->t_rbmblocks_delta); in xfs_trans_unreserve_and_mod_sb()
630 if (tp->t_rblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
631 error = xfs_sb_mod64(&mp->m_sb.sb_rblocks, tp->t_rblocks_delta); in xfs_trans_unreserve_and_mod_sb()
635 if (tp->t_rextents_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
637 tp->t_rextents_delta); in xfs_trans_unreserve_and_mod_sb()
641 if (tp->t_rextslog_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
643 tp->t_rextslog_delta); in xfs_trans_unreserve_and_mod_sb()
651 if (tp->t_rextents_delta) in xfs_trans_unreserve_and_mod_sb()
652 xfs_sb_mod64(&mp->m_sb.sb_rextents, -tp->t_rextents_delta); in xfs_trans_unreserve_and_mod_sb()
654 if (tp->t_rblocks_delta) in xfs_trans_unreserve_and_mod_sb()
655 xfs_sb_mod64(&mp->m_sb.sb_rblocks, -tp->t_rblocks_delta); in xfs_trans_unreserve_and_mod_sb()
657 if (tp->t_rbmblocks_delta) in xfs_trans_unreserve_and_mod_sb()
658 xfs_sb_mod32(&mp->m_sb.sb_rbmblocks, -tp->t_rbmblocks_delta); in xfs_trans_unreserve_and_mod_sb()
660 if (tp->t_rextsize_delta) in xfs_trans_unreserve_and_mod_sb()
661 xfs_sb_mod32(&mp->m_sb.sb_rextsize, -tp->t_rextsize_delta); in xfs_trans_unreserve_and_mod_sb()
663 if (tp->t_rextsize_delta) in xfs_trans_unreserve_and_mod_sb()
664 xfs_sb_mod8(&mp->m_sb.sb_imax_pct, -tp->t_imaxpct_delta); in xfs_trans_unreserve_and_mod_sb()
666 if (tp->t_agcount_delta) in xfs_trans_unreserve_and_mod_sb()
667 xfs_sb_mod32(&mp->m_sb.sb_agcount, -tp->t_agcount_delta); in xfs_trans_unreserve_and_mod_sb()
669 if (tp->t_dblocks_delta) in xfs_trans_unreserve_and_mod_sb()
670 xfs_sb_mod64(&mp->m_sb.sb_dblocks, -tp->t_dblocks_delta); in xfs_trans_unreserve_and_mod_sb()
696 struct xfs_trans *tp, in xfs_trans_add_item() argument
701 ASSERT(lip->li_mountp == tp->t_mountp); in xfs_trans_add_item()
702 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
708 list_add_tail(&lidp->lid_trans, &tp->t_items); in xfs_trans_add_item()
738 struct xfs_trans *tp, in xfs_trans_free_items() argument
744 list_for_each_entry_safe(lidp, next, &tp->t_items, lid_trans) { in xfs_trans_free_items()
890 struct xfs_trans *tp, in __xfs_trans_commit() argument
893 struct xfs_mount *mp = tp->t_mountp; in __xfs_trans_commit()
896 int sync = tp->t_flags & XFS_TRANS_SYNC; in __xfs_trans_commit()
905 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in __xfs_trans_commit()
913 ASSERT(tp->t_ticket != NULL); in __xfs_trans_commit()
918 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in __xfs_trans_commit()
919 xfs_trans_apply_sb_deltas(tp); in __xfs_trans_commit()
920 xfs_trans_apply_dquot_deltas(tp); in __xfs_trans_commit()
922 xfs_log_commit_cil(mp, tp, &commit_lsn, regrant); in __xfs_trans_commit()
924 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in __xfs_trans_commit()
925 xfs_trans_free(tp); in __xfs_trans_commit()
941 xfs_trans_unreserve_and_mod_sb(tp); in __xfs_trans_commit()
948 xfs_trans_unreserve_and_mod_dquots(tp); in __xfs_trans_commit()
949 if (tp->t_ticket) { in __xfs_trans_commit()
950 commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, regrant); in __xfs_trans_commit()
954 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in __xfs_trans_commit()
955 xfs_trans_free_items(tp, NULLCOMMITLSN, !!error); in __xfs_trans_commit()
956 xfs_trans_free(tp); in __xfs_trans_commit()
964 struct xfs_trans *tp) in xfs_trans_commit() argument
966 return __xfs_trans_commit(tp, false); in xfs_trans_commit()
979 struct xfs_trans *tp) in xfs_trans_cancel() argument
981 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_cancel()
982 bool dirty = (tp->t_flags & XFS_TRANS_DIRTY); in xfs_trans_cancel()
997 list_for_each_entry(lidp, &tp->t_items, lid_trans) in xfs_trans_cancel()
1001 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
1002 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
1004 if (tp->t_ticket) in xfs_trans_cancel()
1005 xfs_log_done(mp, tp->t_ticket, NULL, false); in xfs_trans_cancel()
1008 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_cancel()
1010 xfs_trans_free_items(tp, NULLCOMMITLSN, dirty); in xfs_trans_cancel()
1011 xfs_trans_free(tp); in xfs_trans_cancel()