From b26bd091bdf72c2ee4f08ed2bb13298ee7a9bd6e Mon Sep 17 00:00:00 2001 From: imp Date: Thu, 16 Nov 2017 21:28:14 +0000 Subject: [PATCH] Only try to enable CK_CLYGRP if we're running on kernel newer than 1200046, the first version that supports this feature. If we set it, then use an old kernel, we'll break the 'contract' of having checksummed cylinder groups this flag signifies. To avoid creating something with an inconsistent state, don't turn the flag on in these cases. The first full fsck with a new kernel will turn this on. Spnsored by: Netflix Differential Revision: https://reviews.freebsd.org/D13114 --- sbin/fsck_ffs/pass5.c | 2 ++ sbin/newfs/mkfs.c | 3 ++- sbin/newfs/newfs.c | 4 ---- sys/sys/param.h | 1 + 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index 16c46bece00b..a4828a20e1f8 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -35,6 +35,7 @@ static const char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95"; #include __FBSDID("$FreeBSD$"); +#define IN_RTLD /* So we pickup the P_OSREL defines */ #include #include @@ -73,6 +74,7 @@ pass5(void) newcg->cg_niblk = fs->fs_ipg; if (preen == 0 && yflag == 0 && fs->fs_magic == FS_UFS2_MAGIC && fswritefd != -1 && (fs->fs_metackhash & CK_CYLGRP) == 0 && + getosreldate() >= P_OSREL_CK_CLYGRP && reply("ADD CYLINDER GROUP CHECKSUM PROTECTION") != 0) { fs->fs_metackhash |= CK_CYLGRP; rewritecg = 1; diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index f68c42ec6b36..a7d570ea5619 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -44,6 +44,7 @@ static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95"; #include __FBSDID("$FreeBSD$"); +#define IN_RTLD /* So we pickup the P_OSREL defines */ #include #include #include @@ -495,7 +496,7 @@ restart: /* * Set flags for metadata that is being check-hashed. */ - if (Oflag > 1) + if (Oflag > 1 && getosreldate() >= P_OSREL_CK_CLYGRP) sblock.fs_metackhash = CK_CYLGRP; /* diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 2928878ad901..8b32792c3c83 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -398,10 +398,6 @@ main(int argc, char *argv[]) if (pp != NULL) pp->p_size *= secperblk; } - if (getosreldate() < __FreeBSD_version) { - warnx("%s is newer than the running kernel and may not be compatible", - getprogname()); - } mkfs(pp, special); ufs_disk_close(&disk); if (!jflag) diff --git a/sys/sys/param.h b/sys/sys/param.h index cac8cbad00dd..e7289d71be30 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -84,6 +84,7 @@ #define P_OSREL_SHUTDOWN_ENOTCONN 1100077 #define P_OSREL_MAP_GUARD 1200035 #define P_OSREL_WRFSBASE 1200041 +#define P_OSREL_CK_CLYGRP 1200046 #define P_OSREL_VMTOTAL64 1200054 #define P_OSREL_MAJOR(x) ((x) / 100000)