From owner-svn-src-stable-12@freebsd.org Tue Nov 17 05:48:01 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F2F4A2D0D1A; Tue, 17 Nov 2020 05:48:01 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZw2n6YVsz3hq7; Tue, 17 Nov 2020 05:48:01 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CF5B41ADEC; Tue, 17 Nov 2020 05:48:01 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH5m1Cg086682; Tue, 17 Nov 2020 05:48:01 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH5m1nB086679; Tue, 17 Nov 2020 05:48:01 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <202011170548.0AH5m1nB086679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 17 Nov 2020 05:48:01 +0000 (UTC) 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 X-SVN-Group: stable-12 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/12/sys/ufs/ffs X-SVN-Commit-Revision: 367749 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 05:48:02 -0000 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. */