From: Darrick J. Wong Date: Thu, 9 Nov 2017 17:35:26 +0000 (-0600) Subject: xfs_repair: fix cowextsize field checking and repairing X-Git-Tag: v4.14.0-rc1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c744e94a494f4770a6f9ba067605902b0e96520;p=thirdparty%2Fxfsprogs-dev.git xfs_repair: fix cowextsize field checking and repairing Make sure that we never leave the filesystem with a zero cowextsize hint while the cowextsize inode flag is set. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/repair/dinode.c b/repair/dinode.c index e62ec335d..32cc76917 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2694,6 +2694,7 @@ _("Cannot have non-zero CoW extent size %u on non-cowextsize inode %" PRIu64 ", be32_to_cpu(dino->di_cowextsize), lino); if (!no_modify) { do_warn(_("resetting to zero\n")); + dino->di_flags2 &= ~cpu_to_be64(XFS_DIFLAG2_COWEXTSIZE); dino->di_cowextsize = 0; *dirty = 1; } else @@ -2701,6 +2702,24 @@ _("Cannot have non-zero CoW extent size %u on non-cowextsize inode %" PRIu64 ", } } + /* + * Can't have the COWEXTSIZE flag set with no hint. + */ + if (dino->di_version >= 3 && + be32_to_cpu(dino->di_cowextsize) == 0 && + (be64_to_cpu(dino->di_flags2) & XFS_DIFLAG2_COWEXTSIZE)) { + do_warn( +_("Cannot have CoW extent size of zero on cowextsize inode %" PRIu64 ", "), + lino); + if (!no_modify) { + do_warn(_("clearing cowextsize flag\n")); + dino->di_flags2 &= ~cpu_to_be64(XFS_DIFLAG2_COWEXTSIZE); + *dirty = 1; + } else { + do_warn(_("would clear cowextsize flag\n")); + } + } + /* * general size/consistency checks: */