From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/9] xfs: reowrk up xlog_state_do_callback
Date: Thu, 8 Jul 2021 21:42:14 -0700 [thread overview]
Message-ID: <20210709044214.GY11588@locust> (raw)
In-Reply-To: <20210630063813.1751007-7-david@fromorbit.com>
On Wed, Jun 30, 2021 at 04:38:10PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Clean it up a bit by factoring and rearranging some of the code.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
> fs/xfs/xfs_log.c | 99 ++++++++++++++++++++++++++----------------------
> 1 file changed, 53 insertions(+), 46 deletions(-)
>
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 6c7cfc052135..bb44dcfcae89 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -2758,67 +2758,74 @@ xlog_state_iodone_process_iclog(
> }
> }
>
> +/*
> + * Loop over all the iclogs, running attached callbacks on them. Return true if
> + * we ran any callbacks, indicating that we dropped the icloglock.
> + */
> +static bool
> +xlog_state_do_iclog_callbacks(
> + struct xlog *log)
> + __releases(&log->l_icloglock)
> + __acquires(&log->l_icloglock)
> +{
> + struct xlog_in_core *iclog = log->l_iclog;
> + struct xlog_in_core *first_iclog = NULL;
> + bool ran_callback = false;
> +
> + for (; iclog != first_iclog; iclog = iclog->ic_next) {
> + LIST_HEAD(cb_list);
> +
> + if (!first_iclog)
> + first_iclog = iclog;
> +
> + if (!xlog_is_shutdown(log)) {
> + if (xlog_state_iodone_process_iclog(log, iclog))
> + break;
> + if (iclog->ic_state != XLOG_STATE_CALLBACK)
> + continue;
> + }
> + list_splice_init(&iclog->ic_callbacks, &cb_list);
> + spin_unlock(&log->l_icloglock);
> +
> + trace_xlog_iclog_callbacks_start(iclog, _RET_IP_);
> + xlog_cil_process_committed(&cb_list);
> + trace_xlog_iclog_callbacks_done(iclog, _RET_IP_);
> + ran_callback = true;
> +
> + spin_lock(&log->l_icloglock);
> + if (xlog_is_shutdown(log))
> + wake_up_all(&iclog->ic_force_wait);
> + else
> + xlog_state_clean_iclog(log, iclog);
> + };
Aside from the unnecessary semicolon here...
> + return ran_callback;
> +}
> +
> +
> +/*
> + * Loop running iclog completion callbacks until there are no more iclogs in a
> + * state that can run callbacks.
> + */
> STATIC void
> xlog_state_do_callback(
> struct xlog *log)
> {
> - struct xlog_in_core *iclog;
> - struct xlog_in_core *first_iclog;
> - bool cycled_icloglock;
> int flushcnt = 0;
> int repeats = 0;
>
> spin_lock(&log->l_icloglock);
> - do {
> - repeats++;
> + while (xlog_state_do_iclog_callbacks(log)) {
> + if (xlog_is_shutdown(log))
> + break;
>
> - /*
> - * Scan all iclogs starting with the one pointed to by the
> - * log. Reset this starting point each time the log is
> - * unlocked (during callbacks).
> - *
> - * Keep looping through iclogs until one full pass is made
> - * without running any callbacks.
> - */
> - cycled_icloglock = false;
> - first_iclog = NULL;
> - for (iclog = log->l_iclog;
> - iclog != first_iclog;
> - iclog = iclog->ic_next) {
> - LIST_HEAD(cb_list);
> -
> - if (!first_iclog)
> - first_iclog = iclog;
> -
> - if (!xlog_is_shutdown(log)) {
> - if (xlog_state_iodone_process_iclog(log, iclog))
> - break;
> - if (iclog->ic_state != XLOG_STATE_CALLBACK)
> - continue;
> - }
> - list_splice_init(&iclog->ic_callbacks, &cb_list);
> - spin_unlock(&log->l_icloglock);
> -
> - trace_xlog_iclog_callbacks_start(iclog, _RET_IP_);
> - xlog_cil_process_committed(&cb_list);
> - trace_xlog_iclog_callbacks_done(iclog, _RET_IP_);
> - cycled_icloglock = true;
> -
> - spin_lock(&log->l_icloglock);
> - if (xlog_is_shutdown(log))
> - wake_up_all(&iclog->ic_force_wait);
> - else
> - xlog_state_clean_iclog(log, iclog);
> - };
> -
> - if (repeats > 5000) {
> + if (repeats++ > 5000) {
> flushcnt += repeats;
> repeats = 0;
> xfs_warn(log->l_mp,
> "%s: possible infinite loop (%d iterations)",
> __func__, flushcnt);
> }
> - } while (!xlog_is_shutdown(log) && cycled_icloglock);
> + };
...and here, this looks like a simple hoist.
With that fixed,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
>
> if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE ||
> xlog_is_shutdown(log))
> --
> 2.31.1
>
next prev parent reply other threads:[~2021-07-09 4:42 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-30 6:38 [PATCH 0/9] xfs: shutdown is a racy mess Dave Chinner
2021-06-30 6:38 ` [PATCH 1/9] xfs: convert XLOG_FORCED_SHUTDOWN() to xlog_is_shutdown() Dave Chinner
2021-06-30 16:10 ` Darrick J. Wong
2021-07-02 7:48 ` Christoph Hellwig
2021-07-02 8:45 ` Dave Chinner
2021-07-02 9:27 ` Christoph Hellwig
2021-06-30 6:38 ` [PATCH 2/9] xfs: XLOG_STATE_IOERROR must die Dave Chinner
2021-06-30 15:22 ` kernel test robot
2021-06-30 15:22 ` [PATCH] xfs: fix semicolon.cocci warnings kernel test robot
2021-07-02 8:00 ` [PATCH 2/9] xfs: XLOG_STATE_IOERROR must die Christoph Hellwig
2021-07-02 8:55 ` Dave Chinner
2021-06-30 6:38 ` [PATCH 3/9] xfs: move recovery needed state updates to xfs_log_mount_finish Dave Chinner
2021-07-02 8:10 ` Christoph Hellwig
2021-06-30 6:38 ` [PATCH 4/9] xfs: convert log flags to an operational state field Dave Chinner
2021-07-02 8:15 ` Christoph Hellwig
2021-07-09 4:33 ` Darrick J. Wong
2021-06-30 6:38 ` [PATCH 5/9] xfs: make forced shutdown processing atomic Dave Chinner
2021-07-02 8:24 ` Christoph Hellwig
2021-07-05 1:28 ` Dave Chinner
2021-07-09 4:40 ` Darrick J. Wong
2021-07-14 3:15 ` Dave Chinner
2021-07-14 5:02 ` Darrick J. Wong
2021-06-30 6:38 ` [PATCH 6/9] xfs: reowrk up xlog_state_do_callback Dave Chinner
2021-07-02 8:28 ` Christoph Hellwig
2021-07-09 4:42 ` Darrick J. Wong [this message]
2021-06-30 6:38 ` [PATCH 7/9] xfs: separate out log shutdown callback processing Dave Chinner
2021-07-02 8:36 ` Christoph Hellwig
2021-07-05 1:46 ` Dave Chinner
2021-06-30 6:38 ` [PATCH 8/9] xfs: don't run shutdown callbacks on active iclogs Dave Chinner
2021-07-02 8:48 ` Christoph Hellwig
2021-07-05 2:04 ` Dave Chinner
2021-06-30 6:38 ` [PATCH 9/9] xfs: log head and tail aren't reliable during shutdown Dave Chinner
2021-07-02 8:53 ` Christoph Hellwig
2021-07-05 2:22 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210709044214.GY11588@locust \
--to=djwong@kernel.org \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).