From: Darrick J. Wong Date: Thu, 18 Aug 2016 23:27:30 +0000 (+1000) Subject: xfs_repair: preserve in-core meta_uuid while zeroing unused sb portions X-Git-Tag: v4.8.0-rc1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2110aea0c86626aaad889d62d15add5b6ce826d6;p=thirdparty%2Fxfsprogs-dev.git xfs_repair: preserve in-core meta_uuid while zeroing unused sb portions 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 Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/repair/agheader.c b/repair/agheader.c index b95cedd8f..cce376f25 100644 --- a/repair/agheader.c +++ b/repair/agheader.c @@ -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"),