From nobody Sat Mar 18 22:47:09 2023 X-Original-To: dev-commits-src-main@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 4PfGNF6973z406x4; Sat, 18 Mar 2023 22:47:25 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from drew.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.franken.de", Issuer "Sectigo RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PfGND0qFfz45bM; Sat, 18 Mar 2023 22:47:24 +0000 (UTC) (envelope-from tuexen@freebsd.org) Authentication-Results: mx1.freebsd.org; none Received: from smtpclient.apple (unknown [IPv6:2a02:8109:1140:c3d:f82b:3d0e:59d9:3576]) (Authenticated sender: micmac) by mail-n.franken.de (Postfix) with ESMTPSA id 8A52672826400; Sat, 18 Mar 2023 23:47:10 +0100 (CET) Content-Type: text/plain; charset=us-ascii List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Subject: Re: git: 069767091e54 - main - Do not panic in case of corrupted UFS/FFS directory. From: tuexen@freebsd.org In-Reply-To: <202303182238.32IMcOAb032844@gitrepo.freebsd.org> Date: Sat, 18 Mar 2023 23:47:09 +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: <4D960CCC-8D07-4CAB-853C-11185548A2D2@freebsd.org> References: <202303182238.32IMcOAb032844@gitrepo.freebsd.org> To: Kirk McKusick X-Mailer: Apple Mail (2.3731.400.51.1.1) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail-n.franken.de X-Rspamd-Queue-Id: 4PfGND0qFfz45bM X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:680, ipnet:2001:638::/32, country:DE] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N > On 18. Mar 2023, at 23:38, Kirk McKusick wrote: >=20 > The branch main has been updated by mckusick: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D069767091e54a2537ae509dcdf3005fb= 0f50ab84 >=20 > commit 069767091e54a2537ae509dcdf3005fb0f50ab84 > Author: Kirk McKusick > AuthorDate: 2023-03-18 22:36:54 +0000 > Commit: Kirk McKusick > CommitDate: 2023-03-18 22:37:58 +0000 >=20 > Do not panic in case of corrupted UFS/FFS directory. >=20 > Historically the system panic'ed when it encountered a corrupt > directory. This change recovers well enough to continue operations. > This change is made in response to a similar change made in the ext2 > filesystem as described in the cited Differential Revision. >=20 > MFC after: 2 weeks > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D38503 > --- > sys/ufs/ufs/ufs_lookup.c | 18 +++++------------- > sys/ufs/ufs/ufs_vnops.c | 4 +++- > 2 files changed, 8 insertions(+), 14 deletions(-) >=20 > diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c > index 4c390f4c42ef..cabd04a50bfd 100644 > --- a/sys/ufs/ufs/ufs_lookup.c > +++ b/sys/ufs/ufs/ufs_lookup.c > @@ -548,9 +548,8 @@ found: > */ > if (i_offset + DIRSIZ(OFSFMT(vdp), ep) > dp->i_size) { > ufs_dirbad(dp, i_offset, "i_size too small"); > - dp->i_size =3D i_offset + DIRSIZ(OFSFMT(vdp), ep); > - DIP_SET(dp, i_size, dp->i_size); > - UFS_INODE_SET_FLAG(dp, IN_SIZEMOD | IN_CHANGE | IN_UPDATE); > + brelse(bp); > + return (EIO); > } > brelse(bp); >=20 > @@ -758,17 +757,10 @@ found: > void > ufs_dirbad(struct inode *ip, doff_t offset, char *how) > { > - struct mount *mp; >=20 > - mp =3D ITOV(ip)->v_mount; > - if ((mp->mnt_flag & MNT_RDONLY) =3D=3D 0) > - panic("ufs_dirbad: %s: bad dir ino %ju at offset %ld: %s", > - mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, > - (long)offset, how); > - else > - (void)printf("%s: bad dir ino %ju at offset %ld: %s\n", > - mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, > - (long)offset, how); > + (void)printf("%s: bad dir ino %ju at offset %ld: %s\n", > + ITOV(ip)->v_mount->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, > + (long)offset, how); > } >=20 > /* > diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c > index ae6d963920f3..54046c285fd7 100644 > --- a/sys/ufs/ufs/ufs_vnops.c > +++ b/sys/ufs/ufs/ufs_vnops.c > @@ -1730,7 +1730,9 @@ relock: > /* Journal must account for each new link. */ > softdep_setup_dotdot_link(tdp, fip); > SET_I_OFFSET(fip, mastertemplate.dot_reclen); > - ufs_dirrewrite(fip, fdp, newparent, DT_DIR, 0); > + if (ufs_dirrewrite(fip, fdp, newparent, DT_DIR, 0) !=3D 0) > + ufs_dirbad(fip, mastertemplate.dot_reclen, > + "rename: missing ".." entry"); This breaks compilation for me: /usr/home/tuexen/freebsd-src/sys/ufs/ufs/ufs_vnops.c:1735:27: error: = expected identifier "rename: missing ".." entry"); ^ Best regards Michael > cache_purge(fdvp); > } > error =3D ufs_dirremove(fdvp, fip, fcnp->cn_flags, 0);