From nobody Wed Jul 8 05:17:03 2026 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 4gw5tr3ry9z6khYM for ; Wed, 08 Jul 2026 05:17:08 +0000 (UTC) (envelope-from git@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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gw5tr2RFNz3tLy for ; Wed, 08 Jul 2026 05:17:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783487828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OacgJVJlXG6cliBo/F1KPbEf1D8ziX+T52uSFMxLrEo=; b=dL8BdIordmX6jt1RM/f4BHIkI2IIfWOv8w47H05UwOnoZ3qJEV9qSHzVnTjFVE2YU4VHiy m+ZQXQTLwgnsE3iV1BnS9R9IuTK5irOK9VWFAKxbHt8wBMGAxSTIKmrHFmgg3qG92R8mtD WVJzDW4uWog2TtpSJZY3qWlxS8/k9/0NmpMWp3sEruVMYAPRudxefrQ9ETn/Y62Xe8RjFG AsPmRwP/mgVbx6m9r1Ea0ZurPs0lViaw8CAJ5SOjG7oYu6zG/F4LLzeFUriuiWB0CBx7pr oKnGsUgW1bdn2rdMpSl+rqnQMZH+dE+P06Oil+ZIPHV6yJB7BaPMEQzWXcllFA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783487828; a=rsa-sha256; cv=none; b=uzy0QQgRhmqVO4IDomGJw1Ipt7HME1ttHZ8yQxAy0gobQPnZiZ3cgvSWoEGZElR2UNTumD anjZXfEhiiYAcCN0+jI/rykMz5NAhkmzQdZ/ETTmsgiEVxe3bj8GaoFcO07lG5+K6cT6/a 2IaZEw7STOBTLqbF9NaFbnUYigVcNrwrnQmvc2q9NXpdK7qNLwpZjfMle3r7yCaAZhpb5w aW1Fa3NecbD3pMFT3oeEUFdVIMiEVhKZGWN/fw7cBeZgL5kvhxznqjVzw3eGwQyr6P97Kn eivsc0vGM3k/VE6i56/HyJ/9RC7blMM5j/4gQuhuKlSbcDnVp+Vu4SWGH8dfCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783487828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OacgJVJlXG6cliBo/F1KPbEf1D8ziX+T52uSFMxLrEo=; b=yyu6B5j6FruU52CHamnAqOEnBYOdkZuJZTqjGmvfJwmjbJh2AsYdzV/o07SBpELmuCWIzg GGi6oR/EV74B4uPkOpksNvPJEUOS1xyloGbcQOw31Qbj1/l3kRfm7Pi7T5QO/bkF8WOcD5 Xaq7Fsp9xzvxTDZkJI/lzR+n7jbzBIGIXxjwy0VaPRLzcf6NI7ZEYWX3P+9J4z4BhlXp1b edB7jll2y8Flca5R+FB8UmnivorxXKYzW80g3HyV4SFIlEF7qX1GMSsGZN4nC+19SKcxNA kQs29r42uTrGlOr5gtiwGJl7P+oxCWrqEy1or7/oGdv/O25LykQNIiLa46Xdag== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gw5tr1QGGz16Ld for ; Wed, 08 Jul 2026 05:17:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 372c2 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 08 Jul 2026 05:17:03 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Ricardo Branco From: Warner Losh Subject: git: 3eb80d8d7daf - main - ufs: Allow read-only mounting of NetBSD FFSv2 WAPBL filesystems 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3eb80d8d7daf4f14c22dd462d8c4e5b6fc818bd4 Auto-Submitted: auto-generated Date: Wed, 08 Jul 2026 05:17:03 +0000 Message-Id: <6a4ddd4f.372c2.5cc2ceb7@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3eb80d8d7daf4f14c22dd462d8c4e5b6fc818bd4 commit 3eb80d8d7daf4f14c22dd462d8c4e5b6fc818bd4 Author: Ricardo Branco AuthorDate: 2026-06-13 08:26:58 +0000 Commit: Warner Losh CommitDate: 2026-07-08 05:16:01 +0000 ufs: Allow read-only mounting of NetBSD FFSv2 WAPBL filesystems Skip UFS2 fs_metaspace upper-bound validation that rejects NetBSD FFSv2 WAPBL filesystems due to differing superblock layouts. Detect the condition during mount instead and permit read-only mounts while rejecting read-write mounts with EROFS. This follows NetBSD's recommendation for systems without WAPBL support and avoids modifying unsupported journal metadata. PR: 296022 Signed-off-by: Ricardo Branco Reviewed by: imp, kirk Pull Request: https://github.com/freebsd/freebsd-src/pull/2279 --- sys/ufs/ffs/ffs_subr.c | 14 +++++++++++++- sys/ufs/ffs/ffs_vfsops.c | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 682dd60ebd44..496de9913eda 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -717,7 +717,19 @@ validate_sblock(struct fs *fs, int flags) howmany(fs->fs_cssize, fs->fs_fsize), %jd); #endif WCHK(fs->fs_metaspace, <, 0, %jd); - WCHK(fs->fs_metaspace, >, fs->fs_fpg / 2, %jd); + /* + * FreeBSD and NetBSD FFSv2 layouts diverge in the superblock region + * following fs_maxbsize. NetBSD's WAPBL journal metadata occupies + * the same bytes as FreeBSD's fs_metaspace and other fields. + * fs_flags cannot serve as a discriminator: ffs_oldfscompat_read() + * may overwrite it from the 8-bit fs_old_flags before this check runs. + * Skip the upper-bound check for UFS2; ffs_mountfs() detects the + * condition and enforces read-only access without modifying the + * on-disk superblock. The check is preserved for UFS1 where no such + * layout divergence exists. + */ + if (fs->fs_magic != FS_UFS2_MAGIC) + WCHK(fs->fs_metaspace, >, fs->fs_fpg / 2, %jd); WCHK(fs->fs_minfree, >, 99, %jd%%); maxfilesize = fs->fs_bsize * UFS_NDADDR - 1; for (sizepb = fs->fs_bsize, i = 0; i < UFS_NIADDR; i++) { diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index a9b04bd290bd..f7f1d3e7ff93 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -604,6 +604,16 @@ ffs_mount(struct mount *mp) if (error) { return (error); } + /* + * Refuse upgrade of NetBSD WAPBL filesystem to + * read-write; see validate_sblock() for details. + */ + if (fs->fs_magic == FS_UFS2_MAGIC && + fs->fs_metaspace > fs->fs_fpg / 2) { + vfs_mount_error(mp, + "WAPBL filesystem must be mounted read-only"); + return (EROFS); + } fs->fs_flags &= ~FS_UNCLEAN; if (fs->fs_clean == 0) { fs->fs_flags |= FS_UNCLEAN; @@ -926,6 +936,23 @@ ffs_mountfs(struct vnode *odevvp, struct mount *mp, struct thread *td) ffs_use_bread); if (error != 0) goto out; + /* + * Per NetBSD's wapbl(4), systems without WAPBL support should mount it + * read-only; see validate_sblock() for details. + */ + if (fs->fs_magic == FS_UFS2_MAGIC && + fs->fs_metaspace > fs->fs_fpg / 2) { + if ((mp->mnt_flag & MNT_RDONLY) == 0) { + vfs_mount_error(mp, + "WAPBL filesystem must be mounted read-only"); + error = EROFS; + goto out; + } + printf("WARNING: %s: WAPBL filesystem mounted read-only" + "(fs_metaspace %jd, fs_fpg/2 %jd)\n", + mp->mnt_stat.f_mntonname, (intmax_t)fs->fs_metaspace, + (intmax_t)fs->fs_fpg / 2); + } fs->fs_flags &= ~FS_UNCLEAN; if (fs->fs_clean == 0) { fs->fs_flags |= FS_UNCLEAN;