hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/fs/xfs/xfs_trans.c
....@@ -9,9 +9,9 @@
99 #include "xfs_shared.h"
1010 #include "xfs_format.h"
1111 #include "xfs_log_format.h"
12
+#include "xfs_log_priv.h"
1213 #include "xfs_trans_resv.h"
1314 #include "xfs_mount.h"
14
-#include "xfs_inode.h"
1515 #include "xfs_extent_busy.h"
1616 #include "xfs_quota.h"
1717 #include "xfs_trans.h"
....@@ -68,11 +68,11 @@
6868 xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false);
6969
7070 trace_xfs_trans_free(tp, _RET_IP_);
71
- atomic_dec(&tp->t_mountp->m_active_trans);
71
+ xfs_trans_clear_context(tp);
7272 if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT))
7373 sb_end_intwrite(tp->t_mountp->m_super);
7474 xfs_trans_free_dqinfo(tp);
75
- kmem_zone_free(xfs_trans_zone, tp);
75
+ kmem_cache_free(xfs_trans_zone, tp);
7676 }
7777
7878 /*
....@@ -91,7 +91,7 @@
9191
9292 trace_xfs_trans_dup(tp, _RET_IP_);
9393
94
- ntp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP);
94
+ ntp = kmem_cache_zalloc(xfs_trans_zone, GFP_KERNEL | __GFP_NOFAIL);
9595
9696 /*
9797 * Initialize the new transaction structure.
....@@ -108,7 +108,8 @@
108108
109109 ntp->t_flags = XFS_TRANS_PERM_LOG_RES |
110110 (tp->t_flags & XFS_TRANS_RESERVE) |
111
- (tp->t_flags & XFS_TRANS_NO_WRITECOUNT);
111
+ (tp->t_flags & XFS_TRANS_NO_WRITECOUNT) |
112
+ (tp->t_flags & XFS_TRANS_RES_FDBLKS);
112113 /* We gave our writer reference to the new transaction */
113114 tp->t_flags |= XFS_TRANS_NO_WRITECOUNT;
114115 ntp->t_ticket = xfs_log_ticket_get(tp->t_ticket);
....@@ -119,14 +120,13 @@
119120
120121 ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used;
121122 tp->t_rtx_res = tp->t_rtx_res_used;
122
- ntp->t_pflags = tp->t_pflags;
123
+
124
+ xfs_trans_switch_context(tp, ntp);
123125
124126 /* move deferred ops over to the new tp */
125127 xfs_defer_move(ntp, tp);
126128
127129 xfs_trans_dup_dqinfo(tp, ntp);
128
-
129
- atomic_inc(&tp->t_mountp->m_active_trans);
130130 return ntp;
131131 }
132132
....@@ -151,11 +151,9 @@
151151 uint blocks,
152152 uint rtextents)
153153 {
154
- int error = 0;
155
- bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0;
156
-
157
- /* Mark this thread as being in a transaction */
158
- current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
154
+ struct xfs_mount *mp = tp->t_mountp;
155
+ int error = 0;
156
+ bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0;
159157
160158 /*
161159 * Attempt to reserve the needed disk blocks by decrementing
....@@ -163,11 +161,9 @@
163161 * fail if the count would go below zero.
164162 */
165163 if (blocks > 0) {
166
- error = xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), rsvd);
167
- if (error != 0) {
168
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
164
+ error = xfs_mod_fdblocks(mp, -((int64_t)blocks), rsvd);
165
+ if (error != 0)
169166 return -ENOSPC;
170
- }
171167 tp->t_blk_res += blocks;
172168 }
173169
....@@ -192,9 +188,9 @@
192188
193189 if (tp->t_ticket != NULL) {
194190 ASSERT(resp->tr_logflags & XFS_TRANS_PERM_LOG_RES);
195
- error = xfs_log_regrant(tp->t_mountp, tp->t_ticket);
191
+ error = xfs_log_regrant(mp, tp->t_ticket);
196192 } else {
197
- error = xfs_log_reserve(tp->t_mountp,
193
+ error = xfs_log_reserve(mp,
198194 resp->tr_logres,
199195 resp->tr_logcount,
200196 &tp->t_ticket, XFS_TRANSACTION,
....@@ -214,7 +210,7 @@
214210 * fail if the count would go below zero.
215211 */
216212 if (rtextents > 0) {
217
- error = xfs_mod_frextents(tp->t_mountp, -((int64_t)rtextents));
213
+ error = xfs_mod_frextents(mp, -((int64_t)rtextents));
218214 if (error) {
219215 error = -ENOSPC;
220216 goto undo_log;
....@@ -230,7 +226,7 @@
230226 */
231227 undo_log:
232228 if (resp->tr_logres > 0) {
233
- xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, false);
229
+ xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket);
234230 tp->t_ticket = NULL;
235231 tp->t_log_res = 0;
236232 tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES;
....@@ -238,12 +234,9 @@
238234
239235 undo_blocks:
240236 if (blocks > 0) {
241
- xfs_mod_fdblocks(tp->t_mountp, (int64_t)blocks, rsvd);
237
+ xfs_mod_fdblocks(mp, (int64_t)blocks, rsvd);
242238 tp->t_blk_res = 0;
243239 }
244
-
245
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
246
-
247240 return error;
248241 }
249242
....@@ -264,11 +257,10 @@
264257 * GFP_NOFS allocation context so that we avoid lockdep false positives
265258 * by doing GFP_KERNEL allocations inside sb_start_intwrite().
266259 */
267
- tp = kmem_zone_zalloc(xfs_trans_zone,
268
- (flags & XFS_TRANS_NOFS) ? KM_NOFS : KM_SLEEP);
269
-
260
+ tp = kmem_cache_zalloc(xfs_trans_zone, GFP_KERNEL | __GFP_NOFAIL);
270261 if (!(flags & XFS_TRANS_NO_WRITECOUNT))
271262 sb_start_intwrite(mp->m_super);
263
+ xfs_trans_set_context(tp);
272264
273265 /*
274266 * Zero-reservation ("empty") transactions can't modify anything, so
....@@ -276,7 +268,8 @@
276268 */
277269 WARN_ON(resp->tr_logres > 0 &&
278270 mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
279
- atomic_inc(&mp->m_active_trans);
271
+ ASSERT(!(flags & XFS_TRANS_RES_FDBLKS) ||
272
+ xfs_sb_version_haslazysbcount(&mp->m_sb));
280273
281274 tp->t_magic = XFS_TRANS_HEADER_MAGIC;
282275 tp->t_flags = flags;
....@@ -300,15 +293,19 @@
300293
301294 /*
302295 * Create an empty transaction with no reservation. This is a defensive
303
- * mechanism for routines that query metadata without actually modifying
304
- * them -- if the metadata being queried is somehow cross-linked (think a
305
- * btree block pointer that points higher in the tree), we risk deadlock.
306
- * However, blocks grabbed as part of a transaction can be re-grabbed.
307
- * The verifiers will notice the corrupt block and the operation will fail
308
- * back to userspace without deadlocking.
296
+ * mechanism for routines that query metadata without actually modifying them --
297
+ * if the metadata being queried is somehow cross-linked (think a btree block
298
+ * pointer that points higher in the tree), we risk deadlock. However, blocks
299
+ * grabbed as part of a transaction can be re-grabbed. The verifiers will
300
+ * notice the corrupt block and the operation will fail back to userspace
301
+ * without deadlocking.
309302 *
310
- * Note the zero-length reservation; this transaction MUST be cancelled
311
- * without any dirty data.
303
+ * Note the zero-length reservation; this transaction MUST be cancelled without
304
+ * any dirty data.
305
+ *
306
+ * Callers should obtain freeze protection to avoid a conflict with fs freezing
307
+ * where we can be grabbing buffers at the same time that freeze is trying to
308
+ * drain the buffer LRU list.
312309 */
313310 int
314311 xfs_trans_alloc_empty(
....@@ -366,6 +363,20 @@
366363 tp->t_blk_res_used += (uint)-delta;
367364 if (tp->t_blk_res_used > tp->t_blk_res)
368365 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
366
+ } else if (delta > 0 && (tp->t_flags & XFS_TRANS_RES_FDBLKS)) {
367
+ int64_t blkres_delta;
368
+
369
+ /*
370
+ * Return freed blocks directly to the reservation
371
+ * instead of the global pool, being careful not to
372
+ * overflow the trans counter. This is used to preserve
373
+ * reservation across chains of transaction rolls that
374
+ * repeatedly free and allocate blocks.
375
+ */
376
+ blkres_delta = min_t(int64_t, delta,
377
+ UINT_MAX - tp->t_blk_res);
378
+ tp->t_blk_res += blkres_delta;
379
+ delta -= blkres_delta;
369380 }
370381 tp->t_fdblocks_delta += delta;
371382 if (xfs_sb_version_haslazysbcount(&mp->m_sb))
....@@ -452,8 +463,8 @@
452463 xfs_buf_t *bp;
453464 int whole = 0;
454465
455
- bp = xfs_trans_getsb(tp, tp->t_mountp, 0);
456
- sbp = XFS_BUF_TO_SBP(bp);
466
+ bp = xfs_trans_getsb(tp);
467
+ sbp = bp->b_addr;
457468
458469 /*
459470 * Check that superblock mods match the mods made to AGF counters.
....@@ -530,57 +541,9 @@
530541 sizeof(sbp->sb_frextents) - 1);
531542 }
532543
533
-STATIC int
534
-xfs_sb_mod8(
535
- uint8_t *field,
536
- int8_t delta)
537
-{
538
- int8_t counter = *field;
539
-
540
- counter += delta;
541
- if (counter < 0) {
542
- ASSERT(0);
543
- return -EINVAL;
544
- }
545
- *field = counter;
546
- return 0;
547
-}
548
-
549
-STATIC int
550
-xfs_sb_mod32(
551
- uint32_t *field,
552
- int32_t delta)
553
-{
554
- int32_t counter = *field;
555
-
556
- counter += delta;
557
- if (counter < 0) {
558
- ASSERT(0);
559
- return -EINVAL;
560
- }
561
- *field = counter;
562
- return 0;
563
-}
564
-
565
-STATIC int
566
-xfs_sb_mod64(
567
- uint64_t *field,
568
- int64_t delta)
569
-{
570
- int64_t counter = *field;
571
-
572
- counter += delta;
573
- if (counter < 0) {
574
- ASSERT(0);
575
- return -EINVAL;
576
- }
577
- *field = counter;
578
- return 0;
579
-}
580
-
581544 /*
582
- * xfs_trans_unreserve_and_mod_sb() is called to release unused reservations
583
- * and apply superblock counter changes to the in-core superblock. The
545
+ * xfs_trans_unreserve_and_mod_sb() is called to release unused reservations and
546
+ * apply superblock counter changes to the in-core superblock. The
584547 * t_res_fdblocks_delta and t_res_frextents_delta fields are explicitly NOT
585548 * applied to the in-core superblock. The idea is that that has already been
586549 * done.
....@@ -589,7 +552,12 @@
589552 * used block counts are not updated in the on disk superblock. In this case,
590553 * XFS_TRANS_SB_DIRTY will not be set when the transaction is updated but we
591554 * still need to update the incore superblock with the changes.
555
+ *
556
+ * Deltas for the inode count are +/-64, hence we use a large batch size of 128
557
+ * so we don't need to take the counter lock on every update.
592558 */
559
+#define XFS_ICOUNT_BATCH 128
560
+
593561 void
594562 xfs_trans_unreserve_and_mod_sb(
595563 struct xfs_trans *tp)
....@@ -625,20 +593,21 @@
625593 /* apply the per-cpu counters */
626594 if (blkdelta) {
627595 error = xfs_mod_fdblocks(mp, blkdelta, rsvd);
628
- if (error)
629
- goto out;
596
+ ASSERT(!error);
630597 }
631598
632599 if (idelta) {
633
- error = xfs_mod_icount(mp, idelta);
634
- if (error)
635
- goto out_undo_fdblocks;
600
+ percpu_counter_add_batch(&mp->m_icount, idelta,
601
+ XFS_ICOUNT_BATCH);
602
+ if (idelta < 0)
603
+ ASSERT(__percpu_counter_compare(&mp->m_icount, 0,
604
+ XFS_ICOUNT_BATCH) >= 0);
636605 }
637606
638607 if (ifreedelta) {
639
- error = xfs_mod_ifree(mp, ifreedelta);
640
- if (error)
641
- goto out_undo_icount;
608
+ percpu_counter_add(&mp->m_ifree, ifreedelta);
609
+ if (ifreedelta < 0)
610
+ ASSERT(percpu_counter_compare(&mp->m_ifree, 0) >= 0);
642611 }
643612
644613 if (rtxdelta == 0 && !(tp->t_flags & XFS_TRANS_SB_DIRTY))
....@@ -646,95 +615,26 @@
646615
647616 /* apply remaining deltas */
648617 spin_lock(&mp->m_sb_lock);
649
- if (rtxdelta) {
650
- error = xfs_sb_mod64(&mp->m_sb.sb_frextents, rtxdelta);
651
- if (error)
652
- goto out_undo_ifree;
653
- }
654
-
655
- if (tp->t_dblocks_delta != 0) {
656
- error = xfs_sb_mod64(&mp->m_sb.sb_dblocks, tp->t_dblocks_delta);
657
- if (error)
658
- goto out_undo_frextents;
659
- }
660
- if (tp->t_agcount_delta != 0) {
661
- error = xfs_sb_mod32(&mp->m_sb.sb_agcount, tp->t_agcount_delta);
662
- if (error)
663
- goto out_undo_dblocks;
664
- }
665
- if (tp->t_imaxpct_delta != 0) {
666
- error = xfs_sb_mod8(&mp->m_sb.sb_imax_pct, tp->t_imaxpct_delta);
667
- if (error)
668
- goto out_undo_agcount;
669
- }
670
- if (tp->t_rextsize_delta != 0) {
671
- error = xfs_sb_mod32(&mp->m_sb.sb_rextsize,
672
- tp->t_rextsize_delta);
673
- if (error)
674
- goto out_undo_imaxpct;
675
- }
676
- if (tp->t_rbmblocks_delta != 0) {
677
- error = xfs_sb_mod32(&mp->m_sb.sb_rbmblocks,
678
- tp->t_rbmblocks_delta);
679
- if (error)
680
- goto out_undo_rextsize;
681
- }
682
- if (tp->t_rblocks_delta != 0) {
683
- error = xfs_sb_mod64(&mp->m_sb.sb_rblocks, tp->t_rblocks_delta);
684
- if (error)
685
- goto out_undo_rbmblocks;
686
- }
687
- if (tp->t_rextents_delta != 0) {
688
- error = xfs_sb_mod64(&mp->m_sb.sb_rextents,
689
- tp->t_rextents_delta);
690
- if (error)
691
- goto out_undo_rblocks;
692
- }
693
- if (tp->t_rextslog_delta != 0) {
694
- error = xfs_sb_mod8(&mp->m_sb.sb_rextslog,
695
- tp->t_rextslog_delta);
696
- if (error)
697
- goto out_undo_rextents;
698
- }
618
+ mp->m_sb.sb_fdblocks += tp->t_fdblocks_delta + tp->t_res_fdblocks_delta;
619
+ mp->m_sb.sb_icount += idelta;
620
+ mp->m_sb.sb_ifree += ifreedelta;
621
+ mp->m_sb.sb_frextents += rtxdelta;
622
+ mp->m_sb.sb_dblocks += tp->t_dblocks_delta;
623
+ mp->m_sb.sb_agcount += tp->t_agcount_delta;
624
+ mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta;
625
+ mp->m_sb.sb_rextsize += tp->t_rextsize_delta;
626
+ mp->m_sb.sb_rbmblocks += tp->t_rbmblocks_delta;
627
+ mp->m_sb.sb_rblocks += tp->t_rblocks_delta;
628
+ mp->m_sb.sb_rextents += tp->t_rextents_delta;
629
+ mp->m_sb.sb_rextslog += tp->t_rextslog_delta;
699630 spin_unlock(&mp->m_sb_lock);
700
- return;
701631
702
-out_undo_rextents:
703
- if (tp->t_rextents_delta)
704
- xfs_sb_mod64(&mp->m_sb.sb_rextents, -tp->t_rextents_delta);
705
-out_undo_rblocks:
706
- if (tp->t_rblocks_delta)
707
- xfs_sb_mod64(&mp->m_sb.sb_rblocks, -tp->t_rblocks_delta);
708
-out_undo_rbmblocks:
709
- if (tp->t_rbmblocks_delta)
710
- xfs_sb_mod32(&mp->m_sb.sb_rbmblocks, -tp->t_rbmblocks_delta);
711
-out_undo_rextsize:
712
- if (tp->t_rextsize_delta)
713
- xfs_sb_mod32(&mp->m_sb.sb_rextsize, -tp->t_rextsize_delta);
714
-out_undo_imaxpct:
715
- if (tp->t_rextsize_delta)
716
- xfs_sb_mod8(&mp->m_sb.sb_imax_pct, -tp->t_imaxpct_delta);
717
-out_undo_agcount:
718
- if (tp->t_agcount_delta)
719
- xfs_sb_mod32(&mp->m_sb.sb_agcount, -tp->t_agcount_delta);
720
-out_undo_dblocks:
721
- if (tp->t_dblocks_delta)
722
- xfs_sb_mod64(&mp->m_sb.sb_dblocks, -tp->t_dblocks_delta);
723
-out_undo_frextents:
724
- if (rtxdelta)
725
- xfs_sb_mod64(&mp->m_sb.sb_frextents, -rtxdelta);
726
-out_undo_ifree:
727
- spin_unlock(&mp->m_sb_lock);
728
- if (ifreedelta)
729
- xfs_mod_ifree(mp, -ifreedelta);
730
-out_undo_icount:
731
- if (idelta)
732
- xfs_mod_icount(mp, -idelta);
733
-out_undo_fdblocks:
734
- if (blkdelta)
735
- xfs_mod_fdblocks(mp, -blkdelta, rsvd);
736
-out:
737
- ASSERT(error == 0);
632
+ /*
633
+ * Debug checks outside of the spinlock so they don't lock up the
634
+ * machine if they fail.
635
+ */
636
+ ASSERT(mp->m_sb.sb_imax_pct >= 0);
637
+ ASSERT(mp->m_sb.sb_rextslog >= 0);
738638 return;
739639 }
740640
....@@ -767,10 +667,9 @@
767667 }
768668
769669 /* Detach and unlock all of the items in a transaction */
770
-void
670
+static void
771671 xfs_trans_free_items(
772672 struct xfs_trans *tp,
773
- xfs_lsn_t commit_lsn,
774673 bool abort)
775674 {
776675 struct xfs_log_item *lip, *next;
....@@ -779,11 +678,10 @@
779678
780679 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
781680 xfs_trans_del_item(lip);
782
- if (commit_lsn != NULLCOMMITLSN)
783
- lip->li_ops->iop_committing(lip, commit_lsn);
784681 if (abort)
785682 set_bit(XFS_LI_ABORTED, &lip->li_flags);
786
- lip->li_ops->iop_unlock(lip);
683
+ if (lip->li_ops->iop_release)
684
+ lip->li_ops->iop_release(lip);
787685 }
788686 }
789687
....@@ -804,7 +702,8 @@
804702 for (i = 0; i < nr_items; i++) {
805703 struct xfs_log_item *lip = log_items[i];
806704
807
- lip->li_ops->iop_unpin(lip, 0);
705
+ if (lip->li_ops->iop_unpin)
706
+ lip->li_ops->iop_unpin(lip, 0);
808707 }
809708 }
810709
....@@ -815,7 +714,7 @@
815714 *
816715 * If we are called with the aborted flag set, it is because a log write during
817716 * a CIL checkpoint commit has failed. In this case, all the items in the
818
- * checkpoint have already gone through iop_commited and iop_unlock, which
717
+ * checkpoint have already gone through iop_committed and iop_committing, which
819718 * means that checkpoint commit abort handling is treated exactly the same
820719 * as an iclog write error even though we haven't started any IO yet. Hence in
821720 * this case all we need to do is iop_committed processing, followed by an
....@@ -833,7 +732,7 @@
833732 struct xfs_ail *ailp,
834733 struct xfs_log_vec *log_vector,
835734 xfs_lsn_t commit_lsn,
836
- int aborted)
735
+ bool aborted)
837736 {
838737 #define LOG_ITEM_BATCH_SIZE 32
839738 struct xfs_log_item *log_items[LOG_ITEM_BATCH_SIZE];
....@@ -852,7 +751,16 @@
852751
853752 if (aborted)
854753 set_bit(XFS_LI_ABORTED, &lip->li_flags);
855
- item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
754
+
755
+ if (lip->li_ops->flags & XFS_ITEM_RELEASE_WHEN_COMMITTED) {
756
+ lip->li_ops->iop_release(lip);
757
+ continue;
758
+ }
759
+
760
+ if (lip->li_ops->iop_committed)
761
+ item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
762
+ else
763
+ item_lsn = commit_lsn;
856764
857765 /* item_lsn of -1 means the item needs no further processing */
858766 if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0)
....@@ -864,7 +772,8 @@
864772 */
865773 if (aborted) {
866774 ASSERT(XFS_FORCED_SHUTDOWN(ailp->ail_mount));
867
- lip->li_ops->iop_unpin(lip, 1);
775
+ if (lip->li_ops->iop_unpin)
776
+ lip->li_ops->iop_unpin(lip, 1);
868777 continue;
869778 }
870779
....@@ -882,7 +791,8 @@
882791 xfs_trans_ail_update(ailp, lip, item_lsn);
883792 else
884793 spin_unlock(&ailp->ail_lock);
885
- lip->li_ops->iop_unpin(lip, 0);
794
+ if (lip->li_ops->iop_unpin)
795
+ lip->li_ops->iop_unpin(lip, 0);
886796 continue;
887797 }
888798
....@@ -922,7 +832,7 @@
922832 bool regrant)
923833 {
924834 struct xfs_mount *mp = tp->t_mountp;
925
- xfs_lsn_t commit_lsn = -1;
835
+ xfs_csn_t commit_seq = 0;
926836 int error = 0;
927837 int sync = tp->t_flags & XFS_TRANS_SYNC;
928838
....@@ -964,9 +874,8 @@
964874 xfs_trans_apply_sb_deltas(tp);
965875 xfs_trans_apply_dquot_deltas(tp);
966876
967
- xfs_log_commit_cil(mp, tp, &commit_lsn, regrant);
877
+ xlog_cil_commit(mp->m_log, tp, &commit_seq, regrant);
968878
969
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
970879 xfs_trans_free(tp);
971880
972881 /*
....@@ -974,7 +883,7 @@
974883 * log out now and wait for it.
975884 */
976885 if (sync) {
977
- error = xfs_log_force_lsn(mp, commit_lsn, XFS_LOG_SYNC, NULL);
886
+ error = xfs_log_force_seq(mp, commit_seq, XFS_LOG_SYNC, NULL);
978887 XFS_STATS_INC(mp, xs_trans_sync);
979888 } else {
980889 XFS_STATS_INC(mp, xs_trans_async);
....@@ -992,13 +901,13 @@
992901 */
993902 xfs_trans_unreserve_and_mod_dquots(tp);
994903 if (tp->t_ticket) {
995
- commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, regrant);
996
- if (commit_lsn == -1 && !error)
997
- error = -EIO;
904
+ if (regrant && !XLOG_FORCED_SHUTDOWN(mp->m_log))
905
+ xfs_log_ticket_regrant(mp->m_log, tp->t_ticket);
906
+ else
907
+ xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket);
998908 tp->t_ticket = NULL;
999909 }
1000
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
1001
- xfs_trans_free_items(tp, NULLCOMMITLSN, !!error);
910
+ xfs_trans_free_items(tp, !!error);
1002911 xfs_trans_free(tp);
1003912
1004913 XFS_STATS_INC(mp, xs_trans_empty);
....@@ -1046,21 +955,18 @@
1046955 struct xfs_log_item *lip;
1047956
1048957 list_for_each_entry(lip, &tp->t_items, li_trans)
1049
- ASSERT(!(lip->li_type == XFS_LI_EFD));
958
+ ASSERT(!xlog_item_is_intent_done(lip));
1050959 }
1051960 #endif
1052961 xfs_trans_unreserve_and_mod_sb(tp);
1053962 xfs_trans_unreserve_and_mod_dquots(tp);
1054963
1055964 if (tp->t_ticket) {
1056
- xfs_log_done(mp, tp->t_ticket, NULL, false);
965
+ xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket);
1057966 tp->t_ticket = NULL;
1058967 }
1059968
1060
- /* mark this thread as no longer being in a transaction */
1061
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
1062
-
1063
- xfs_trans_free_items(tp, NULLCOMMITLSN, dirty);
969
+ xfs_trans_free_items(tp, dirty);
1064970 xfs_trans_free(tp);
1065971 }
1066972