aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_trans.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_trans.c')
-rw-r--r--fs/xfs/xfs_trans.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 912b42f5fe4a..d42a68d8313b 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -11,7 +11,6 @@
11#include "xfs_log_format.h" 11#include "xfs_log_format.h"
12#include "xfs_trans_resv.h" 12#include "xfs_trans_resv.h"
13#include "xfs_mount.h" 13#include "xfs_mount.h"
14#include "xfs_inode.h"
15#include "xfs_extent_busy.h" 14#include "xfs_extent_busy.h"
16#include "xfs_quota.h" 15#include "xfs_quota.h"
17#include "xfs_trans.h" 16#include "xfs_trans.h"
@@ -264,9 +263,7 @@ xfs_trans_alloc(
264 * GFP_NOFS allocation context so that we avoid lockdep false positives 263 * GFP_NOFS allocation context so that we avoid lockdep false positives
265 * by doing GFP_KERNEL allocations inside sb_start_intwrite(). 264 * by doing GFP_KERNEL allocations inside sb_start_intwrite().
266 */ 265 */
267 tp = kmem_zone_zalloc(xfs_trans_zone, 266 tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP);
268 (flags & XFS_TRANS_NOFS) ? KM_NOFS : KM_SLEEP);
269
270 if (!(flags & XFS_TRANS_NO_WRITECOUNT)) 267 if (!(flags & XFS_TRANS_NO_WRITECOUNT))
271 sb_start_intwrite(mp->m_super); 268 sb_start_intwrite(mp->m_super);
272 269
@@ -452,7 +449,7 @@ xfs_trans_apply_sb_deltas(
452 xfs_buf_t *bp; 449 xfs_buf_t *bp;
453 int whole = 0; 450 int whole = 0;
454 451
455 bp = xfs_trans_getsb(tp, tp->t_mountp, 0); 452 bp = xfs_trans_getsb(tp, tp->t_mountp);
456 sbp = XFS_BUF_TO_SBP(bp); 453 sbp = XFS_BUF_TO_SBP(bp);
457 454
458 /* 455 /*
@@ -767,10 +764,9 @@ xfs_trans_del_item(
767} 764}
768 765
769/* Detach and unlock all of the items in a transaction */ 766/* Detach and unlock all of the items in a transaction */
770void 767static void
771xfs_trans_free_items( 768xfs_trans_free_items(
772 struct xfs_trans *tp, 769 struct xfs_trans *tp,
773 xfs_lsn_t commit_lsn,
774 bool abort) 770 bool abort)
775{ 771{
776 struct xfs_log_item *lip, *next; 772 struct xfs_log_item *lip, *next;
@@ -779,11 +775,10 @@ xfs_trans_free_items(
779 775
780 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { 776 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
781 xfs_trans_del_item(lip); 777 xfs_trans_del_item(lip);
782 if (commit_lsn != NULLCOMMITLSN)
783 lip->li_ops->iop_committing(lip, commit_lsn);
784 if (abort) 778 if (abort)
785 set_bit(XFS_LI_ABORTED, &lip->li_flags); 779 set_bit(XFS_LI_ABORTED, &lip->li_flags);
786 lip->li_ops->iop_unlock(lip); 780 if (lip->li_ops->iop_release)
781 lip->li_ops->iop_release(lip);
787 } 782 }
788} 783}
789 784
@@ -804,7 +799,8 @@ xfs_log_item_batch_insert(
804 for (i = 0; i < nr_items; i++) { 799 for (i = 0; i < nr_items; i++) {
805 struct xfs_log_item *lip = log_items[i]; 800 struct xfs_log_item *lip = log_items[i];
806 801
807 lip->li_ops->iop_unpin(lip, 0); 802 if (lip->li_ops->iop_unpin)
803 lip->li_ops->iop_unpin(lip, 0);
808 } 804 }
809} 805}
810 806
@@ -815,7 +811,7 @@ xfs_log_item_batch_insert(
815 * 811 *
816 * If we are called with the aborted flag set, it is because a log write during 812 * If we are called with the aborted flag set, it is because a log write during
817 * a CIL checkpoint commit has failed. In this case, all the items in the 813 * 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 814 * checkpoint have already gone through iop_committed and iop_committing, which
819 * means that checkpoint commit abort handling is treated exactly the same 815 * means that checkpoint commit abort handling is treated exactly the same
820 * as an iclog write error even though we haven't started any IO yet. Hence in 816 * as an iclog write error even though we haven't started any IO yet. Hence in
821 * this case all we need to do is iop_committed processing, followed by an 817 * this case all we need to do is iop_committed processing, followed by an
@@ -833,7 +829,7 @@ xfs_trans_committed_bulk(
833 struct xfs_ail *ailp, 829 struct xfs_ail *ailp,
834 struct xfs_log_vec *log_vector, 830 struct xfs_log_vec *log_vector,
835 xfs_lsn_t commit_lsn, 831 xfs_lsn_t commit_lsn,
836 int aborted) 832 bool aborted)
837{ 833{
838#define LOG_ITEM_BATCH_SIZE 32 834#define LOG_ITEM_BATCH_SIZE 32
839 struct xfs_log_item *log_items[LOG_ITEM_BATCH_SIZE]; 835 struct xfs_log_item *log_items[LOG_ITEM_BATCH_SIZE];
@@ -852,7 +848,16 @@ xfs_trans_committed_bulk(
852 848
853 if (aborted) 849 if (aborted)
854 set_bit(XFS_LI_ABORTED, &lip->li_flags); 850 set_bit(XFS_LI_ABORTED, &lip->li_flags);
855 item_lsn = lip->li_ops->iop_committed(lip, commit_lsn); 851
852 if (lip->li_ops->flags & XFS_ITEM_RELEASE_WHEN_COMMITTED) {
853 lip->li_ops->iop_release(lip);
854 continue;
855 }
856
857 if (lip->li_ops->iop_committed)
858 item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
859 else
860 item_lsn = commit_lsn;
856 861
857 /* item_lsn of -1 means the item needs no further processing */ 862 /* item_lsn of -1 means the item needs no further processing */
858 if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0) 863 if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0)
@@ -864,7 +869,8 @@ xfs_trans_committed_bulk(
864 */ 869 */
865 if (aborted) { 870 if (aborted) {
866 ASSERT(XFS_FORCED_SHUTDOWN(ailp->ail_mount)); 871 ASSERT(XFS_FORCED_SHUTDOWN(ailp->ail_mount));
867 lip->li_ops->iop_unpin(lip, 1); 872 if (lip->li_ops->iop_unpin)
873 lip->li_ops->iop_unpin(lip, 1);
868 continue; 874 continue;
869 } 875 }
870 876
@@ -882,7 +888,8 @@ xfs_trans_committed_bulk(
882 xfs_trans_ail_update(ailp, lip, item_lsn); 888 xfs_trans_ail_update(ailp, lip, item_lsn);
883 else 889 else
884 spin_unlock(&ailp->ail_lock); 890 spin_unlock(&ailp->ail_lock);
885 lip->li_ops->iop_unpin(lip, 0); 891 if (lip->li_ops->iop_unpin)
892 lip->li_ops->iop_unpin(lip, 0);
886 continue; 893 continue;
887 } 894 }
888 895
@@ -998,7 +1005,7 @@ out_unreserve:
998 tp->t_ticket = NULL; 1005 tp->t_ticket = NULL;
999 } 1006 }
1000 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); 1007 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
1001 xfs_trans_free_items(tp, NULLCOMMITLSN, !!error); 1008 xfs_trans_free_items(tp, !!error);
1002 xfs_trans_free(tp); 1009 xfs_trans_free(tp);
1003 1010
1004 XFS_STATS_INC(mp, xs_trans_empty); 1011 XFS_STATS_INC(mp, xs_trans_empty);
@@ -1060,7 +1067,7 @@ xfs_trans_cancel(
1060 /* mark this thread as no longer being in a transaction */ 1067 /* mark this thread as no longer being in a transaction */
1061 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); 1068 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
1062 1069
1063 xfs_trans_free_items(tp, NULLCOMMITLSN, dirty); 1070 xfs_trans_free_items(tp, dirty);
1064 xfs_trans_free(tp); 1071 xfs_trans_free(tp);
1065} 1072}
1066 1073