]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: preserve in-core meta_uuid while zeroing unused sb portions
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 18 Aug 2016 23:27:30 +0000 (09:27 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 18 Aug 2016 23:27:30 +0000 (09:27 +1000)
If we zero unused parts of the superblock, we must preserve meta_uuid
across the zeroing because meta_uuid is used to verify the v5 format
checksums even on non-metauuid filesystems.  If we don't, the next
thing that happens is that all metadata fails in the verifier and the
whole filesystem is "toast".

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
repair/agheader.c

index b95cedd8f9fb9d519c493da5199c9d00810ff871..cce376f25c466ce4ae17a1e35de8f7bba36101bb 100644 (file)
@@ -258,6 +258,7 @@ secondary_sb_whack(
        int             size;
        char            *ip;
        int             rval = 0;;
+       uuid_t          tmpuuid;
 
        rval = do_bzero = 0;
 
@@ -310,10 +311,13 @@ secondary_sb_whack(
                         * be set, and the latter is never updated past
                         * the last field - just zap them both.
                         */
+                       memcpy(&tmpuuid, &sb->sb_meta_uuid, sizeof(uuid_t));
                        memset((void *)((intptr_t)sb + size), 0,
                                mp->m_sb.sb_sectsize - size);
                        memset(XFS_BUF_PTR(sbuf) + size, 0,
                                mp->m_sb.sb_sectsize - size);
+                       /* Preserve meta_uuid so we don't fail uuid checks */
+                       memcpy(&sb->sb_meta_uuid, &tmpuuid, sizeof(uuid_t));
                } else
                        do_warn(
        _("would zero unused portion of %s superblock (AG #%u)\n"),