From nobody Tue May 30 02:35:12 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QVc2621YSz4XcYm for ; Tue, 30 May 2023 02:35:26 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QVc256HSnz45kt for ; Tue, 30 May 2023 02:35:25 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-30ae4ec1ac7so1513151f8f.2 for ; Mon, 29 May 2023 19:35:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685414124; x=1688006124; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u4NNTEdesUWfMXX4nUhN8LvNXfLhx38R0vjqtooAcK4=; b=ZjAyMX7OTC1sT2jgJ46WsDFSkGu0VaEKbodEI9TVMpZuf+e1hiKKJdIxRdN8Mk5Ao/ DtL/fDYtDvt7oipAbs3UYLVMWSO3gIRWwhnDN0wcf42Es3OiSJ6aPSC558Gd01ls7ADf gCvWITXNc4/8fZyyRTTKO4RjYjpmdundtGZLGbvBWidV5KtYdGvmm7sU/L2ujOJfy6iU cKoOEzNw+J5ZpbD6pWbNNiq2LaZdNntZnDc0wgG9vxiVqI5SFLbk0/S9rBewo3TLpjOJ HNInRyfzOi0HWVs4STG2Pi/tp/69nmyyDbJoQrlhcLqxGjU03b2wnXDvwJIUhfwm/Lgd 9utg== X-Gm-Message-State: AC+VfDy6Xni8n6/qz+UiC8N0mZFmjwrkZbPnqmSa0dnJUyv7dnLVAuQf DnV5oDOYsmLFuVCcI9y8PekfPg== X-Google-Smtp-Source: ACHHUZ5BRBxQ8sdQVMu+qxMbENLiwn/xHNdlHg4yFOselhmZQex4hTYsO209uVJ1wkCTN7+G+VnBtA== X-Received: by 2002:a5d:4dce:0:b0:309:41d8:eec4 with SMTP id f14-20020a5d4dce000000b0030941d8eec4mr326101wru.39.1685414124149; Mon, 29 May 2023 19:35:24 -0700 (PDT) Received: from smtpclient.apple ([131.111.5.246]) by smtp.gmail.com with ESMTPSA id z11-20020adfdf8b000000b0030aed4223e0sm1565138wrl.105.2023.05.29.19.35.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 May 2023 19:35:23 -0700 (PDT) Content-Type: text/plain; charset=us-ascii List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: git: d464a7698de8 - main - ffs: restore backward compatibility of newfs and makefs with older binaries From: Jessica Clarke In-Reply-To: <202305300228.34U2S2QI062128@gitrepo.freebsd.org> Date: Tue, 30 May 2023 03:35:12 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <31C0370D-59E1-47FF-9A27-AB08F19C3F8E@freebsd.org> References: <202305300228.34U2S2QI062128@gitrepo.freebsd.org> To: Chuck Silvers X-Mailer: Apple Mail (2.3731.500.231) X-Rspamd-Queue-Id: 4QVc256HSnz45kt X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On 30 May 2023, at 03:28, Chuck Silvers wrote: >=20 > The branch main has been updated by chs: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3Dd464a7698de8fe18530ea65fac90dce5= 6b860a59 >=20 > commit d464a7698de8fe18530ea65fac90dce56b860a59 > Author: Chuck Silvers > AuthorDate: 2023-05-30 02:26:28 +0000 > Commit: Chuck Silvers > CommitDate: 2023-05-30 02:26:28 +0000 >=20 > ffs: restore backward compatibility of newfs and makefs with older = binaries >=20 > The previous change to CGSIZE had the unintended side-effect of = allowing > newfs and makefs to create file systems that would fail validation = when > examined by older commands and kernels, by allowing newfs/makefs to = pack > slightly more blocks into a CG than those older binaries think is = valid. > Fix this by having newfs/makefs artificially restrict the number of = blocks > in a CG to the slightly smaller value that those older binaries = will accept. > The validation code will continue to accept the slightly larger = value > that the current newfs/makefs (before this change) could create. Can we ditch this once 13 is EOL? Jess > Fixes: 0a6e34e950cd5889122a199c34519b67569be9cc > Reviewed by: mckusick > MFC after: 3 days > Sponsored by: Netflix > --- > sbin/newfs/mkfs.c | 26 +++++++++++++++++++++++--- > usr.sbin/makefs/ffs/mkfs.c | 26 +++++++++++++++++++++++--- > 2 files changed, 46 insertions(+), 6 deletions(-) >=20 > diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c > index adc64f47cac6..28b02d250e17 100644 > --- a/sbin/newfs/mkfs.c > +++ b/sbin/newfs/mkfs.c > @@ -76,6 +76,23 @@ __FBSDID("$FreeBSD$"); > #define UMASK 0755 > #define POWEROF2(num) (((num) & ((num) - 1)) =3D=3D 0) >=20 > +/* > + * The definition of "struct cg" used to contain an extra field at = the end > + * to represent the variable-length data that followed the fixed = structure. > + * This had the effect of artificially limiting the number of blocks = that > + * newfs would put in a CG, since newfs thought that the fixed-size = header > + * was bigger than it really was. When we started validating that = the CG > + * header data actually fit into one fs block, the placeholder field = caused > + * a problem because it caused struct cg to be a different size = depending on > + * platform. The placeholder field was later removed, but this = caused a > + * backward compatibility problem with older binaries that still = thought > + * struct cg was larger, and a new file system could fail validation = if > + * viewed by the older binaries. To avoid this compatibility = problem, we > + * now artificially reduce the amount of space that the = variable-length data > + * can use such that new file systems will pass validation by older = binaries. > + */ > +#define CGSIZEFUDGE 8 > + > static struct csum *fscs; > #define sblock disk.d_fs > #define acg disk.d_cg > @@ -369,7 +386,8 @@ retry: > sblock.fs_fpg =3D minfpg; > sblock.fs_ipg =3D roundup(howmany(sblock.fs_fpg, fragsperinode), > INOPB(&sblock)); > - if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize) > + if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize - > + CGSIZEFUDGE) > break; > density -=3D sblock.fs_fsize; > } > @@ -388,9 +406,11 @@ retry: > if (Oflag > 1 || (Oflag =3D=3D 1 && sblock.fs_ipg <=3D 0x7fff)) { > if (sblock.fs_size / sblock.fs_fpg < MINCYLGRPS) > break; > - if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize) > + if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize - > + CGSIZEFUDGE) > continue; > - if (CGSIZE(&sblock) =3D=3D (unsigned long)sblock.fs_bsize) > + if (CGSIZE(&sblock) =3D=3D (unsigned long)sblock.fs_bsize - > + CGSIZEFUDGE) > break; > } > sblock.fs_fpg -=3D sblock.fs_frag; > diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c > index d48dc65aac68..4e88dae7aae8 100644 > --- a/usr.sbin/makefs/ffs/mkfs.c > +++ b/usr.sbin/makefs/ffs/mkfs.c > @@ -80,6 +80,23 @@ static int count_digits(int); > #define UMASK 0755 > #define POWEROF2(num) (((num) & ((num) - 1)) =3D=3D 0) >=20 > +/* > + * The definition of "struct cg" used to contain an extra field at = the end > + * to represent the variable-length data that followed the fixed = structure. > + * This had the effect of artificially limiting the number of blocks = that > + * newfs would put in a CG, since newfs thought that the fixed-size = header > + * was bigger than it really was. When we started validating that = the CG > + * header data actually fit into one fs block, the placeholder field = caused > + * a problem because it caused struct cg to be a different size = depending on > + * platform. The placeholder field was later removed, but this = caused a > + * backward compatibility problem with older binaries that still = thought > + * struct cg was larger, and a new file system could fail validation = if > + * viewed by the older binaries. To avoid this compatibility = problem, we > + * now artificially reduce the amount of space that the = variable-length data > + * can use such that new file systems will pass validation by older = binaries. > + */ > +#define CGSIZEFUDGE 8 > + > static union { > struct fs fs; > char pad[SBLOCKSIZE]; > @@ -347,7 +364,8 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, = time_t tstamp) > sblock.fs_fpg =3D minfpg; > sblock.fs_ipg =3D roundup(howmany(sblock.fs_fpg, fragsperinode), > INOPB(&sblock)); > - if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize) > + if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize - > + CGSIZEFUDGE) > break; > density -=3D sblock.fs_fsize; > } > @@ -366,9 +384,11 @@ ffs_mkfs(const char *fsys, const fsinfo_t = *fsopts, time_t tstamp) > INOPB(&sblock)); > if (sblock.fs_size / sblock.fs_fpg < 1) > break; > - if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize) > + if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize - > + CGSIZEFUDGE) > continue; > - if (CGSIZE(&sblock) =3D=3D (unsigned long)sblock.fs_bsize) > + if (CGSIZE(&sblock) =3D=3D (unsigned long)sblock.fs_bsize - > + CGSIZEFUDGE) > break; > sblock.fs_fpg -=3D sblock.fs_frag; > sblock.fs_ipg =3D roundup(howmany(sblock.fs_fpg, fragsperinode),