From nobody Fri Apr 12 17:31:48 2024 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 4VGNsd3xXrz5Hm3d; Fri, 12 Apr 2024 17:31:49 +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 4VGNsd1rkQz45Q9; Fri, 12 Apr 2024 17:31:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712943109; 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=H2f2fjTbktg2ezWeRjMyyqa0X0rsDJ7SzbvGa+3VySw=; b=nV6zbRBz7CHJcXi0perfIGIqvaFK3tsjimINjMT3OZDA6G+0zOarw7jTE9qsOQi8+PUoAB 4MAfU6O1FYGvp1MVG6xeuXU0xyykZSHdUqZh90Y+hyJqDLIzW1F46IRjObY2VL/s3wguj5 yWFp0//K5hDn51LLv0DU+Cw7uNZjD89Qj7Y17/AawVKEo40IUPIJ6B+AfyMi1QAlJ7r81J B2okXiz9erSR1QmqniN6l+cVSzN+7K9ofKJYKooZvAWDFMfxxGky3yFGkWt7EinJBa12PR qEPvSBwqPkko1jxlifzi2iUTsTrOOsqz1ZLI9wl6Aqf9CZyAcmIPlLekpPziJw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712943109; a=rsa-sha256; cv=none; b=PVOobovLY3uRtG2mQD074iSDn0co/9SEjnpH2Y7ya+Hr1vaMAZhajjNeIA389mkyPrpeeO YXGqQBHdFAGIvrSPU00M8PhHScsNWL4n6pEZL5dt0G48xlLCpWlOq1MVDTObC5Zwb8081P jLxPi2LTu5hPP7btReD79TER0yjHXz2j28AwqTjIv1qdj0RTwS1WzmHXZrbktdZKnQSERP LYXSng/u/9X3KYpbrm8lXrcerd++atWQx1FEsSKgemaZpQvGfZiXcJ3uwbiR7cOpNEea0t +UEZQsDtkB5o86HC2YKRrpUWagbOVUNOB5qQWyYGZfvT/iGDNQJgrqbouPBGkQ== 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=1712943109; 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=H2f2fjTbktg2ezWeRjMyyqa0X0rsDJ7SzbvGa+3VySw=; b=xhDk0m6G1TVs99k/wgXJ0VyiJvjh8F+5Ii26oHf2I3XtUut2N9cvMBaU0WugS/82XYgwGl 41EA6TDP9mcIRAlhHOTQn/8iA7T7dVlWn+VacIYjLba6nnvIMrulRYIQsa6/40LlAI1Jny AKb1eV0zYPYuBYZvgFnMCK1NSsTjDEYAYpIebElt8t+Zr6lyhydyRHa3A30cOVhv4OG6vh RJt1V+ZVYe/JUNNvoQQV/WB8xhhmT4M/zJLXCLcJckxTtQYMoSLxSMVumWL5S4e00yVkx5 U3P3bOCHnHjx5+95tLG/BR47iyOltNJWzA3qRw6ZVyebtN6MZ9AMtn0gG06L7A== 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 4VGNsc667HzyD8; Fri, 12 Apr 2024 17:31:48 +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 43CHVmnW006811; Fri, 12 Apr 2024 17:31:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43CHVmEc006809; Fri, 12 Apr 2024 17:31:48 GMT (envelope-from git) Date: Fri, 12 Apr 2024 17:31:48 GMT Message-Id: <202404121731.43CHVmEc006809@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 4336161cc9c6 - main - install: Don't skip syncing in the common case. 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: 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4336161cc9c631d40d00adee97dfc8161b6bec9f Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=4336161cc9c631d40d00adee97dfc8161b6bec9f commit 4336161cc9c631d40d00adee97dfc8161b6bec9f Author: Dag-Erling Smørgrav AuthorDate: 2024-04-12 17:30:55 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-04-12 17:31:35 +0000 install: Don't skip syncing in the common case. In `copy()`, if no digest was requested (which is the common case), we use `copy_file_range()` to avoid needlessly copying the contents of the file into user space and back. When `copy_file_range()` returns successfully (which, again, is the common case), we simply return, and therefore never get to the point where we call `fsync()` if the `-S` option was specified. Fix this. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44756 --- usr.bin/xinstall/xinstall.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 6ab0a88d5cd7..d696a8429c88 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1232,15 +1232,12 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name, #ifndef BOOTSTRAP_XINSTALL /* Try copy_file_range() if no digest is requested */ if (digesttype == DIGEST_NONE) { - ret = 1; - while (ret > 0) { + do { ret = copy_file_range(from_fd, NULL, to_fd, NULL, SSIZE_MAX, 0); - } - if (ret == 0) { - /* DIGEST_NONE always returns NULL */ - return (NULL); - } + } while (ret > 0); + if (ret == 0) + goto done; if (errno != EINVAL) { serrno = errno; (void)unlink(to_name); @@ -1313,6 +1310,7 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name, err(EX_OSERR, "%s", from_name); } } +done: if (safecopy && fsync(to_fd) == -1) { serrno = errno; (void)unlink(to_name);