From nobody Tue Apr 11 13:20:54 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 4PwmgW0Q1tz44rYD; Tue, 11 Apr 2023 13:20:55 +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 4PwmgV6g6Kz3rNq; Tue, 11 Apr 2023 13:20:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681219255; 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=u08Tc81UJJX+IqrBWVC/gvVBatUVYz+FQRehiekpi2Y=; b=DS86qhLJtmKHEnSlYbQwehUbmugNjndh2CCiSTiL5yyN8zn/CBd6EW+QZYc6WklQHP7kOD 2LJJ1Co0L2DAjmI6ZlKeH1UyKClAWPpJUJFncAlqfqG42Cq83UqouSVsAGyfR+c3in7uYL wuVOa+wOEkBGrWaW16EGyPL44/0ajlEzOHOweTKZENyAFEGGhmWOfz617lKfQhtxEQArvi f1iSoPrAhjf7bv8xnBUmYTFFTM8Ldsdpz+UwLTVzHi+tZFVhO+nm3K14p9cidXQRDHCcxU pmoCYSySGbR66gH6jZ90idBad6nZSFjZ28geELLHHqHAu78KAFd66D6rqnUuIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681219255; 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=u08Tc81UJJX+IqrBWVC/gvVBatUVYz+FQRehiekpi2Y=; b=HAcuhNwoGsISKBsPWW/gbgvKiBMLrFYbGbA0WvOkC+/TtxaDE0CnZNcSANFiYSwAOq8bxo UcE8HAe04a0uBTN9lcjyO/c3ustwTzTBYBXSYEqLClpETzOem1ObpDa/v2wK8h6ii7b5YD 5uKzUeFauAx6bo/fLBMTB6Wl5jgV/IM3/IrvkLcJ+PfnJ6TXNHEvwxw1ykePqvEyvSZsS9 WVFyV/qsI//ADbiQpiSztigL8ZPEfa6UHyliDTpRyCh7mZDZcfKVcel0+Gstj5D48Y+qLM H7PKNztMLLNufS+NKHOvZtd6P3kF2a6DGiULyVyORBkvigh8lRRR+dnTNEP/YA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681219255; a=rsa-sha256; cv=none; b=skoGmmTAR2QFq7mJiOEMb6+rjlg3KL4JRNEnjMxvlsecnWNvECsWofVW8G5OA4SH7u/ooS zPvO2PVyuUMGfIlecIVcRAjziFWjnMhxhLMHF4RJsElumeWVJP2pRP2y8svvQfx47VIv44 KzRzDcMfN9lJ26yCqHh0pz9gP5SJEilraNUnhMw8Et9fsLjBwHIbXl9FaJhjzKdXrkezx+ S+/rZ690TkNYKGkPCJwVdwiWsIoa0DhTGJP9lh4Sk1Hk2rFspFV1N7/ctidX+M2XjJE0OI IfQDLHo0PqDqg/b8L6pumpUutbINAnzfp3EJEspYMqHRmda1Y5uVeD3s/ISirA== 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 4PwmgV539pzJyp; Tue, 11 Apr 2023 13:20:54 +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 33BDKs3g010230; Tue, 11 Apr 2023 13:20:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33BDKsuv010229; Tue, 11 Apr 2023 13:20:54 GMT (envelope-from git) Date: Tue, 11 Apr 2023 13:20:54 GMT Message-Id: <202304111320.33BDKsuv010229@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: afa8f8971b86 - main - vn_start_write(): consistently set *mpp to NULL on error or after failed sleep 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: afa8f8971b869b8b5d1468e431d18c615a35a63e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=afa8f8971b869b8b5d1468e431d18c615a35a63e commit afa8f8971b869b8b5d1468e431d18c615a35a63e Author: Konstantin Belousov AuthorDate: 2023-04-05 21:00:04 +0000 Commit: Konstantin Belousov CommitDate: 2023-04-11 12:59:46 +0000 vn_start_write(): consistently set *mpp to NULL on error or after failed sleep This ensures that *mpp != NULL iff vn_finished_write() should be called, regardless of the returned error, except for V_NOWAIT. The only exception that must be maintained is the case where vn_start_write(V_NOWAIT) is called with the intent of later dropping other locks and then doing vn_start_write(V_XSLEEP), which needs the mp value calculated from the non-waitable call above it. Also note that V_XSLEEP is not supported by vn_start_secondary_write(). Reviewed by: markj, mjg (previous version), rmacklem (previous version) Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39441 --- sys/kern/vfs_vnops.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 122e53c0d9fb..52242cce0692 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1935,7 +1935,10 @@ vn_start_write(struct vnode *vp, struct mount **mpp, int flags) if (vp == NULL) vfs_ref(mp); - return (vn_start_write_refed(mp, flags, false)); + error = vn_start_write_refed(mp, flags, false); + if (error != 0 && (flags & V_NOWAIT) == 0) + *mpp = NULL; + return (error); } /* @@ -1951,7 +1954,7 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags) struct mount *mp; int error, mflags; - KASSERT((flags & ~V_VALID_FLAGS) == 0, + KASSERT((flags & (~V_VALID_FLAGS | V_XSLEEP)) == 0, ("%s: invalid flags passed %d\n", __func__, flags)); retry: @@ -1989,6 +1992,7 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags) if ((flags & V_NOWAIT) != 0) { MNT_REL(mp); MNT_IUNLOCK(mp); + *mpp = NULL; return (EWOULDBLOCK); } /* @@ -2004,6 +2008,7 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags) vfs_rel(mp); if (error == 0) goto retry; + *mpp = NULL; return (error); }