Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Nov 2020 05:48:01 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r367749 - stable/12/sys/ufs/ffs
Message-ID:  <202011170548.0AH5m1nB086679@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mckusick
Date: Tue Nov 17 05:48:00 2020
New Revision: 367749
URL: https://svnweb.freebsd.org/changeset/base/367749

Log:
  MFC of 340927 and 367034.
  
  Move clear of UFS feature flags from ufs_mountfs() to ffs_sbget() to
  ensure that the appropriate feature flags get cleared by filesystem
  utilities as well as the kernel when they modify the filesystem.
  
  Note 340927 is relevant for this even though it was done for a
  different reason at the time.
  
  Sponsored by: Netflix

Modified:
  stable/12/sys/ufs/ffs/ffs_subr.c
  stable/12/sys/ufs/ffs/ffs_vfsops.c
  stable/12/sys/ufs/ffs/fs.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/ufs/ffs/ffs_subr.c
==============================================================================
--- stable/12/sys/ufs/ffs/ffs_subr.c	Tue Nov 17 05:01:55 2020	(r367748)
+++ stable/12/sys/ufs/ffs/ffs_subr.c	Tue Nov 17 05:48:00 2020	(r367749)
@@ -316,7 +316,20 @@ readsuper(void *devfd, struct fs **fsp, off_t sblocklo
 	    fs->fs_ncg >= 1 &&
 	    fs->fs_bsize >= MINBSIZE &&
 	    fs->fs_bsize <= MAXBSIZE &&
-	    fs->fs_bsize >= roundup(sizeof(struct fs), DEV_BSIZE)) {
+	    fs->fs_bsize >= roundup(sizeof(struct fs), DEV_BSIZE) &&
+	    fs->fs_sbsize <= SBLOCKSIZE) {
+		/*
+		 * If the filesystem has been run on a kernel without
+		 * metadata check hashes, disable them.
+		 */
+		if ((fs->fs_flags & FS_METACKHASH) == 0)
+			fs->fs_metackhash = 0;
+		/*
+		 * Clear any check-hashes that are not maintained
+		 * by this kernel. Also clear any unsupported flags.
+		 */
+		fs->fs_metackhash &= CK_SUPPORTED;
+		fs->fs_flags &= FS_SUPPORTED;
 		/* Have to set for old filesystems that predate this field */
 		fs->fs_sblockactualloc = sblockloc;
 		/* Not yet any summary information */

Modified: stable/12/sys/ufs/ffs/ffs_vfsops.c
==============================================================================
--- stable/12/sys/ufs/ffs/ffs_vfsops.c	Tue Nov 17 05:01:55 2020	(r367748)
+++ stable/12/sys/ufs/ffs/ffs_vfsops.c	Tue Nov 17 05:48:00 2020	(r367749)
@@ -828,13 +828,6 @@ ffs_mountfs(devvp, mp, td)
 	if ((error = ffs_sbget(devvp, &fs, -1, M_UFSMNT, ffs_use_bread)) != 0)
 		goto out;
 	fs->fs_fmod = 0;
-	/* if we ran on a kernel without metadata check hashes, disable them */
-	if ((fs->fs_flags & FS_METACKHASH) == 0)
-		fs->fs_metackhash = 0;
-	/* none of these types of check-hashes are maintained by this kernel */
-	fs->fs_metackhash &= ~(CK_SUPERBLOCK | CK_INODE | CK_INDIR | CK_DIR);
-	/* no support for any undefined flags */
-	fs->fs_flags &= FS_SUPPORTED;
 	fs->fs_flags &= ~FS_UNCLEAN;
 	if (fs->fs_clean == 0) {
 		fs->fs_flags |= FS_UNCLEAN;

Modified: stable/12/sys/ufs/ffs/fs.h
==============================================================================
--- stable/12/sys/ufs/ffs/fs.h	Tue Nov 17 05:01:55 2020	(r367748)
+++ stable/12/sys/ufs/ffs/fs.h	Tue Nov 17 05:48:00 2020	(r367749)
@@ -475,6 +475,7 @@ CTASSERT(sizeof(struct fs) == 1376);
 #define	CK_INODE	0x0004	/* inodes */
 #define	CK_INDIR	0x0008	/* indirect blocks */
 #define	CK_DIR		0x0010	/* directory contents */
+#define	CK_SUPPORTED	0x0002	/* supported flags, others cleared at mount */
 /*
  * The BX_FSPRIV buffer b_xflags are used to track types of data in buffers.
  */



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