From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: sandeen@redhat.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/4] xfs_db: use iocursor type to guess btree geometry if bad magic
Date: Tue, 11 Apr 2017 10:03:32 +1000 [thread overview]
Message-ID: <20170411000332.GB12369@dastard> (raw)
In-Reply-To: <149186447366.32572.11858750403661352513.stgit@birch.djwong.org>
On Mon, Apr 10, 2017 at 03:47:53PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> The function block_to_bt plays an integral role in determining the btree
> geometry of a block that we want to manipulate with the debugger.
> Normally we use the block magic to find the geometry profile, but if the
> magic is bad we'll never find it and return NULL. The callers of this
> function do not check for NULL and crash.
>
> Therefore, if we can't find a geometry profile matching the magic
> number, use the iocursor type to guess the profile and scowl about that
> to stdout. This makes it so that even with a corrupt magic we can try
> to print the fields instead of crashing the debugger.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> v2: be less macro-happy and only evaluate hascrc once
> ---
> db/btblock.c | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 44 insertions(+), 8 deletions(-)
>
>
> diff --git a/db/btblock.c b/db/btblock.c
> index 835a5f0..e494f3e 100644
> --- a/db/btblock.c
> +++ b/db/btblock.c
> @@ -25,6 +25,8 @@
> #include "print.h"
> #include "bit.h"
> #include "init.h"
> +#include "io.h"
> +#include "output.h"
>
> /*
> * Definition of the possible btree block layouts.
> @@ -122,13 +124,50 @@ static struct xfs_db_btree *
> block_to_bt(
> struct xfs_btree_block *bb)
> {
> - struct xfs_db_btree *btp = &btrees[0];
> + struct xfs_db_btree *btp;
> + uint32_t magic;
> + bool crc;
> +
> + magic = be32_to_cpu((bb)->bb_magic);
> + for (btp = &btrees[0]; btp->magic != 0; btp++)
> + if (magic == btp->magic)
> + return btp;
{}
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2017-04-11 0:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 22:47 [PATCH v2 0/4] xfs_db misc. btree dumping improvements Darrick J. Wong
2017-04-10 22:47 ` [PATCH 1/4] xfs_db: don't print arrays off the end of a buffer Darrick J. Wong
2017-04-26 17:12 ` Eric Sandeen
2017-04-26 17:45 ` Darrick J. Wong
2017-04-10 22:47 ` [PATCH 2/4] xfs_db: use iocursor type to guess btree geometry if bad magic Darrick J. Wong
2017-04-11 0:03 ` Dave Chinner [this message]
2017-04-11 0:19 ` Darrick J. Wong
2017-04-11 0:20 ` [PATCH v2 " Darrick J. Wong
2017-04-26 17:48 ` Eric Sandeen
2017-04-26 18:25 ` Darrick J. Wong
2017-04-26 18:41 ` Eric Sandeen
2017-04-26 18:43 ` Darrick J. Wong
2017-04-26 18:47 ` [PATCH v3 " Eric Sandeen
2017-04-26 19:11 ` Darrick J. Wong
2017-04-10 22:47 ` [PATCH 3/4] xfs_db: complain about dir/attr blocks with bad magics Darrick J. Wong
2017-04-11 21:42 ` Darrick J. Wong
2017-04-10 22:48 ` [PATCH 4/4] xfs_db: dump metadata btrees via 'btdump' Darrick J. Wong
2017-04-26 19:50 ` Eric Sandeen
2017-04-26 20:27 ` Darrick J. Wong
2017-04-26 20:36 ` [PATCH v2 " Darrick J. Wong
2017-04-26 21:35 ` Eric Sandeen
-- strict thread matches above, loose matches on Subject: below --
2017-04-08 3:03 [RFC PATCH v1 0/4] xfs_db misc. btree dumping improvements Darrick J. Wong
2017-04-08 3:03 ` [PATCH 2/4] xfs_db: use iocursor type to guess btree geometry if bad magic Darrick J. Wong
2017-04-08 23:19 ` Dave Chinner
2017-04-10 21:08 ` Darrick J. Wong
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=20170411000332.GB12369@dastard \
--to=david@fromorbit.com \
--cc=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.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