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_firstblock = NULLFSBLOCK; 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()
298 xfs_trans_cancel(tp); in xfs_trans_alloc()
302 trace_xfs_trans_alloc(tp, _RET_IP_); in xfs_trans_alloc()
304 *tpp = tp; in xfs_trans_alloc()
352 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
357 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_sb()
361 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
366 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
377 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
378 if (tp->t_blk_res_used > tp->t_blk_res) in xfs_trans_mod_sb()
380 } else if (delta > 0 && (tp->t_flags & XFS_TRANS_RES_FDBLKS)) { in xfs_trans_mod_sb()
391 UINT_MAX - tp->t_blk_res); in xfs_trans_mod_sb()
392 tp->t_blk_res += blkres_delta; in xfs_trans_mod_sb()
395 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
405 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
416 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
417 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
419 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
428 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
431 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
435 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
438 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
441 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
444 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
447 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
450 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
453 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
460 tp->t_flags |= flags; in xfs_trans_mod_sb()
473 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
479 bp = xfs_trans_getsb(tp); in xfs_trans_apply_sb_deltas()
485 if (!xfs_has_lazysbcount((tp->t_mountp))) { in xfs_trans_apply_sb_deltas()
486 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
487 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
488 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
489 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
490 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
491 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
492 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
493 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
510 if (tp->t_frextents_delta || tp->t_res_frextents_delta) { in xfs_trans_apply_sb_deltas()
511 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_apply_sb_deltas()
514 rtxdelta = tp->t_frextents_delta + tp->t_res_frextents_delta; in xfs_trans_apply_sb_deltas()
522 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
523 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
526 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
527 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
530 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
531 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
534 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
535 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
538 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
539 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
542 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
543 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
546 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
547 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
550 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
551 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
555 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); in xfs_trans_apply_sb_deltas()
560 xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1); in xfs_trans_apply_sb_deltas()
566 xfs_trans_log_buf(tp, bp, offsetof(struct xfs_dsb, sb_icount), in xfs_trans_apply_sb_deltas()
590 struct xfs_trans *tp) in xfs_trans_unreserve_and_mod_sb() argument
592 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_unreserve_and_mod_sb()
593 bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_unreserve_and_mod_sb()
601 if (tp->t_blk_res > 0) in xfs_trans_unreserve_and_mod_sb()
602 blkdelta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
603 if ((tp->t_fdblocks_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
605 (tp->t_flags & XFS_TRANS_SB_DIRTY))) in xfs_trans_unreserve_and_mod_sb()
606 blkdelta += tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
608 if (tp->t_rtx_res > 0) in xfs_trans_unreserve_and_mod_sb()
609 rtxdelta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
610 if ((tp->t_frextents_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
611 (tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
612 rtxdelta += tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
615 (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
616 idelta = tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
617 ifreedelta = tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
638 if (!(tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
643 mp->m_sb.sb_fdblocks += tp->t_fdblocks_delta + tp->t_res_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
652 mp->m_sb.sb_dblocks += tp->t_dblocks_delta; in xfs_trans_unreserve_and_mod_sb()
653 mp->m_sb.sb_agcount += tp->t_agcount_delta; in xfs_trans_unreserve_and_mod_sb()
654 mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_unreserve_and_mod_sb()
655 mp->m_sb.sb_rextsize += tp->t_rextsize_delta; in xfs_trans_unreserve_and_mod_sb()
656 mp->m_sb.sb_rbmblocks += tp->t_rbmblocks_delta; in xfs_trans_unreserve_and_mod_sb()
657 mp->m_sb.sb_rblocks += tp->t_rblocks_delta; in xfs_trans_unreserve_and_mod_sb()
658 mp->m_sb.sb_rextents += tp->t_rextents_delta; in xfs_trans_unreserve_and_mod_sb()
659 mp->m_sb.sb_rextslog += tp->t_rextslog_delta; in xfs_trans_unreserve_and_mod_sb()
674 struct xfs_trans *tp, in xfs_trans_add_item() argument
677 ASSERT(lip->li_log == tp->t_mountp->m_log); in xfs_trans_add_item()
678 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
682 list_add_tail(&lip->li_trans, &tp->t_items); in xfs_trans_add_item()
683 trace_xfs_trans_add_item(tp, _RET_IP_); in xfs_trans_add_item()
702 struct xfs_trans *tp, in xfs_trans_free_items() argument
707 trace_xfs_trans_free_items(tp, _RET_IP_); in xfs_trans_free_items()
709 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { in xfs_trans_free_items()
898 struct xfs_trans *tp) in xfs_trans_run_precommits() argument
900 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_run_precommits()
909 list_sort(NULL, &tp->t_items, xfs_trans_precommit_sort); in xfs_trans_run_precommits()
917 list_for_each_entry_safe(lip, n, &tp->t_items, li_trans) { in xfs_trans_run_precommits()
921 error = lip->li_ops->iop_precommit(tp, lip); in xfs_trans_run_precommits()
945 struct xfs_trans *tp, in __xfs_trans_commit() argument
948 struct xfs_mount *mp = tp->t_mountp; in __xfs_trans_commit()
952 int sync = tp->t_flags & XFS_TRANS_SYNC; in __xfs_trans_commit()
954 trace_xfs_trans_commit(tp, _RET_IP_); in __xfs_trans_commit()
956 error = xfs_trans_run_precommits(tp); in __xfs_trans_commit()
958 if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) in __xfs_trans_commit()
959 xfs_defer_cancel(tp); in __xfs_trans_commit()
967 WARN_ON_ONCE(!list_empty(&tp->t_dfops) && in __xfs_trans_commit()
968 !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in __xfs_trans_commit()
969 if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) { in __xfs_trans_commit()
970 error = xfs_defer_finish_noroll(&tp); in __xfs_trans_commit()
982 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in __xfs_trans_commit()
996 ASSERT(tp->t_ticket != NULL); in __xfs_trans_commit()
1001 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in __xfs_trans_commit()
1002 xfs_trans_apply_sb_deltas(tp); in __xfs_trans_commit()
1003 xfs_trans_apply_dquot_deltas(tp); in __xfs_trans_commit()
1005 xlog_cil_commit(log, tp, &commit_seq, regrant); in __xfs_trans_commit()
1007 xfs_trans_free(tp); in __xfs_trans_commit()
1023 xfs_trans_unreserve_and_mod_sb(tp); in __xfs_trans_commit()
1030 xfs_trans_unreserve_and_mod_dquots(tp); in __xfs_trans_commit()
1031 if (tp->t_ticket) { in __xfs_trans_commit()
1033 xfs_log_ticket_regrant(log, tp->t_ticket); in __xfs_trans_commit()
1035 xfs_log_ticket_ungrant(log, tp->t_ticket); in __xfs_trans_commit()
1036 tp->t_ticket = NULL; in __xfs_trans_commit()
1038 xfs_trans_free_items(tp, !!error); in __xfs_trans_commit()
1039 xfs_trans_free(tp); in __xfs_trans_commit()
1047 struct xfs_trans *tp) in xfs_trans_commit() argument
1049 return __xfs_trans_commit(tp, false); in xfs_trans_commit()
1070 struct xfs_trans *tp) in xfs_trans_cancel() argument
1072 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_cancel()
1074 bool dirty = (tp->t_flags & XFS_TRANS_DIRTY); in xfs_trans_cancel()
1076 trace_xfs_trans_cancel(tp, _RET_IP_); in xfs_trans_cancel()
1083 if (!list_empty(&tp->t_dfops)) { in xfs_trans_cancel()
1084 ASSERT(xfs_is_shutdown(mp) || list_empty(&tp->t_dfops)); in xfs_trans_cancel()
1085 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_cancel()
1087 xfs_defer_cancel(tp); in xfs_trans_cancel()
1105 list_for_each_entry(lip, &tp->t_items, li_trans) in xfs_trans_cancel()
1109 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
1110 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
1112 if (tp->t_ticket) { in xfs_trans_cancel()
1113 xfs_log_ticket_ungrant(log, tp->t_ticket); in xfs_trans_cancel()
1114 tp->t_ticket = NULL; in xfs_trans_cancel()
1117 xfs_trans_free_items(tp, dirty); in xfs_trans_cancel()
1118 xfs_trans_free(tp); in xfs_trans_cancel()
1185 struct xfs_trans *tp; in xfs_trans_alloc_inode() local
1193 force ? XFS_TRANS_RESERVE : 0, &tp); in xfs_trans_alloc_inode()
1198 xfs_trans_ijoin(tp, ip, 0); in xfs_trans_alloc_inode()
1207 error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, force); in xfs_trans_alloc_inode()
1209 xfs_trans_cancel(tp); in xfs_trans_alloc_inode()
1218 *tpp = tp; in xfs_trans_alloc_inode()
1222 xfs_trans_cancel(tp); in xfs_trans_alloc_inode()
1241 struct xfs_trans *tp; in xfs_trans_alloc_icreate() local
1246 error = xfs_trans_alloc(mp, resv, dblocks, 0, 0, &tp); in xfs_trans_alloc_icreate()
1250 error = xfs_trans_reserve_quota_icreate(tp, udqp, gdqp, pdqp, dblocks); in xfs_trans_alloc_icreate()
1252 xfs_trans_cancel(tp); in xfs_trans_alloc_icreate()
1258 xfs_trans_cancel(tp); in xfs_trans_alloc_icreate()
1262 *tpp = tp; in xfs_trans_alloc_icreate()
1284 struct xfs_trans *tp; in xfs_trans_alloc_ichange() local
1293 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); in xfs_trans_alloc_ichange()
1298 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_trans_alloc_ichange()
1328 error = xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp, in xfs_trans_alloc_ichange()
1332 xfs_trans_cancel(tp); in xfs_trans_alloc_ichange()
1341 *tpp = tp; in xfs_trans_alloc_ichange()
1345 xfs_trans_cancel(tp); in xfs_trans_alloc_ichange()
1369 struct xfs_trans *tp; in xfs_trans_alloc_dir() local
1378 error = xfs_trans_alloc(mp, resv, resblks, 0, 0, &tp); in xfs_trans_alloc_dir()
1382 error = xfs_trans_alloc(mp, resv, resblks, 0, 0, &tp); in xfs_trans_alloc_dir()
1389 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); in xfs_trans_alloc_dir()
1390 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_trans_alloc_dir()
1409 error = xfs_trans_reserve_quota_nblks(tp, dp, resblks, 0, false); in xfs_trans_alloc_dir()
1412 xfs_trans_cancel(tp); in xfs_trans_alloc_dir()
1426 *tpp = tp; in xfs_trans_alloc_dir()
1431 xfs_trans_cancel(tp); in xfs_trans_alloc_dir()