Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: josef@toxicpanda.com, kernel-team@fb.com,
	linux-btrfs@vger.kernel.org, Josef Bacik <jbacik@fb.com>
Subject: Re: [PATCH] btrfs-progs: print the csum length in debug-tree
Date: Fri, 1 Sep 2017 17:10:34 +0200	[thread overview]
Message-ID: <20170901151034.GR2866@twin.jikos.cz> (raw)
In-Reply-To: <93debd97-9f8c-ace8-4941-04e95e6771f6@suse.com>

On Fri, Aug 25, 2017 at 04:48:43PM +0300, Nikolay Borisov wrote:
> 
> 
> On 25.08.2017 16:13, josef@toxicpanda.com wrote:
> > From: Josef Bacik <jbacik@fb.com>
> > 
> > While looking at a log of a corrupted fs I needed to verify we were
> > missing csums for a given range.  Make this easier by printing out how
> > many bytes a csum extent item represents when using btrfs_debug_tree.
> > 
> > Signed-off-by: Josef Bacik <jbacik@fb.com>
> > ---
> >  print-tree.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/print-tree.c b/print-tree.c
> > index 5927ed3..a124c96 100644
> > --- a/print-tree.c
> > +++ b/print-tree.c
> > @@ -1103,9 +1103,15 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *eb)
> >  		case BTRFS_CSUM_ITEM_KEY:
> >  			printf("\t\tcsum item\n");
> >  			break;
> > -		case BTRFS_EXTENT_CSUM_KEY:
> > -			printf("\t\textent csum item\n");
> > +		case BTRFS_EXTENT_CSUM_KEY: {
> > +			u16 csum_size =
> > +				btrfs_super_csum_size(root->fs_info->super_copy);
> > +			u32 size = (item_size / csum_size) *
> > +				root->fs_info->sectorsize;
> > +			printf("\t\textent csum item bytes %lu\n",
> > +			       (unsigned long)size);
> 
> Currently for a csum item we get:
> 
> item 0 key (EXTENT_CSUM EXTENT_CSUM 1103101952) itemoff 16279 itemsize 4
> 		extent csum item
> 
> 
>  Why don't you go one step further and print the covered range -
> it would be key.offset + size (the number you've calculated) And so you
> can print something like:
> 
> item 0 key (EXTENT_CSUM EXTENT_CSUM 1103101952) itemoff 16279 itemsize 4
> 		extent csum item 1103101952-1103106048
> 
> "extent csum item range %llu-%lly\n", key.offset, key.offset + size

I think the calculation is really simple to do, if one needs it.

The 'bytes' seem to refer to the range so I'll change that to length.

      parent reply	other threads:[~2017-09-01 15:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25 13:13 [PATCH] btrfs-progs: print the csum length in debug-tree josef
2017-08-25 13:48 ` Nikolay Borisov
2017-08-25 14:06   ` Josef Bacik
2017-09-01 15:10   ` David Sterba [this message]

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=20170901151034.GR2866@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=jbacik@fb.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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