From 2110aea0c86626aaad889d62d15add5b6ce826d6 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 19 Aug 2016 09:27:30 +1000 Subject: [PATCH] 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 --- repair/agheader.c | 4 ++++ 1 file changed, 4 insertions(+) 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"), -- 2.47.2