linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Allison Henderson <allison.henderson@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v24 02/11] xfs: Capture buffers for delayed ops
Date: Mon, 30 Aug 2021 10:44:07 -0700	[thread overview]
Message-ID: <20210830174407.GA9942@magnolia> (raw)
In-Reply-To: <20210824224434.968720-3-allison.henderson@oracle.com>

On Tue, Aug 24, 2021 at 03:44:25PM -0700, Allison Henderson wrote:
> This patch enables delayed operations to capture held buffers with in
> the xfs_defer_capture. Buffers are then rejoined to the new
> transaction in xlog_finish_defer_ops
> 
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> ---
>  fs/xfs/libxfs/xfs_defer.c  | 7 ++++++-
>  fs/xfs/libxfs/xfs_defer.h  | 4 +++-
>  fs/xfs/xfs_bmap_item.c     | 2 +-
>  fs/xfs/xfs_buf.c           | 1 +
>  fs/xfs/xfs_buf.h           | 1 +
>  fs/xfs/xfs_extfree_item.c  | 2 +-
>  fs/xfs/xfs_log_recover.c   | 7 +++++++
>  fs/xfs/xfs_refcount_item.c | 2 +-
>  fs/xfs/xfs_rmap_item.c     | 2 +-
>  9 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
> index eff4a127188e..d1d09b6aca55 100644
> --- a/fs/xfs/libxfs/xfs_defer.c
> +++ b/fs/xfs/libxfs/xfs_defer.c
> @@ -639,6 +639,7 @@ xfs_defer_ops_capture(
>  	dfc = kmem_zalloc(sizeof(*dfc), KM_NOFS);
>  	INIT_LIST_HEAD(&dfc->dfc_list);
>  	INIT_LIST_HEAD(&dfc->dfc_dfops);
> +	INIT_LIST_HEAD(&dfc->dfc_buffers);
>  
>  	xfs_defer_create_intents(tp);
>  
> @@ -690,7 +691,8 @@ int
>  xfs_defer_ops_capture_and_commit(
>  	struct xfs_trans		*tp,
>  	struct xfs_inode		*capture_ip,
> -	struct list_head		*capture_list)
> +	struct list_head		*capture_list,
> +	struct xfs_buf			*bp)

I wonder if xfs_defer_ops_capture should learn to pick up the inodes and
buffers to hold automatically from the transaction that's being
committed?  Seeing as xfs_defer_trans_roll already knows how to do that
across transaction rolls, and that's more or less the same thing we're
doing here, but in a much more roundabout way.

>  {
>  	struct xfs_mount		*mp = tp->t_mountp;
>  	struct xfs_defer_capture	*dfc;
> @@ -703,6 +705,9 @@ xfs_defer_ops_capture_and_commit(
>  	if (!dfc)
>  		return xfs_trans_commit(tp);
>  
> +	if (bp && bp->b_transp == tp)
> +		list_add_tail(&bp->b_delay, &dfc->dfc_buffers);
> +
>  	/* Commit the transaction and add the capture structure to the list. */
>  	error = xfs_trans_commit(tp);
>  	if (error) {
> diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
> index 05472f71fffe..739f70d72fd5 100644
> --- a/fs/xfs/libxfs/xfs_defer.h
> +++ b/fs/xfs/libxfs/xfs_defer.h
> @@ -74,6 +74,7 @@ struct xfs_defer_capture {
>  
>  	/* Deferred ops state saved from the transaction. */
>  	struct list_head	dfc_dfops;
> +	struct list_head	dfc_buffers;
>  	unsigned int		dfc_tpflags;
>  
>  	/* Block reservations for the data and rt devices. */
> @@ -95,7 +96,8 @@ struct xfs_defer_capture {
>   * This doesn't normally happen except log recovery.
>   */
>  int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp,
> -		struct xfs_inode *capture_ip, struct list_head *capture_list);
> +		struct xfs_inode *capture_ip, struct list_head *capture_list,
> +		struct xfs_buf *bp);
>  void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp,
>  		struct xfs_inode **captured_ipp);
>  void xfs_defer_ops_release(struct xfs_mount *mp, struct xfs_defer_capture *d);
> diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> index 03159970133f..51ba8ee368ca 100644
> --- a/fs/xfs/xfs_bmap_item.c
> +++ b/fs/xfs/xfs_bmap_item.c
> @@ -532,7 +532,7 @@ xfs_bui_item_recover(
>  	 * Commit transaction, which frees the transaction and saves the inode
>  	 * for later replay activities.
>  	 */
> -	error = xfs_defer_ops_capture_and_commit(tp, ip, capture_list);
> +	error = xfs_defer_ops_capture_and_commit(tp, ip, capture_list, NULL);
>  	if (error)
>  		goto err_unlock;
>  
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 047bd6e3f389..29b4655a0a65 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -233,6 +233,7 @@ _xfs_buf_alloc(
>  	init_completion(&bp->b_iowait);
>  	INIT_LIST_HEAD(&bp->b_lru);
>  	INIT_LIST_HEAD(&bp->b_list);
> +	INIT_LIST_HEAD(&bp->b_delay);
>  	INIT_LIST_HEAD(&bp->b_li_list);
>  	sema_init(&bp->b_sema, 0); /* held, no waiters */
>  	spin_lock_init(&bp->b_lock);
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index 6b0200b8007d..c51445705dc6 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -151,6 +151,7 @@ struct xfs_buf {
>  	int			b_io_error;	/* internal IO error state */
>  	wait_queue_head_t	b_waiters;	/* unpin waiters */
>  	struct list_head	b_list;
> +	struct list_head	b_delay;	/* delayed operations list */
>  	struct xfs_perag	*b_pag;		/* contains rbtree root */
>  	struct xfs_mount	*b_mount;
>  	struct xfs_buftarg	*b_target;	/* buffer target (device) */

The bare list-conveyance machinery looks fine to me, but adding 16 bytes
to struct xfs_buf for something that only happens during log recovery is
rather expensive.  Can you reuse b_list for this purpose?  I think the
only user of b_list are the buffer delwri functions, which shouldn't be
active here since the xattr recovery mechanism (a) holds the buffer lock
and (b) doesn't itself use delwri buffer lists for xattr leaf blocks.

(The AIL uses delwri lists, but it won't touch a locked buffer.)

> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index 3f8a0713573a..046f21338c48 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -637,7 +637,7 @@ xfs_efi_item_recover(
>  
>  	}
>  
> -	return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list);
> +	return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list, NULL);
>  
>  abort_error:
>  	xfs_trans_cancel(tp);
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 10562ecbd9ea..6a3c0bb16b69 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -2465,6 +2465,7 @@ xlog_finish_defer_ops(
>  	struct list_head	*capture_list)
>  {
>  	struct xfs_defer_capture *dfc, *next;
> +	struct xfs_buf		*bp, *bnext;
>  	struct xfs_trans	*tp;
>  	struct xfs_inode	*ip;
>  	int			error = 0;
> @@ -2489,6 +2490,12 @@ xlog_finish_defer_ops(
>  			return error;
>  		}
>  
> +		list_for_each_entry_safe(bp, bnext, &dfc->dfc_buffers, b_delay) {
> +			xfs_trans_bjoin(tp, bp);
> +			xfs_trans_bhold(tp, bp);
> +			list_del_init(&bp->b_delay);
> +		}

Why isn't this in xfs_defer_ops_continue, like the code that extracts
the inodes from the capture struct and hands them back to the caller?

> +
>  		/*
>  		 * Transfer to this new transaction all the dfops we captured
>  		 * from recovering a single intent item.
> diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> index 46904b793bd4..a6e7351ca4f9 100644
> --- a/fs/xfs/xfs_refcount_item.c
> +++ b/fs/xfs/xfs_refcount_item.c
> @@ -557,7 +557,7 @@ xfs_cui_item_recover(
>  	}
>  
>  	xfs_refcount_finish_one_cleanup(tp, rcur, error);
> -	return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list);
> +	return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list, NULL);
>  
>  abort_error:
>  	xfs_refcount_finish_one_cleanup(tp, rcur, error);
> diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> index 5f0695980467..8c70a4af80a9 100644
> --- a/fs/xfs/xfs_rmap_item.c
> +++ b/fs/xfs/xfs_rmap_item.c
> @@ -587,7 +587,7 @@ xfs_rui_item_recover(
>  	}
>  
>  	xfs_rmap_finish_one_cleanup(tp, rcur, error);
> -	return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list);
> +	return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list, NULL);
>  
>  abort_error:
>  	xfs_rmap_finish_one_cleanup(tp, rcur, error);
> -- 
> 2.25.1
> 

  parent reply	other threads:[~2021-08-30 17:44 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 22:44 [PATCH v24 00/11] Log Attribute Replay Allison Henderson
2021-08-24 22:44 ` [PATCH v24 01/11] xfs: Return from xfs_attr_set_iter if there are no more rmtblks to process Allison Henderson
2021-08-24 22:44 ` [PATCH v24 02/11] xfs: Capture buffers for delayed ops Allison Henderson
2021-08-27 11:33   ` Chandan Babu R
2021-08-31 18:03     ` Allison Henderson
2021-08-30 17:44   ` Darrick J. Wong [this message]
2021-08-31 17:50     ` Allison Henderson
2021-09-18  0:02       ` Darrick J. Wong
2021-08-24 22:44 ` [PATCH v24 03/11] xfs: Set up infrastructure for log atrribute replay Allison Henderson
2021-08-27 14:17   ` Chandan Babu R
2021-08-31 18:03     ` Allison Henderson
2021-08-31  0:48   ` Dave Chinner
2021-08-31 19:03     ` Allison Henderson
2021-08-31 21:52   ` Dave Chinner
2021-09-01  5:34     ` Allison Henderson
2021-08-24 22:44 ` [PATCH v24 04/11] xfs: Implement attr logging and replay Allison Henderson
2021-08-30  7:47   ` Chandan Babu R
2021-08-31 18:11     ` Allison Henderson
2021-08-24 22:44 ` [PATCH v24 05/11] RFC xfs: Skip flip flags for delayed attrs Allison Henderson
2021-08-30 10:15   ` Chandan Babu R
2021-08-31 18:11     ` Allison Henderson
2021-08-24 22:44 ` [PATCH v24 06/11] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Allison Henderson
2021-08-30 10:27   ` Chandan Babu R
2021-08-31 18:12     ` Allison Henderson
2021-09-01  3:47   ` Dave Chinner
2021-09-01  5:34     ` Allison Henderson
2021-08-24 22:44 ` [PATCH v24 07/11] xfs: Remove unused xfs_attr_*_args Allison Henderson
2021-08-24 22:44 ` [PATCH v24 08/11] xfs: Add log attribute error tag Allison Henderson
2021-08-24 22:44 ` [PATCH v24 09/11] xfs: Add larp debug option Allison Henderson
2021-08-30 12:03   ` Chandan Babu R
2021-08-31 18:12     ` Allison Henderson
2021-08-24 22:44 ` [PATCH v24 10/11] xfs: Merge xfs_delattr_context into xfs_attr_item Allison Henderson
2021-08-24 22:44 ` [PATCH v24 11/11] xfs: Add helper function xfs_attr_leaf_addname Allison Henderson
2021-08-30 14:17   ` Chandan Babu R
2021-08-31 18:13     ` Allison Henderson
2021-08-31  0:20 ` [PATCH v24 00/11] Log Attribute Replay Dave Chinner
2021-08-31 18:27   ` Allison Henderson
2021-09-01  6:29     ` Dave Chinner
2021-09-01  7:30 ` [PATCH 0/5] xfs: various logged attribute fixes Dave Chinner
2021-09-01  7:30   ` [PATCH 1/5] xfs: fix fallthrough annotations in xfs_attr_set_iter() Dave Chinner
2021-09-01  7:30   ` [PATCH 2/5] xfs: fix flags passed to kvmalloc() by xfs_attri_init() Dave Chinner
2021-09-01  7:30   ` [PATCH 3/5] xfs: hide log iovec alignment constraints Dave Chinner
2021-09-01  7:30   ` [PATCH 4/5] xfs: fix attribute log iovec sizing Dave Chinner
2021-09-01  7:30   ` [PATCH 5/5] [RFC] xfs: don't commit the first deferred transaction without intents Dave Chinner
2021-09-01 21:43   ` [PATCH 0/5] xfs: various logged attribute fixes Allison Henderson

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=20210830174407.GA9942@magnolia \
    --to=djwong@kernel.org \
    --cc=allison.henderson@oracle.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).