From nobody Wed Jun 7 23:15:39 2023 X-Original-To: dev-commits-src-branches@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 4Qc39R3Cgwz4bhXs; Wed, 7 Jun 2023 23:15:39 +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 4Qc39R2ghBz3D8m; Wed, 7 Jun 2023 23:15:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686179739; 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=/RFXUQR2OAv8w0oRRCeYG+hlZpKN4HD5IuTVDLWY3rw=; b=VpXD2ur0ZH2TUnLNYxZbFsoe6z1c8cXwVl1zP00MGQAXU838sDSgOfzkuotlUyyEWpWqdf 2zl45q7sv3O7P/ZEQoPD7ANAORe1hP10Tl7HcyjaK4kOPJ5d0j6Ufx07PPY/3hLPVs2RZN HAbKlsDMQ0sV0u2FsMJWTw+jfNXhZApSOlpk5Vk/lXRUvSKLoomGXfWCMK4BKDPQDkSWBL yjXTKQGn+94hRbeLRIja8zfBHNifJYjH4b3sqHe74HnOqBUldQfwfSwpzLxS/Elxtn01WJ HgX2jwPaQqkV4iEFnQAua0e9dvvvAhof3bjzPg3oNWpdrQAbH66nKmLbPKY26A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686179739; 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=/RFXUQR2OAv8w0oRRCeYG+hlZpKN4HD5IuTVDLWY3rw=; b=mKlthAoL+zBsjHS9GsizwwgcgSYYNWXH1hA0AfpJ7ra182jIZNDAg9WPdSQaX/HCIT+RdS gkNvT2TewsVE/OOZvRFPAUGhrPBzszM44jp3j0ITTSXqgWZoUOFZ/VuguiV0pcvQAGQ4Z7 kLT/bBzxcFp6sbHP8BnVSkq+Pc+0mRFVBDM0SGfCKQUjkkb1U++/vPrhmBIppviY4Eih+k s2NcPKo6r1uTuLtcZ538UN4Bm+6VzEswetxOWAj/Ime3WA/Kf+YbRajeMXk3JwW8kPqGVq KArHaQyee5/Ru+vVIMZO2VbEbN4KwaRU/AmGR4QlHMzas/p6Zh8vyqlVvrGZqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686179739; a=rsa-sha256; cv=none; b=Da0PWOGrSzqtCRUtpgvCEg4rm3/GOEltvWgvlpDpgAaTPXEbKXrewxgOv/wfwG108j3iov Ph8diwQT9IAcM+zI4qh5fEWDvNyRYL77Ghmqgvys5nncqWV1VTEM2UldcjY52BdBJZiJFt SivNcbNuBiy2kNez55Um11p0rt+PZGe5EyTWr4G9ui+BbT/XsgKrG/Eoq2OLOT9tIowFwM Lgy9/QzKUMz7qgZBwzd5XFKsn8Ofl1SczahpaiByT6R3rKM+5/3lZGJekmFEwycBqLPdEM d/RsE3bwhGBn0wFAzykgeQQcpG1SncqXDrc0ftqybP+/Sg4jR5seWbd2BIXLww== 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 4Qc39R1dF5zWQt; Wed, 7 Jun 2023 23:15:39 +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 357NFdBl048460; Wed, 7 Jun 2023 23:15:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 357NFdUV048459; Wed, 7 Jun 2023 23:15:39 GMT (envelope-from git) Date: Wed, 7 Jun 2023 23:15:39 GMT Message-Id: <202306072315.357NFdUV048459@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kirk McKusick Subject: git: 90532db778dc - stable/13 - Cleanups to fsck_ffs(8). List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 90532db778dc2bca557d5be43c5b9813ba44d80a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=90532db778dc2bca557d5be43c5b9813ba44d80a commit 90532db778dc2bca557d5be43c5b9813ba44d80a Author: Kirk McKusick AuthorDate: 2023-05-29 21:54:52 +0000 Commit: Kirk McKusick CommitDate: 2023-06-07 22:54:13 +0000 Cleanups to fsck_ffs(8). Sponsored-by: The FreeBSD Foundation (cherry picked from commit 5267120645fa52eac771c9bd8e28d68620a3bb89) --- 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++;