From nobody Sat Mar 18 06:16:51 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 4PdrPH4RbJz3y9WF; Sat, 18 Mar 2023 06:16:51 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PdrPH3hfzz3J8P; Sat, 18 Mar 2023 06:16:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679120211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HpPQhIk9d8DC2WlWDCTvE/obHRHt8Lz3GMTN0y/1i9c=; b=gPtMKvlrPypVYi8xrxa53RrQ3UFycFyhTJUCHoFVFKFF39/6+mEBPw8GmW1vBOQ1dOMpud zR0rbJIfKV8BHBM51MlGIZ6QDBxVA7YRXACSwG9FSlcNY2RPgZlAGuQofbgG3bRrIGqaUw IM/JDjkwsZMkXry6JUnQZ/PO2p5yw6IyPEXAsjn0kPa6iXjhzh7d1V7UtybHL3cC+f8V2K 9rVvZJ15k68l/sSiczuARkppjBgUyEl3oyTgWzzLcutmgT7SW88v1M+TD7YeKgeGDQ042w V1m3MqaUnMQPkPeTTGy9y3ia8/4HZf1OozrDSGi4pOW5igbKY8c026qHuMhcqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679120211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HpPQhIk9d8DC2WlWDCTvE/obHRHt8Lz3GMTN0y/1i9c=; b=Q2t6yKcpLhYvw9c8Rr6I2fr6Papz3PB+IGzIfmIqrwDuIFeAGP3Lt0nVOj7v9hmQqi0v/1 k51mTFnZGY1+YuvKr7EIPhqKTTO1n2/Rcvh1OjEZxOvk4LD6TiPh5lZNQFnKMs9d/CVBPs nrqLXfy3pANDEahhg8h1d/XD53EvBzG+kH2iIUYvY3K7NL3SvrfmyholSZT3OBq5xL6p1O ukA/CZqS0DQAAdb+mRTomfxn7mUlzAdq+/xJw/fIm1tTe184UeXPJUjie69sPsooXy7Vr2 RTIZvs3dkmwuJU+9K4gMv2FyOHndI4wiDMxYK6mlBQU/yob6nFeBAOlwyQmCdw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679120211; a=rsa-sha256; cv=none; b=Wjf4NykrIuU5IM/wSfCNMGogDQt6VJ9KpMJvAw181A15Aqav1MbRVzezLLgTibOE5wOjbH QCg9NKJcTaRfVVptdvEUXDFjnLlQb49sSyo019nigC3FrnmwmNPufzrZEvlcw8r6/4loGt DTBcCctJ88wiqQN2CS/rQVl66neZGvpluMaHRrPo8X/Xqj00P7o5I8an+yzPfp3cMv0lIq Ai/zauo/c8EJJM8Pj3cGetUHo9WnwhE3pwTdis7Vcv6WBhKgnklnZUZnaANF2+x+2eiPu8 tLU9ps9672LrP4v1OFYliErSa1vKAaOrV+qUtctN/ZNzGUaN0fi6CifmQhRVIg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PdrPH2R1rzwLh; Sat, 18 Mar 2023 06:16:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32I6Gpmp023091; Sat, 18 Mar 2023 06:16:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32I6GpHD023090; Sat, 18 Mar 2023 06:16:51 GMT (envelope-from git) Date: Sat, 18 Mar 2023 06:16:51 GMT Message-Id: <202303180616.32I6GpHD023090@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Fedor Uporov Subject: git: 3c2dc524c333 - main - Do not panic in case of corrupted directory 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fsu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3c2dc524c333747a8c5deb3f0f88b29a8e36dff4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by fsu: URL: https://cgit.FreeBSD.org/src/commit/?id=3c2dc524c333747a8c5deb3f0f88b29a8e36dff4 commit 3c2dc524c333747a8c5deb3f0f88b29a8e36dff4 Author: Fedor Uporov AuthorDate: 2023-03-18 06:11:27 +0000 Commit: Fedor Uporov CommitDate: 2023-03-18 06:16:24 +0000 Do not panic in case of corrupted directory The panic() will be called under ext2_dirbad() function in case of rw mount. It cause user confusion, like in BZ 265951. PR: 265951 Reviewed by: pfg, mckusick MFC after: 2 week Differential revision: https://reviews.freebsd.org/D38503 --- sys/fs/ext2fs/ext2_lookup.c | 14 +++++--------- sys/fs/ext2fs/ext2_vnops.c | 9 +++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c index 93a2d172e01f..4859d51f8429 100644 --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -539,8 +539,8 @@ found: if (entryoffsetinblock + EXT2_DIR_REC_LEN(ep->e2d_namlen) > dp->i_size) { ext2_dirbad(dp, i_offset, "i_size too small"); - dp->i_size = entryoffsetinblock + EXT2_DIR_REC_LEN(ep->e2d_namlen); - dp->i_flag |= IN_CHANGE | IN_UPDATE; + brelse(bp); + return (EIO); } brelse(bp); @@ -802,13 +802,9 @@ ext2_dirbad(struct inode *ip, doff_t offset, char *how) struct mount *mp; mp = ITOV(ip)->v_mount; - if ((mp->mnt_flag & MNT_RDONLY) == 0) - panic("ext2_dirbad: %s: bad dir ino %ju at offset %ld: %s\n", - mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, - (long)offset, how); - else - SDT_PROBE4(ext2fs, , trace, ext2_dirbad_error, - mp->mnt_stat.f_mntonname, ip->i_number, offset, how); + + SDT_PROBE4(ext2fs, , trace, ext2_dirbad_error, + mp->mnt_stat.f_mntonname, ip->i_number, offset, how); } /* diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index a7da8249ab4d..8ec12f9a7f8f 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -1088,6 +1088,15 @@ abortit: if (namlen != 2 || dirbuf->dotdot_name[0] != '.' || dirbuf->dotdot_name[1] != '.') { + /* + * The filesystem is in corrupted state, + * need to run fsck to fix mangled dir + * entry. From other side this error + * need to be ignored because it is + * too difficult to revert directories + * to state before rename from this + * point. + */ ext2_dirbad(xp, (doff_t)12, "rename: mangled dir"); } else {