This is a note to let you know that I've just added the patch titled xfs: factor common AIL item deletion code 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-common-ail-item-deletion-code.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 foo@baz Wed Oct 26 04:49:40 PM CEST 2022 From: Chandan Babu R <chandan.babu@xxxxxxxxxx> Date: Wed, 26 Oct 2022 11:58:36 +0530 Subject: xfs: factor common AIL item deletion code 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: <20221026062843.927600-20-chandan.babu@xxxxxxxxxx> From: Dave Chinner <dchinner@xxxxxxxxxx> commit 4165994ac9672d91134675caa6de3645a9ace6c8 upstream. Factor the common AIL deletion code that does all the wakeups into a helper so we only have one copy of this somewhat tricky code to interface with all the wakeups necessary when the LSN of the log tail changes. Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Allison Collins <allison.henderson@xxxxxxxxxx> Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx> Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Chandan Babu R <chandan.babu@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/xfs/xfs_inode_item.c | 12 +----------- fs/xfs/xfs_trans_ail.c | 48 ++++++++++++++++++++++++++---------------------- fs/xfs/xfs_trans_priv.h | 4 +++- 3 files changed, 30 insertions(+), 34 deletions(-) --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -744,17 +744,7 @@ xfs_iflush_done( xfs_clear_li_failed(blip); } } - - if (mlip_changed) { - if (!XFS_FORCED_SHUTDOWN(ailp->ail_mount)) - xlog_assign_tail_lsn_locked(ailp->ail_mount); - if (list_empty(&ailp->ail_head)) - wake_up_all(&ailp->ail_empty); - } - spin_unlock(&ailp->ail_lock); - - if (mlip_changed) - xfs_log_space_wake(ailp->ail_mount); + xfs_ail_update_finish(ailp, mlip_changed); } /* --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c @@ -680,6 +680,27 @@ xfs_ail_push_all_sync( finish_wait(&ailp->ail_empty, &wait); } +void +xfs_ail_update_finish( + struct xfs_ail *ailp, + bool do_tail_update) __releases(ailp->ail_lock) +{ + struct xfs_mount *mp = ailp->ail_mount; + + if (!do_tail_update) { + spin_unlock(&ailp->ail_lock); + return; + } + + if (!XFS_FORCED_SHUTDOWN(mp)) + xlog_assign_tail_lsn_locked(mp); + + if (list_empty(&ailp->ail_head)) + wake_up_all(&ailp->ail_empty); + spin_unlock(&ailp->ail_lock); + xfs_log_space_wake(mp); +} + /* * xfs_trans_ail_update - bulk AIL insertion operation. * @@ -739,15 +760,7 @@ xfs_trans_ail_update_bulk( if (!list_empty(&tmp)) xfs_ail_splice(ailp, cur, &tmp, lsn); - if (mlip_changed) { - if (!XFS_FORCED_SHUTDOWN(ailp->ail_mount)) - xlog_assign_tail_lsn_locked(ailp->ail_mount); - spin_unlock(&ailp->ail_lock); - - xfs_log_space_wake(ailp->ail_mount); - } else { - spin_unlock(&ailp->ail_lock); - } + xfs_ail_update_finish(ailp, mlip_changed); } bool @@ -791,10 +804,10 @@ void xfs_trans_ail_delete( struct xfs_ail *ailp, struct xfs_log_item *lip, - int shutdown_type) __releases(ailp->ail_lock) + int shutdown_type) { struct xfs_mount *mp = ailp->ail_mount; - bool mlip_changed; + bool need_update; if (!test_bit(XFS_LI_IN_AIL, &lip->li_flags)) { spin_unlock(&ailp->ail_lock); @@ -807,17 +820,8 @@ xfs_trans_ail_delete( return; } - mlip_changed = xfs_ail_delete_one(ailp, lip); - if (mlip_changed) { - if (!XFS_FORCED_SHUTDOWN(mp)) - xlog_assign_tail_lsn_locked(mp); - if (list_empty(&ailp->ail_head)) - wake_up_all(&ailp->ail_empty); - } - - spin_unlock(&ailp->ail_lock); - if (mlip_changed) - xfs_log_space_wake(ailp->ail_mount); + need_update = xfs_ail_delete_one(ailp, lip); + xfs_ail_update_finish(ailp, need_update); } int --- a/fs/xfs/xfs_trans_priv.h +++ b/fs/xfs/xfs_trans_priv.h @@ -92,8 +92,10 @@ xfs_trans_ail_update( } bool xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip); +void xfs_ail_update_finish(struct xfs_ail *ailp, bool do_tail_update) + __releases(ailp->ail_lock); void xfs_trans_ail_delete(struct xfs_ail *ailp, struct xfs_log_item *lip, - int shutdown_type) __releases(ailp->ail_lock); + int shutdown_type); static inline void xfs_trans_ail_remove( Patches currently in stable-queue which might be from chandan.babu@xxxxxxxxxx are queue-5.4/xfs-check-owner-of-dir3-blocks.patch queue-5.4/xfs-throttle-commits-on-delayed-background-cil-push.patch queue-5.4/xfs-factor-common-ail-item-deletion-code.patch queue-5.4/xfs-remove-the-xfs_dq_logitem_t-typedef.patch queue-5.4/xfs-fix-buffer-corruption-reporting-when-xfs_dir3_free_header_check-fails.patch queue-5.4/xfs-xfs_buf_corruption_error-should-take-__this_address.patch queue-5.4/xfs-open-code-insert-range-extent-split-helper.patch queue-5.4/xfs-don-t-write-a-corrupt-unmount-record-to-force-summary-counter-recalc.patch queue-5.4/xfs-check-owner-of-dir3-data-blocks.patch queue-5.4/xfs-factor-out-quotaoff-intent-ail-removal-and-memory-free.patch queue-5.4/xfs-trylock-underlying-buffer-on-dquot-flush.patch queue-5.4/xfs-remove-the-xfs_disk_dquot_t-and-xfs_dquot_t.patch queue-5.4/xfs-add-a-function-to-deal-with-corrupt-buffers-post-verifiers.patch queue-5.4/xfs-fix-use-after-free-on-cil-context-on-shutdown.patch queue-5.4/xfs-tail-updates-only-need-to-occur-when-lsn-changes.patch queue-5.4/xfs-use-scnprintf-for-avoiding-potential-buffer-overflow.patch queue-5.4/xfs-move-inode-flush-to-the-sync-workqueue.patch queue-5.4/xfs-lower-cil-flush-limit-for-large-logs.patch queue-5.4/xfs-rework-collapse-range-into-an-atomic-operation.patch queue-5.4/xfs-remove-the-xfs_qoff_logitem_t-typedef.patch queue-5.4/xfs-fix-unmount-hang-and-memory-leak-on-shutdown-during-quotaoff.patch queue-5.4/xfs-preserve-default-grace-interval-during-quotacheck.patch queue-5.4/xfs-replace-function-declaration-by-actual-definition.patch queue-5.4/xfs-rework-insert-range-into-an-atomic-operation.patch queue-5.4/xfs-factor-out-a-new-xfs_log_force_inode-helper.patch queue-5.4/xfs-reflink-should-force-the-log-out-if-mounted-with-wsync.patch