Lines Matching refs:tp

66 	struct xfs_trans	*tp)  in xfs_trans_free()  argument
68 xfs_extent_busy_sort(&tp->t_busy); in xfs_trans_free()
69 xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false); in xfs_trans_free()
71 trace_xfs_trans_free(tp, _RET_IP_); in xfs_trans_free()
72 xfs_trans_clear_context(tp); in xfs_trans_free()
73 if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT)) in xfs_trans_free()
74 sb_end_intwrite(tp->t_mountp->m_super); in xfs_trans_free()
75 xfs_trans_free_dqinfo(tp); in xfs_trans_free()
76 kmem_cache_free(xfs_trans_cache, tp); in xfs_trans_free()
89 struct xfs_trans *tp) in xfs_trans_dup() argument
93 trace_xfs_trans_dup(tp, _RET_IP_); in xfs_trans_dup()
101 ntp->t_mountp = tp->t_mountp; in xfs_trans_dup()
107 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_dup()
108 ASSERT(tp->t_ticket != NULL); in xfs_trans_dup()
111 (tp->t_flags & XFS_TRANS_RESERVE) | in xfs_trans_dup()
112 (tp->t_flags & XFS_TRANS_NO_WRITECOUNT) | in xfs_trans_dup()
113 (tp->t_flags & XFS_TRANS_RES_FDBLKS); in xfs_trans_dup()
115 tp->t_flags |= XFS_TRANS_NO_WRITECOUNT; in xfs_trans_dup()
116 ntp->t_ticket = xfs_log_ticket_get(tp->t_ticket); in xfs_trans_dup()
118 ASSERT(tp->t_blk_res >= tp->t_blk_res_used); in xfs_trans_dup()
119 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; in xfs_trans_dup()
120 tp->t_blk_res = tp->t_blk_res_used; in xfs_trans_dup()
122 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; in xfs_trans_dup()
123 tp->t_rtx_res = tp->t_rtx_res_used; in xfs_trans_dup()
125 xfs_trans_switch_context(tp, ntp); in xfs_trans_dup()
128 xfs_defer_move(ntp, tp); in xfs_trans_dup()
130 xfs_trans_dup_dqinfo(tp, ntp); in xfs_trans_dup()
150 struct xfs_trans *tp, in xfs_trans_reserve() argument
155 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_reserve()
157 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_reserve()
168 tp->t_blk_res += blocks; in xfs_trans_reserve()
177 ASSERT(tp->t_log_res == 0 || in xfs_trans_reserve()
178 tp->t_log_res == resp->tr_logres); in xfs_trans_reserve()
179 ASSERT(tp->t_log_count == 0 || in xfs_trans_reserve()
180 tp->t_log_count == resp->tr_logcount); in xfs_trans_reserve()
183 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
186 ASSERT(tp->t_ticket == NULL); in xfs_trans_reserve()
187 ASSERT(!(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in xfs_trans_reserve()
190 if (tp->t_ticket != NULL) { in xfs_trans_reserve()
192 error = xfs_log_regrant(mp, tp->t_ticket); in xfs_trans_reserve()
196 &tp->t_ticket, permanent); in xfs_trans_reserve()
202 tp->t_log_res = resp->tr_logres; in xfs_trans_reserve()
203 tp->t_log_count = resp->tr_logcount; in xfs_trans_reserve()
217 tp->t_rtx_res += rtextents; in xfs_trans_reserve()
228 xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); in xfs_trans_reserve()
229 tp->t_ticket = NULL; in xfs_trans_reserve()
230 tp->t_log_res = 0; in xfs_trans_reserve()
231 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
237 tp->t_blk_res = 0; in xfs_trans_reserve()
251 struct xfs_trans *tp; in xfs_trans_alloc() local
261 tp = kmem_cache_zalloc(xfs_trans_cache, GFP_KERNEL | __GFP_NOFAIL); in xfs_trans_alloc()
264 xfs_trans_set_context(tp); in xfs_trans_alloc()
275 tp->t_magic = XFS_TRANS_HEADER_MAGIC; in xfs_trans_alloc()
276 tp->t_flags = flags; in xfs_trans_alloc()
277 tp->t_mountp = mp; in xfs_trans_alloc()
278 INIT_LIST_HEAD(&tp->t_items); in xfs_trans_alloc()
279 INIT_LIST_HEAD(&tp->t_busy); in xfs_trans_alloc()
280 INIT_LIST_HEAD(&tp->t_dfops); in xfs_trans_alloc()
281 tp->t_highest_agno = NULLAGNUMBER; in xfs_trans_alloc()
283 error = xfs_trans_reserve(tp, resp, blocks, rtextents); in xfs_trans_alloc()
285 xfs_trans_cancel(tp); in xfs_trans_alloc()
300 xfs_trans_cancel(tp); in xfs_trans_alloc()
304 trace_xfs_trans_alloc(tp, _RET_IP_); in xfs_trans_alloc()
306 *tpp = tp; in xfs_trans_alloc()
354 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
359 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_sb()
363 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
368 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
379 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
380 if (tp->t_blk_res_used > tp->t_blk_res) in xfs_trans_mod_sb()
382 } else if (delta > 0 && (tp->t_flags & XFS_TRANS_RES_FDBLKS)) { in xfs_trans_mod_sb()
393 UINT_MAX - tp->t_blk_res); in xfs_trans_mod_sb()
394 tp->t_blk_res += blkres_delta; in xfs_trans_mod_sb()
397 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
407 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
418 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
419 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
421 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
430 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
433 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
437 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
440 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
443 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
446 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
449 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
452 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
455 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
462 tp->t_flags |= flags; in xfs_trans_mod_sb()
475 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
481 bp = xfs_trans_getsb(tp); in xfs_trans_apply_sb_deltas()
487 if (!xfs_has_lazysbcount((tp->t_mountp))) { in xfs_trans_apply_sb_deltas()
488 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
489 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
490 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
491 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
492 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
493 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
494 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
495 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
512 if (tp->t_frextents_delta || tp->t_res_frextents_delta) { in xfs_trans_apply_sb_deltas()
513 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_apply_sb_deltas()
516 rtxdelta = tp->t_frextents_delta + tp->t_res_frextents_delta; in xfs_trans_apply_sb_deltas()
524 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
525 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
528 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
529 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
532 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
533 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
536 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
537 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
540 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
541 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
544 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
545 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
548 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
549 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
552 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
553 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
557 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); in xfs_trans_apply_sb_deltas()
562 xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1); in xfs_trans_apply_sb_deltas()
568 xfs_trans_log_buf(tp, bp, offsetof(struct xfs_dsb, 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()
640 if (!(tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
645 mp->m_sb.sb_fdblocks += tp->t_fdblocks_delta + tp->t_res_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
654 mp->m_sb.sb_dblocks += tp->t_dblocks_delta; in xfs_trans_unreserve_and_mod_sb()
655 mp->m_sb.sb_agcount += tp->t_agcount_delta; in xfs_trans_unreserve_and_mod_sb()
656 mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_unreserve_and_mod_sb()
657 mp->m_sb.sb_rextsize += tp->t_rextsize_delta; in xfs_trans_unreserve_and_mod_sb()
658 mp->m_sb.sb_rbmblocks += tp->t_rbmblocks_delta; in xfs_trans_unreserve_and_mod_sb()
659 mp->m_sb.sb_rblocks += tp->t_rblocks_delta; in xfs_trans_unreserve_and_mod_sb()
660 mp->m_sb.sb_rextents += tp->t_rextents_delta; in xfs_trans_unreserve_and_mod_sb()
661 mp->m_sb.sb_rextslog += tp->t_rextslog_delta; in xfs_trans_unreserve_and_mod_sb()
676 struct xfs_trans *tp, in xfs_trans_add_item() argument
679 ASSERT(lip->li_log == tp->t_mountp->m_log); in xfs_trans_add_item()
680 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
684 list_add_tail(&lip->li_trans, &tp->t_items); in xfs_trans_add_item()
685 trace_xfs_trans_add_item(tp, _RET_IP_); in xfs_trans_add_item()
704 struct xfs_trans *tp, in xfs_trans_free_items() argument
709 trace_xfs_trans_free_items(tp, _RET_IP_); in xfs_trans_free_items()
711 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { in xfs_trans_free_items()
900 struct xfs_trans *tp) in xfs_trans_run_precommits() argument
902 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_run_precommits()
911 list_sort(NULL, &tp->t_items, xfs_trans_precommit_sort); in xfs_trans_run_precommits()
919 list_for_each_entry_safe(lip, n, &tp->t_items, li_trans) { in xfs_trans_run_precommits()
923 error = lip->li_ops->iop_precommit(tp, lip); in xfs_trans_run_precommits()
947 struct xfs_trans *tp, in __xfs_trans_commit() argument
950 struct xfs_mount *mp = tp->t_mountp; in __xfs_trans_commit()
954 int sync = tp->t_flags & XFS_TRANS_SYNC; in __xfs_trans_commit()
956 trace_xfs_trans_commit(tp, _RET_IP_); in __xfs_trans_commit()
958 error = xfs_trans_run_precommits(tp); in __xfs_trans_commit()
960 if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) in __xfs_trans_commit()
961 xfs_defer_cancel(tp); in __xfs_trans_commit()
969 WARN_ON_ONCE(!list_empty(&tp->t_dfops) && in __xfs_trans_commit()
970 !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in __xfs_trans_commit()
971 if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) { in __xfs_trans_commit()
972 error = xfs_defer_finish_noroll(&tp); in __xfs_trans_commit()
977 error = xfs_trans_run_precommits(tp); in __xfs_trans_commit()
989 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in __xfs_trans_commit()
1003 ASSERT(tp->t_ticket != NULL); in __xfs_trans_commit()
1008 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in __xfs_trans_commit()
1009 xfs_trans_apply_sb_deltas(tp); in __xfs_trans_commit()
1010 xfs_trans_apply_dquot_deltas(tp); in __xfs_trans_commit()
1012 xlog_cil_commit(log, tp, &commit_seq, regrant); in __xfs_trans_commit()
1014 xfs_trans_free(tp); in __xfs_trans_commit()
1030 xfs_trans_unreserve_and_mod_sb(tp); in __xfs_trans_commit()
1037 xfs_trans_unreserve_and_mod_dquots(tp); in __xfs_trans_commit()
1038 if (tp->t_ticket) { in __xfs_trans_commit()
1040 xfs_log_ticket_regrant(log, tp->t_ticket); in __xfs_trans_commit()
1042 xfs_log_ticket_ungrant(log, tp->t_ticket); in __xfs_trans_commit()
1043 tp->t_ticket = NULL; in __xfs_trans_commit()
1045 xfs_trans_free_items(tp, !!error); in __xfs_trans_commit()
1046 xfs_trans_free(tp); in __xfs_trans_commit()
1054 struct xfs_trans *tp) in xfs_trans_commit() argument
1056 return __xfs_trans_commit(tp, false); in xfs_trans_commit()
1077 struct xfs_trans *tp) in xfs_trans_cancel() argument
1079 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_cancel()
1081 bool dirty = (tp->t_flags & XFS_TRANS_DIRTY); in xfs_trans_cancel()
1083 trace_xfs_trans_cancel(tp, _RET_IP_); in xfs_trans_cancel()
1091 if (!list_empty(&tp->t_dfops)) { in xfs_trans_cancel()
1092 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_cancel()
1094 xfs_defer_cancel(tp); in xfs_trans_cancel()
1112 list_for_each_entry(lip, &tp->t_items, li_trans) in xfs_trans_cancel()
1116 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
1117 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
1119 if (tp->t_ticket) { in xfs_trans_cancel()
1120 xfs_log_ticket_ungrant(log, tp->t_ticket); in xfs_trans_cancel()
1121 tp->t_ticket = NULL; in xfs_trans_cancel()
1124 xfs_trans_free_items(tp, dirty); in xfs_trans_cancel()
1125 xfs_trans_free(tp); in xfs_trans_cancel()
1192 struct xfs_trans *tp; in xfs_trans_alloc_inode() local
1200 force ? XFS_TRANS_RESERVE : 0, &tp); in xfs_trans_alloc_inode()
1205 xfs_trans_ijoin(tp, ip, 0); in xfs_trans_alloc_inode()
1214 error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, force); in xfs_trans_alloc_inode()
1216 xfs_trans_cancel(tp); in xfs_trans_alloc_inode()
1225 *tpp = tp; in xfs_trans_alloc_inode()
1229 xfs_trans_cancel(tp); in xfs_trans_alloc_inode()
1248 struct xfs_trans *tp; in xfs_trans_alloc_icreate() local
1253 error = xfs_trans_alloc(mp, resv, dblocks, 0, 0, &tp); in xfs_trans_alloc_icreate()
1257 error = xfs_trans_reserve_quota_icreate(tp, udqp, gdqp, pdqp, dblocks); in xfs_trans_alloc_icreate()
1259 xfs_trans_cancel(tp); in xfs_trans_alloc_icreate()
1265 xfs_trans_cancel(tp); in xfs_trans_alloc_icreate()
1269 *tpp = tp; in xfs_trans_alloc_icreate()
1291 struct xfs_trans *tp; in xfs_trans_alloc_ichange() local
1300 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); in xfs_trans_alloc_ichange()
1305 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_trans_alloc_ichange()
1335 error = xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp, in xfs_trans_alloc_ichange()
1339 xfs_trans_cancel(tp); in xfs_trans_alloc_ichange()
1348 *tpp = tp; in xfs_trans_alloc_ichange()
1352 xfs_trans_cancel(tp); in xfs_trans_alloc_ichange()
1376 struct xfs_trans *tp; in xfs_trans_alloc_dir() local
1385 error = xfs_trans_alloc(mp, resv, resblks, 0, 0, &tp); in xfs_trans_alloc_dir()
1389 error = xfs_trans_alloc(mp, resv, resblks, 0, 0, &tp); in xfs_trans_alloc_dir()
1396 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); in xfs_trans_alloc_dir()
1397 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_trans_alloc_dir()
1416 error = xfs_trans_reserve_quota_nblks(tp, dp, resblks, 0, false); in xfs_trans_alloc_dir()
1419 xfs_trans_cancel(tp); in xfs_trans_alloc_dir()
1433 *tpp = tp; in xfs_trans_alloc_dir()
1438 xfs_trans_cancel(tp); in xfs_trans_alloc_dir()