From nobody Sun Dec 04 06:10:58 2022 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 4NPxBV473xz4jSVj; Sun, 4 Dec 2022 06:10:58 +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 4NPxBV36M6z4TwK; Sun, 4 Dec 2022 06:10:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670134258; 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=/OU3NG7wDKV8aAEzTw7efBKagtgwXMkjfwWnOp9K/vo=; b=IQpAaTyKPN0x77Ip9FkYcLSzqrQLziosD6M3GR3gk+Zsa4DGeff0t8E26uo+uYF8k60/8j mxGGOny/NSbR28sDGoY9egJjGH77wZ8XsQ8XYOghMGrtbcYjLBS2GLYuGj7mcjx+SZcMOe 0gByitZi2XIUkq7dp+wy4gp3RxLB3uSJBH7RLYY0EJXnZN2jWDx8IaK3LZh/rUs3Dj9WKv l4b+Q2fpCwbMu0iJ4D1cH0KxO7GQJ8XXxzorNQEvodoP+W1WMJdWiHuPryQvsakBJjELpi qV0TIqPQoSVDCqi8nkrUJxtArrO4z4nqCBanNlMwjmG+taMd/pWwA5TuNCI75A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670134258; 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=/OU3NG7wDKV8aAEzTw7efBKagtgwXMkjfwWnOp9K/vo=; b=YMDq5rPdIS0GHjlnoj7UdAPTk4H6PpA+zVgRQYSS+1JFbmAnFsySKn1Xh6QKGpj9+/OPYN MmMUqo2Ofo0nfnOmXZiBbulHrawuKaUvVTBYPv0B+o6VcdaYw0foITcJyF9yCJnKTqt6kd PNqg8AHA1SLrwTXbTb0j36UEDXaAqnEuOp3vEjuTsLWWnkSzwYT7ZSbxteYElbk9kYfonS yPuIJ5+66ROJoJ/PZkTugsklAjPVEa/lhwxgQLRwiGCtjPZR1YrEuUGFHft5HQwt7SRt/G Y8YbLPHFKjgSfJda8K2q9jlbXUn8f4SjQaOKvn7HSw/RJbJ/3An/IldgAObwyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670134258; a=rsa-sha256; cv=none; b=LGDVsHCykirv1zJEWtsSMunY2ddh8QbHTo/0zuAS0VpnWc4xsL7CP5eeAc0mjU/bKkoo4k l/3nalVZF5T4D1IlRdNoFg7NnmO0C9oO2kHVyl58HAKxoMFZtvfpdqY62c0OJ4ee7O1tHP UveL1JaEj6mPQbN7qCTVw0ZKqp9LeQZYud7HbEB0uY2MgxZ8jF1bVdxoJHUN1xberCwRRz MWml4hzTVYbWZMFBlXt3pJiTRdOSJrBJKxb8lEQf9uiBvtRHrXqW1XjKNOfBHqzSTIvvZF YRb4fTrHiRlSNVzUeCaGBnjS8UX7LERA0CRhAdL4kTGYvUe3RKL6VxOEs90pQg== 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 4NPxBV1gWWz1N7J; Sun, 4 Dec 2022 06:10:58 +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 2B46Awpv010636; Sun, 4 Dec 2022 06:10:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B46AwxZ010635; Sun, 4 Dec 2022 06:10:58 GMT (envelope-from git) Date: Sun, 4 Dec 2022 06:10:58 GMT Message-Id: <202212040610.2B46AwxZ010635@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: 7317bd0de973 - stable/13 - Explicitly initialize rather than reading newly allocated UFS inodes. 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: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7317bd0de9731c787f58103bedc049dee7d18db9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=7317bd0de9731c787f58103bedc049dee7d18db9 commit 7317bd0de9731c787f58103bedc049dee7d18db9 Author: Kirk McKusick AuthorDate: 2022-08-13 20:50:08 +0000 Commit: Kirk McKusick CommitDate: 2022-12-04 05:52:11 +0000 Explicitly initialize rather than reading newly allocated UFS inodes. (cherry picked from commit 6b9d4fbb7fe550788d82168e7beeabcd5ad238ce) Sponsored by: The FreeBSD Foundation --- sys/ufs/ffs/ffs_alloc.c | 2 +- sys/ufs/ffs/ffs_extern.h | 1 + sys/ufs/ffs/ffs_vfsops.c | 54 +++++++++++++++++++++++++++--------------------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 6eaec9edf17b..4b0c7b108cb6 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1159,7 +1159,7 @@ retry: * return the error. */ if ((error = ffs_vgetf(pvp->v_mount, ino, LK_EXCLUSIVE, vpp, - FFSV_FORCEINSMQ | FFSV_REPLACE)) != 0) { + FFSV_FORCEINSMQ | FFSV_REPLACE | FFSV_NEWINODE)) != 0) { ffs_vfree(pvp, ino, mode); return (error); } diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index c835239986ba..1ea473e69f52 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -130,6 +130,7 @@ int ffs_breadz(struct ufsmount *, struct vnode *, daddr_t, daddr_t, int, doomed */ #define FFSV_FORCEINODEDEP 0x0008 /* Force allocation of inodedep, ignore MNT_SOFTDEP */ +#define FFSV_NEWINODE 0x0010 /* Newly allocated inode */ /* * Flags to ffs_reload diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 2d5db7722a0f..3dc6f6d9ee23 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1948,40 +1948,48 @@ ffs_vgetf(struct mount *mp, MPASS((ffs_flags & FFSV_REPLACE) == 0); return (0); } - - /* Read in the disk contents for the inode, copy into the inode. */ - dbn = fsbtodb(fs, ino_to_fsba(fs, ino)); - error = ffs_breadz(ump, ump->um_devvp, dbn, dbn, (int)fs->fs_bsize, - NULL, NULL, 0, NOCRED, 0, NULL, &bp); - if (error != 0) { - /* - * The inode does not contain anything useful, so it would - * be misleading to leave it on its hash chain. With mode - * still zero, it will be unlinked and returned to the free - * list by vput(). - */ - vgone(vp); - vput(vp); - *vpp = NULL; - return (error); - } if (I_IS_UFS1(ip)) ip->i_din1 = uma_zalloc(uma_ufs1, M_WAITOK); else ip->i_din2 = uma_zalloc(uma_ufs2, M_WAITOK); - if ((error = ffs_load_inode(bp, ip, fs, ino)) != 0) { + + if ((ffs_flags & FFSV_NEWINODE) != 0) { + /* New inode, just zero out its contents. */ + if (I_IS_UFS1(ip)) + memset(ip->i_din1, 0, sizeof(struct ufs1_dinode)); + else + memset(ip->i_din2, 0, sizeof(struct ufs2_dinode)); + } else { + /* Read the disk contents for the inode, copy into the inode. */ + dbn = fsbtodb(fs, ino_to_fsba(fs, ino)); + error = ffs_breadz(ump, ump->um_devvp, dbn, dbn, + (int)fs->fs_bsize, NULL, NULL, 0, NOCRED, 0, NULL, &bp); + if (error != 0) { + /* + * The inode does not contain anything useful, so it + * would be misleading to leave it on its hash chain. + * With mode still zero, it will be unlinked and + * returned to the free list by vput(). + */ + vgone(vp); + vput(vp); + *vpp = NULL; + return (error); + } + if ((error = ffs_load_inode(bp, ip, fs, ino)) != 0) { + bqrelse(bp); + vgone(vp); + vput(vp); + *vpp = NULL; + return (error); + } bqrelse(bp); - vgone(vp); - vput(vp); - *vpp = NULL; - return (error); } if (DOINGSOFTDEP(vp) && (!fs->fs_ronly || (ffs_flags & FFSV_FORCEINODEDEP) != 0)) softdep_load_inodeblock(ip); else ip->i_effnlink = ip->i_nlink; - bqrelse(bp); /* * Initialize the vnode from the inode, check for aliases.