From: Eric Sandeen <sandeen@sandeen.net>
To: xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH 1/2] xfs_db: fix inode CRC validity state, and warn on read if invalid
Date: Sat, 06 Sep 2014 12:46:07 -0500 [thread overview]
Message-ID: <540B485F.8070502@sandeen.net> (raw)
In-Reply-To: <540B4399.4020804@sandeen.net>
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.
In addition, when reading an inode, print the current
CRC state.
Note, if 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>
---
diff --git a/db/inode.c b/db/inode.c
index 24170ba..244d03b 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 = xfs_verify_cksum((char *)dip,
+ mp->m_sb.sb_inodesize,
+ XFS_DINODE_CRC_OFF);
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);
+
/* track updated info in ring */
ring_add();
}
diff --git a/db/io.c b/db/io.c
index 7f1b76a..93ebf5c 100644
--- a/db/io.c
+++ b/db/io.c
@@ -473,6 +473,17 @@ write_cur(void)
write_cur_bbs();
else
write_cur_buf();
+
+ if (iocur_top->ino_buf) {
+ xfs_dinode_t *dip;
+ xfs_ino_t ino;
+
+ dip = iocur_top->data;
+ ino = iocur_top->ino;
+ iocur_top->ino_crc_ok = xfs_verify_cksum((char *)dip,
+ mp->m_sb.sb_inodesize,
+ XFS_DINODE_CRC_OFF);
+ }
}
void
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-09-06 17:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-06 17:25 [PATCH 0/2] xfsprogs: xfs_db crc fixes/changes Eric Sandeen
2014-09-06 17:46 ` Eric Sandeen [this message]
2014-09-06 23:00 ` [PATCH 1/2] xfs_db: fix inode CRC validity state, and warn on read if invalid Dave Chinner
2014-09-06 17:52 ` [PATCH 2/2] xfsprogs: xfs_db: add crc manipulation commands Eric Sandeen
2015-03-09 15:47 ` Eric Sandeen
2014-09-16 15:26 ` [PATCH 1/2 V2] xfs_db: fix inode CRC validity state, and warn on read if invalid Eric Sandeen
2014-09-16 15:29 ` [PATCH 2/2 V2] xfs_db: add crc manipulation commands Eric Sandeen
2014-09-16 22:06 ` Eric Sandeen
2014-09-16 23:52 ` Dave Chinner
2014-09-17 2:15 ` [PATCH 2/2 V3] " Eric Sandeen
2015-03-02 23:48 ` [PATCH 0/2] xfsprogs: xfs_db crc fixes/changes 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=540B485F.8070502@sandeen.net \
--to=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