Lines Matching refs:tp
146 xfs_trans_t *tp; in _xfs_trans_alloc() local
149 tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP); in _xfs_trans_alloc()
154 tp->t_magic = XFS_TRANS_MAGIC; in _xfs_trans_alloc()
155 tp->t_type = type; in _xfs_trans_alloc()
156 tp->t_mountp = mp; in _xfs_trans_alloc()
157 tp->t_items_free = XFS_LIC_NUM_SLOTS; in _xfs_trans_alloc()
158 tp->t_busy_free = XFS_LBC_NUM_SLOTS; in _xfs_trans_alloc()
159 XFS_LIC_INIT(&(tp->t_items)); in _xfs_trans_alloc()
160 XFS_LBC_INIT(&(tp->t_busy)); in _xfs_trans_alloc()
162 return (tp); in _xfs_trans_alloc()
175 xfs_trans_t *tp) in xfs_trans_dup() argument
185 ntp->t_type = tp->t_type; in xfs_trans_dup()
186 ntp->t_mountp = tp->t_mountp; in xfs_trans_dup()
192 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_dup()
195 ASSERT(!xlog_debug || tp->t_ticket != NULL); in xfs_trans_dup()
197 ASSERT(tp->t_ticket != NULL); in xfs_trans_dup()
199 ntp->t_flags = XFS_TRANS_PERM_LOG_RES | (tp->t_flags & XFS_TRANS_RESERVE); in xfs_trans_dup()
200 ntp->t_ticket = tp->t_ticket; in xfs_trans_dup()
201 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; in xfs_trans_dup()
202 tp->t_blk_res = tp->t_blk_res_used; in xfs_trans_dup()
203 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; in xfs_trans_dup()
204 tp->t_rtx_res = tp->t_rtx_res_used; in xfs_trans_dup()
205 PFLAGS_DUP(&tp->t_pflags, &ntp->t_pflags); in xfs_trans_dup()
207 XFS_TRANS_DUP_DQINFO(tp->t_mountp, tp, ntp); in xfs_trans_dup()
209 atomic_inc(&tp->t_mountp->m_active_trans); in xfs_trans_dup()
229 xfs_trans_t *tp, in xfs_trans_reserve() argument
241 rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_reserve()
244 PFLAGS_SET_FSTRANS(&tp->t_pflags); in xfs_trans_reserve()
252 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS, in xfs_trans_reserve()
255 PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); in xfs_trans_reserve()
258 tp->t_blk_res += blocks; in xfs_trans_reserve()
265 ASSERT((tp->t_log_res == 0) || (tp->t_log_res == logspace)); in xfs_trans_reserve()
266 ASSERT((tp->t_log_count == 0) || in xfs_trans_reserve()
267 (tp->t_log_count == logcount)); in xfs_trans_reserve()
270 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
272 ASSERT(tp->t_ticket == NULL); in xfs_trans_reserve()
273 ASSERT(!(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in xfs_trans_reserve()
277 error = xfs_log_reserve(tp->t_mountp, logspace, logcount, in xfs_trans_reserve()
278 &tp->t_ticket, in xfs_trans_reserve()
283 tp->t_log_res = logspace; in xfs_trans_reserve()
284 tp->t_log_count = logcount; in xfs_trans_reserve()
293 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FREXTENTS, in xfs_trans_reserve()
299 tp->t_rtx_res += rtextents; in xfs_trans_reserve()
315 xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, log_flags); in xfs_trans_reserve()
316 tp->t_ticket = NULL; in xfs_trans_reserve()
317 tp->t_log_res = 0; in xfs_trans_reserve()
318 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
323 (void) xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS, in xfs_trans_reserve()
325 tp->t_blk_res = 0; in xfs_trans_reserve()
328 PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); in xfs_trans_reserve()
343 xfs_trans_t *tp, in xfs_trans_callback() argument
347 ASSERT(tp->t_callback == NULL); in xfs_trans_callback()
348 tp->t_callback = callback; in xfs_trans_callback()
349 tp->t_callarg = arg; in xfs_trans_callback()
363 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
370 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
373 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
382 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
383 ASSERT(tp->t_blk_res_used <= tp->t_blk_res); in xfs_trans_mod_sb()
385 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
394 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
403 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
404 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
406 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
415 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
419 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
423 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
426 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
429 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
432 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
435 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
438 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
441 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
448 tp->t_flags |= (XFS_TRANS_SB_DIRTY | XFS_TRANS_DIRTY); in xfs_trans_mod_sb()
461 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
467 bp = xfs_trans_getsb(tp, tp->t_mountp, 0); in xfs_trans_apply_sb_deltas()
473 ASSERT((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == in xfs_trans_apply_sb_deltas()
474 (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + in xfs_trans_apply_sb_deltas()
475 tp->t_ag_btree_delta)); in xfs_trans_apply_sb_deltas()
477 if (tp->t_icount_delta != 0) { in xfs_trans_apply_sb_deltas()
478 INT_MOD(sbp->sb_icount, ARCH_CONVERT, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
480 if (tp->t_ifree_delta != 0) { in xfs_trans_apply_sb_deltas()
481 INT_MOD(sbp->sb_ifree, ARCH_CONVERT, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
484 if (tp->t_fdblocks_delta != 0) { in xfs_trans_apply_sb_deltas()
485 INT_MOD(sbp->sb_fdblocks, ARCH_CONVERT, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
487 if (tp->t_res_fdblocks_delta != 0) { in xfs_trans_apply_sb_deltas()
488 INT_MOD(sbp->sb_fdblocks, ARCH_CONVERT, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
491 if (tp->t_frextents_delta != 0) { in xfs_trans_apply_sb_deltas()
492 INT_MOD(sbp->sb_frextents, ARCH_CONVERT, tp->t_frextents_delta); in xfs_trans_apply_sb_deltas()
494 if (tp->t_res_frextents_delta != 0) { in xfs_trans_apply_sb_deltas()
495 INT_MOD(sbp->sb_frextents, ARCH_CONVERT, tp->t_res_frextents_delta); in xfs_trans_apply_sb_deltas()
497 if (tp->t_dblocks_delta != 0) { in xfs_trans_apply_sb_deltas()
498 INT_MOD(sbp->sb_dblocks, ARCH_CONVERT, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
501 if (tp->t_agcount_delta != 0) { in xfs_trans_apply_sb_deltas()
502 INT_MOD(sbp->sb_agcount, ARCH_CONVERT, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
505 if (tp->t_imaxpct_delta != 0) { in xfs_trans_apply_sb_deltas()
506 INT_MOD(sbp->sb_imax_pct, ARCH_CONVERT, tp->t_imaxpct_delta); in xfs_trans_apply_sb_deltas()
509 if (tp->t_rextsize_delta != 0) { in xfs_trans_apply_sb_deltas()
510 INT_MOD(sbp->sb_rextsize, ARCH_CONVERT, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
513 if (tp->t_rbmblocks_delta != 0) { in xfs_trans_apply_sb_deltas()
514 INT_MOD(sbp->sb_rbmblocks, ARCH_CONVERT, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
517 if (tp->t_rblocks_delta != 0) { in xfs_trans_apply_sb_deltas()
518 INT_MOD(sbp->sb_rblocks, ARCH_CONVERT, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
521 if (tp->t_rextents_delta != 0) { in xfs_trans_apply_sb_deltas()
522 INT_MOD(sbp->sb_rextents, ARCH_CONVERT, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
525 if (tp->t_rextslog_delta != 0) { in xfs_trans_apply_sb_deltas()
526 INT_MOD(sbp->sb_rextslog, ARCH_CONVERT, tp->t_rextslog_delta); in xfs_trans_apply_sb_deltas()
534 xfs_trans_log_buf(tp, bp, 0, sizeof(xfs_sb_t) - 1); in xfs_trans_apply_sb_deltas()
540 xfs_trans_log_buf(tp, bp, offsetof(xfs_sb_t, sb_icount), in xfs_trans_apply_sb_deltas()
544 XFS_MTOVFS(tp->t_mountp)->vfs_super->s_dirt = 1; in xfs_trans_apply_sb_deltas()
556 xfs_trans_t *tp) in xfs_trans_unreserve_and_mod_sb() argument
565 rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_unreserve_and_mod_sb()
571 if (tp->t_blk_res > 0) { in xfs_trans_unreserve_and_mod_sb()
573 msbp->msb_delta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
581 if (tp->t_rtx_res > 0) { in xfs_trans_unreserve_and_mod_sb()
583 msbp->msb_delta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
593 if (tp->t_flags & XFS_TRANS_SB_DIRTY) { in xfs_trans_unreserve_and_mod_sb()
594 if (tp->t_icount_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
596 msbp->msb_delta = (int)tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
599 if (tp->t_ifree_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
601 msbp->msb_delta = (int)tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
604 if (tp->t_fdblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
606 msbp->msb_delta = (int)tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
609 if (tp->t_frextents_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
611 msbp->msb_delta = (int)tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
614 if (tp->t_dblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
616 msbp->msb_delta = (int)tp->t_dblocks_delta; in xfs_trans_unreserve_and_mod_sb()
619 if (tp->t_agcount_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
621 msbp->msb_delta = (int)tp->t_agcount_delta; in xfs_trans_unreserve_and_mod_sb()
624 if (tp->t_imaxpct_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
626 msbp->msb_delta = (int)tp->t_imaxpct_delta; in xfs_trans_unreserve_and_mod_sb()
629 if (tp->t_rextsize_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
631 msbp->msb_delta = (int)tp->t_rextsize_delta; in xfs_trans_unreserve_and_mod_sb()
634 if (tp->t_rbmblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
636 msbp->msb_delta = (int)tp->t_rbmblocks_delta; in xfs_trans_unreserve_and_mod_sb()
639 if (tp->t_rblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
641 msbp->msb_delta = (int)tp->t_rblocks_delta; in xfs_trans_unreserve_and_mod_sb()
644 if (tp->t_rextents_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
646 msbp->msb_delta = (int)tp->t_rextents_delta; in xfs_trans_unreserve_and_mod_sb()
649 if (tp->t_rextslog_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
651 msbp->msb_delta = (int)tp->t_rextslog_delta; in xfs_trans_unreserve_and_mod_sb()
660 error = xfs_mod_incore_sb_batch(tp->t_mountp, msb, in xfs_trans_unreserve_and_mod_sb()
684 xfs_trans_t *tp, in xfs_trans_commit() argument
711 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_commit()
716 mp = tp->t_mountp; in xfs_trans_commit()
727 if (!(tp->t_flags & XFS_TRANS_DIRTY) || shutdown) { in xfs_trans_commit()
728 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_commit()
735 XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp); in xfs_trans_commit()
736 if (tp->t_ticket) { in xfs_trans_commit()
737 commit_lsn = xfs_log_done(mp, tp->t_ticket, in xfs_trans_commit()
742 PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); in xfs_trans_commit()
743 xfs_trans_free_items(tp, shutdown? XFS_TRANS_ABORT : 0); in xfs_trans_commit()
744 xfs_trans_free_busy(tp); in xfs_trans_commit()
745 xfs_trans_free(tp); in xfs_trans_commit()
752 ASSERT(!xlog_debug || tp->t_ticket != NULL); in xfs_trans_commit()
754 ASSERT(tp->t_ticket != NULL); in xfs_trans_commit()
760 if (tp->t_flags & XFS_TRANS_SB_DIRTY) { in xfs_trans_commit()
761 xfs_trans_apply_sb_deltas(tp); in xfs_trans_commit()
763 XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp); in xfs_trans_commit()
771 nvec = xfs_trans_count_vecs(tp); in xfs_trans_commit()
791 xfs_trans_fill_vecs(tp, log_vector); in xfs_trans_commit()
797 error = xfs_log_write(mp, log_vector, nvec, tp->t_ticket, in xfs_trans_commit()
798 &(tp->t_lsn)); in xfs_trans_commit()
802 commit_lsn = xfs_log_done(mp, tp->t_ticket, in xfs_trans_commit()
806 tp->t_lsn = trans_lsn++; in xfs_trans_commit()
815 commit_lsn = xfs_log_done(mp, tp->t_ticket, &commit_iclog, log_flags); in xfs_trans_commit()
818 tp->t_commit_lsn = commit_lsn; in xfs_trans_commit()
831 PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); in xfs_trans_commit()
832 xfs_trans_uncommit(tp, flags|XFS_TRANS_ABORT); in xfs_trans_commit()
842 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_commit()
844 sync = tp->t_flags & XFS_TRANS_SYNC; in xfs_trans_commit()
858 tp->t_logcb.cb_func = (void(*)(void*, int))xfs_trans_committed; in xfs_trans_commit()
859 tp->t_logcb.cb_arg = tp; in xfs_trans_commit()
868 shutdown = xfs_log_notify(mp, commit_iclog, &(tp->t_logcb)); in xfs_trans_commit()
873 PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); in xfs_trans_commit()
888 xfs_trans_unlock_items(tp, commit_lsn); in xfs_trans_commit()
901 xfs_trans_committed(tp, XFS_LI_ABORTED); in xfs_trans_commit()
935 xfs_trans_t *tp) in xfs_trans_count_vecs() argument
941 lidp = xfs_trans_first_item(tp); in xfs_trans_count_vecs()
956 lidp = xfs_trans_next_item(tp, lidp); in xfs_trans_count_vecs()
961 lidp = xfs_trans_next_item(tp, lidp); in xfs_trans_count_vecs()
973 xfs_trans_t *tp, in xfs_trans_uncommit() argument
978 for (lidp = xfs_trans_first_item(tp); in xfs_trans_uncommit()
980 lidp = xfs_trans_next_item(tp, lidp)) { in xfs_trans_uncommit()
985 IOP_UNPIN_REMOVE(lidp->lid_item, tp); in xfs_trans_uncommit()
988 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_uncommit()
989 XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(tp->t_mountp, tp); in xfs_trans_uncommit()
991 xfs_trans_free_items(tp, flags); in xfs_trans_uncommit()
992 xfs_trans_free_busy(tp); in xfs_trans_uncommit()
993 xfs_trans_free(tp); in xfs_trans_uncommit()
1007 xfs_trans_t *tp, in xfs_trans_fill_vecs() argument
1021 lidp = xfs_trans_first_item(tp); in xfs_trans_fill_vecs()
1028 lidp = xfs_trans_next_item(tp, lidp); in xfs_trans_fill_vecs()
1042 lidp = xfs_trans_next_item(tp, lidp); in xfs_trans_fill_vecs()
1049 tp->t_header.th_magic = XFS_TRANS_HEADER_MAGIC; in xfs_trans_fill_vecs()
1050 tp->t_header.th_type = tp->t_type; in xfs_trans_fill_vecs()
1051 tp->t_header.th_num_items = nitems; in xfs_trans_fill_vecs()
1052 log_vector->i_addr = (xfs_caddr_t)&tp->t_header; in xfs_trans_fill_vecs()
1067 xfs_trans_t *tp, in xfs_trans_cancel() argument
1082 if ((flags & XFS_TRANS_ABORT) && !(tp->t_flags & XFS_TRANS_DIRTY)) in xfs_trans_cancel()
1089 if ((tp->t_flags & XFS_TRANS_DIRTY) && in xfs_trans_cancel()
1090 !XFS_FORCED_SHUTDOWN(tp->t_mountp)) in xfs_trans_cancel()
1091 xfs_force_shutdown(tp->t_mountp, XFS_CORRUPT_INCORE); in xfs_trans_cancel()
1094 licp = &(tp->t_items); in xfs_trans_cancel()
1103 if (!XFS_FORCED_SHUTDOWN(tp->t_mountp)) in xfs_trans_cancel()
1110 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
1111 XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(tp->t_mountp, tp); in xfs_trans_cancel()
1113 if (tp->t_ticket) { in xfs_trans_cancel()
1115 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_cancel()
1120 xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, log_flags); in xfs_trans_cancel()
1124 PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); in xfs_trans_cancel()
1126 xfs_trans_free_items(tp, flags); in xfs_trans_cancel()
1127 xfs_trans_free_busy(tp); in xfs_trans_cancel()
1128 xfs_trans_free(tp); in xfs_trans_cancel()
1138 xfs_trans_t *tp) in xfs_trans_free() argument
1140 atomic_dec(&tp->t_mountp->m_active_trans); in xfs_trans_free()
1141 XFS_TRANS_FREE_DQINFO(tp->t_mountp, tp); in xfs_trans_free()
1142 kmem_zone_free(xfs_trans_zone, tp); in xfs_trans_free()
1161 xfs_trans_t *tp, in xfs_trans_committed() argument
1174 if (tp->t_callback != NULL) { in xfs_trans_committed()
1175 tp->t_callback(tp, tp->t_callarg); in xfs_trans_committed()
1181 licp = &(tp->t_items); in xfs_trans_committed()
1183 xfs_trans_chunk_committed(licp, tp->t_lsn, abortflag); in xfs_trans_committed()
1192 xfs_trans_chunk_committed(licp, tp->t_lsn, abortflag); in xfs_trans_committed()
1201 lbcp = &tp->t_busy; in xfs_trans_committed()
1205 xfs_alloc_clear_busy(tp, lbsp->lbc_ag, in xfs_trans_committed()
1211 xfs_trans_free_busy(tp); in xfs_trans_committed()
1216 xfs_trans_free(tp); in xfs_trans_committed()