Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Aug 2022 16:58:35 +0200
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        Alexander Motin <mav@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org,  dev-commits-src-main@freebsd.org
Subject:   Re: git: 35b7759c05cb - main - cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED.
Message-ID:  <CAGudoHEphH-4pKGf=ta4AWir2Uj9Mg_tUysU1V5ic6z_XVQG4Q@mail.gmail.com>
In-Reply-To: <202208301453.27UEroGr037461@gitrepo.freebsd.org>
References:  <202208301453.27UEroGr037461@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 8/30/22, Alexander Motin <mav@freebsd.org> wrote:
> The branch main has been updated by mav:
>
> URL:
> https://cgit.FreeBSD.org/src/commit/?id=35b7759c05cbc65c06d87141da79f0f80af0f458
>
> commit 35b7759c05cbc65c06d87141da79f0f80af0f458
> Author:     Alexander Motin <mav@FreeBSD.org>
> AuthorDate: 2022-08-30 14:51:21 +0000
> Commit:     Alexander Motin <mav@FreeBSD.org>
> 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.
>

This should be of no use thanks to copy_file_range

>     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;
>  			}
>
>


-- 
Mateusz Guzik <mjguzik gmail.com>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHEphH-4pKGf=ta4AWir2Uj9Mg_tUysU1V5ic6z_XVQG4Q>