public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: dsterba@suse.cz, Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 2/2] btrfs: pretty print leaked root name
Date: Wed, 9 Sep 2020 09:37:23 +0200	[thread overview]
Message-ID: <20200909073723.GE18399@twin.jikos.cz> (raw)
In-Reply-To: <20200907122853.GZ28318@twin.jikos.cz>

On Mon, Sep 07, 2020 at 02:28:54PM +0200, David Sterba wrote:
> On Thu, Sep 03, 2020 at 02:29:51PM -0400, Josef Bacik wrote:
> > --- a/fs/btrfs/print-tree.c
> > +++ b/fs/btrfs/print-tree.c
> > @@ -7,6 +7,45 @@
> >  #include "disk-io.h"
> >  #include "print-tree.h"
> >  
> > +struct name_map {
> > +	u64 id;
> > +	char *name;
> 
> 	const char* or maybe even a fixed length string, removing the
> 	_TREE suffix
> 
> > +};
> > +
> > +static const struct name_map root_map[] = {
> > +	{ BTRFS_ROOT_TREE_OBJECTID,		"ROOT_TREE"		},
> > +	{ BTRFS_EXTENT_TREE_OBJECTID,		"EXTENT_TREE"		},
> > +	{ BTRFS_CHUNK_TREE_OBJECTID,		"CHUNK_TREE"		},
> > +	{ BTRFS_DEV_TREE_OBJECTID,		"DEV_TREE"		},
> > +	{ BTRFS_FS_TREE_OBJECTID,		"FS_TREE"		},
> > +	{ BTRFS_ROOT_TREE_DIR_OBJECTID,		"ROOT_TREE_DIR"		},
> 
> This is not a tree id
> 
> > +	{ BTRFS_CSUM_TREE_OBJECTID,		"CSUM_TREE"		},
> > +	{ BTRFS_TREE_LOG_OBJECTID,		"TREE_LOG"		},
> > +	{ BTRFS_QUOTA_TREE_OBJECTID,		"QUOTA_TREE"		},
> > +	{ BTRFS_UUID_TREE_OBJECTID,		"UUID_TREE"		},
> > +	{ BTRFS_FREE_SPACE_TREE_OBJECTID,	"FREE_SPACE_TREE"	},
> > +	{ BTRFS_DATA_RELOC_TREE_OBJECTID,	"DATA_RELOC_TREE"	},
> 
> I've noticed we have the id -> str mapping already in
> btrfs_lockdep_keysets, so there could be just one such structure and
> we'd add wrappers around that.
> 
> Also the C99 initializers should be used.
> 
> > +};
> > +
> > +char *btrfs_root_name(u64 objectid, char *buf)
> > +{
> > +	int i;
> > +
> > +	if (objectid == BTRFS_TREE_RELOC_OBJECTID) {
> > +		snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN,
> > +			 "TREE_RELOC offset=%llu", objectid);
> 
> The reloc tree is an outlier here so I wonder if we'd rather have a nice
> pretty printer of the tree root name and deal with the oddities where
> required rather than inside the helper. In this case there would have to
> be some conditionals in btrfs_check_leaked_roots, as we can't do that in
> the format string.

I had another thought, we want a pretty printer, the above still holds
but needs more restructuring so let's take this. I'll do the fixups and
add it to misc-next.

  reply	other threads:[~2020-09-09  7:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 18:29 [PATCH 0/2][v3] Some leaked root fixes Josef Bacik
2020-09-03 18:29 ` [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
2020-09-07 12:50   ` David Sterba
2020-09-03 18:29 ` [PATCH 2/2] btrfs: pretty print leaked root name Josef Bacik
2020-09-07 12:28   ` David Sterba
2020-09-09  7:37     ` David Sterba [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-08-20 20:00 [PATCH 0/2][v2] Some leaked root fixes Josef Bacik
2020-08-20 20:00 ` [PATCH 2/2] btrfs: pretty print leaked root name Josef Bacik
2020-08-21  7:35   ` Nikolay Borisov
2020-08-21 10:13     ` David Sterba
2020-08-21 10:25       ` Nikolay Borisov
2020-08-21 14:00       ` Josef Bacik
2020-08-24 11:30         ` David Sterba
2020-08-24 12:46     ` David Sterba

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=20200909073723.GE18399@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox