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

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