From nobody Fri May 20 17:25:59 2022 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 776BF1B388C2; Fri, 20 May 2022 17:25:59 +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 4L4YXl2GDDz4mNr; Fri, 20 May 2022 17:25:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653067559; 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=HakOXs0AS4Q8yVWlwmfTVSqHw9WOXa+iX9Ygb6+ts6I=; b=tI4la8tQbJLuxsFp4bFc+pRIIJzMxkJFD2WCIOBBoDnIw4bs0maQd8X2PBn2cltdzmUgar XBbfgx36JTKytW8PqbKw1/m21sxlSs0ueQF7khO4Vabc+xXed6whoNvOOCiuW6kNDa/gUa 2ux9/5CuRNAGMoiF0caE42vO42E599dXnl/t461TWmxpMVTjeXIvdr7nRtjcLjlZikPpZp tMmydfOIXbO+QvCMqJutwrYYDBxtb2On9fIXGNPqu73caOsxANF305qaW3xZLpwa1OqgY+ T1XF1p1pCU644GZiAu60englCuemxLZy7hknAHoIvL00u8DVxgomseLC4IRugg== 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 207E716A26; Fri, 20 May 2022 17:25:59 +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 24KHPxoS058779; Fri, 20 May 2022 17:25:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24KHPxLt058778; Fri, 20 May 2022 17:25:59 GMT (envelope-from git) Date: Fri, 20 May 2022 17:25:59 GMT Message-Id: <202205201725.24KHPxLt058778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: ec3c225711ae - main - vfs: call vn_truncate_locked from kern_truncate 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ec3c225711ae7d5b8e71ed036aada09ef91149ec Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653067559; 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=HakOXs0AS4Q8yVWlwmfTVSqHw9WOXa+iX9Ygb6+ts6I=; b=Fm+LVLsAJIgfTKxWZrCr9yabJgF5mzHBDjZcOzzeeACi63HER1NPTc0HC4OskBudeVvej1 7NuqvTuhs6PC/rypfF4DUYXrJ6901KFCYreadRPNBBe1Nd2voJoknzBcFwzJlHOH4092r0 2lpLKyMXInwYthjKw4KD9O8Ly7/rH0AtHyZg2wgOxGOlzBwZDdsyOPyCxOGvzIyY8qOMZ4 88jWxaOmWJvE5QEU/KqPXIiju5GelWA67eArKDMMaHL9cdyPodDdi/r6dAY31INJjqeAC4 WPkwKwWYnocGmx5L/l5cfjF06fqcklfvm/lcPilKQ4vP9XhQWhJEa+2MCYbX7Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653067559; a=rsa-sha256; cv=none; b=PrUH7b/TYUs8tdAePNbcV61dLqfTrdyYi/QT20+/+YWTIeemi/E90wrxLCJjEdsg6paPwv q7CNqqAYU6yz4z3xjL9JNHxLlQWMRzwDA6+VuktD2IaYMnPbQw/f1Ir/byrprwXSQP9+HV bFvpJFNuL3Vj45iGngZG3YpGPJKtmh5KVGAHqqs6PcLsUk1/nyROY0Zdn71RVyOd3Bx23w +3kKynfpPME3sRpKMifzGf5uD8Pfc19XZPM2J0SYd0cjfzLPouQtnBqzlqPKSZtS0xlzVP 420N7KmekIkMhFAt1k9wUJNfCRvYpidWWCHN81gUP4TjoGfHtAOdLdA+To4Buw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ec3c225711ae7d5b8e71ed036aada09ef91149ec commit ec3c225711ae7d5b8e71ed036aada09ef91149ec Author: Mateusz Guzik AuthorDate: 2022-05-16 01:28:22 +0000 Commit: Mateusz Guzik CommitDate: 2022-05-20 17:25:51 +0000 vfs: call vn_truncate_locked from kern_truncate This fixes a bug where the syscall would not bump writecount. PR: 263999 --- sys/kern/vfs_syscalls.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 86ef3fc7a095..600299fbe6eb 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3460,7 +3460,6 @@ kern_truncate(struct thread *td, const char *path, enum uio_seg pathseg, struct mount *mp; struct vnode *vp; void *rl_cookie; - struct vattr vattr; struct nameidata nd; int error; @@ -3480,18 +3479,21 @@ retry: return (error); } vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - if (vp->v_type == VDIR) + if (vp->v_type == VDIR) { error = EISDIR; -#ifdef MAC - else if ((error = mac_vnode_check_write(td->td_ucred, NOCRED, vp))) { + goto out; } +#ifdef MAC + error = mac_vnode_check_write(td->td_ucred, NOCRED, vp); + if (error != 0) + goto out; #endif - else if ((error = vn_writechk(vp)) == 0 && - (error = VOP_ACCESS(vp, VWRITE, td->td_ucred, td)) == 0) { - VATTR_NULL(&vattr); - vattr.va_size = length; - error = VOP_SETATTR(vp, &vattr, td->td_ucred); - } + error = VOP_ACCESS(vp, VWRITE, td->td_ucred, td); + if (error != 0) + goto out; + + error = vn_truncate_locked(vp, 0, false, td->td_ucred); +out: VOP_UNLOCK(vp); vn_finished_write(mp); vn_rangelock_unlock(vp, rl_cookie);