Lines Matching refs:tp

64 	struct xfs_trans	*tp)  in xfs_trans_free()  argument
66 xfs_extent_busy_sort(&tp->t_busy); in xfs_trans_free()
67 xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false); in xfs_trans_free()
69 trace_xfs_trans_free(tp, _RET_IP_); in xfs_trans_free()
70 atomic_dec(&tp->t_mountp->m_active_trans); in xfs_trans_free()
71 if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT)) in xfs_trans_free()
72 sb_end_intwrite(tp->t_mountp->m_super); in xfs_trans_free()
73 xfs_trans_free_dqinfo(tp); in xfs_trans_free()
74 kmem_zone_free(xfs_trans_zone, tp); in xfs_trans_free()
87 struct xfs_trans *tp) in xfs_trans_dup() argument
91 trace_xfs_trans_dup(tp, _RET_IP_); in xfs_trans_dup()
99 ntp->t_mountp = tp->t_mountp; in xfs_trans_dup()
105 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_dup()
106 ASSERT(tp->t_ticket != NULL); in xfs_trans_dup()
109 (tp->t_flags & XFS_TRANS_RESERVE) | in xfs_trans_dup()
110 (tp->t_flags & XFS_TRANS_NO_WRITECOUNT); in xfs_trans_dup()
112 tp->t_flags |= XFS_TRANS_NO_WRITECOUNT; in xfs_trans_dup()
113 ntp->t_ticket = xfs_log_ticket_get(tp->t_ticket); in xfs_trans_dup()
115 ASSERT(tp->t_blk_res >= tp->t_blk_res_used); in xfs_trans_dup()
116 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; in xfs_trans_dup()
117 tp->t_blk_res = tp->t_blk_res_used; in xfs_trans_dup()
119 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; in xfs_trans_dup()
120 tp->t_rtx_res = tp->t_rtx_res_used; in xfs_trans_dup()
121 ntp->t_pflags = tp->t_pflags; in xfs_trans_dup()
124 xfs_defer_move(ntp, tp); in xfs_trans_dup()
126 xfs_trans_dup_dqinfo(tp, ntp); in xfs_trans_dup()
128 atomic_inc(&tp->t_mountp->m_active_trans); in xfs_trans_dup()
148 struct xfs_trans *tp, in xfs_trans_reserve() argument
154 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_reserve()
157 current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); in xfs_trans_reserve()
165 error = xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), rsvd); in xfs_trans_reserve()
167 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); in xfs_trans_reserve()
170 tp->t_blk_res += blocks; in xfs_trans_reserve()
179 ASSERT(tp->t_log_res == 0 || in xfs_trans_reserve()
180 tp->t_log_res == resp->tr_logres); in xfs_trans_reserve()
181 ASSERT(tp->t_log_count == 0 || in xfs_trans_reserve()
182 tp->t_log_count == resp->tr_logcount); in xfs_trans_reserve()
185 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
188 ASSERT(tp->t_ticket == NULL); in xfs_trans_reserve()
189 ASSERT(!(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in xfs_trans_reserve()
192 if (tp->t_ticket != NULL) { in xfs_trans_reserve()
194 error = xfs_log_regrant(tp->t_mountp, tp->t_ticket); in xfs_trans_reserve()
196 error = xfs_log_reserve(tp->t_mountp, in xfs_trans_reserve()
199 &tp->t_ticket, XFS_TRANSACTION, in xfs_trans_reserve()
206 tp->t_log_res = resp->tr_logres; in xfs_trans_reserve()
207 tp->t_log_count = resp->tr_logcount; in xfs_trans_reserve()
216 error = xfs_mod_frextents(tp->t_mountp, -((int64_t)rtextents)); in xfs_trans_reserve()
221 tp->t_rtx_res += rtextents; in xfs_trans_reserve()
232 xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, false); in xfs_trans_reserve()
233 tp->t_ticket = NULL; in xfs_trans_reserve()
234 tp->t_log_res = 0; in xfs_trans_reserve()
235 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
240 xfs_mod_fdblocks(tp->t_mountp, (int64_t)blocks, rsvd); in xfs_trans_reserve()
241 tp->t_blk_res = 0; in xfs_trans_reserve()
244 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); in xfs_trans_reserve()
258 struct xfs_trans *tp; in xfs_trans_alloc() local
266 tp = kmem_zone_zalloc(xfs_trans_zone, 0); in xfs_trans_alloc()
278 tp->t_magic = XFS_TRANS_HEADER_MAGIC; in xfs_trans_alloc()
279 tp->t_flags = flags; in xfs_trans_alloc()
280 tp->t_mountp = mp; in xfs_trans_alloc()
281 INIT_LIST_HEAD(&tp->t_items); in xfs_trans_alloc()
282 INIT_LIST_HEAD(&tp->t_busy); in xfs_trans_alloc()
283 INIT_LIST_HEAD(&tp->t_dfops); in xfs_trans_alloc()
284 tp->t_firstblock = NULLFSBLOCK; in xfs_trans_alloc()
286 error = xfs_trans_reserve(tp, resp, blocks, rtextents); in xfs_trans_alloc()
288 xfs_trans_cancel(tp); in xfs_trans_alloc()
292 trace_xfs_trans_alloc(tp, _RET_IP_); in xfs_trans_alloc()
294 *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()
367 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
377 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
388 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
389 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
391 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
400 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
404 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
408 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
411 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
414 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
417 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
420 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
423 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
426 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
433 tp->t_flags |= flags; in xfs_trans_mod_sb()
446 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
452 bp = xfs_trans_getsb(tp, tp->t_mountp); in xfs_trans_apply_sb_deltas()
458 ASSERT((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == in xfs_trans_apply_sb_deltas()
459 (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + in xfs_trans_apply_sb_deltas()
460 tp->t_ag_btree_delta)); in xfs_trans_apply_sb_deltas()
465 if (!xfs_sb_version_haslazysbcount(&(tp->t_mountp->m_sb))) { in xfs_trans_apply_sb_deltas()
466 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
467 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
468 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
469 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
470 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
471 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
472 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
473 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
476 if (tp->t_frextents_delta) in xfs_trans_apply_sb_deltas()
477 be64_add_cpu(&sbp->sb_frextents, tp->t_frextents_delta); in xfs_trans_apply_sb_deltas()
478 if (tp->t_res_frextents_delta) in xfs_trans_apply_sb_deltas()
479 be64_add_cpu(&sbp->sb_frextents, tp->t_res_frextents_delta); in xfs_trans_apply_sb_deltas()
481 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
482 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
485 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
486 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
489 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
490 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
493 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
494 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
497 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
498 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
501 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
502 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
505 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
506 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
509 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
510 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
514 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); in xfs_trans_apply_sb_deltas()
519 xfs_trans_log_buf(tp, bp, 0, sizeof(xfs_dsb_t) - 1); in xfs_trans_apply_sb_deltas()
525 xfs_trans_log_buf(tp, bp, offsetof(xfs_dsb_t, sb_icount), in xfs_trans_apply_sb_deltas()
592 struct xfs_trans *tp) in xfs_trans_unreserve_and_mod_sb() argument
594 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_unreserve_and_mod_sb()
595 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_unreserve_and_mod_sb()
603 if (tp->t_blk_res > 0) in xfs_trans_unreserve_and_mod_sb()
604 blkdelta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
605 if ((tp->t_fdblocks_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
607 (tp->t_flags & XFS_TRANS_SB_DIRTY))) in xfs_trans_unreserve_and_mod_sb()
608 blkdelta += tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
610 if (tp->t_rtx_res > 0) in xfs_trans_unreserve_and_mod_sb()
611 rtxdelta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
612 if ((tp->t_frextents_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
613 (tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
614 rtxdelta += tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
617 (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
618 idelta = tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
619 ifreedelta = tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
641 if (rtxdelta == 0 && !(tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
652 if (tp->t_dblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
653 error = xfs_sb_mod64(&mp->m_sb.sb_dblocks, tp->t_dblocks_delta); in xfs_trans_unreserve_and_mod_sb()
657 if (tp->t_agcount_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
658 error = xfs_sb_mod32(&mp->m_sb.sb_agcount, tp->t_agcount_delta); in xfs_trans_unreserve_and_mod_sb()
662 if (tp->t_imaxpct_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
663 error = xfs_sb_mod8(&mp->m_sb.sb_imax_pct, tp->t_imaxpct_delta); in xfs_trans_unreserve_and_mod_sb()
667 if (tp->t_rextsize_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
669 tp->t_rextsize_delta); in xfs_trans_unreserve_and_mod_sb()
673 if (tp->t_rbmblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
675 tp->t_rbmblocks_delta); in xfs_trans_unreserve_and_mod_sb()
679 if (tp->t_rblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
680 error = xfs_sb_mod64(&mp->m_sb.sb_rblocks, tp->t_rblocks_delta); in xfs_trans_unreserve_and_mod_sb()
684 if (tp->t_rextents_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
686 tp->t_rextents_delta); in xfs_trans_unreserve_and_mod_sb()
690 if (tp->t_rextslog_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
692 tp->t_rextslog_delta); in xfs_trans_unreserve_and_mod_sb()
700 if (tp->t_rextents_delta) in xfs_trans_unreserve_and_mod_sb()
701 xfs_sb_mod64(&mp->m_sb.sb_rextents, -tp->t_rextents_delta); in xfs_trans_unreserve_and_mod_sb()
703 if (tp->t_rblocks_delta) in xfs_trans_unreserve_and_mod_sb()
704 xfs_sb_mod64(&mp->m_sb.sb_rblocks, -tp->t_rblocks_delta); in xfs_trans_unreserve_and_mod_sb()
706 if (tp->t_rbmblocks_delta) in xfs_trans_unreserve_and_mod_sb()
707 xfs_sb_mod32(&mp->m_sb.sb_rbmblocks, -tp->t_rbmblocks_delta); in xfs_trans_unreserve_and_mod_sb()
709 if (tp->t_rextsize_delta) in xfs_trans_unreserve_and_mod_sb()
710 xfs_sb_mod32(&mp->m_sb.sb_rextsize, -tp->t_rextsize_delta); in xfs_trans_unreserve_and_mod_sb()
712 if (tp->t_rextsize_delta) in xfs_trans_unreserve_and_mod_sb()
713 xfs_sb_mod8(&mp->m_sb.sb_imax_pct, -tp->t_imaxpct_delta); in xfs_trans_unreserve_and_mod_sb()
715 if (tp->t_agcount_delta) in xfs_trans_unreserve_and_mod_sb()
716 xfs_sb_mod32(&mp->m_sb.sb_agcount, -tp->t_agcount_delta); in xfs_trans_unreserve_and_mod_sb()
718 if (tp->t_dblocks_delta) in xfs_trans_unreserve_and_mod_sb()
719 xfs_sb_mod64(&mp->m_sb.sb_dblocks, -tp->t_dblocks_delta); in xfs_trans_unreserve_and_mod_sb()
741 struct xfs_trans *tp, in xfs_trans_add_item() argument
744 ASSERT(lip->li_mountp == tp->t_mountp); in xfs_trans_add_item()
745 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
749 list_add_tail(&lip->li_trans, &tp->t_items); in xfs_trans_add_item()
750 trace_xfs_trans_add_item(tp, _RET_IP_); in xfs_trans_add_item()
769 struct xfs_trans *tp, in xfs_trans_free_items() argument
774 trace_xfs_trans_free_items(tp, _RET_IP_); in xfs_trans_free_items()
776 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { in xfs_trans_free_items()
928 struct xfs_trans *tp, in __xfs_trans_commit() argument
931 struct xfs_mount *mp = tp->t_mountp; in __xfs_trans_commit()
934 int sync = tp->t_flags & XFS_TRANS_SYNC; in __xfs_trans_commit()
936 trace_xfs_trans_commit(tp, _RET_IP_); in __xfs_trans_commit()
942 WARN_ON_ONCE(!list_empty(&tp->t_dfops) && in __xfs_trans_commit()
943 !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in __xfs_trans_commit()
944 if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) { in __xfs_trans_commit()
945 error = xfs_defer_finish_noroll(&tp); in __xfs_trans_commit()
957 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in __xfs_trans_commit()
965 ASSERT(tp->t_ticket != NULL); in __xfs_trans_commit()
970 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in __xfs_trans_commit()
971 xfs_trans_apply_sb_deltas(tp); in __xfs_trans_commit()
972 xfs_trans_apply_dquot_deltas(tp); in __xfs_trans_commit()
974 xfs_log_commit_cil(mp, tp, &commit_lsn, regrant); in __xfs_trans_commit()
976 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); in __xfs_trans_commit()
977 xfs_trans_free(tp); in __xfs_trans_commit()
993 xfs_trans_unreserve_and_mod_sb(tp); in __xfs_trans_commit()
1000 xfs_trans_unreserve_and_mod_dquots(tp); in __xfs_trans_commit()
1001 if (tp->t_ticket) { in __xfs_trans_commit()
1002 commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, regrant); in __xfs_trans_commit()
1005 tp->t_ticket = NULL; in __xfs_trans_commit()
1007 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); in __xfs_trans_commit()
1008 xfs_trans_free_items(tp, !!error); in __xfs_trans_commit()
1009 xfs_trans_free(tp); in __xfs_trans_commit()
1017 struct xfs_trans *tp) in xfs_trans_commit() argument
1019 return __xfs_trans_commit(tp, false); in xfs_trans_commit()
1032 struct xfs_trans *tp) in xfs_trans_cancel() argument
1034 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_cancel()
1035 bool dirty = (tp->t_flags & XFS_TRANS_DIRTY); in xfs_trans_cancel()
1037 trace_xfs_trans_cancel(tp, _RET_IP_); in xfs_trans_cancel()
1039 if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) in xfs_trans_cancel()
1040 xfs_defer_cancel(tp); in xfs_trans_cancel()
1055 list_for_each_entry(lip, &tp->t_items, li_trans) in xfs_trans_cancel()
1059 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
1060 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
1062 if (tp->t_ticket) { in xfs_trans_cancel()
1063 xfs_log_done(mp, tp->t_ticket, NULL, false); in xfs_trans_cancel()
1064 tp->t_ticket = NULL; in xfs_trans_cancel()
1068 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); in xfs_trans_cancel()
1070 xfs_trans_free_items(tp, dirty); in xfs_trans_cancel()
1071 xfs_trans_free(tp); in xfs_trans_cancel()