linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/9] xfs: move recovery needed state updates to xfs_log_mount_finish
Date: Wed, 14 Jul 2021 14:54:18 -0700	[thread overview]
Message-ID: <20210714215418.GO22402@magnolia> (raw)
In-Reply-To: <20210714031958.2614411-4-david@fromorbit.com>

On Wed, Jul 14, 2021 at 01:19:52PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> xfs_log_mount_finish() needs to know if recovery is needed or not to
> make descisions on whether to flush the log and AIL.  Move the

s/descisions/decisions/

> handling of the NEED_RECOVERY state out to this function rather than
> needing a temporary variable to store this state over the call to
> xlog_recover_finish().
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

With that fixed, this looks like a nice cleanup.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_log.c         | 24 ++++++++-----
>  fs/xfs/xfs_log_recover.c | 73 +++++++++++++++-------------------------
>  2 files changed, 43 insertions(+), 54 deletions(-)
> 
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 75cc487da578..6760608642cc 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -698,9 +698,9 @@ int
>  xfs_log_mount_finish(
>  	struct xfs_mount	*mp)
>  {
> -	int	error = 0;
> -	bool	readonly = (mp->m_flags & XFS_MOUNT_RDONLY);
> -	bool	recovered = mp->m_log->l_flags & XLOG_RECOVERY_NEEDED;
> +	struct xlog		*log = mp->m_log;
> +	bool			readonly = (mp->m_flags & XFS_MOUNT_RDONLY);
> +	int			error = 0;
>  
>  	if (mp->m_flags & XFS_MOUNT_NORECOVERY) {
>  		ASSERT(mp->m_flags & XFS_MOUNT_RDONLY);
> @@ -731,7 +731,8 @@ xfs_log_mount_finish(
>  	 * mount failure occurs.
>  	 */
>  	mp->m_super->s_flags |= SB_ACTIVE;
> -	error = xlog_recover_finish(mp->m_log);
> +	if (log->l_flags & XLOG_RECOVERY_NEEDED)
> +		error = xlog_recover_finish(log);
>  	if (!error)
>  		xfs_log_work_queue(mp);
>  	mp->m_super->s_flags &= ~SB_ACTIVE;
> @@ -746,17 +747,24 @@ xfs_log_mount_finish(
>  	 * Don't push in the error case because the AIL may have pending intents
>  	 * that aren't removed until recovery is cancelled.
>  	 */
> -	if (!error && recovered) {
> -		xfs_log_force(mp, XFS_LOG_SYNC);
> -		xfs_ail_push_all_sync(mp->m_ail);
> +	if (log->l_flags & XLOG_RECOVERY_NEEDED) {
> +		if (!error) {
> +			xfs_log_force(mp, XFS_LOG_SYNC);
> +			xfs_ail_push_all_sync(mp->m_ail);
> +		}
> +		xfs_notice(mp, "Ending recovery (logdev: %s)",
> +				mp->m_logname ? mp->m_logname : "internal");
> +	} else {
> +		xfs_info(mp, "Ending clean mount");
>  	}
>  	xfs_buftarg_drain(mp->m_ddev_targp);
>  
> +	log->l_flags &= ~XLOG_RECOVERY_NEEDED;
>  	if (readonly)
>  		mp->m_flags |= XFS_MOUNT_RDONLY;
>  
>  	/* Make sure the log is dead if we're returning failure. */
> -	ASSERT(!error || (mp->m_log->l_flags & XLOG_IO_ERROR));
> +	ASSERT(!error || xlog_is_shutdown(log));
>  
>  	return error;
>  }
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 37296f87a435..c384ecdd6389 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -3416,62 +3416,43 @@ xlog_recover(
>  }
>  
>  /*
> - * In the first part of recovery we replay inodes and buffers and build
> - * up the list of extent free items which need to be processed.  Here
> - * we process the extent free items and clean up the on disk unlinked
> - * inode lists.  This is separated from the first part of recovery so
> - * that the root and real-time bitmap inodes can be read in from disk in
> - * between the two stages.  This is necessary so that we can free space
> - * in the real-time portion of the file system.
> + * In the first part of recovery we replay inodes and buffers and build up the
> + * list of intents which need to be processed.  Here we process the intents  and
> + * clean up the on disk unlinked inode lists.  This is separated from the first
> + * part of recovery so that the root and real-time bitmap inodes can be read in
> + * from disk in between the two stages.  This is necessary so that we can free
> + * space in the real-time portion of the file system.
>   */
>  int
>  xlog_recover_finish(
>  	struct xlog	*log)
>  {
> -	/*
> -	 * Now we're ready to do the transactions needed for the
> -	 * rest of recovery.  Start with completing all the extent
> -	 * free intent records and then process the unlinked inode
> -	 * lists.  At this point, we essentially run in normal mode
> -	 * except that we're still performing recovery actions
> -	 * rather than accepting new requests.
> -	 */
> -	if (log->l_flags & XLOG_RECOVERY_NEEDED) {
> -		int	error;
> -		error = xlog_recover_process_intents(log);
> -		if (error) {
> -			/*
> -			 * Cancel all the unprocessed intent items now so that
> -			 * we don't leave them pinned in the AIL.  This can
> -			 * cause the AIL to livelock on the pinned item if
> -			 * anyone tries to push the AIL (inode reclaim does
> -			 * this) before we get around to xfs_log_mount_cancel.
> -			 */
> -			xlog_recover_cancel_intents(log);
> -			xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR);
> -			xfs_alert(log->l_mp, "Failed to recover intents");
> -			return error;
> -		}
> +	int	error;
>  
> +	error = xlog_recover_process_intents(log);
> +	if (error) {
>  		/*
> -		 * Sync the log to get all the intents out of the AIL.
> -		 * This isn't absolutely necessary, but it helps in
> -		 * case the unlink transactions would have problems
> -		 * pushing the intents out of the way.
> +		 * Cancel all the unprocessed intent items now so that we don't
> +		 * leave them pinned in the AIL.  This can cause the AIL to
> +		 * livelock on the pinned item if anyone tries to push the AIL
> +		 * (inode reclaim does this) before we get around to
> +		 * xfs_log_mount_cancel.
>  		 */
> -		xfs_log_force(log->l_mp, XFS_LOG_SYNC);
> -
> -		xlog_recover_process_iunlinks(log);
> +		xlog_recover_cancel_intents(log);
> +		xfs_alert(log->l_mp, "Failed to recover intents");
> +		xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR);
> +		return error;
> +	}
>  
> -		xlog_recover_check_summary(log);
> +	/*
> +	 * Sync the log to get all the intents out of the AIL.  This isn't
> +	 * absolutely necessary, but it helps in case the unlink transactions
> +	 * would have problems pushing the intents out of the way.
> +	 */
> +	xfs_log_force(log->l_mp, XFS_LOG_SYNC);
> +	xlog_recover_process_iunlinks(log);
>  
> -		xfs_notice(log->l_mp, "Ending recovery (logdev: %s)",
> -				log->l_mp->m_logname ? log->l_mp->m_logname
> -						     : "internal");
> -		log->l_flags &= ~XLOG_RECOVERY_NEEDED;
> -	} else {
> -		xfs_info(log->l_mp, "Ending clean mount");
> -	}
> +	xlog_recover_check_summary(log);
>  	return 0;
>  }
>  
> -- 
> 2.31.1
> 

  reply	other threads:[~2021-07-14 21:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14  3:19 [PATCH 0/9 v2] xfs: shutdown is a racy mess Dave Chinner
2021-07-14  3:19 ` [PATCH 1/9] xfs: convert XLOG_FORCED_SHUTDOWN() to xlog_is_shutdown() Dave Chinner
2021-07-14  6:09   ` Christoph Hellwig
2021-07-14  3:19 ` [PATCH 2/9] xfs: XLOG_STATE_IOERROR must die Dave Chinner
2021-07-14  6:13   ` Christoph Hellwig
2021-07-14 21:51   ` Darrick J. Wong
2021-07-14  3:19 ` [PATCH 3/9] xfs: move recovery needed state updates to xfs_log_mount_finish Dave Chinner
2021-07-14 21:54   ` Darrick J. Wong [this message]
2021-07-14  3:19 ` [PATCH 4/9] xfs: convert log flags to an operational state field Dave Chinner
2021-07-14  3:19 ` [PATCH 5/9] xfs: make forced shutdown processing atomic Dave Chinner
2021-07-14  6:15   ` Christoph Hellwig
2021-07-14 21:57   ` Darrick J. Wong
2021-07-14  3:19 ` [PATCH 6/9] xfs: rework xlog_state_do_callback() Dave Chinner
2021-07-14  3:19 ` [PATCH 7/9] xfs: separate out log shutdown callback processing Dave Chinner
2021-07-14  6:17   ` Christoph Hellwig
2021-07-14 22:00   ` Darrick J. Wong
2021-07-14  3:19 ` [PATCH 8/9] xfs: don't run shutdown callbacks on active iclogs Dave Chinner
2021-07-14 22:09   ` Darrick J. Wong
2021-07-14  3:19 ` [PATCH 9/9] xfs: log head and tail aren't reliable during shutdown Dave Chinner
2021-07-14 22:12   ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2021-08-10  5:18 [PATCH 0/9 v3] xfs: shutdown is a racy mess Dave Chinner
2021-08-10  5:18 ` [PATCH 3/9] xfs: move recovery needed state updates to xfs_log_mount_finish Dave Chinner
2021-06-30  6:38 [PATCH 0/9] xfs: shutdown is a racy mess 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

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=20210714215418.GO22402@magnolia \
    --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).