From owner-svn-src-all@FreeBSD.ORG Tue Feb 3 13:45:56 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8CFA106570E; Tue, 3 Feb 2009 13:45:56 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 92C468FC1D; Tue, 3 Feb 2009 13:45:56 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 3925B46B06; Tue, 3 Feb 2009 08:45:56 -0500 (EST) Date: Tue, 3 Feb 2009 13:45:56 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Diomidis Spinellis In-Reply-To: <200902031307.n13D7Y8l030992@svn.freebsd.org> Message-ID: References: <200902031307.n13D7Y8l030992@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r188069 - stable/7/bin/cp X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Feb 2009 13:45:58 -0000 On Tue, 3 Feb 2009, Diomidis Spinellis wrote: > Author: dds > Date: Tue Feb 3 13:07:34 2009 > New Revision: 188069 > URL: http://svn.freebsd.org/changeset/base/188069 > > Log: > MFC r184342 from head to stable/7 > > Add fallback when mmap fails on regular files. Some filesystems, > like smbnetfs, do not support mmap. You mean smbfs? Robert N M Watson Computer Laboratory University of Cambridge > > Reported by: Harti Brandt > > _M cp > M cp/utils.c > > Modified: > stable/7/bin/cp/ (props changed) > stable/7/bin/cp/utils.c > > Modified: stable/7/bin/cp/utils.c > ============================================================================== > --- stable/7/bin/cp/utils.c Tue Feb 3 12:56:05 2009 (r188068) > +++ stable/7/bin/cp/utils.c Tue Feb 3 13:07:34 2009 (r188069) > @@ -137,41 +137,39 @@ copy_file(const FTSENT *entp, int dne) > * Mmap and write if less than 8M (the limit is so we don't totally > * trash memory on big files. This is really a minor hack, but it > * wins some CPU back. > + * Some filesystems, such as smbnetfs, don't support mmap, > + * so this is a best-effort attempt. > */ > #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED > if (S_ISREG(fs->st_mode) && fs->st_size > 0 && > - fs->st_size <= 8 * 1048576) { > - if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ, > - MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) { > + fs->st_size <= 8 * 1024 * 1024 && > + (p = mmap(NULL, (size_t)fs->st_size, PROT_READ, > + MAP_SHARED, from_fd, (off_t)0)) != MAP_FAILED) { > + wtotal = 0; > + for (bufp = p, wresid = fs->st_size; ; > + bufp += wcount, wresid -= (size_t)wcount) { > + wcount = write(to_fd, bufp, wresid); > + if (wcount <= 0) > + break; > + wtotal += wcount; > + if (info) { > + info = 0; > + (void)fprintf(stderr, > + "%s -> %s %3d%%\n", > + entp->fts_path, to.p_path, > + cp_pct(wtotal, fs->st_size)); > + } > + if (wcount >= (ssize_t)wresid) > + break; > + } > + if (wcount != (ssize_t)wresid) { > + warn("%s", to.p_path); > + rval = 1; > + } > + /* Some systems don't unmap on close(2). */ > + if (munmap(p, fs->st_size) < 0) { > warn("%s", entp->fts_path); > rval = 1; > - } else { > - wtotal = 0; > - for (bufp = p, wresid = fs->st_size; ; > - bufp += wcount, wresid -= (size_t)wcount) { > - wcount = write(to_fd, bufp, wresid); > - if (wcount <= 0) > - break; > - wtotal += wcount; > - if (info) { > - info = 0; > - (void)fprintf(stderr, > - "%s -> %s %3d%%\n", > - entp->fts_path, to.p_path, > - cp_pct(wtotal, fs->st_size)); > - } > - if (wcount >= (ssize_t)wresid) > - break; > - } > - if (wcount != (ssize_t)wresid) { > - warn("%s", to.p_path); > - rval = 1; > - } > - /* Some systems don't unmap on close(2). */ > - if (munmap(p, fs->st_size) < 0) { > - warn("%s", entp->fts_path); > - rval = 1; > - } > } > } else > #endif >