From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Eric Sandeen <sandeen@redhat.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 1/4] xfs_repair: validate & fix inode CRCs
Date: Fri, 13 Mar 2015 09:20:06 -0400 [thread overview]
Message-ID: <20150313132006.GA2678@laptop.bfoster> (raw)
In-Reply-To: <54F771DE.40107@sandeen.net>
On Wed, Mar 04, 2015 at 02:58:06PM -0600, Eric Sandeen wrote:
> xfs_repair doesn't ever check an inode's CRC, so it never repairs
> them. If the root inode or realtime inodes have bad crcs, the
> fs won't even mount and can't be fixed (without using xfs_db).
>
> It's fairly straightforward to just test the inode CRC before
> we do any other checking or modification of the inode, once we
> get past the "verify only" phase of process_dinode_int();
> just mark it dirty if it's wrong and needs to be re-written.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> Resend of patch from a while ago, but with CRC verification
> now earlier in the function, prior to any changes are made.
>
> diff --git a/repair/dinode.c b/repair/dinode.c
> index 5d9094b..384e2dd 100644
> --- a/repair/dinode.c
> +++ b/repair/dinode.c
> @@ -2291,6 +2291,27 @@ process_dinode_int(xfs_mount_t *mp,
> */
> ASSERT(uncertain == 0 || verify_mode != 0);
>
> + /*
> + * We'd really like to know if the CRC is bad before we
> + * go fixing anything; that way we have some hint about
> + * bit-rot vs bugs. Also, any changes will invalidate the
> + * existing CRC, so this is the only valid point to test it.
> + *
> + * Of course if we make any modifications after this, the
> + * inode gets rewritten, and CRC is updated automagically.
> + */
> + if (!verify_mode && xfs_sb_version_hascrc(&mp->m_sb)) {
What about verify_mode? It should probably report the inode as bunk if
the crc is bad. Some of the subsequent checks handle this with some
logic to just return 1 if something is bogus and we're in verify mode.
> + if(!xfs_verify_cksum((char *)dino, mp->m_sb.sb_inodesize,
> + XFS_DINODE_CRC_OFF)) {
I got a whitespace damage warning here:
/.../xfsprogs-dev/.git/rebase-apply/patch:25: space before tab in indent.
XFS_DINODE_CRC_OFF)) {
warning: 1 line adds whitespace errors.
Brian
> + do_warn(_("bad CRC for inode %" PRIu64), lino);
> + if (!no_modify) {
> + do_warn(_(", will rewrite\n"));
> + *dirty = 1;
> + } else
> + do_warn(_(", would rewrite\n"));
> + }
> + }
> +
> if (be16_to_cpu(dino->di_magic) != XFS_DINODE_MAGIC) {
> retval = 1;
> if (!uncertain)
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-03-13 13:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 20:56 [PATCH 0/4] xfsprogs: a handful of fixes Eric Sandeen
2015-03-04 20:58 ` [PATCH 1/4] xfs_repair: validate & fix inode CRCs Eric Sandeen
2015-03-09 18:41 ` Carlos Maiolino
2015-03-13 13:20 ` Brian Foster [this message]
2015-03-13 22:42 ` Eric Sandeen
2015-03-04 20:59 ` [PATCH 2/4] xfs_repair: clear need_root_dotdot if we rebuild the root dir Eric Sandeen
2015-03-09 18:43 ` Carlos Maiolino
2015-03-04 21:00 ` [PATCH 3/4] xfs_db: show nlink fields for di_version == 3, too Eric Sandeen
2015-03-09 18:49 ` Carlos Maiolino
2015-03-09 20:41 ` Eric Sandeen
2015-03-13 13:20 ` Brian Foster
2015-03-04 21:02 ` [PATCH 4/4] xfs_repair: set *parent if process_dir2_data() fixes root inode's parent Eric Sandeen
2015-03-09 18:50 ` Carlos Maiolino
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=20150313132006.GA2678@laptop.bfoster \
--to=bfoster@redhat.com \
--cc=sandeen@redhat.com \
--cc=sandeen@sandeen.net \
--cc=xfs@oss.sgi.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