From nobody Wed May 08 13:07:44 2024 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 4VZFmx280Pz5J5qT; Wed, 08 May 2024 13:07:45 +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 4VZFmx0SNlz4RTy; Wed, 8 May 2024 13:07:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715173665; 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=ofYs2CnL+1sVBy+Lxice9JX7eMxgWMhaa4q94qUTfZI=; b=thukUiSvUrkHx68H4hx/U69lZlQAFlVxcgjNDRQVV4o71dxtQylnkNDPZXx+QxVN1CMjST xh92PySkQH+j9dVlILu5b2EamQnvxvp/ZX42QdRE+zEJ6IoTdQSayqjfiqRmNTcNCN0Jjr IwW0luWwZofnRjL4o2Yu3cyUVwO7wBP7rZJc0cjicqPns7ZWV8Cw9dnEMC8ktvxxgU23vG qeKq1/TZRlYN2TY1NHhSAcOtA7yICfjwPtWkfD006c5teZiVrsXWeRLMeXFz1YNjkGJDd+ oY59lJEor3/Uk+5uOvpdXE5G3VWwS6/1ew4xPCiEhnG5lR3FCNK3lYkWvgZnVw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715173665; a=rsa-sha256; cv=none; b=DgK369qKTuM+L7W3lyUDyTwn8Os+tHZefFCaFWfDOYW9A3bVYvBUihPdakzXuNiIDttX6R Zs05lJP9izw1kMtcYH0SBK0IPLjOEFpO5OHaz8xQomq7kmF82MpX017i/WV+sz7COkqR0R HqDIeAx7TXMH7E8C+NcmAUamXPviRZ1Yu0gozwvvb/tR62FW+UmRzl+otOJJQ2HQm9Hxsu t7ky3vV6aitErCtbEXEJTJUUdfcqOgSDkQT94hUX97wWa7qDDYTnRd9iimUYI/KdCriMu5 496xmYcHsLtcpL5oQjrIf5aRq+gIWiYaCL5xtQzblwxYNQ9pjnJ5hGHfpczFOg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715173665; 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=ofYs2CnL+1sVBy+Lxice9JX7eMxgWMhaa4q94qUTfZI=; b=DnOgnv5NKFIVwLHCBY3XwEMzyMg9gNpQWqCzFRfISFVWQK7F+9wNse8WfwJH/EC/SDbWNz Kxm+RkWS788Zx4IYAkLu4XE1kQO/Q8W0S/IsxhYS8BsKTuFbhcFN1ap3OrKBRXh38oDIMi SMREOuWfYuQz9DRw/drHe5rvL3sBAP3FnkViUeBxql5f9AgsM7F7zH+c6DKm7yaeLdxGvb Exansu5ZadcVttRxSZMC6tw2AnjKuJ2zskuvUy36arRu4iYvobQ553FQlYaYfRZK2GK/Ap iQQmsuEDV7fmB4gnPMoawhMYCwuNmGaltPrhKoQXrfC/1mtQ4n3T6/a0wMAJug== 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 4VZFmw6DvZzQYM; Wed, 8 May 2024 13:07:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 448D7i2b080290; Wed, 8 May 2024 13:07:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 448D7iJV080287; Wed, 8 May 2024 13:07:44 GMT (envelope-from git) Date: Wed, 8 May 2024 13:07:44 GMT Message-Id: <202405081307.448D7iJV080287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e3b27cc3546f - stable/14 - copy_file_range: Call vn_rdwr() at least once 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e3b27cc3546fb39ec579d023b3520d15a1628021 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e3b27cc3546fb39ec579d023b3520d15a1628021 commit e3b27cc3546fb39ec579d023b3520d15a1628021 Author: Mark Johnston AuthorDate: 2024-04-04 15:18:03 +0000 Commit: Mark Johnston CommitDate: 2024-05-08 13:06:16 +0000 copy_file_range: Call vn_rdwr() at least once This ensures that we invoke VOP_READ on the input file even if it's empty, which in turn helps ensure that filesystems update the atime of the file. PR: 274615 Reviewed by: olce, rmacklem, kib MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D43524 (cherry picked from commit 08f3d5b60cdfff434e391d96cdffc5a90c550b07) --- sys/kern/vfs_vnops.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 51386d0e9581..1171b72a3a96 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3341,7 +3341,7 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, off_t startoff, endoff, xfer, xfer2; u_long blksize; int error, interrupted; - bool cantseek, readzeros, eof, lastblock, holetoeof, sparse; + bool cantseek, readzeros, eof, first, lastblock, holetoeof, sparse; ssize_t aresid, r = 0; size_t copylen, len, savlen; off_t outsize; @@ -3482,6 +3482,7 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, endts.tv_sec++; } else timespecclear(&endts); + first = true; holetoeof = eof = false; while (len > 0 && error == 0 && !eof && interrupted == 0) { endoff = 0; /* To shut up compilers. */ @@ -3583,10 +3584,17 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, */ xfer -= (*inoffp % blksize); } - /* Loop copying the data block. */ - while (copylen > 0 && error == 0 && !eof && interrupted == 0) { + + /* + * Loop copying the data block. If this was our first attempt + * to copy anything, allow a zero-length block so that the VOPs + * get a chance to update metadata, specifically the atime. + */ + while (error == 0 && ((copylen > 0 && !eof) || first) && + interrupted == 0) { if (copylen < xfer) xfer = copylen; + first = false; error = vn_lock(invp, LK_SHARED); if (error != 0) goto out; @@ -3596,7 +3604,7 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, curthread); VOP_UNLOCK(invp); lastblock = false; - if (error == 0 && aresid > 0) { + if (error == 0 && (xfer == 0 || aresid > 0)) { /* Stop the copy at EOF on the input file. */ xfer -= aresid; eof = true;