]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
repair: fix unnecessary secondary scan if only last sb is corrupt
authorBrian Foster <bfoster@redhat.com>
Thu, 5 Feb 2015 23:28:00 +0000 (10:28 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 5 Feb 2015 23:28:00 +0000 (10:28 +1100)
verify_set_primary_sb() scans the secondary superbocks based on the
geometry specified in the primary and determines the most likely correct
geometry by tracking how many superblocks are consistent across the set.
The most frequent geometry is copied into the primary superblock. The
return value is checked by the caller (phase1()) to determine whether a
brute force secondary scan is necessary.

This generally occurs when not enough secondary sb's are consistent to
declare the geometry correct. If enough secondaries are consistent,
verify_set_primary_sb() returns the status of the last secondary sb that
was scanned. Corruptions to secondary supers other than the last are
thus resolved fine. If the last secondary is corrupt, however, an error
is returned to phase1(). This causes a brute force scan even if enough
supers were found to repair the last secondary.

Move the initialization of retval to after the sb scan to return an
error only if not enough secondary supers were found to declare a
correct geometry.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
repair/sb.c

index ad277569a115ab9074c7611d7ff93e988776181a..dc154f74c9481817da1a19b8cd40e8f8267160c3 100644 (file)
@@ -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;
 }