All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH, realtime-rmap branch] xfs: lock the RT bitmap inode in xfs_efi_item_recover
Date: Tue, 31 Oct 2023 09:53:30 -0700	[thread overview]
Message-ID: <20231031165330.GC1041814@frogsfrogsfrogs> (raw)
In-Reply-To: <20231031095038.1559309-1-hch@lst.de>

On Tue, Oct 31, 2023 at 10:50:38AM +0100, Christoph Hellwig wrote:
> xfs_trans_free_extent expects the rtbitmap and rtsum inodes to be locked.
> Ensure that is the case during log recovery as well.
> 
> Fixes: 3ea32f5cc5f9 ("xfs: support logging EFIs for realtime extents")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> I found this when testing the realtime-rmap branch with additional
> patches on top.  Probably makes sense to just fold it in for the next
> rebase of that branch.
> 
>  fs/xfs/xfs_extfree_item.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index 5b3e7dca4e1ba0..070070b6401d66 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -768,6 +768,8 @@ xfs_efi_item_recover(
>  
>  		if (!requeue_only) {
>  			xfs_extent_free_get_group(mp, &fake);
> +			if (xfs_efi_is_realtime(&fake))
> +				xfs_rtbitmap_lock(tp, mp);

Curious, I thought that patch "xfs: support logging EFIs for realtime
extents" already locked the rt bitmap?

	resv = xlog_recover_resv(&M_RES(mp)->tr_itruncate);
	error = xfs_trans_alloc(mp, &resv, 0, 0, 0, &tp);
	if (error)
		return error;
	efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents);

	/* Lock the rt bitmap if we've any realtime extents to free. */
	for (i = 0; i < efip->efi_format.efi_nextents; i++) {
		struct xfs_extent		*extp;

		extp = &efip->efi_format.efi_extents[i];
		if (extp->ext_len & XFS_EFI_EXTLEN_REALTIME_EXT) {
			xfs_rtbitmap_lock(tp, mp);

Here			^^^^^^^^^

			break;
		}
	}

	for (i = 0; i < efip->efi_format.efi_nextents; i++) {
		struct xfs_extent_free_item	fake = {
			.xefi_owner		= XFS_RMAP_OWN_UNKNOWN,
			.xefi_agresv		= XFS_AG_RESV_NONE,
		};
		struct xfs_extent		*extp;
		unsigned int			len;

		extp = &efip->efi_format.efi_extents[i];

		fake.xefi_startblock = extp->ext_start;
		len = extp->ext_len;
		if (len & XFS_EFI_EXTLEN_REALTIME_EXT) {
			len &= ~XFS_EFI_EXTLEN_REALTIME_EXT;
			fake.xefi_flags |= XFS_EFI_REALTIME;
		}
		fake.xefi_blockcount = len;

		if (!requeue_only) {
			xfs_extent_free_get_group(mp, &fake);
			error = xfs_trans_free_extent(tp, efdp, &fake);
			xfs_extent_free_put_group(&fake);
		}

So that by the time we get to this part of the loop, the rtbitmap will
be locked already?

What sort of error message did you get?

<confused>

--D

>  			error = xfs_trans_free_extent(tp, efdp, &fake);
>  			xfs_extent_free_put_group(&fake);
>  		}
> -- 
> 2.39.2
> 

  parent reply	other threads:[~2023-10-31 17:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31  9:50 [PATCH, realtime-rmap branch] xfs: lock the RT bitmap inode in xfs_efi_item_recover Christoph Hellwig
2023-10-31 16:47 ` kernel test robot
2023-10-31 16:53 ` Darrick J. Wong [this message]
2023-10-31 17:14   ` 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=20231031165330.GC1041814@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=hch@lst.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.