Blame SOURCES/xfsprogs-4.9.0-junk-attr-leaf-count-zero.patch

e59f31
xfs_repair: junk leaf attribute if count == 0
e59f31
e59f31
We have recently seen a case where, during log replay, the
e59f31
attr3 leaf verifier reported corruption when encountering a
e59f31
leaf attribute with a count of 0 in the header.
e59f31
e59f31
We chalked this up to a transient state when a shortform leaf
e59f31
was created, the attribute didn't fit, and we promoted the
e59f31
(empty) attribute to the larger leaf form.
e59f31
e59f31
I've recently been given a metadump of unknown provenance which actually
e59f31
contains a leaf attribute with count 0 on disk.  This causes the
e59f31
verifier to fire every time xfs_repair is run:
e59f31
e59f31
 Metadata corruption detected at xfs_attr3_leaf block 0x480988/0x1000
e59f31
e59f31
If this 0-count state is detected, we should just junk the leaf, same
e59f31
as we would do if the count was too high.  With this change, we now
e59f31
remedy the problem:
e59f31
e59f31
 Metadata corruption detected at xfs_attr3_leaf block 0x480988/0x1000
e59f31
 bad attribute count 0 in attr block 0, inode 12587828
e59f31
 problem with attribute contents in inode 12587828
e59f31
 clearing inode 12587828 attributes
e59f31
 correcting nblocks for inode 12587828, was 2 - counted 1
e59f31
e59f31
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
e59f31
Reviewed-by: Brian Foster <bfoster@redhat.com>
e59f31
---
e59f31
e59f31
diff --git a/repair/attr_repair.c b/repair/attr_repair.c
e59f31
index 40cb5f7..b855a10 100644
e59f31
--- a/repair/attr_repair.c
e59f31
+++ b/repair/attr_repair.c
e59f31
@@ -593,7 +593,8 @@ process_leaf_attr_block(
e59f31
 	stop = xfs_attr3_leaf_hdr_size(leaf);
e59f31
 
e59f31
 	/* does the count look sorta valid? */
e59f31
-	if (leafhdr.count * sizeof(xfs_attr_leaf_entry_t) + stop >
e59f31
+	if (!leafhdr.count ||
e59f31
+	    leafhdr.count * sizeof(xfs_attr_leaf_entry_t) + stop >
e59f31
 						mp->m_sb.sb_blocksize) {
e59f31
 		do_warn(
e59f31
 	_("bad attribute count %d in attr block %u, inode %" PRIu64 "\n"),
e59f31
--
e59f31
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
e59f31
the body of a message to majordomo@vger.kernel.org
e59f31
More majordomo info at  http://vger.kernel.org/majordomo-info.html
e59f31
e59f31