From nobody Tue Aug 30 14:53:50 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 4MH9L71fgJz4ZfWy; Tue, 30 Aug 2022 14:53:51 +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 4MH9L714whz3ssV; Tue, 30 Aug 2022 14:53:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661871231; 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=vXxYU41NKbAUlYko9cQNxRLo6dbdlKKMmBkHfCt+7Lo=; b=MwTYgaUDbqpM+xrGH43YCwTCitgtIsMtewaOdByHmr891QheJufQB4OoL5+zVIl8PTOV6T oNFt6tVHZC1eT991eOhhfdO5vfsRfj71FJqo0wA6kR6yQz4JrDwFsspOEevsShp18aEE6q z2lOytcaj8DVmA5vpoADR+WG2rSQE6gg82DIlT2NTlQ49WKB9FB9Jl5nJMXCBQ/AHtxn2l FH/PZ8aD2iJIgLN5k/UCDdNxkB+C1QD63/uKkSUftCGWaev85AsKtQumgb7tY59s/IZh++ NPgP4dcFSrZzM9eHKY7hStC3Rjte9OMnNxSk9ykSevhhF66b2jk+Dx3vUF5pdw== 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 4MH9L706YSzpY6; Tue, 30 Aug 2022 14:53:51 +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 27UEront037462; Tue, 30 Aug 2022 14:53:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27UEroGr037461; Tue, 30 Aug 2022 14:53:50 GMT (envelope-from git) Date: Tue, 30 Aug 2022 14:53:50 GMT Message-Id: <202208301453.27UEroGr037461@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 35b7759c05cb - main - cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED. 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 35b7759c05cbc65c06d87141da79f0f80af0f458 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661871231; 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=vXxYU41NKbAUlYko9cQNxRLo6dbdlKKMmBkHfCt+7Lo=; b=M1eVsgJLJYaBmOIK/uMlMmV/bajQyktc+rvw8S0PKsg3zDee5dqa4RzvNUZAJGZV3gQJZc BFNLLXBGaNEbEGYCO059VpaRzCgZ0xo9iLyMYbdUOZgrnrjA7EQYUZhpdc/HWeV3qusIVv x6bP5X3TVtKPb+jKS3pJ/WSbmz2Z01GL0nKlZ/Xtr2BZZ9JGWmgzElcUxiqxXZt9pfGX5E jNVnntoZtZ4ClNcLrJiKHF7UgFFI7aJIe5ATcs+RLxo9X5ADloXJ36qksdWzDVeP0Ger5C 5KWBqOeRf7pnTgMLnu30LWr5Blx7Ektxwvy+05p+jTt6Mj25h/x9YtIhA5/13A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661871231; a=rsa-sha256; cv=none; b=vkJsRV866APSBmJnbOJuXP1K/ZME74DSv61DSSr2BZSVKdgieeO7ix9Fv17KokmdHyI/ey SrkMNfIQfXeF/F8tsrDOUf1QE4Z7ycrmDFX3ayv5VyLPj1UYjakUsXmhTU0ujFeAt/ZyEc SURt3vW+0LSVjqwY6yLxEuCnoLFhZmi+nY028LRDK8cLNkUC/iNmvC3gV8p0isqw+UGkwc 8vRZQ+W+mnMTlUuaoP7Mu9D4xN11fpeuT84jkyBVTdt7DRpm5clO1EVhWx9gaKPamU7Flf r+hPDiqCk3r6XbnJ81r+Z2LEwYmh54dzJ558u5SdjYkuAO0mSqEIV2LHsVRTlA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=35b7759c05cbc65c06d87141da79f0f80af0f458 commit 35b7759c05cbc65c06d87141da79f0f80af0f458 Author: Alexander Motin AuthorDate: 2022-08-30 14:51:21 +0000 Commit: Alexander Motin CommitDate: 2022-08-30 14:51:21 +0000 cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED. It allows to not use mmap() for small files, which is not helpful in case of ZFS. Should be no functional change. MFC after: 1 week --- bin/cp/utils.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bin/cp/utils.c b/bin/cp/utils.c index e7ae0c9dd733..07de0495ba9e 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -99,13 +99,12 @@ copy_file(const FTSENT *entp, int dne) static char *buf = NULL; static size_t bufsize; struct stat *fs; - ssize_t rcount, wcount; - size_t wresid; + ssize_t wcount; off_t wtotal; int ch, checkch, from_fd, rval, to_fd; - char *bufp; #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED - char *p; + size_t wresid; + char *bufp, *p; #endif int use_copy_file_range = 1; @@ -234,18 +233,18 @@ copy_file(const FTSENT *entp, int dne) wtotal = 0; do { if (use_copy_file_range) { - rcount = copy_file_range(from_fd, NULL, + wcount = copy_file_range(from_fd, NULL, to_fd, NULL, SSIZE_MAX, 0); - if (rcount < 0 && errno == EINVAL) { + if (wcount < 0 && errno == EINVAL) { /* Prob a non-seekable FD */ use_copy_file_range = 0; } } if (!use_copy_file_range) { - rcount = copy_fallback(from_fd, to_fd, + wcount = copy_fallback(from_fd, to_fd, buf, bufsize); } - wtotal += rcount; + wtotal += wcount; if (info) { info = 0; (void)fprintf(stderr, @@ -253,8 +252,8 @@ copy_file(const FTSENT *entp, int dne) entp->fts_path, to.p_path, cp_pct(wtotal, fs->st_size)); } - } while (rcount > 0); - if (rcount < 0) { + } while (wcount > 0); + if (wcount < 0) { warn("%s", entp->fts_path); rval = 1; }