From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 02/13] xfs_db: fix inode CRC validity state, and warn on read if invalid
Date: Thu, 19 Mar 2015 11:07:21 -0400 [thread overview]
Message-ID: <20150319150721.GB11669@laptop.bfoster> (raw)
In-Reply-To: <1426624395-8258-3-git-send-email-sandeen@redhat.com>
On Tue, Mar 17, 2015 at 03:33:04PM -0500, Eric Sandeen wrote:
> Currently, the "ino_crc_ok" field on the io cursor reflects
> overall inode validity, not CRC correctness. Because it is
> only used when printing CRC validity, change it to reflect
> only that state - and update it whenever we re-write the
> inode (thus updating the CRC).
>
> In addition, when reading an inode, warn if the CRC is bad.
>
> Note, when specifying an inode which doesn't actually exist,
> this will claim corruption; I'm not sure if that's good or
> bad. Today, it already issues corruption errors on the way;
> this adds a new message as well:
>
> xfs_db> inode 129
> Metadata corruption detected at block 0x80/0x2000
> Metadata corruption detected at block 0x80/0x2000
> ...
> Metadata CRC error detected for ino 129
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
So is the objective here to simply give the field an explicit meaning?
E.g., indicate whether the crc is valid, irrespective of whether
something else might be wrong with the inode?
> db/inode.c | 7 ++++++-
> db/io.c | 4 +++-
> include/libxfs.h | 2 ++
> 3 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/db/inode.c b/db/inode.c
> index 24170ba..982acb7 100644
> --- a/db/inode.c
> +++ b/db/inode.c
> @@ -684,13 +684,18 @@ set_cur_inode(
> numblks, DB_RING_IGN, NULL);
> off_cur(offset << mp->m_sb.sb_inodelog, mp->m_sb.sb_inodesize);
> dip = iocur_top->data;
> - iocur_top->ino_crc_ok = libxfs_dinode_verify(mp, ino, dip);
> + iocur_top->ino_crc_ok = libxfs_verify_cksum((char *)dip,
> + mp->m_sb.sb_inodesize,
> + XFS_DINODE_CRC_OFF);
With this replaced, it doesn't look like anybody else will call
libxfs_dinode_verify (analogous to xfs_iread() in kernel). Is that
intentional? I guess the magic and version should be checked in the read
verifier, but there are a couple other checks in that helper as well.
> iocur_top->ino_buf = 1;
> iocur_top->ino = ino;
> iocur_top->mode = be16_to_cpu(dip->di_mode);
> if ((iocur_top->mode & S_IFMT) == S_IFDIR)
> iocur_top->dirino = ino;
>
> + if (xfs_sb_version_hascrc(&mp->m_sb) && !iocur_top->ino_crc_ok)
> + dbprintf(_("Metadata CRC error detected for ino %lld\n"), ino);
> +
Hmm.. if we keep this, could we combine with the hunk above? I ask
simply because I'd rather see the _hascrc() check around the verify_cksum()
check as well, rather than verifying a cksum and ignoring it.
It's also a little confusing how this field is handled without crc
enabled. write_cur() looks like it sets it and calls
libxfs_dinode_calc_crc() blindly, which asserts that crc is enabled. I
guess we just don't print anything if crc=0, but it would be nice if the
flag was consistent.
Brian
> /* track updated info in ring */
> ring_add();
> }
> diff --git a/db/io.c b/db/io.c
> index c5898f1..91858e2 100644
> --- a/db/io.c
> +++ b/db/io.c
> @@ -471,8 +471,10 @@ write_cur(void)
> return;
> }
>
> - if (iocur_top->ino_buf)
> + if (iocur_top->ino_buf) {
> libxfs_dinode_calc_crc(mp, iocur_top->data);
> + iocur_top->ino_crc_ok = 1;
> + }
> if (iocur_top->dquot_buf)
> xfs_update_cksum(iocur_top->data, sizeof(struct xfs_dqblk),
> XFS_DQUOT_CRC_OFF);
> diff --git a/include/libxfs.h b/include/libxfs.h
> index 45a924f..962e319 100644
> --- a/include/libxfs.h
> +++ b/include/libxfs.h
> @@ -782,6 +782,8 @@ extern uint32_t crc32c_le(uint32_t crc, unsigned char const *p, size_t len);
>
> #include <xfs/xfs_cksum.h>
>
> +#define libxfs_verify_cksum xfs_verify_cksum
> +
> static inline int
> xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
> {
> --
> 1.7.1
>
> _______________________________________________
> 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-19 15:07 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 20:33 [PATCH 00/13] xfsprogs: roll-up of previously sent patches Eric Sandeen
2015-03-17 20:33 ` [PATCH 01/13] xfs_db: Allow writes of corrupted data by optionally skipping write verifiers Eric Sandeen
2015-03-19 15:07 ` Brian Foster
2015-03-23 20:00 ` [PATCH 01/13 V2] " Eric Sandeen
2015-03-24 12:07 ` Brian Foster
2015-03-17 20:33 ` [PATCH 02/13] xfs_db: fix inode CRC validity state, and warn on read if invalid Eric Sandeen
2015-03-19 15:07 ` Brian Foster [this message]
2015-03-21 2:26 ` Eric Sandeen
2015-03-21 14:18 ` Brian Foster
2015-03-23 20:11 ` [PATCH 02/13 V2] " Eric Sandeen
2015-03-24 12:07 ` Brian Foster
2015-03-17 20:33 ` [PATCH 03/13] xfs_db: add crc manipulation commands Eric Sandeen
2015-03-19 15:07 ` Brian Foster
2015-03-21 2:30 ` Eric Sandeen
2015-03-21 14:18 ` Brian Foster
2015-03-23 20:01 ` [PATCH 03/13 DROP] " Eric Sandeen
2015-03-17 20:33 ` [PATCH 04/13] xfs_db: nlink fields are valid for di_version == 3, too Eric Sandeen
2015-03-17 20:33 ` [PATCH 05/13] xfs_repair: dirty inode in process_sf_dir2 if we change namelen Eric Sandeen
2015-03-17 20:33 ` [PATCH 06/13] xfs_repair: remove impossible tests in process_sf_dir2 Eric Sandeen
2015-03-17 20:33 ` [PATCH 07/13] xfs_repair: collapse 2 cases " Eric Sandeen
2015-03-17 20:33 ` [PATCH 08/13] xfs_repair: remove last-entry hack " Eric Sandeen
2015-03-17 20:33 ` [PATCH 09/13] libxfs: remove ASSERT on ftype read from disk Eric Sandeen
2015-03-19 16:46 ` Brian Foster
2015-03-19 17:27 ` Eric Sandeen
2015-03-23 20:13 ` PATCH 09/13 V2] " Eric Sandeen
2015-03-24 12:07 ` Brian Foster
2015-03-17 20:33 ` [PATCH 10/13] xfs_repair: clear need_root_dotdot if we rebuild the root dir Eric Sandeen
2015-03-17 20:33 ` [PATCH 11/13] xfs_repair: set *parent if process_dir2_data() fixes root inode Eric Sandeen
2015-03-17 20:33 ` [PATCH 12/13] xfs_repair: don't clear . or .. in process_dir2_data Eric Sandeen
2015-03-19 16:47 ` Brian Foster
2015-03-19 17:29 ` Eric Sandeen
2015-03-19 17:54 ` Brian Foster
2015-03-19 17:59 ` Eric Sandeen
2015-03-19 18:07 ` Brian Foster
2015-03-23 20:17 ` [PATCH 12/13 V2] " Eric Sandeen
2015-03-24 12:07 ` Brian Foster
2015-03-17 20:33 ` [PATCH 13/13] xfs_repair: validate & fix inode CRCs Eric Sandeen
2015-03-19 16:47 ` Brian Foster
2015-03-23 20:19 ` [PATCH 13/13 V2] " Eric Sandeen
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=20150319150721.GB11669@laptop.bfoster \
--to=bfoster@redhat.com \
--cc=sandeen@redhat.com \
--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