Lines Matching refs:tp
590 xfs_trans_t *tp; in _xfs_trans_alloc() local
594 tp = kmem_zone_zalloc(xfs_trans_zone, memflags); in _xfs_trans_alloc()
595 tp->t_magic = XFS_TRANS_MAGIC; in _xfs_trans_alloc()
596 tp->t_type = type; in _xfs_trans_alloc()
597 tp->t_mountp = mp; in _xfs_trans_alloc()
598 INIT_LIST_HEAD(&tp->t_items); in _xfs_trans_alloc()
599 INIT_LIST_HEAD(&tp->t_busy); in _xfs_trans_alloc()
600 return tp; in _xfs_trans_alloc()
609 struct xfs_trans *tp) in xfs_trans_free() argument
611 xfs_alloc_busy_sort(&tp->t_busy); in xfs_trans_free()
612 xfs_alloc_busy_clear(tp->t_mountp, &tp->t_busy, false); in xfs_trans_free()
614 atomic_dec(&tp->t_mountp->m_active_trans); in xfs_trans_free()
615 xfs_trans_free_dqinfo(tp); in xfs_trans_free()
616 kmem_zone_free(xfs_trans_zone, tp); in xfs_trans_free()
629 xfs_trans_t *tp) in xfs_trans_dup() argument
639 ntp->t_type = tp->t_type; in xfs_trans_dup()
640 ntp->t_mountp = tp->t_mountp; in xfs_trans_dup()
644 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_dup()
645 ASSERT(tp->t_ticket != NULL); in xfs_trans_dup()
647 ntp->t_flags = XFS_TRANS_PERM_LOG_RES | (tp->t_flags & XFS_TRANS_RESERVE); in xfs_trans_dup()
648 ntp->t_ticket = xfs_log_ticket_get(tp->t_ticket); in xfs_trans_dup()
649 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; in xfs_trans_dup()
650 tp->t_blk_res = tp->t_blk_res_used; in xfs_trans_dup()
651 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; in xfs_trans_dup()
652 tp->t_rtx_res = tp->t_rtx_res_used; in xfs_trans_dup()
653 ntp->t_pflags = tp->t_pflags; in xfs_trans_dup()
655 xfs_trans_dup_dqinfo(tp, ntp); in xfs_trans_dup()
657 atomic_inc(&tp->t_mountp->m_active_trans); in xfs_trans_dup()
677 xfs_trans_t *tp, in xfs_trans_reserve() argument
685 int rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_reserve()
688 current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_reserve()
696 error = xfs_icsb_modify_counters(tp->t_mountp, XFS_SBS_FDBLOCKS, in xfs_trans_reserve()
699 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_reserve()
702 tp->t_blk_res += blocks; in xfs_trans_reserve()
711 ASSERT(tp->t_log_res == 0 || tp->t_log_res == logspace); in xfs_trans_reserve()
712 ASSERT(tp->t_log_count == 0 || tp->t_log_count == logcount); in xfs_trans_reserve()
715 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
718 ASSERT(tp->t_ticket == NULL); in xfs_trans_reserve()
719 ASSERT(!(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); in xfs_trans_reserve()
722 if (tp->t_ticket != NULL) { in xfs_trans_reserve()
724 error = xfs_log_regrant(tp->t_mountp, tp->t_ticket); in xfs_trans_reserve()
726 error = xfs_log_reserve(tp->t_mountp, logspace, in xfs_trans_reserve()
727 logcount, &tp->t_ticket, in xfs_trans_reserve()
729 tp->t_type); in xfs_trans_reserve()
735 tp->t_log_res = logspace; in xfs_trans_reserve()
736 tp->t_log_count = logcount; in xfs_trans_reserve()
745 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FREXTENTS, in xfs_trans_reserve()
751 tp->t_rtx_res += rtextents; in xfs_trans_reserve()
769 xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, log_flags); in xfs_trans_reserve()
770 tp->t_ticket = NULL; in xfs_trans_reserve()
771 tp->t_log_res = 0; in xfs_trans_reserve()
772 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; in xfs_trans_reserve()
777 xfs_icsb_modify_counters(tp->t_mountp, XFS_SBS_FDBLOCKS, in xfs_trans_reserve()
779 tp->t_blk_res = 0; in xfs_trans_reserve()
782 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_reserve()
805 xfs_trans_t *tp, in xfs_trans_mod_sb() argument
810 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_sb()
814 tp->t_icount_delta += delta; in xfs_trans_mod_sb()
819 tp->t_ifree_delta += delta; in xfs_trans_mod_sb()
830 tp->t_blk_res_used += (uint)-delta; in xfs_trans_mod_sb()
831 ASSERT(tp->t_blk_res_used <= tp->t_blk_res); in xfs_trans_mod_sb()
833 tp->t_fdblocks_delta += delta; in xfs_trans_mod_sb()
844 tp->t_res_fdblocks_delta += delta; in xfs_trans_mod_sb()
855 tp->t_rtx_res_used += (uint)-delta; in xfs_trans_mod_sb()
856 ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res); in xfs_trans_mod_sb()
858 tp->t_frextents_delta += delta; in xfs_trans_mod_sb()
867 tp->t_res_frextents_delta += delta; in xfs_trans_mod_sb()
871 tp->t_dblocks_delta += delta; in xfs_trans_mod_sb()
875 tp->t_agcount_delta += delta; in xfs_trans_mod_sb()
878 tp->t_imaxpct_delta += delta; in xfs_trans_mod_sb()
881 tp->t_rextsize_delta += delta; in xfs_trans_mod_sb()
884 tp->t_rbmblocks_delta += delta; in xfs_trans_mod_sb()
887 tp->t_rblocks_delta += delta; in xfs_trans_mod_sb()
890 tp->t_rextents_delta += delta; in xfs_trans_mod_sb()
893 tp->t_rextslog_delta += delta; in xfs_trans_mod_sb()
900 tp->t_flags |= flags; in xfs_trans_mod_sb()
913 xfs_trans_t *tp) in xfs_trans_apply_sb_deltas() argument
919 bp = xfs_trans_getsb(tp, tp->t_mountp, 0); in xfs_trans_apply_sb_deltas()
925 ASSERT((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == in xfs_trans_apply_sb_deltas()
926 (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + in xfs_trans_apply_sb_deltas()
927 tp->t_ag_btree_delta)); in xfs_trans_apply_sb_deltas()
932 if (!xfs_sb_version_haslazysbcount(&(tp->t_mountp->m_sb))) { in xfs_trans_apply_sb_deltas()
933 if (tp->t_icount_delta) in xfs_trans_apply_sb_deltas()
934 be64_add_cpu(&sbp->sb_icount, tp->t_icount_delta); in xfs_trans_apply_sb_deltas()
935 if (tp->t_ifree_delta) in xfs_trans_apply_sb_deltas()
936 be64_add_cpu(&sbp->sb_ifree, tp->t_ifree_delta); in xfs_trans_apply_sb_deltas()
937 if (tp->t_fdblocks_delta) in xfs_trans_apply_sb_deltas()
938 be64_add_cpu(&sbp->sb_fdblocks, tp->t_fdblocks_delta); in xfs_trans_apply_sb_deltas()
939 if (tp->t_res_fdblocks_delta) in xfs_trans_apply_sb_deltas()
940 be64_add_cpu(&sbp->sb_fdblocks, tp->t_res_fdblocks_delta); in xfs_trans_apply_sb_deltas()
943 if (tp->t_frextents_delta) in xfs_trans_apply_sb_deltas()
944 be64_add_cpu(&sbp->sb_frextents, tp->t_frextents_delta); in xfs_trans_apply_sb_deltas()
945 if (tp->t_res_frextents_delta) in xfs_trans_apply_sb_deltas()
946 be64_add_cpu(&sbp->sb_frextents, tp->t_res_frextents_delta); in xfs_trans_apply_sb_deltas()
948 if (tp->t_dblocks_delta) { in xfs_trans_apply_sb_deltas()
949 be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta); in xfs_trans_apply_sb_deltas()
952 if (tp->t_agcount_delta) { in xfs_trans_apply_sb_deltas()
953 be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta); in xfs_trans_apply_sb_deltas()
956 if (tp->t_imaxpct_delta) { in xfs_trans_apply_sb_deltas()
957 sbp->sb_imax_pct += tp->t_imaxpct_delta; in xfs_trans_apply_sb_deltas()
960 if (tp->t_rextsize_delta) { in xfs_trans_apply_sb_deltas()
961 be32_add_cpu(&sbp->sb_rextsize, tp->t_rextsize_delta); in xfs_trans_apply_sb_deltas()
964 if (tp->t_rbmblocks_delta) { in xfs_trans_apply_sb_deltas()
965 be32_add_cpu(&sbp->sb_rbmblocks, tp->t_rbmblocks_delta); in xfs_trans_apply_sb_deltas()
968 if (tp->t_rblocks_delta) { in xfs_trans_apply_sb_deltas()
969 be64_add_cpu(&sbp->sb_rblocks, tp->t_rblocks_delta); in xfs_trans_apply_sb_deltas()
972 if (tp->t_rextents_delta) { in xfs_trans_apply_sb_deltas()
973 be64_add_cpu(&sbp->sb_rextents, tp->t_rextents_delta); in xfs_trans_apply_sb_deltas()
976 if (tp->t_rextslog_delta) { in xfs_trans_apply_sb_deltas()
977 sbp->sb_rextslog += tp->t_rextslog_delta; in xfs_trans_apply_sb_deltas()
985 xfs_trans_log_buf(tp, bp, 0, sizeof(xfs_dsb_t) - 1); in xfs_trans_apply_sb_deltas()
991 xfs_trans_log_buf(tp, bp, offsetof(xfs_dsb_t, sb_icount), in xfs_trans_apply_sb_deltas()
1017 xfs_trans_t *tp) in xfs_trans_unreserve_and_mod_sb() argument
1021 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_unreserve_and_mod_sb()
1031 rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; in xfs_trans_unreserve_and_mod_sb()
1034 if (tp->t_blk_res > 0) in xfs_trans_unreserve_and_mod_sb()
1035 blkdelta = tp->t_blk_res; in xfs_trans_unreserve_and_mod_sb()
1036 if ((tp->t_fdblocks_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
1038 (tp->t_flags & XFS_TRANS_SB_DIRTY))) in xfs_trans_unreserve_and_mod_sb()
1039 blkdelta += tp->t_fdblocks_delta; in xfs_trans_unreserve_and_mod_sb()
1041 if (tp->t_rtx_res > 0) in xfs_trans_unreserve_and_mod_sb()
1042 rtxdelta = tp->t_rtx_res; in xfs_trans_unreserve_and_mod_sb()
1043 if ((tp->t_frextents_delta != 0) && in xfs_trans_unreserve_and_mod_sb()
1044 (tp->t_flags & XFS_TRANS_SB_DIRTY)) in xfs_trans_unreserve_and_mod_sb()
1045 rtxdelta += tp->t_frextents_delta; in xfs_trans_unreserve_and_mod_sb()
1048 (tp->t_flags & XFS_TRANS_SB_DIRTY)) { in xfs_trans_unreserve_and_mod_sb()
1049 idelta = tp->t_icount_delta; in xfs_trans_unreserve_and_mod_sb()
1050 ifreedelta = tp->t_ifree_delta; in xfs_trans_unreserve_and_mod_sb()
1082 if (tp->t_flags & XFS_TRANS_SB_DIRTY) { in xfs_trans_unreserve_and_mod_sb()
1083 if (tp->t_dblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
1085 msbp->msb_delta = tp->t_dblocks_delta; in xfs_trans_unreserve_and_mod_sb()
1088 if (tp->t_agcount_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
1090 msbp->msb_delta = tp->t_agcount_delta; in xfs_trans_unreserve_and_mod_sb()
1093 if (tp->t_imaxpct_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
1095 msbp->msb_delta = tp->t_imaxpct_delta; in xfs_trans_unreserve_and_mod_sb()
1098 if (tp->t_rextsize_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
1100 msbp->msb_delta = tp->t_rextsize_delta; in xfs_trans_unreserve_and_mod_sb()
1103 if (tp->t_rbmblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
1105 msbp->msb_delta = tp->t_rbmblocks_delta; in xfs_trans_unreserve_and_mod_sb()
1108 if (tp->t_rblocks_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
1110 msbp->msb_delta = tp->t_rblocks_delta; in xfs_trans_unreserve_and_mod_sb()
1113 if (tp->t_rextents_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
1115 msbp->msb_delta = tp->t_rextents_delta; in xfs_trans_unreserve_and_mod_sb()
1118 if (tp->t_rextslog_delta != 0) { in xfs_trans_unreserve_and_mod_sb()
1120 msbp->msb_delta = tp->t_rextslog_delta; in xfs_trans_unreserve_and_mod_sb()
1129 error = xfs_mod_incore_sb_batch(tp->t_mountp, msb, in xfs_trans_unreserve_and_mod_sb()
1158 struct xfs_trans *tp, in xfs_trans_add_item() argument
1163 ASSERT(lip->li_mountp == tp->t_mountp); in xfs_trans_add_item()
1164 ASSERT(lip->li_ailp == tp->t_mountp->m_ail); in xfs_trans_add_item()
1170 list_add_tail(&lidp->lid_trans, &tp->t_items); in xfs_trans_add_item()
1200 struct xfs_trans *tp, in xfs_trans_free_items() argument
1206 list_for_each_entry_safe(lidp, next, &tp->t_items, lid_trans) { in xfs_trans_free_items()
1349 struct xfs_trans *tp, in xfs_trans_commit() argument
1352 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_commit()
1356 int sync = tp->t_flags & XFS_TRANS_SYNC; in xfs_trans_commit()
1363 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_commit()
1374 if (!(tp->t_flags & XFS_TRANS_DIRTY)) in xfs_trans_commit()
1382 ASSERT(tp->t_ticket != NULL); in xfs_trans_commit()
1387 if (tp->t_flags & XFS_TRANS_SB_DIRTY) in xfs_trans_commit()
1388 xfs_trans_apply_sb_deltas(tp); in xfs_trans_commit()
1389 xfs_trans_apply_dquot_deltas(tp); in xfs_trans_commit()
1391 error = xfs_log_commit_cil(mp, tp, &commit_lsn, flags); in xfs_trans_commit()
1398 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_commit()
1399 xfs_trans_free(tp); in xfs_trans_commit()
1418 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_commit()
1425 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_commit()
1426 if (tp->t_ticket) { in xfs_trans_commit()
1427 commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, log_flags); in xfs_trans_commit()
1431 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_commit()
1432 xfs_trans_free_items(tp, NULLCOMMITLSN, error ? XFS_TRANS_ABORT : 0); in xfs_trans_commit()
1433 xfs_trans_free(tp); in xfs_trans_commit()
1449 xfs_trans_t *tp, in xfs_trans_cancel() argument
1453 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_cancel()
1459 if ((flags & XFS_TRANS_ABORT) && !(tp->t_flags & XFS_TRANS_DIRTY)) in xfs_trans_cancel()
1466 if ((tp->t_flags & XFS_TRANS_DIRTY) && !XFS_FORCED_SHUTDOWN(mp)) { in xfs_trans_cancel()
1474 list_for_each_entry(lidp, &tp->t_items, lid_trans) in xfs_trans_cancel()
1478 xfs_trans_unreserve_and_mod_sb(tp); in xfs_trans_cancel()
1479 xfs_trans_unreserve_and_mod_dquots(tp); in xfs_trans_cancel()
1481 if (tp->t_ticket) { in xfs_trans_cancel()
1483 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_trans_cancel()
1488 xfs_log_done(mp, tp->t_ticket, NULL, log_flags); in xfs_trans_cancel()
1492 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); in xfs_trans_cancel()
1494 xfs_trans_free_items(tp, NULLCOMMITLSN, flags); in xfs_trans_cancel()
1495 xfs_trans_free(tp); in xfs_trans_cancel()