Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: don't use xfs_trans_free_items in the commit path

While commiting items looks very similar to freeing them on error it is
a different operation, and they will diverge a bit soon.

Split out the commit case from xfs_trans_free_items, inline it into
xfs_log_commit_cil and give it a separate trace point.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

authored by

Christoph Hellwig and committed by
Darrick J. Wong
195cd83d 8e4b20ea

+14 -12
+10 -3
fs/xfs/xfs_log_cil.c
··· 985 985 { 986 986 struct xlog *log = mp->m_log; 987 987 struct xfs_cil *cil = log->l_cilp; 988 + struct xfs_log_item *lip, *next; 988 989 xfs_lsn_t xc_commit_lsn; 989 990 990 991 /* ··· 1010 1009 1011 1010 /* 1012 1011 * Once all the items of the transaction have been copied to the CIL, 1013 - * the items can be unlocked and freed. 1012 + * the items can be unlocked and possibly freed. 1014 1013 * 1015 1014 * This needs to be done before we drop the CIL context lock because we 1016 1015 * have to update state in the log items and unlock them before they go ··· 1019 1018 * the log items. This affects (at least) processing of stale buffers, 1020 1019 * inodes and EFIs. 1021 1020 */ 1022 - xfs_trans_free_items(tp, xc_commit_lsn, false); 1023 - 1021 + trace_xfs_trans_commit_items(tp, _RET_IP_); 1022 + list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { 1023 + xfs_trans_del_item(lip); 1024 + if (lip->li_ops->iop_committing) 1025 + lip->li_ops->iop_committing(lip, xc_commit_lsn); 1026 + if (lip->li_ops->iop_unlock) 1027 + lip->li_ops->iop_unlock(lip); 1028 + } 1024 1029 xlog_cil_push_background(log); 1025 1030 1026 1031 up_read(&cil->xc_ctx_lock);
+1
fs/xfs/xfs_trace.h
··· 3360 3360 DEFINE_TRANS_EVENT(xfs_trans_free); 3361 3361 DEFINE_TRANS_EVENT(xfs_trans_roll); 3362 3362 DEFINE_TRANS_EVENT(xfs_trans_add_item); 3363 + DEFINE_TRANS_EVENT(xfs_trans_commit_items); 3363 3364 DEFINE_TRANS_EVENT(xfs_trans_free_items); 3364 3365 3365 3366 TRACE_EVENT(xfs_iunlink_update_bucket,
+3 -7
fs/xfs/xfs_trans.c
··· 767 767 } 768 768 769 769 /* Detach and unlock all of the items in a transaction */ 770 - void 770 + static void 771 771 xfs_trans_free_items( 772 772 struct xfs_trans *tp, 773 - xfs_lsn_t commit_lsn, 774 773 bool abort) 775 774 { 776 775 struct xfs_log_item *lip, *next; ··· 778 779 779 780 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) { 780 781 xfs_trans_del_item(lip); 781 - if (commit_lsn != NULLCOMMITLSN && 782 - lip->li_ops->iop_committing) 783 - lip->li_ops->iop_committing(lip, commit_lsn); 784 782 if (abort) 785 783 set_bit(XFS_LI_ABORTED, &lip->li_flags); 786 784 ··· 1003 1007 tp->t_ticket = NULL; 1004 1008 } 1005 1009 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); 1006 - xfs_trans_free_items(tp, NULLCOMMITLSN, !!error); 1010 + xfs_trans_free_items(tp, !!error); 1007 1011 xfs_trans_free(tp); 1008 1012 1009 1013 XFS_STATS_INC(mp, xs_trans_empty); ··· 1065 1069 /* mark this thread as no longer being in a transaction */ 1066 1070 current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); 1067 1071 1068 - xfs_trans_free_items(tp, NULLCOMMITLSN, dirty); 1072 + xfs_trans_free_items(tp, dirty); 1069 1073 xfs_trans_free(tp); 1070 1074 } 1071 1075
-2
fs/xfs/xfs_trans_priv.h
··· 16 16 void xfs_trans_init(struct xfs_mount *); 17 17 void xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *); 18 18 void xfs_trans_del_item(struct xfs_log_item *); 19 - void xfs_trans_free_items(struct xfs_trans *tp, xfs_lsn_t commit_lsn, 20 - bool abort); 21 19 void xfs_trans_unreserve_and_mod_sb(struct xfs_trans *tp); 22 20 23 21 void xfs_trans_committed_bulk(struct xfs_ail *ailp, struct xfs_log_vec *lv,