From nobody Thu Apr 04 21:16:47 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 4V9ZDw0GSjz5G3gr; Thu, 4 Apr 2024 21:16:48 +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 4V9ZDv6VTvz4Jwl; Thu, 4 Apr 2024 21:16:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712265407; 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=A9oPEgOoSfLxsqKmuuiEyJnJ539pHj2htX4nmk1JjVo=; b=fF2U1Gao7cuqCKT4lZzGRxNL2xWL5I4oT6DJbaS0D9jbjluatgoODrgT6nfCaJX8QDxb3j es6f7Rr1TLxs1AnUdyGtX8cCgUKsNJ+PQChcYLQ67nE0ljDhHIg/m9gfBnFFMFAec+380a yOI7xycyp+i5VSFBYu/hvzaWnR6DV4xzRNZJMBW6w9JxbmsJ+a4hYpKfd2ODqH5bNObnwp W3yCgTgMZfHgDX/uTT4fU4u8V/wlNl1thLjBkWy4tGNCpm6lP1ZnNjPstF+d94vs56pJvr aCSgiYC9ymZFAwPbcJ63PwMU4pVdrF01m12HB6PCj+flOeBlvpIoTX4ieP7bVw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712265407; a=rsa-sha256; cv=none; b=gqLet0gkKPii21FXyLOIbKfcsznfSpKmluz3h/uaCYMLeIWeT0lWZfE9+nYMyQFOJ+OmWn 8barhLh6jB1j9Jeo+d38FBkjSn5pwm+I8pR4s/hgEbS6al8t9rMMFEb/oHTq45O6jGC4oE VYtuWkFDmdVi0KCGsU7D+EIMYGaTPg4EdpqJLKhNWAwsUwAm6+2yrP1lV+Q19PvtSvx3AT 7EOWzISzQpoGnnxZsh58Py0NYyKhM9f7K1xCpc/Gde0uDN87R6OKZ9kVX04AmAMDh2UIdm 3tRWUy4CGAmdG5VXIbBJ3Ae4Ma2C41WQTXVOAiw1QXEIjg4FQJov9vFiQXvoQw== 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=1712265407; 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=A9oPEgOoSfLxsqKmuuiEyJnJ539pHj2htX4nmk1JjVo=; b=uxIHm6ilrY9VDyO6W35xQExWAb4tKSjeIKzhuJwfYBXgmWhjURCnHeNwChgTkHQwMWVmDf HB9plFEaYAtyXkDMDPm2eDaxEsgXPTaH75cg8b00qeffzRhBiixJFq6T4JMI+9z3RPjQrS JfcptK/kqX/sqvcGoMge9YXk1blmy4ut7Acd3vLhrjKCT519pcuas/9x/xqQ50IBTqFxQk kp36zBgpu0BteaNPj7eKmRWhE8VNgnLhEfnkn4RWvP0m/Rru7quta6jqUFqE6KFx/To8gr VGYNc8KH91asnEjatwLVwY6JbwO5J7xYsX56Ae9QX/DIW4Igc95gMIIUaEJfRQ== 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 4V9ZDv5npnzY67; Thu, 4 Apr 2024 21:16:47 +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 434LGl8B045558; Thu, 4 Apr 2024 21:16:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 434LGltV045555; Thu, 4 Apr 2024 21:16:47 GMT (envelope-from git) Date: Thu, 4 Apr 2024 21:16:47 GMT Message-Id: <202404042116.434LGltV045555@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 08f3d5b60cdf - main - 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: 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 08f3d5b60cdfff434e391d96cdffc5a90c550b07 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=08f3d5b60cdfff434e391d96cdffc5a90c550b07 commit 08f3d5b60cdfff434e391d96cdffc5a90c550b07 Author: Mark Johnston AuthorDate: 2024-04-04 15:18:03 +0000 Commit: Mark Johnston CommitDate: 2024-04-04 21:03:07 +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 --- 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 d79707555ac1..0e864f959e36 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3339,7 +3339,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; @@ -3480,6 +3480,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. */ @@ -3581,10 +3582,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; @@ -3594,7 +3602,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;