diff mbox

[V2] xfs_db: properly set inode type

Message ID c17ce413-430e-acce-e63d-51fd1b684f62@sandeen.net (mailing list archive)
State Accepted
Headers show

Commit Message

Eric Sandeen July 18, 2017, 1:51 a.m. UTC
When we set the type to "inode" the verifier may validate multiple
inodes in the current fs block, so setting the buffer size to
that of just one inode is not sufficient and it'll emit spurious
verifier errors for all but the first, as we read off the end:

xfs_db> daddr 99
xfs_db> type inode
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200

Use the special set_cur_inode() function for this purpose
as is done in inode_f().

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

V2: Warn if the daddr given was reset to an inode-aligned
address


--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Bill O'Donnell July 18, 2017, 9:26 p.m. UTC | #1
On Mon, Jul 17, 2017 at 08:51:13PM -0500, Eric Sandeen wrote:
> When we set the type to "inode" the verifier may validate multiple
> inodes in the current fs block, so setting the buffer size to
> that of just one inode is not sufficient and it'll emit spurious
> verifier errors for all but the first, as we read off the end:
> 
> xfs_db> daddr 99
> xfs_db> type inode
> Metadata corruption detected at xfs_inode block 0x63/0x200
> Metadata corruption detected at xfs_inode block 0x63/0x200
> Metadata corruption detected at xfs_inode block 0x63/0x200
> Metadata corruption detected at xfs_inode block 0x63/0x200
> Metadata corruption detected at xfs_inode block 0x63/0x200
> Metadata corruption detected at xfs_inode block 0x63/0x200
> Metadata corruption detected at xfs_inode block 0x63/0x200
> 
> Use the special set_cur_inode() function for this purpose
> as is done in inode_f().
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---

I ran the new, proposed test xfs/424 to test this patch and
it runs fine. Thanks!

Reviewed-by: Bill O'Donnell <billodo@redhat.com>

> 
> V2: Warn if the daddr given was reset to an inode-aligned
> address
> 
> diff --git a/db/io.c b/db/io.c
> index b046c8d..4153da0 100644
> --- a/db/io.c
> +++ b/db/io.c
> @@ -616,6 +616,22 @@ set_iocur_type(
>  {
>  	struct xfs_buf	*bp = iocur_top->bp;
>  
> +	/* Inodes are special; verifier checks all inodes in the buffer */
> +	if (type->typnm == TYP_INODE) {
> +		xfs_daddr_t	b = iocur_top->bb;
> +		xfs_ino_t	ino;
> +
> +		ino = XFS_AGINO_TO_INO(mp, xfs_daddr_to_agno(mp, b),
> +			((b << BBSHIFT) >> mp->m_sb.sb_inodelog) %
> +			(mp->m_sb.sb_agblocks << mp->m_sb.sb_inopblog));
> +		set_cur_inode(ino);
> +		if (iocur_top->bb != b)
> +			dbprintf(
> +_("cursor set to nearest inode %llu at daddr %lld\n"),
> +				 ino, iocur_top->bb);
> +		return;
> +	}
> +
>  	/* adjust buffer size for types with fields & hence fsize() */
>  	if (type->fields) {
>  		int bb_count;	/* type's size in basic blocks */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/db/io.c b/db/io.c
index b046c8d..4153da0 100644
--- a/db/io.c
+++ b/db/io.c
@@ -616,6 +616,22 @@  set_iocur_type(
 {
 	struct xfs_buf	*bp = iocur_top->bp;
 
+	/* Inodes are special; verifier checks all inodes in the buffer */
+	if (type->typnm == TYP_INODE) {
+		xfs_daddr_t	b = iocur_top->bb;
+		xfs_ino_t	ino;
+
+		ino = XFS_AGINO_TO_INO(mp, xfs_daddr_to_agno(mp, b),
+			((b << BBSHIFT) >> mp->m_sb.sb_inodelog) %
+			(mp->m_sb.sb_agblocks << mp->m_sb.sb_inopblog));
+		set_cur_inode(ino);
+		if (iocur_top->bb != b)
+			dbprintf(
+_("cursor set to nearest inode %llu at daddr %lld\n"),
+				 ino, iocur_top->bb);
+		return;
+	}
+
 	/* adjust buffer size for types with fields & hence fsize() */
 	if (type->fields) {
 		int bb_count;	/* type's size in basic blocks */