From 6d23d9a5dad9003d3b4e8e970c393f90a137d10d Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Fri, 6 Feb 2015 10:28:00 +1100 Subject: [PATCH] repair: fix unnecessary secondary scan if only last sb is corrupt 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 Reviewed-by: Eric Sandeen Signed-off-by: Dave Chinner --- repair/sb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repair/sb.c b/repair/sb.c index ad277569a..dc154f74c 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; } -- 2.50.1