Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Dec 2018 18:49:31 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r342134 - head/sys/ufs/ffs
Message-ID:  <201812151849.wBFInVl0086769@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mckusick
Date: Sat Dec 15 18:49:30 2018
New Revision: 342134
URL: https://svnweb.freebsd.org/changeset/base/342134

Log:
  Ensure that the inode check-hash is not left zeroed out in the case where
  the check-hash fails. Prior to the fix in -r342133 the inode with the
  zeroed out check-hash was written back to disk causing further confusion.
  
  Reported by:  Gary Jennejohn (gj)
  Sponsored by: Netflix

Modified:
  head/sys/ufs/ffs/ffs_subr.c

Modified: head/sys/ufs/ffs/ffs_subr.c
==============================================================================
--- head/sys/ufs/ffs/ffs_subr.c	Sat Dec 15 18:35:46 2018	(r342133)
+++ head/sys/ufs/ffs/ffs_subr.c	Sat Dec 15 18:49:30 2018	(r342134)
@@ -161,7 +161,7 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struc
 int
 ffs_verify_dinode_ckhash(struct fs *fs, struct ufs2_dinode *dip)
 {
-	uint32_t save_ckhash;
+	uint32_t ckhash, save_ckhash;
 
 	/*
 	 * Return success if unallocated or we are not doing inode check-hash.
@@ -174,10 +174,11 @@ ffs_verify_dinode_ckhash(struct fs *fs, struct ufs2_di
 	 */
 	save_ckhash = dip->di_ckhash;
 	dip->di_ckhash = 0;
-	if (save_ckhash != calculate_crc32c(~0L, (void *)dip, sizeof(*dip)))
-		return (EINVAL);
+	ckhash = calculate_crc32c(~0L, (void *)dip, sizeof(*dip));
 	dip->di_ckhash = save_ckhash;
-	return (0);
+	if (save_ckhash == ckhash)
+		return (0);
+	return (EINVAL);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812151849.wBFInVl0086769>