Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1201238

Summary: xfs_repair verify the last secondary superblock corruption failed
Product: Red Hat Enterprise Linux 7 Reporter: Zorro Lang <zlang>
Component: xfsprogsAssignee: Eric Sandeen <esandeen>
Status: CLOSED ERRATA QA Contact: Zorro Lang <zlang>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: eguan, esandeen, fs-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: xfsprogs-3.2.2-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 13:51:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1205796    

Description Zorro Lang 2015-03-12 11:54:34 UTC
Description of problem:
xfstests xfs/070 run failed on RHEL7.1. more details as below:

Version-Release number of selected component (if applicable):
kernel-3.10.0-231.el7
xfsprogs-3.2.1-6.el7

How reproducible:
xfstests xfs/070

or you can run these steps:
Steps to Reproduce:
1. mkfs.xfs /dev/sda2, got agcount (Eg: agcount=4)
2. xfs_db -x -c "sb $((agcount - 1))" -c "type data" -c "write fill 0xff 0 512" /dev/sda2
3. xfs_repair -n /dev/sda2

Actual results:
If you run xfs/070 case, you will get error messages likes:
----
Phase 1 - find and verify superblock...
couldn't verify primary superblock - bad magic number !!!

attempting to find secondary superblock...
............................................/tests/xfs/070: line 70:  5326 Broken pipe             $XFS_REPAIR_PROG $SCRATCH_DEV 2>&1
      5327 Killed                  | tee -a $seqres.full > $tmp.repair
xfs_repair resorted to brute force scan
----

Or if you run manually, you will got:
----
[root@hp-dc5800-01 xfsprogs-3.2.1]# xfs_repair -n /dev/sda2
Phase 1 - find and verify superblock...
couldn't verify primary superblock - bad magic number !!!

attempting to find secondary superblock...
.......................found candidate secondary superblock...
error reading superblock 1 -- seek to offset 312478593024 failed
unable to verify superblock, continuing...
...........................found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
error reading superblock 1 -- seek to offset 17179869184 failed
unable to verify superblock, continuing...
found candidate secondary superblock...
superblock read failed, offset 16106127360, size 131072, ag 960, rval 0

fatal error -- Invalid argument
----

Expected results:
xfs/070 run pass

Additional info:

Comment 1 Zorro Lang 2015-03-12 12:08:46 UTC
I tried this xfsprogs upstream commit 6d23d9a5dad9003d3b4e8e970c393f90a137d10d from Bian Foster.
diff --git a/repair/sb.c b/repair/sb.c
index ad27756..dc154f7 100644
--- a/repair/sb.c
+++ b/repair/sb.c
@@ -724,7 +724,6 @@ verify_set_primary_sb(xfs_sb_t              *rsb,
         * sector size rather than the sector size in @rsb.
         */
        size = NUM_AGH_SECTS * (1 << (XFS_MAX_SECTORSIZE_LOG));
-       retval = 0;
        list = NULL;
        num_ok = 0;
        *sb_modified = 0;
@@ -779,6 +778,7 @@ verify_set_primary_sb(xfs_sb_t              *rsb,
        /*
         * see if we have enough superblocks to bother with
         */
+       retval = 0;
        if (num_ok < num_sbs / 2) {
                retval = XR_INSUFF_SEC_SB;
                goto out_free_list;
@@ -868,5 +868,5 @@ out_free_list:
        free_geo(list);
        free(sb);
        free(checked);
-       return(retval);
+       return retval;
 }

It looks good, after patch it and run xfs/070 again. I got this new output:
----
[root@hp-dc5800-01 xfstests]# less /var/lib/xfstests/results/xfs/xfs-070.full
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
bad magic number
bad on-disk superblock 3 - bad magic number
primary/secondary superblock 3 conflict - AG superblock geometry info conflicts with filesystem geometry
zeroing unused portion of secondary superblock (AG #3)
non-null project quota inode field in superblock 3
reset bad sb for ag 3
        - found root inode chunk
Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
        - process known inodes and perform inode discovery...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
        - process newly discovered inodes...
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - check for inodes claiming duplicate blocks...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
Phase 5 - rebuild AG headers and trees...
        - reset superblock...
Phase 6 - check inode connectivity...
        - resetting contents of realtime bitmap and summary inodes
        - traversing filesystem ...
        - traversal finished ...
        - moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
done
----

That's nearly same with expected result, except one line is un-expected:
"non-null project quota inode field in superblock AGNO" in Phase 2.

I can't sure if this line is a bug?

Comment 4 Eric Sandeen 2015-06-15 20:43:58 UTC
Fixed in xfsprogs-3.2.2-1.el7

Comment 6 Zorro Lang 2015-10-08 06:10:45 UTC
xfs/070 test passed on xfsprogs-3.2.2-2.el7.

Comment 7 errata-xmlrpc 2015-11-19 13:51:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2015-2151.html