From nobody Mon May 29 21:57:02 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 4QVTrt5mXSz4XDX5; Mon, 29 May 2023 21:57:02 +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 4QVTrt3lv7z3G3x; Mon, 29 May 2023 21:57:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685397422; 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=AxVjLIdXM+1IZHSHTOQiM5kxrfCGdjKmxBL1AQyUY/M=; b=a2tnAA/ChcJPALNQQNNi7dNgYdP26sukftmmHBdq1UkprVtYltp2lP3er/4dBIRN1AUM+G FtMUtDdThN1witNknFkFDXP7+0lgHWY3xw8YQfMsg963a1t/c5mI1e6iGRwlZJ5fRvR5C0 65oDzAh/xay4+PxrNdErHnkL0wyZkQjMV1a4wcHcIOfFoSqWB4yhuC5E4ZkAmB+gnoH01A wTNY/YilcodvztKMy43BH5wW9wxaKJqzcNswPdcTMt+wp1b2Io9KXvmAGfw0wTv7a5vAIZ U+n0/5i9ZOcjmd1B0Z9r+lx20zV5l4WgaLZK6RMFN1+kcJXIc6ALE4Zmj5/a9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685397422; 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=AxVjLIdXM+1IZHSHTOQiM5kxrfCGdjKmxBL1AQyUY/M=; b=eBhej6O0pwAOeAfloArbKjP3cfAZ1LmgwilonZPGvc2O3WW7uHFUYw8svmdeTi07ZV4cOE vzsuXnJ2CJOYGTE1qRLGOKblgsZDhw7uRJu3MLslnq9p2tI5C1Cq4DKWCN5IkjHqpXkkle 5RTNtWtqiIn1cV9bdTMOZBH5jVS0BV6AAjm5o/96MBq0BwC8G8eeeOHivOEYyujOaFyi9g HETLPCli6jc5eEl/cZOAaencmR61ICHKBiiSyL9r1CJ2b2xWT2yIO7w8kcJ9liqKovyqcK VKS7fU72yLiCeamZ4X+MfMJYYVeupjxkJNsbi/I9xtu8s2YqFDOuJaKDlR2/Sg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685397422; a=rsa-sha256; cv=none; b=dOXaXZiHjHJ7jOD6Q5E4a7uqP9TNgcc3SebrcaZgXPlSp6hVKOvlwfV+VuLyIIDaqztG9E MLtbRgnBU3JqUGJeFq/jvu6r6D7ElhcINgwIICYFXVj/p2OlweaBL06HinihEunlK67Fce dCvh3HN7pkCRU+1fbi7aP6xcf13mQ7YMs/osQ1x2nrcxyod7jwyDfn4uuT/nevnbRq/PxX I9MGgYEPaIlajTIq5Bd93yYOxIoaJXiwcBnn2m857f2W29M0AJyrhZnH2A74XVbyVlXuxF qby1Om8aurMhorhyHgmCDJbuAIxdW+MN36vpCRJlBwm31o8t4V9L2ltT8h67qQ== 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 4QVTrt2r83zSbk; Mon, 29 May 2023 21:57:02 +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 34TLv2Qj015449; Mon, 29 May 2023 21:57:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34TLv20T015448; Mon, 29 May 2023 21:57:02 GMT (envelope-from git) Date: Mon, 29 May 2023 21:57:02 GMT Message-Id: <202305292157.34TLv20T015448@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 5267120645fa - main - Cleanups to fsck_ffs(8). 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5267120645fa52eac771c9bd8e28d68620a3bb89 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=5267120645fa52eac771c9bd8e28d68620a3bb89 commit 5267120645fa52eac771c9bd8e28d68620a3bb89 Author: Kirk McKusick AuthorDate: 2023-05-29 21:54:52 +0000 Commit: Kirk McKusick CommitDate: 2023-05-29 21:55:54 +0000 Cleanups to fsck_ffs(8). When checking an inode ensure that it does not have a negative size. Stop scaning a directory when an unallocated block is found. Fully clear an inode when it is first allocated. Ensure that an inode is marked dirty whenever it is updated and that it has a correct check hash when it is released. MFC-after: 1 week Sponsored-by: The FreeBSD Foundation --- sbin/fsck_ffs/dir.c | 3 +++ sbin/fsck_ffs/inode.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index 7ea471bcb30a..3ff6c467ee08 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -725,6 +725,7 @@ changeino(ino_t dir, const char *name, ino_t newnum, int depth) ginode(dir, &ip); if (((error = ckinode(ip.i_dp, &idesc)) & ALTERED) && newnum != 0) { DIP_SET(ip.i_dp, di_dirdepth, depth); + inodirty(&ip); getinoinfo(dir)->i_depth = depth; } free(idesc.id_name); @@ -879,6 +880,7 @@ expanddir(struct inode *ip, char *name) DIP_SET(dp, di_ib[0], indirblk); DIP_SET(dp, di_blocks, DIP(dp, di_blocks) + btodb(sblock.fs_bsize)); + inodirty(ip); } IBLK_SET(nbp, lastlbn - UFS_NDADDR, newblk); dirty(nbp); @@ -969,6 +971,7 @@ allocdir(ino_t parent, ino_t request, int mode) } else { inp->i_depth = parentinp->i_depth + 1; DIP_SET(dp, di_dirdepth, inp->i_depth); + inodirty(&ip); } inoinfo(ino)->ino_type = DT_DIR; inoinfo(ino)->ino_state = inoinfo(parent)->ino_state; diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index 7dca95129ed1..c56d938cce41 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -90,6 +90,10 @@ ckinode(union dinode *dp, struct inodesc *idesc) dino.dp1 = dp->dp1; else dino.dp2 = dp->dp2; + if (DIP(&dino, di_size) < 0) { + pfatal("NEGATIVE INODE SIZE %jd\n", DIP(&dino, di_size)); + return (STOP); + } ndb = howmany(DIP(&dino, di_size), sblock.fs_bsize); for (i = 0; i < UFS_NDADDR; i++) { idesc->id_lbn++; @@ -116,6 +120,7 @@ ckinode(union dinode *dp, struct inodesc *idesc) inodirty(&ip); irelse(&ip); } + return (STOP); } continue; } @@ -498,6 +503,11 @@ irelse(struct inode *ip) /* Check for failed inode read */ if (ip->i_bp == NULL) return; + if (debug && sblock.fs_magic == FS_UFS2_MAGIC && + ffs_verify_dinode_ckhash(&sblock, (struct ufs2_dinode *)ip->i_dp)) { + pwarn("irelse: releasing inode with bad check-hash"); + prtinode(ip); + } if (ip->i_bp->b_refcnt <= 0) pfatal("irelse: releasing unreferenced ino %ju\n", (uintmax_t) ip->i_number); @@ -1419,21 +1429,20 @@ retry: cgdirty(cgbp); ginode(ino, &ip); dp = ip.i_dp; + memset(dp, 0, ((sblock.fs_magic == FS_UFS1_MAGIC) ? + sizeof(struct ufs1_dinode) : sizeof(struct ufs2_dinode))); DIP_SET(dp, di_db[0], allocblk(ino_to_cg(&sblock, ino), (long)1, std_checkblkavail)); if (DIP(dp, di_db[0]) == 0) { inoinfo(ino)->ino_state = USTATE; + inodirty(&ip); irelse(&ip); return (0); } DIP_SET(dp, di_mode, type); - DIP_SET(dp, di_flags, 0); DIP_SET(dp, di_atime, time(NULL)); DIP_SET(dp, di_ctime, DIP(dp, di_atime)); DIP_SET(dp, di_mtime, DIP(dp, di_ctime)); - DIP_SET(dp, di_mtimensec, 0); - DIP_SET(dp, di_ctimensec, 0); - DIP_SET(dp, di_atimensec, 0); DIP_SET(dp, di_size, sblock.fs_fsize); DIP_SET(dp, di_blocks, btodb(sblock.fs_fsize)); n_files++;