Lines Matching refs:tp

67 	struct xfs_trans	*tp)  in xfs_trans_free()  argument
69 xfs_extent_busy_sort(&tp->t_busy); in xfs_trans_free()
70 xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false); in xfs_trans_free()
72 trace_xfs_trans_free(tp, _RET_IP_); in xfs_trans_free()
73 xfs_trans_clear_context(tp); in xfs_trans_free()
74 if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT)) in xfs_trans_free()
75 sb_end_intwrite(tp->t_mountp->m_super); in xfs_trans_free()
76 xfs_trans_free_dqinfo(tp); in xfs_trans_free()
77 kmem_cache_free(xfs_trans_cache, tp); in xfs_trans_free()
90 struct xfs_trans *tp) in xfs_trans_dup() argument
94 trace_xfs_trans_dup(tp, _RET_IP_); in xfs_trans_dup()
102 ntp->t_mountp = tp->t_mountp; in xfs_trans_dup()
108 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_dup()
109 ASSERT(tp->t_ticket != NULL); in xfs_trans_dup()
112 (tp->t_flags & XFS_TRANS_RESERVE) | in xfs_trans_dup()
113 (tp->t_flags & XFS_TRANS_NO_WRITECOUNT) | in xfs_trans_dup()
114 (tp->t_flags & XFS_TRANS_RES_FDBLKS); in xfs_trans_dup()
116 tp->t_flags |= XFS_TRANS_NO_WRITECOUNT; in xfs_trans_dup()
117 ntp->t_ticket = xfs_log_ticket_get(tp->t_ticket); in xfs_trans_dup()
119 ASSERT(tp->t_blk_res >= tp->t_blk_res_used); in xfs_trans_dup()
120 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; in xfs_trans_dup()
121 tp->t_blk_res = tp->t_blk_res_used; in xfs_trans_dup()
123 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; in xfs_trans_dup()
124 tp->t_rtx_res = tp->t_rtx_res_used; in xfs_trans_dup()
126 xfs_trans_switch_context(tp, ntp); in xfs_trans_dup()
129 xfs_defer_move(ntp, tp); in xfs_trans_dup()
131 xfs_trans_dup_dqinfo(tp, ntp); in xfs_trans_dup()
151 struct xfs_trans *tp, in xfs_trans_reserve() argument
156 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_reserve()
158 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_reserve()
169 tp->t_blk_res += blocks; in xfs_trans_reserve()
178 ASSERT(tp->t_log_res == 0 || in xfs_trans_reserve()
179 tp->t_log_res == resp->tr_logres); in xfs_trans_reserve()
180 ASSERT(tp->t_log_count == 0 || in xfs_trans_reserve()
181 tp->t_log_count == resp->tr_logcount); in xfs_trans_reserve()
184 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
187 ASSERT(tp->t_ticket == NULL); in xfs_trans_reserve()
188 ASSERT(!(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in xfs_trans_reserve()
191 if (tp->t_ticket != NULL) { in xfs_trans_reserve()
193 error = xfs_log_regrant(mp, tp->t_ticket); in xfs_trans_reserve()
197 &tp->t_ticket, permanent); 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
262 tp = kmem_cache_zalloc(xfs_trans_cache, GFP_KERNEL | __GFP_NOFAIL); in xfs_trans_alloc()
265 xfs_trans_set_context(tp); in xfs_trans_alloc()
276 tp->t_magic = XFS_TRANS_HEADER_MAGIC; in xfs_trans_alloc()
277 tp->t_flags = flags; in xfs_trans_alloc()
278 tp->t_mountp = mp; in xfs_trans_alloc()
279 INIT_LIST_HEAD(&tp->t_items); in xfs_trans_alloc()
280 INIT_LIST_HEAD(&tp->t_busy); in xfs_trans_alloc()
281 INIT_LIST_HEAD(&tp->t_dfops); in xfs_trans_alloc()
282 tp->t_highest_agno = NULLAGNUMBER; in xfs_trans_alloc()
284 error = xfs_trans_reserve(tp, resp, blocks, rtextents); in xfs_trans_alloc()
286 xfs_trans_cancel(tp); in xfs_trans_alloc()
301 xfs_trans_cancel(tp); in xfs_trans_alloc()
305 trace_xfs_trans_alloc(tp, _RET_IP_); in xfs_trans_alloc()
307 *tpp = tp; in xfs_trans_alloc()
355 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
360 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_sb()
364 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
369 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
380 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
381 if (tp->t_blk_res_used > tp->t_blk_res) in xfs_trans_mod_sb()
383 } else if (delta > 0 && (tp->t_flags & XFS_TRANS_RES_FDBLKS)) { in xfs_trans_mod_sb()
394 UINT_MAX - tp->t_blk_res); in xfs_trans_mod_sb()
395 tp->t_blk_res += blkres_delta; in xfs_trans_mod_sb()
398 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
408 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
419 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
420 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
422 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
431 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
434 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
438 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
441 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
444 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
447 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
450 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
453 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
456 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
463 tp->t_flags |= flags; in xfs_trans_mod_sb()
476 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
482 bp = xfs_trans_getsb(tp); in xfs_trans_apply_sb_deltas()
488 if (!xfs_has_lazysbcount((tp->t_mountp))) { in xfs_trans_apply_sb_deltas()
489 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
490 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
491 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
492 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
493 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
494 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
495 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
496 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
513 if (tp->t_frextents_delta || tp->t_res_frextents_delta) { in xfs_trans_apply_sb_deltas()
514 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_apply_sb_deltas()
517 rtxdelta = tp->t_frextents_delta + tp->t_res_frextents_delta; in xfs_trans_apply_sb_deltas()
525 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
526 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
529 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
530 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
533 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
534 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
537 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
538 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
541 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
542 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
545 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
546 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
549 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
550 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
553 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
554 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
558 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); in xfs_trans_apply_sb_deltas()
563 xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1); in xfs_trans_apply_sb_deltas()
569 xfs_trans_log_buf(tp, bp, offsetof(struct xfs_dsb, sb_icount), in xfs_trans_apply_sb_deltas()
593 struct xfs_trans *tp) in xfs_trans_unreserve_and_mod_sb() argument
595 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_unreserve_and_mod_sb()
596 int64_t blkdelta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
597 int64_t rtxdelta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
614 ASSERT(tp->t_blk_res || tp->t_fdblocks_delta >= 0); in xfs_trans_unreserve_and_mod_sb()
615 if (xfs_has_lazysbcount(mp) || (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
616 blkdelta += tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
620 ASSERT(tp->t_rtx_res || tp->t_frextents_delta >= 0); in xfs_trans_unreserve_and_mod_sb()
621 if (tp->t_flags & XFS_TRANS_SB_DIRTY) { in xfs_trans_unreserve_and_mod_sb()
622 rtxdelta += tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
626 if (xfs_has_lazysbcount(mp) || (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
627 idelta = tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
628 ifreedelta = tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
645 if (!(tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
650 mp->m_sb.sb_fdblocks += tp->t_fdblocks_delta + tp->t_res_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
659 mp->m_sb.sb_dblocks += tp->t_dblocks_delta; in xfs_trans_unreserve_and_mod_sb()
660 mp->m_sb.sb_agcount += tp->t_agcount_delta; in xfs_trans_unreserve_and_mod_sb()
661 mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_unreserve_and_mod_sb()
662 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()
667 mp->m_sb.sb_rbmblocks += tp->t_rbmblocks_delta; in xfs_trans_unreserve_and_mod_sb()
668 mp->m_sb.sb_rblocks += tp->t_rblocks_delta; in xfs_trans_unreserve_and_mod_sb()
669 mp->m_sb.sb_rextents += tp->t_rextents_delta; in xfs_trans_unreserve_and_mod_sb()
670 mp->m_sb.sb_rextslog += tp->t_rextslog_delta; in xfs_trans_unreserve_and_mod_sb()
684 struct xfs_trans *tp, in xfs_trans_add_item() argument
687 ASSERT(lip->li_log == tp->t_mountp->m_log); in xfs_trans_add_item()
688 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
692 list_add_tail(&lip->li_trans, &tp->t_items); in xfs_trans_add_item()
693 trace_xfs_trans_add_item(tp, _RET_IP_); in xfs_trans_add_item()
712 struct xfs_trans *tp, in xfs_trans_free_items() argument
717 trace_xfs_trans_free_items(tp, _RET_IP_); in xfs_trans_free_items()
719 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { in xfs_trans_free_items()
779 struct xfs_trans *tp) in xfs_trans_run_precommits() argument
781 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_run_precommits()
790 list_sort(NULL, &tp->t_items, xfs_trans_precommit_sort); in xfs_trans_run_precommits()
798 list_for_each_entry_safe(lip, n, &tp->t_items, li_trans) { in xfs_trans_run_precommits()
802 error = lip->li_ops->iop_precommit(tp, lip); in xfs_trans_run_precommits()
826 struct xfs_trans *tp, in __xfs_trans_commit() argument
829 struct xfs_mount *mp = tp->t_mountp; in __xfs_trans_commit()
833 int sync = tp->t_flags & XFS_TRANS_SYNC; in __xfs_trans_commit()
835 trace_xfs_trans_commit(tp, _RET_IP_); in __xfs_trans_commit()
837 error = xfs_trans_run_precommits(tp); in __xfs_trans_commit()
839 if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) in __xfs_trans_commit()
840 xfs_defer_cancel(tp); in __xfs_trans_commit()
848 WARN_ON_ONCE(!list_empty(&tp->t_dfops) && in __xfs_trans_commit()
849 !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in __xfs_trans_commit()
850 if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) { in __xfs_trans_commit()
851 error = xfs_defer_finish_noroll(&tp); in __xfs_trans_commit()
856 error = xfs_trans_run_precommits(tp); in __xfs_trans_commit()
868 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in __xfs_trans_commit()
882 ASSERT(tp->t_ticket != NULL); in __xfs_trans_commit()
887 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in __xfs_trans_commit()
888 xfs_trans_apply_sb_deltas(tp); in __xfs_trans_commit()
889 xfs_trans_apply_dquot_deltas(tp); in __xfs_trans_commit()
891 xlog_cil_commit(log, tp, &commit_seq, regrant); in __xfs_trans_commit()
893 xfs_trans_free(tp); in __xfs_trans_commit()
909 xfs_trans_unreserve_and_mod_sb(tp); in __xfs_trans_commit()
916 xfs_trans_unreserve_and_mod_dquots(tp); in __xfs_trans_commit()
917 if (tp->t_ticket) { in __xfs_trans_commit()
919 xfs_log_ticket_regrant(log, tp->t_ticket); in __xfs_trans_commit()
921 xfs_log_ticket_ungrant(log, tp->t_ticket); in __xfs_trans_commit()
922 tp->t_ticket = NULL; in __xfs_trans_commit()
924 xfs_trans_free_items(tp, !!error); in __xfs_trans_commit()
925 xfs_trans_free(tp); in __xfs_trans_commit()
933 struct xfs_trans *tp) in xfs_trans_commit() argument
935 return __xfs_trans_commit(tp, false); in xfs_trans_commit()
956 struct xfs_trans *tp) in xfs_trans_cancel() argument
958 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_cancel()
960 bool dirty = (tp->t_flags & XFS_TRANS_DIRTY); in xfs_trans_cancel()
962 trace_xfs_trans_cancel(tp, _RET_IP_); in xfs_trans_cancel()
970 if (!list_empty(&tp->t_dfops)) { in xfs_trans_cancel()
971 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_cancel()
973 xfs_defer_cancel(tp); in xfs_trans_cancel()
991 list_for_each_entry(lip, &tp->t_items, li_trans) in xfs_trans_cancel()
995 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
996 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
998 if (tp->t_ticket) { in xfs_trans_cancel()
999 xfs_log_ticket_ungrant(log, tp->t_ticket); in xfs_trans_cancel()
1000 tp->t_ticket = NULL; in xfs_trans_cancel()
1003 xfs_trans_free_items(tp, dirty); in xfs_trans_cancel()
1004 xfs_trans_free(tp); in xfs_trans_cancel()
1071 struct xfs_trans *tp; in xfs_trans_alloc_inode() local
1079 force ? XFS_TRANS_RESERVE : 0, &tp); in xfs_trans_alloc_inode()
1084 xfs_trans_ijoin(tp, ip, 0); in xfs_trans_alloc_inode()
1093 error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, force); in xfs_trans_alloc_inode()
1095 xfs_trans_cancel(tp); in xfs_trans_alloc_inode()
1104 *tpp = tp; in xfs_trans_alloc_inode()
1108 xfs_trans_cancel(tp); in xfs_trans_alloc_inode()
1124 struct xfs_trans *tp, in xfs_trans_reserve_more() argument
1130 return xfs_trans_reserve(tp, &resv, blocks, rtextents); in xfs_trans_reserve_more()
1139 struct xfs_trans *tp, in xfs_trans_reserve_more_inode() argument
1152 error = xfs_trans_reserve(tp, &resv, dblocks, rtx); in xfs_trans_reserve_more_inode()
1159 if (tp->t_flags & XFS_TRANS_RESERVE) in xfs_trans_reserve_more_inode()
1162 error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, in xfs_trans_reserve_more_inode()
1169 tp->t_blk_res -= dblocks; in xfs_trans_reserve_more_inode()
1171 tp->t_rtx_res -= rtx; in xfs_trans_reserve_more_inode()
1189 struct xfs_trans *tp; in xfs_trans_alloc_icreate() local
1194 error = xfs_trans_alloc(mp, resv, dblocks, 0, 0, &tp); in xfs_trans_alloc_icreate()
1198 error = xfs_trans_reserve_quota_icreate(tp, udqp, gdqp, pdqp, dblocks); in xfs_trans_alloc_icreate()
1200 xfs_trans_cancel(tp); in xfs_trans_alloc_icreate()
1206 xfs_trans_cancel(tp); in xfs_trans_alloc_icreate()
1210 *tpp = tp; in xfs_trans_alloc_icreate()
1232 struct xfs_trans *tp; in xfs_trans_alloc_ichange() local
1241 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); in xfs_trans_alloc_ichange()
1246 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_trans_alloc_ichange()
1276 error = xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp, in xfs_trans_alloc_ichange()
1280 xfs_trans_cancel(tp); in xfs_trans_alloc_ichange()
1289 *tpp = tp; in xfs_trans_alloc_ichange()
1293 xfs_trans_cancel(tp); in xfs_trans_alloc_ichange()
1319 struct xfs_trans *tp; in xfs_trans_alloc_dir() local
1328 error = xfs_trans_alloc(mp, resv, resblks, 0, 0, &tp); in xfs_trans_alloc_dir()
1332 error = xfs_trans_alloc(mp, resv, resblks, 0, 0, &tp); in xfs_trans_alloc_dir()
1339 xfs_trans_ijoin(tp, dp, 0); in xfs_trans_alloc_dir()
1340 xfs_trans_ijoin(tp, ip, 0); in xfs_trans_alloc_dir()
1359 error = xfs_trans_reserve_quota_nblks(tp, dp, resblks, 0, false); in xfs_trans_alloc_dir()
1362 xfs_trans_cancel(tp); in xfs_trans_alloc_dir()
1379 *tpp = tp; in xfs_trans_alloc_dir()
1384 xfs_trans_cancel(tp); in xfs_trans_alloc_dir()