All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [RFC v3 10/11] btrfs: check for leaks of ordered stripes on umount
Date: Thu, 20 Oct 2022 11:37:45 -0400	[thread overview]
Message-ID: <Y1FrSaKIMNI3bWDm@localhost.localdomain> (raw)
In-Reply-To: <c939c2fdd361800a4361707bf9d5cc68e30e7907.1666007330.git.johannes.thumshirn@wdc.com>

On Mon, Oct 17, 2022 at 04:55:28AM -0700, Johannes Thumshirn wrote:
> Check if we're leaking any ordered stripes when unmounting a filesystem
> with an stripe tree.
> 
> This check is gated behind CONFIG_BTRFS_DEBUG to not affect any production
> type systems.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/disk-io.c          |  2 ++
>  fs/btrfs/raid-stripe-tree.c | 29 +++++++++++++++++++++++++++++
>  fs/btrfs/raid-stripe-tree.h |  1 +
>  3 files changed, 32 insertions(+)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 190caabf5fb7..e479e9829c3e 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -43,6 +43,7 @@
>  #include "space-info.h"
>  #include "zoned.h"
>  #include "subpage.h"
> +#include "raid-stripe-tree.h"
>  
>  #define BTRFS_SUPER_FLAG_SUPP	(BTRFS_HEADER_FLAG_WRITTEN |\
>  				 BTRFS_HEADER_FLAG_RELOC |\
> @@ -1480,6 +1481,7 @@ void btrfs_free_fs_info(struct btrfs_fs_info *fs_info)
>  	btrfs_put_root(fs_info->stripe_root);
>  	btrfs_check_leaked_roots(fs_info);
>  	btrfs_extent_buffer_leak_debug_check(fs_info);
> +	btrfs_check_ordered_stripe_leak(fs_info);
>  	kfree(fs_info->super_copy);
>  	kfree(fs_info->super_for_commit);
>  	kfree(fs_info->subpage_info);
> diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c
> index 91e67600e01a..9a913c4cd44e 100644
> --- a/fs/btrfs/raid-stripe-tree.c
> +++ b/fs/btrfs/raid-stripe-tree.c
> @@ -30,6 +30,35 @@ static int ordered_stripe_less(struct rb_node *rba, const struct rb_node *rbb)
>  	return ordered_stripe_cmp(&stripe->logical, rbb);
>  }
>  
> +void btrfs_check_ordered_stripe_leak(struct btrfs_fs_info *fs_info)
> +{
> +#ifdef CONFIG_BTRFS_DEBUG
> +	struct rb_node *node;
> +
> +	if (!fs_info->stripe_root ||
> +	    RB_EMPTY_ROOT(&fs_info->stripe_update_tree))
> +		return;
> +
> +	mutex_lock(&fs_info->stripe_update_lock);
> +	while ((node = rb_first_postorder(&fs_info->stripe_update_tree))
> +	       != NULL) {
> +		struct btrfs_ordered_stripe *stripe =
> +			rb_entry(node, struct btrfs_ordered_stripe, rb_node);
> +

Can we get a WARN_ON_ONCE() in here?  That way xfstests failures will get
noticed as we'll get the dmesg failures.  Thanks,

Josef

  reply	other threads:[~2022-10-20 15:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 11:55 [RFC v3 00/11] btrfs: raid-stripe-tree draft patches Johannes Thumshirn
2022-10-17 11:55 ` [RFC v3 01/11] btrfs: add raid stripe tree definitions Johannes Thumshirn
2022-10-20 15:21   ` Josef Bacik
2022-10-20 15:49     ` Johannes Thumshirn
2022-10-17 11:55 ` [RFC v3 02/11] btrfs: read raid-stripe-tree from disk Johannes Thumshirn
2022-10-17 11:55 ` [RFC v3 03/11] btrfs: add support for inserting raid stripe extents Johannes Thumshirn
2022-10-20 15:24   ` Josef Bacik
2022-10-20 15:30   ` Josef Bacik
2022-10-21  8:13     ` Johannes Thumshirn
2022-10-17 11:55 ` [RFC v3 04/11] btrfs: delete stripe extent on extent deletion Johannes Thumshirn
2022-10-17 11:55 ` [RFC v3 05/11] btrfs: lookup physical address from stripe extent Johannes Thumshirn
2022-10-20 15:34   ` Josef Bacik
2022-10-21  8:16     ` Johannes Thumshirn
2022-10-17 11:55 ` [RFC v3 06/11] btrfs: add raid stripe tree pretty printer Johannes Thumshirn
2022-10-20 15:34   ` Josef Bacik
2022-10-17 11:55 ` [RFC v3 07/11] btrfs: zoned: allow zoned RAID1 Johannes Thumshirn
2022-10-20 15:35   ` Josef Bacik
2022-10-17 11:55 ` [RFC v3 08/11] btrfs: allow zoned RAID0 and 10 Johannes Thumshirn
2022-10-20 15:36   ` Josef Bacik
2022-10-17 11:55 ` [RFC v3 09/11] btrfs: fix striping with RST Johannes Thumshirn
2022-10-20 15:36   ` Josef Bacik
2022-10-17 11:55 ` [RFC v3 10/11] btrfs: check for leaks of ordered stripes on umount Johannes Thumshirn
2022-10-20 15:37   ` Josef Bacik [this message]
2022-10-21  8:17     ` Johannes Thumshirn
2022-10-17 11:55 ` [RFC v3 11/11] btrfs: add tracepoints for ordered stripes Johannes Thumshirn
2022-10-20 15:38   ` Josef Bacik
2022-10-20 15:42 ` [RFC v3 00/11] btrfs: raid-stripe-tree draft patches Josef Bacik
2022-10-21  8:40   ` Johannes Thumshirn

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=Y1FrSaKIMNI3bWDm@localhost.localdomain \
    --to=josef@toxicpanda.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@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.