This is a note to let you know that I've just added the patch titled xfs: factor out a xfs_defer_create_intent helper to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-factor-out-a-xfs_defer_create_intent-helper.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From chandan.babu@xxxxxxxxxx Thu Feb 16 06:21:02 2023 From: Chandan Babu R <chandan.babu@xxxxxxxxxx> Date: Thu, 16 Feb 2023 10:49:58 +0530 Subject: xfs: factor out a xfs_defer_create_intent helper To: gregkh@xxxxxxxxxxxxxxxxxxx Cc: sashal@xxxxxxxxxx, mcgrof@xxxxxxxxxx, linux-xfs@xxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx, djwong@xxxxxxxxxx, chandan.babu@xxxxxxxxxx, amir73il@xxxxxxxxx, leah.rumancik@xxxxxxxxx Message-ID: <20230216052019.368896-5-chandan.babu@xxxxxxxxxx> From: Christoph Hellwig <hch@xxxxxx> commit e046e949486ec92d83b2ccdf0e7e9144f74ef028 upstream. Create a helper that encapsulates the whole logic to create a defer intent. This reorders some of the work that was done, but none of that has an affect on the operation as only fields that don't directly interact are affected. Signed-off-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx> Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Signed-off-by: Chandan Babu R <chandan.babu@xxxxxxxxxx> Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/xfs/libxfs/xfs_defer.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -178,6 +178,23 @@ static const struct xfs_defer_op_type *d [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, }; +static void +xfs_defer_create_intent( + struct xfs_trans *tp, + struct xfs_defer_pending *dfp, + bool sort) +{ + const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type]; + struct list_head *li; + + if (sort) + list_sort(tp->t_mountp, &dfp->dfp_work, ops->diff_items); + + dfp->dfp_intent = ops->create_intent(tp, dfp->dfp_count); + list_for_each(li, &dfp->dfp_work) + ops->log_item(tp, dfp->dfp_intent, li); +} + /* * For each pending item in the intake list, log its intent item and the * associated extents, then add the entire intake list to the end of @@ -187,17 +204,11 @@ STATIC void xfs_defer_create_intents( struct xfs_trans *tp) { - struct list_head *li; struct xfs_defer_pending *dfp; - const struct xfs_defer_op_type *ops; list_for_each_entry(dfp, &tp->t_dfops, dfp_list) { - ops = defer_op_types[dfp->dfp_type]; - dfp->dfp_intent = ops->create_intent(tp, dfp->dfp_count); trace_xfs_defer_create_intent(tp->t_mountp, dfp); - list_sort(tp->t_mountp, &dfp->dfp_work, ops->diff_items); - list_for_each(li, &dfp->dfp_work) - ops->log_item(tp, dfp->dfp_intent, li); + xfs_defer_create_intent(tp, dfp, true); } } @@ -427,17 +438,13 @@ xfs_defer_finish_noroll( } if (error == -EAGAIN) { /* - * Caller wants a fresh transaction, so log a - * new log intent item to replace the old one - * and roll the transaction. See "Requesting - * a Fresh Transaction while Finishing - * Deferred Work" above. + * Caller wants a fresh transaction, so log a new log + * intent item to replace the old one and roll the + * transaction. See "Requesting a Fresh Transaction + * while Finishing Deferred Work" above. */ - dfp->dfp_intent = ops->create_intent(*tp, - dfp->dfp_count); dfp->dfp_done = NULL; - list_for_each(li, &dfp->dfp_work) - ops->log_item(*tp, dfp->dfp_intent, li); + xfs_defer_create_intent(*tp, dfp, false); } else { /* Done with the dfp, free it. */ list_del(&dfp->dfp_list); Patches currently in stable-queue which might be from chandan.babu@xxxxxxxxxx are queue-5.4/xfs-remove-the-xfs_efd_log_item_t-typedef.patch queue-5.4/xfs-change-the-order-in-which-child-and-parent-defer-ops-are-finished.patch queue-5.4/xfs-refactor-xfs_defer_finish_noroll.patch queue-5.4/xfs-sync-lazy-sb-accounting-on-quiesce-of-read-only-mounts.patch queue-5.4/xfs-clean-up-xfs_bui_item_recover-iget-trans_alloc-ilock-ordering.patch queue-5.4/xfs-xfs_defer_capture-should-absorb-remaining-block-reservations.patch queue-5.4/xfs-factor-out-a-xfs_defer_create_intent-helper.patch queue-5.4/xfs-turn-dfp_intent-into-a-xfs_log_item.patch queue-5.4/xfs-fix-finobt-btree-block-recovery-ordering.patch queue-5.4/xfs-xfs_defer_capture-should-absorb-remaining-transaction-reservation.patch queue-5.4/xfs-merge-the-diff_items-defer-op-into-create_intent.patch queue-5.4/xfs-prevent-uaf-in-xfs_log_item_in_current_chkpt.patch queue-5.4/xfs-fix-missing-cow-blocks-writeback-conversion-retry.patch queue-5.4/xfs-remove-the-xfs_efi_log_item_t-typedef.patch queue-5.4/xfs-only-relog-deferred-intent-items-if-free-space-in-the-log-gets-low.patch queue-5.4/xfs-proper-replay-of-deferred-ops-queued-during-log-recovery.patch queue-5.4/xfs-clean-up-bmap-intent-item-recovery-checking.patch queue-5.4/xfs-fix-the-forward-progress-assertion-in-xfs_iwalk_run_callbacks.patch queue-5.4/xfs-log-new-intent-items-created-as-part-of-finishing-recovered-intent-items.patch queue-5.4/xfs-ensure-inobt-record-walks-always-make-forward-progress.patch queue-5.4/xfs-remove-the-xfs_inode_log_item_t-typedef.patch queue-5.4/xfs-fix-an-incore-inode-uaf-in-xfs_bui_recover.patch queue-5.4/xfs-expose-the-log-push-threshold.patch queue-5.4/xfs-periodically-relog-deferred-intent-items.patch queue-5.4/xfs-merge-the-log_item-defer-op-into-create_intent.patch